|
View:
New views
10 Messages
—
Rating Filter:
Alert me
|
|
|
Invoking a function on a moduleHello,
I’ve looked at the Python API docs but feel that a few common examples would be of use. For example, I can pass a String to PythonInterpreter and execute it, but how can I invoke the method ‘test’ on the module ‘mymodule.py’, which is in the classpath? Or even better, if my classpath contains a directory ‘mypackage’, and the module lives inside it, how do I do: import mypackage.mymodule mypackage.mymodule.test(‘params’)
through the Python API? Thanks, John
This e-mail (including any attachments) is confidential, may contain
proprietary or privileged information and is intended for the named
recipient(s) only. Unintended recipients are prohibited from taking action
on the basis of information in this e-mail and must delete all copies.
Nomura will not accept responsibility or liability for the accuracy or
completeness of, or the presence of any virus or disabling code in, this
e-mail. If verification is sought please request a hard copy. Any reference
to the terms of executed transactions should be treated as preliminary only
and subject to formal written confirmation by Nomura. Nomura reserves the
right to monitor e-mail communications through its networks (in accordance
with applicable laws). No confidentiality or privilege is waived or lost by
Nomura by any mistransmission of this e-mail. Any reference to "Nomura" is
a reference to any entity in the Nomura Holdings, Inc. group. Please read
our Electronic Communications Legal Notice which forms part of this e-mail:
http://www.Nomura.com/email_disclaimer.htm
------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Jython-users mailing list Jython-users@... https://lists.sourceforge.net/lists/listinfo/jython-users |
|
|
Re: Invoking a function on a modulehttp://wiki.python.org/jython/UserGuide#embedding-jython
john.m.baker@... wrote: > > Hello, > > I’ve looked at the Python API docs but feel that a few common examples > would be of use. For example, I can pass a String to PythonInterpreter > and execute it, but how can I invoke the method ‘test’ on the module > ‘mymodule.py’, which is in the classpath? Or even better, if my > classpath contains a directory ‘mypackage’, and the module lives > inside it, how do I do: > > import mypackage.mymodule > > mypackage.mymodule.test(‘params’) > > through the Python API? > > Thanks, > > > John > > > > This e-mail (including any attachments) is confidential, may contain > proprietary or privileged information and is intended for the named > recipient(s) only. Unintended recipients are prohibited from taking > action > on the basis of information in this e-mail and must delete all copies. > Nomura will not accept responsibility or liability for the accuracy or > completeness of, or the presence of any virus or disabling code in, this > e-mail. If verification is sought please request a hard copy. Any > reference > to the terms of executed transactions should be treated as preliminary > only > and subject to formal written confirmation by Nomura. Nomura reserves the > right to monitor e-mail communications through its networks (in > accordance > with applicable laws). No confidentiality or privilege is waived or > lost by > Nomura by any mistransmission of this e-mail. Any reference to > "Nomura" is > a reference to any entity in the Nomura Holdings, Inc. group. Please read > our Electronic Communications Legal Notice which forms part of this > e-mail: > http://www.Nomura.com/email_disclaimer.htm > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > ------------------------------------------------------------------------ > > _______________________________________________ > Jython-users mailing list > Jython-users@... > https://lists.sourceforge.net/lists/listinfo/jython-users > ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Jython-users mailing list Jython-users@... https://lists.sourceforge.net/lists/listinfo/jython-users |
|
|
Re: Invoking a function on a modulejohn.m.baker@... kirjoitti:
> > Hello, > > I’ve looked at the Python API docs but feel that a few common examples > would be of use. For example, I can pass a String to PythonInterpreter > and execute it, but how can I invoke the method ‘test’ on the module > ‘mymodule.py’, which is in the classpath? Or even better, if my > classpath contains a directory ‘mypackage’, and the module lives > inside it, how do I do: > > import mypackage.mymodule > > mypackage.mymodule.test(‘params’) > > through the Python API? > difficult to figure out :) > > Thanks, > > > John > > > > This e-mail (including any attachments) is confidential, may contain > proprietary or privileged information and is intended for the named > recipient(s) only. Unintended recipients are prohibited from taking > action > on the basis of information in this e-mail and must delete all copies. > Nomura will not accept responsibility or liability for the accuracy or > completeness of, or the presence of any virus or disabling code in, this > e-mail. If verification is sought please request a hard copy. Any > reference > to the terms of executed transactions should be treated as preliminary > only > and subject to formal written confirmation by Nomura. Nomura reserves the > right to monitor e-mail communications through its networks (in > accordance > with applicable laws). No confidentiality or privilege is waived or > lost by > Nomura by any mistransmission of this e-mail. Any reference to > "Nomura" is > a reference to any entity in the Nomura Holdings, Inc. group. Please read > our Electronic Communications Legal Notice which forms part of this > e-mail: > http://www.Nomura.com/email_disclaimer.htm > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > ------------------------------------------------------------------------ > > _______________________________________________ > Jython-users mailing list > Jython-users@... > https://lists.sourceforge.net/lists/listinfo/jython-users > ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Jython-users mailing list Jython-users@... https://lists.sourceforge.net/lists/listinfo/jython-users |
|
|
Re: Invoking a function on a moduleWell I assumed I'd have to create a PyModule and invoke a function on it...
> -----Original Message----- > From: Alex Grönholm [mailto:alex.gronholm@...] > Sent: 04 November 2009 17:27 > To: jython-users@... > Subject: Re: [Jython-users] Invoking a function on a module > > john.m.baker@... kirjoitti: > > > > Hello, > > > > I've looked at the Python API docs but feel that a few common > examples > > would be of use. For example, I can pass a String to > PythonInterpreter > > and execute it, but how can I invoke the method 'test' on the module > > 'mymodule.py', which is in the classpath? Or even better, if my > > classpath contains a directory 'mypackage', and the module lives > > inside it, how do I do: > > > > import mypackage.mymodule > > > > mypackage.mymodule.test('params') > > > > through the Python API? > > > Just exec() those statements one after another. Shouldn't be that > difficult to figure out :) > > > > Thanks, > > > > > > John > > > > > > > > This e-mail (including any attachments) is confidential, may contain > > proprietary or privileged information and is intended for the named > > recipient(s) only. Unintended recipients are prohibited from taking > > action > > on the basis of information in this e-mail and must delete all copies. > > Nomura will not accept responsibility or liability for the accuracy > or > > completeness of, or the presence of any virus or disabling code in, > this > > e-mail. If verification is sought please request a hard copy. Any > > reference > > to the terms of executed transactions should be treated as > preliminary > > only > > and subject to formal written confirmation by Nomura. Nomura reserves > the > > right to monitor e-mail communications through its networks (in > > accordance > > with applicable laws). No confidentiality or privilege is waived or > > lost by > > Nomura by any mistransmission of this e-mail. Any reference to > > "Nomura" is > > a reference to any entity in the Nomura Holdings, Inc. group. Please > read > > our Electronic Communications Legal Notice which forms part of this > > e-mail: > > http://www.Nomura.com/email_disclaimer.htm > > --------------------------------------------------------------------- > --- > > > > --------------------------------------------------------------------- > --------- > > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 > 30-Day > > trial. Simplify your report design, integration and deployment - and > focus on > > what you do best, core application coding. Discover what's new with > > Crystal Reports now. http://p.sf.net/sfu/bobj-july > > --------------------------------------------------------------------- > --- > > > > _______________________________________________ > > Jython-users mailing list > > Jython-users@... > > https://lists.sourceforge.net/lists/listinfo/jython-users > > > > > ----------------------------------------------------------------------- > ------- > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 > 30-Day > trial. Simplify your report design, integration and deployment - and > focus on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > Jython-users mailing list > Jython-users@... > https://lists.sourceforge.net/lists/listinfo/jython-users This e-mail (including any attachments) is confidential, may contain proprietary or privileged information and is intended for the named recipient(s) only. Unintended recipients are prohibited from taking action on the basis of information in this e-mail and must delete all copies. Nomura will not accept responsibility or liability for the accuracy or completeness of, or the presence of any virus or disabling code in, this e-mail. If verification is sought please request a hard copy. Any reference to the terms of executed transactions should be treated as preliminary only and subject to formal written confirmation by Nomura. Nomura reserves the right to monitor e-mail communications through its networks (in accordance with applicable laws). No confidentiality or privilege is waived or lost by Nomura by any mistransmission of this e-mail. Any reference to "Nomura" is a reference to any entity in the Nomura Holdings, Inc. group. Please read our Electronic Communications Legal Notice which forms part of this e-mail: http://www.Nomura.com/email_disclaimer.htm ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Jython-users mailing list Jython-users@... https://lists.sourceforge.net/lists/listinfo/jython-users |
|
|
Re: Invoking a function on a moduleHi,
If I want to do: Import mypackage.mymodule Mypackage.mymodule.mymethod('a', 123) Then how do I do it like this: PyModule module = ... ? PyObject result = module.invoke("mymethod", new PyObject[] { new PyString('a'), new PyInteger(123) } ) I don't know how to get a reference to module - the reason I ask is I'd like to implement this slightly more strictly than running PythonInterpreter.exec for each method call. Thanks, john > -----Original Message----- > From: Alex Grönholm [mailto:alex.gronholm@...] > Sent: 04 November 2009 17:27 > To: jython-users@... > Subject: Re: [Jython-users] Invoking a function on a module > > john.m.baker@... kirjoitti: > > > > Hello, > > > > I've looked at the Python API docs but feel that a few common > examples > > would be of use. For example, I can pass a String to > PythonInterpreter > > and execute it, but how can I invoke the method 'test' on the module > > 'mymodule.py', which is in the classpath? Or even better, if my > > classpath contains a directory 'mypackage', and the module lives > > inside it, how do I do: > > > > import mypackage.mymodule > > > > mypackage.mymodule.test('params') > > > > through the Python API? > > > Just exec() those statements one after another. Shouldn't be that > difficult to figure out :) > > > > Thanks, > > > > > > John > > > > > > > > This e-mail (including any attachments) is confidential, may contain > > proprietary or privileged information and is intended for the named > > recipient(s) only. Unintended recipients are prohibited from taking > > action > > on the basis of information in this e-mail and must delete all copies. > > Nomura will not accept responsibility or liability for the accuracy > or > > completeness of, or the presence of any virus or disabling code in, > this > > e-mail. If verification is sought please request a hard copy. Any > > reference > > to the terms of executed transactions should be treated as > preliminary > > only > > and subject to formal written confirmation by Nomura. Nomura reserves > the > > right to monitor e-mail communications through its networks (in > > accordance > > with applicable laws). No confidentiality or privilege is waived or > > lost by > > Nomura by any mistransmission of this e-mail. Any reference to > > "Nomura" is > > a reference to any entity in the Nomura Holdings, Inc. group. Please > read > > our Electronic Communications Legal Notice which forms part of this > > e-mail: > > http://www.Nomura.com/email_disclaimer.htm > > --------------------------------------------------------------------- > --- > > > > --------------------------------------------------------------------- > --------- > > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 > 30-Day > > trial. Simplify your report design, integration and deployment - and > focus on > > what you do best, core application coding. Discover what's new with > > Crystal Reports now. http://p.sf.net/sfu/bobj-july > > --------------------------------------------------------------------- > --- > > > > _______________________________________________ > > Jython-users mailing list > > Jython-users@... > > https://lists.sourceforge.net/lists/listinfo/jython-users > > > > > ----------------------------------------------------------------------- > ------- > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 > 30-Day > trial. Simplify your report design, integration and deployment - and > focus on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > Jython-users mailing list > Jython-users@... > https://lists.sourceforge.net/lists/listinfo/jython-users This e-mail (including any attachments) is confidential, may contain proprietary or privileged information and is intended for the named recipient(s) only. Unintended recipients are prohibited from taking action on the basis of information in this e-mail and must delete all copies. Nomura will not accept responsibility or liability for the accuracy or completeness of, or the presence of any virus or disabling code in, this e-mail. If verification is sought please request a hard copy. Any reference to the terms of executed transactions should be treated as preliminary only and subject to formal written confirmation by Nomura. Nomura reserves the right to monitor e-mail communications through its networks (in accordance with applicable laws). No confidentiality or privilege is waived or lost by Nomura by any mistransmission of this e-mail. Any reference to "Nomura" is a reference to any entity in the Nomura Holdings, Inc. group. Please read our Electronic Communications Legal Notice which forms part of this e-mail: http://www.Nomura.com/email_disclaimer.htm ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Jython-users mailing list Jython-users@... https://lists.sourceforge.net/lists/listinfo/jython-users |
|
|
Re: Invoking a function on a moduleMay I suggest the far easier mechanism of using an object factory? It's more general than the incomplete snippet presented, and we have lots of experience using it for Java integration:
http://jythonpodcast.hostjava.net/jythonbook/chapter10.html#object-factories An alternative would be to use JSR223, also documented in chapter 10. - Jim On Thu, Nov 5, 2009 at 9:36 AM, <john.m.baker@...> wrote: Hi, -- Jim Baker jbaker@... ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Jython-users mailing list Jython-users@... https://lists.sourceforge.net/lists/listinfo/jython-users |
|
|
Re: Invoking a function on a moduleinterp.exec("from mypackage.mymodule import mymethod"); PyObject f = interp.get('mymethod'); PyObject result = f.__call__(new PyString("a"),new PyInteger(123)); john.m.baker@... wrote: > Hi, > > If I want to do: > > Import mypackage.mymodule > Mypackage.mymodule.mymethod('a', 123) > > Then how do I do it like this: > > PyModule module = ... ? > PyObject result = module.invoke("mymethod", > new PyObject[] { > new PyString('a'), > new PyInteger(123) > } > ) > > I don't know how to get a reference to module - the reason I ask is I'd like to implement this slightly more strictly than running PythonInterpreter.exec for each method call. > > Thanks, > > > john > > >> -----Original Message----- >> From: Alex Grönholm [mailto:alex.gronholm@...] >> Sent: 04 November 2009 17:27 >> To: jython-users@... >> Subject: Re: [Jython-users] Invoking a function on a module >> >> john.m.baker@... kirjoitti: >> >>> Hello, >>> >>> I've looked at the Python API docs but feel that a few common >>> >> examples >> >>> would be of use. For example, I can pass a String to >>> >> PythonInterpreter >> >>> and execute it, but how can I invoke the method 'test' on the module >>> 'mymodule.py', which is in the classpath? Or even better, if my >>> classpath contains a directory 'mypackage', and the module lives >>> inside it, how do I do: >>> >>> import mypackage.mymodule >>> >>> mypackage.mymodule.test('params') >>> >>> through the Python API? >>> >>> >> Just exec() those statements one after another. Shouldn't be that >> difficult to figure out :) >> >>> Thanks, >>> >>> >>> John >>> >>> >>> >>> This e-mail (including any attachments) is confidential, may contain >>> proprietary or privileged information and is intended for the named >>> recipient(s) only. Unintended recipients are prohibited from taking >>> action >>> on the basis of information in this e-mail and must delete all copies. >>> Nomura will not accept responsibility or liability for the accuracy >>> >> or >> >>> completeness of, or the presence of any virus or disabling code in, >>> >> this >> >>> e-mail. If verification is sought please request a hard copy. Any >>> reference >>> to the terms of executed transactions should be treated as >>> >> preliminary >> >>> only >>> and subject to formal written confirmation by Nomura. Nomura reserves >>> >> the >> >>> right to monitor e-mail communications through its networks (in >>> accordance >>> with applicable laws). No confidentiality or privilege is waived or >>> lost by >>> Nomura by any mistransmission of this e-mail. Any reference to >>> "Nomura" is >>> a reference to any entity in the Nomura Holdings, Inc. group. Please >>> >> read >> >>> our Electronic Communications Legal Notice which forms part of this >>> e-mail: >>> http://www.Nomura.com/email_disclaimer.htm >>> --------------------------------------------------------------------- >>> >> --- >> >>> --------------------------------------------------------------------- >>> >> --------- >> >>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 >>> >> 30-Day >> >>> trial. Simplify your report design, integration and deployment - and >>> >> focus on >> >>> what you do best, core application coding. Discover what's new with >>> Crystal Reports now. http://p.sf.net/sfu/bobj-july >>> --------------------------------------------------------------------- >>> >> --- >> >>> _______________________________________________ >>> Jython-users mailing list >>> Jython-users@... >>> https://lists.sourceforge.net/lists/listinfo/jython-users >>> >>> >> ----------------------------------------------------------------------- >> ------- >> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 >> 30-Day >> trial. Simplify your report design, integration and deployment - and >> focus on >> what you do best, core application coding. Discover what's new with >> Crystal Reports now. http://p.sf.net/sfu/bobj-july >> _______________________________________________ >> Jython-users mailing list >> Jython-users@... >> https://lists.sourceforge.net/lists/listinfo/jython-users >> > > > > This e-mail (including any attachments) is confidential, may contain > proprietary or privileged information and is intended for the named > recipient(s) only. Unintended recipients are prohibited from taking action > on the basis of information in this e-mail and must delete all copies. > Nomura will not accept responsibility or liability for the accuracy or > completeness of, or the presence of any virus or disabling code in, this > e-mail. If verification is sought please request a hard copy. Any reference > to the terms of executed transactions should be treated as preliminary only > and subject to formal written confirmation by Nomura. Nomura reserves the > right to monitor e-mail communications through its networks (in accordance > with applicable laws). No confidentiality or privilege is waived or lost by > Nomura by any mistransmission of this e-mail. Any reference to "Nomura" is > a reference to any entity in the Nomura Holdings, Inc. group. Please read > our Electronic Communications Legal Notice which forms part of this e-mail: > http://www.Nomura.com/email_disclaimer.htm > > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > Jython-users mailing list > Jython-users@... > https://lists.sourceforge.net/lists/listinfo/jython-users > ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Jython-users mailing list Jython-users@... https://lists.sourceforge.net/lists/listinfo/jython-users |
|
|
Re: Invoking a function on a moduleGreat, thanks. Why can't I do:
interp.exec("import mypackage.mymodule") PythonObject f= interp.get("mypackage.mymodule.mymethod"); f is null? > -----Original Message----- > From: Jeff Emanuel [mailto:jemanuel@...] > Sent: 05 November 2009 21:55 > To: Baker, John (IT/UK) > Cc: jython-users@... > Subject: Re: [Jython-users] Invoking a function on a module > > > > interp.exec("from mypackage.mymodule import mymethod"); > PyObject f = interp.get('mymethod'); > PyObject result = f.__call__(new PyString("a"),new PyInteger(123)); > > > > > john.m.baker@... wrote: > > Hi, > > > > If I want to do: > > > > Import mypackage.mymodule > > Mypackage.mymodule.mymethod('a', 123) > > > > Then how do I do it like this: > > > > PyModule module = ... ? > > PyObject result = module.invoke("mymethod", > > new PyObject[] { > > new PyString('a'), > > new PyInteger(123) > > } > > ) > > > > I don't know how to get a reference to module - the reason I ask is > I'd like to implement this slightly more strictly than running > PythonInterpreter.exec for each method call. > > > > Thanks, > > > > > > john > > > > > >> -----Original Message----- > >> From: Alex Grönholm [mailto:alex.gronholm@...] > >> Sent: 04 November 2009 17:27 > >> To: jython-users@... > >> Subject: Re: [Jython-users] Invoking a function on a module > >> > >> john.m.baker@... kirjoitti: > >> > >>> Hello, > >>> > >>> I've looked at the Python API docs but feel that a few common > >>> > >> examples > >> > >>> would be of use. For example, I can pass a String to > >>> > >> PythonInterpreter > >> > >>> and execute it, but how can I invoke the method 'test' on the > module > >>> 'mymodule.py', which is in the classpath? Or even better, if my > >>> classpath contains a directory 'mypackage', and the module lives > >>> inside it, how do I do: > >>> > >>> import mypackage.mymodule > >>> > >>> mypackage.mymodule.test('params') > >>> > >>> through the Python API? > >>> > >>> > >> Just exec() those statements one after another. Shouldn't be that > >> difficult to figure out :) > >> > >>> Thanks, > >>> > >>> > >>> John > >>> > >>> > >>> > >>> This e-mail (including any attachments) is confidential, may > contain > >>> proprietary or privileged information and is intended for the named > >>> recipient(s) only. Unintended recipients are prohibited from taking > >>> action > >>> on the basis of information in this e-mail and must delete all > copies. > >>> Nomura will not accept responsibility or liability for the accuracy > >>> > >> or > >> > >>> completeness of, or the presence of any virus or disabling code in, > >>> > >> this > >> > >>> e-mail. If verification is sought please request a hard copy. Any > >>> reference > >>> to the terms of executed transactions should be treated as > >>> > >> preliminary > >> > >>> only > >>> and subject to formal written confirmation by Nomura. Nomura > reserves > >>> > >> the > >> > >>> right to monitor e-mail communications through its networks (in > >>> accordance > >>> with applicable laws). No confidentiality or privilege is waived or > >>> lost by > >>> Nomura by any mistransmission of this e-mail. Any reference to > >>> "Nomura" is > >>> a reference to any entity in the Nomura Holdings, Inc. group. > Please > >>> > >> read > >> > >>> our Electronic Communications Legal Notice which forms part of this > >>> e-mail: > >>> http://www.Nomura.com/email_disclaimer.htm > >>> ------------------------------------------------------------------- > -- > >>> > >> --- > >> > >>> ------------------------------------------------------------------- > -- > >>> > >> --------- > >> > >>> Let Crystal Reports handle the reporting - Free Crystal Reports > 2008 > >>> > >> 30-Day > >> > >>> trial. Simplify your report design, integration and deployment - > and > >>> > >> focus on > >> > >>> what you do best, core application coding. Discover what's new with > >>> Crystal Reports now. http://p.sf.net/sfu/bobj-july > >>> ------------------------------------------------------------------- > -- > >>> > >> --- > >> > >>> _______________________________________________ > >>> Jython-users mailing list > >>> Jython-users@... > >>> https://lists.sourceforge.net/lists/listinfo/jython-users > >>> > >>> > >> -------------------------------------------------------------------- > --- > >> ------- > >> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 > >> 30-Day > >> trial. Simplify your report design, integration and deployment - and > >> focus on > >> what you do best, core application coding. Discover what's new with > >> Crystal Reports now. http://p.sf.net/sfu/bobj-july > >> _______________________________________________ > >> Jython-users mailing list > >> Jython-users@... > >> https://lists.sourceforge.net/lists/listinfo/jython-users > >> > > > > > > > > This e-mail (including any attachments) is confidential, may contain > > proprietary or privileged information and is intended for the named > > recipient(s) only. Unintended recipients are prohibited from taking > action > > on the basis of information in this e-mail and must delete all copies. > > Nomura will not accept responsibility or liability for the accuracy > or > > completeness of, or the presence of any virus or disabling code in, > this > > e-mail. If verification is sought please request a hard copy. Any > reference > > to the terms of executed transactions should be treated as > preliminary only > > and subject to formal written confirmation by Nomura. Nomura reserves > the > > right to monitor e-mail communications through its networks (in > accordance > > with applicable laws). No confidentiality or privilege is waived or > lost by > > Nomura by any mistransmission of this e-mail. Any reference to > "Nomura" is > > a reference to any entity in the Nomura Holdings, Inc. group. Please > read > > our Electronic Communications Legal Notice which forms part of this > e-mail: > > http://www.Nomura.com/email_disclaimer.htm > > > > > > --------------------------------------------------------------------- > --------- > > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 > 30-Day > > trial. Simplify your report design, integration and deployment - and > focus on > > what you do best, core application coding. Discover what's new with > > Crystal Reports now. http://p.sf.net/sfu/bobj-july > > _______________________________________________ > > Jython-users mailing list > > Jython-users@... > > https://lists.sourceforge.net/lists/listinfo/jython-users > > This e-mail (including any attachments) is confidential, may contain proprietary or privileged information and is intended for the named recipient(s) only. Unintended recipients are prohibited from taking action on the basis of information in this e-mail and must delete all copies. Nomura will not accept responsibility or liability for the accuracy or completeness of, or the presence of any virus or disabling code in, this e-mail. If verification is sought please request a hard copy. Any reference to the terms of executed transactions should be treated as preliminary only and subject to formal written confirmation by Nomura. Nomura reserves the right to monitor e-mail communications through its networks (in accordance with applicable laws). No confidentiality or privilege is waived or lost by Nomura by any mistransmission of this e-mail. Any reference to "Nomura" is a reference to any entity in the Nomura Holdings, Inc. group. Please read our Electronic Communications Legal Notice which forms part of this e-mail: http://www.Nomura.com/email_disclaimer.htm ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Jython-users mailing list Jython-users@... https://lists.sourceforge.net/lists/listinfo/jython-users |
|
|
Re: Invoking a function on a modulejohn.m.baker@... kirjoitti:
> Great, thanks. Why can't I do: > > interp.exec("import mypackage.mymodule") > PythonObject f= interp.get("mypackage.mymodule.mymethod"); > > f is null? > Try interp.eval() > >> -----Original Message----- >> From: Jeff Emanuel [mailto:jemanuel@...] >> Sent: 05 November 2009 21:55 >> To: Baker, John (IT/UK) >> Cc: jython-users@... >> Subject: Re: [Jython-users] Invoking a function on a module >> >> >> >> interp.exec("from mypackage.mymodule import mymethod"); >> PyObject f = interp.get('mymethod'); >> PyObject result = f.__call__(new PyString("a"),new PyInteger(123)); >> >> >> >> >> john.m.baker@... wrote: >> >>> Hi, >>> >>> If I want to do: >>> >>> Import mypackage.mymodule >>> Mypackage.mymodule.mymethod('a', 123) >>> >>> Then how do I do it like this: >>> >>> PyModule module = ... ? >>> PyObject result = module.invoke("mymethod", >>> new PyObject[] { >>> new PyString('a'), >>> new PyInteger(123) >>> } >>> ) >>> >>> I don't know how to get a reference to module - the reason I ask is >>> >> I'd like to implement this slightly more strictly than running >> PythonInterpreter.exec for each method call. >> >>> Thanks, >>> >>> >>> john >>> >>> >>> >>>> -----Original Message----- >>>> From: Alex Grönholm [mailto:alex.gronholm@...] >>>> Sent: 04 November 2009 17:27 >>>> To: jython-users@... >>>> Subject: Re: [Jython-users] Invoking a function on a module >>>> >>>> john.m.baker@... kirjoitti: >>>> >>>> >>>>> Hello, >>>>> >>>>> I've looked at the Python API docs but feel that a few common >>>>> >>>>> >>>> examples >>>> >>>> >>>>> would be of use. For example, I can pass a String to >>>>> >>>>> >>>> PythonInterpreter >>>> >>>> >>>>> and execute it, but how can I invoke the method 'test' on the >>>>> >> module >> >>>>> 'mymodule.py', which is in the classpath? Or even better, if my >>>>> classpath contains a directory 'mypackage', and the module lives >>>>> inside it, how do I do: >>>>> >>>>> import mypackage.mymodule >>>>> >>>>> mypackage.mymodule.test('params') >>>>> >>>>> through the Python API? >>>>> >>>>> >>>>> >>>> Just exec() those statements one after another. Shouldn't be that >>>> difficult to figure out :) >>>> >>>> >>>>> Thanks, >>>>> >>>>> >>>>> John >>>>> >>>>> >>>>> >>>>> This e-mail (including any attachments) is confidential, may >>>>> >> contain >> >>>>> proprietary or privileged information and is intended for the named >>>>> recipient(s) only. Unintended recipients are prohibited from taking >>>>> action >>>>> on the basis of information in this e-mail and must delete all >>>>> >> copies. >> >>>>> Nomura will not accept responsibility or liability for the accuracy >>>>> >>>>> >>>> or >>>> >>>> >>>>> completeness of, or the presence of any virus or disabling code in, >>>>> >>>>> >>>> this >>>> >>>> >>>>> e-mail. If verification is sought please request a hard copy. Any >>>>> reference >>>>> to the terms of executed transactions should be treated as >>>>> >>>>> >>>> preliminary >>>> >>>> >>>>> only >>>>> and subject to formal written confirmation by Nomura. Nomura >>>>> >> reserves >> >>>> the >>>> >>>> >>>>> right to monitor e-mail communications through its networks (in >>>>> accordance >>>>> with applicable laws). No confidentiality or privilege is waived or >>>>> lost by >>>>> Nomura by any mistransmission of this e-mail. Any reference to >>>>> "Nomura" is >>>>> a reference to any entity in the Nomura Holdings, Inc. group. >>>>> >> Please >> >>>> read >>>> >>>> >>>>> our Electronic Communications Legal Notice which forms part of this >>>>> e-mail: >>>>> http://www.Nomura.com/email_disclaimer.htm >>>>> ------------------------------------------------------------------- >>>>> >> -- >> >>>> --- >>>> >>>> >>>>> ------------------------------------------------------------------- >>>>> >> -- >> >>>> --------- >>>> >>>> >>>>> Let Crystal Reports handle the reporting - Free Crystal Reports >>>>> >> 2008 >> >>>> 30-Day >>>> >>>> >>>>> trial. Simplify your report design, integration and deployment - >>>>> >> and >> >>>> focus on >>>> >>>> >>>>> what you do best, core application coding. Discover what's new with >>>>> Crystal Reports now. http://p.sf.net/sfu/bobj-july >>>>> ------------------------------------------------------------------- >>>>> >> -- >> >>>> --- >>>> >>>> >>>>> _______________________________________________ >>>>> Jython-users mailing list >>>>> Jython-users@... >>>>> https://lists.sourceforge.net/lists/listinfo/jython-users >>>>> >>>>> >>>>> >>>> -------------------------------------------------------------------- >>>> >> --- >> >>>> ------- >>>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 >>>> 30-Day >>>> trial. Simplify your report design, integration and deployment - and >>>> focus on >>>> what you do best, core application coding. Discover what's new with >>>> Crystal Reports now. http://p.sf.net/sfu/bobj-july >>>> _______________________________________________ >>>> Jython-users mailing list >>>> Jython-users@... >>>> https://lists.sourceforge.net/lists/listinfo/jython-users >>>> >>>> >>> >>> This e-mail (including any attachments) is confidential, may contain >>> proprietary or privileged information and is intended for the named >>> recipient(s) only. Unintended recipients are prohibited from taking >>> >> action >> >>> on the basis of information in this e-mail and must delete all copies. >>> Nomura will not accept responsibility or liability for the accuracy >>> >> or >> >>> completeness of, or the presence of any virus or disabling code in, >>> >> this >> >>> e-mail. If verification is sought please request a hard copy. Any >>> >> reference >> >>> to the terms of executed transactions should be treated as >>> >> preliminary only >> >>> and subject to formal written confirmation by Nomura. Nomura reserves >>> >> the >> >>> right to monitor e-mail communications through its networks (in >>> >> accordance >> >>> with applicable laws). No confidentiality or privilege is waived or >>> >> lost by >> >>> Nomura by any mistransmission of this e-mail. Any reference to >>> >> "Nomura" is >> >>> a reference to any entity in the Nomura Holdings, Inc. group. Please >>> >> read >> >>> our Electronic Communications Legal Notice which forms part of this >>> >> e-mail: >> >>> http://www.Nomura.com/email_disclaimer.htm >>> >>> >>> --------------------------------------------------------------------- >>> >> --------- >> >>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 >>> >> 30-Day >> >>> trial. Simplify your report design, integration and deployment - and >>> >> focus on >> >>> what you do best, core application coding. Discover what's new with >>> Crystal Reports now. http://p.sf.net/sfu/bobj-july >>> _______________________________________________ >>> Jython-users mailing list >>> Jython-users@... >>> https://lists.sourceforge.net/lists/listinfo/jython-users >>> >>> > > > > This e-mail (including any attachments) is confidential, may contain > proprietary or privileged information and is intended for the named > recipient(s) only. Unintended recipients are prohibited from taking action > on the basis of information in this e-mail and must delete all copies. > Nomura will not accept responsibility or liability for the accuracy or > completeness of, or the presence of any virus or disabling code in, this > e-mail. If verification is sought please request a hard copy. Any reference > to the terms of executed transactions should be treated as preliminary only > and subject to formal written confirmation by Nomura. Nomura reserves the > right to monitor e-mail communications through its networks (in accordance > with applicable laws). No confidentiality or privilege is waived or lost by > Nomura by any mistransmission of this e-mail. Any reference to "Nomura" is > a reference to any entity in the Nomura Holdings, Inc. group. Please read > our Electronic Communications Legal Notice which forms part of this e-mail: > http://www.Nomura.com/email_disclaimer.htm > > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > Jython-users mailing list > Jython-users@... > https://lists.sourceforge.net/lists/listinfo/jython-users > ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Jython-users mailing list Jython-users@... https://lists.sourceforge.net/lists/listinfo/jython-users |
|
|
Re: Invoking a function on a moduleI also just updated the PythonInterpreter section of the book and sent to Apress. I will be updating the online book at some point in the not too distant future. For now, here is a table that I put together that describes all of the different methods available for use with the PythonInterpreter. Perhaps it will help you out a bit with the PythonInterpreter. However, I agree with Jim that object factories are the best way to go. Check out the PlyJy (http://kenai.com/projects/plyjy) project for some working examples.
Here is that table (unformatted and ugly): PythonInterpreter Methods Method Description setIn(PyObject) Set the Python object to use for the standard input stream setIn(java.io.Reader) Set a java.io.Reader to use for the standard input stream setIn(java.io.InputStream) Set a java.io.InputStream to use for the standard input stream setOut(PyObject) Set the Python object to use for the standard output stream setOut(java.io.Writer) Set the java.io.Writer to use for the standard output stream setOut(java,io.OutputStream) Set the java.io.OutputStream to use for the standard output stream setErr(PyObject) Set a Python error object to use for the standard error stream setErr(java.io.Writer Set a java.io.Writer to use for the standard error stream setErr(java.io.OutputStream) Set a java.io.OutputStream to use for the standard error stream eval(String) Evaluate a string as Python source and return the result eval(PyObject) Evaluate a Python code object and return the result exec(String) Execute a string of Python source in the local namespace exec(PyObject) Execute a Python code object in the local namespace execfile(String filename) Execute a file of Python source in the local namespace execfile(java.io.InputStream) Execute an input stream of Python source in the local namespace compile(String) Compile a string of Python source as an expression or module compile(script, filename) Compile a script of Python source as an expression or module set(String name, Object value) Set a variable of Object type in the local namespace set(String name, PyObject value) Set a varuable of PyObject type in the local namespace get(String) Get the value of a variable in the local namespace get(String name, Class<T> javaclass Get the value of a variable in the local namespace. The value will be returned as an instance of the given Java class. Hope this helps. juneau001@... http://jj-blogger.blogspot.com Twitter ID: javajuneau 2009/11/6 Alex Grönholm <alex.gronholm@...>
------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Jython-users mailing list Jython-users@... https://lists.sourceforge.net/lists/listinfo/jython-users |
| Free embeddable forum powered by Nabble | Forum Help |