Re: [Py4j-users] How to access attributes ?
Status: Beta
Brought to you by:
barthe
From: Barthelemy D. <bar...@in...> - 2014-12-04 10:23:40
|
Hi! Thanks for using Py4J! To access fields, you can either use gateway.get_field(object, "test1") or set auto_field=True when initializing the gateway to access object.test1. Reference: http://py4j.sourceforge.net/faq.html#how-to-access-a-field auto_field is False by default because it costs an extra lookup. Barthelemy On Wed Dec 03 2014 at 10:30:12 PM Wilfried Fauvel <wil...@gm...> wrote: > Hi, I am testing py4j and I would like to know if it is possible to > access class attributes. > In the Stack class from the getting started page, I added : > > public static final String test1 = "TEST"; > public static final int test2 = 12; > public int test3 = 12; > > and with python 2.7 : > > gateway = JavaGateway() > stack = gateway.entry_point.getStack() > print(gateway.help(stack)) > >>> field section is empty > > print stack.test1 > print stack.test2 > print stack.test3 > >>> <py4j.java_gateway.JavaMember object at 0x7fd7b1647250> > >>> <py4j.java_gateway.JavaMember object at 0x7fd7b1647a10> > >>> <py4j.java_gateway.JavaMember object at 0x7fd7b16479d0> > > Thank you, > Wilfried. > > ------------------------------------------------------------ > ------------------ > Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server > from Actuate! Instantly Supercharge Your Business Reports and Dashboards > with Interactivity, Sharing, Native Excel Exports, App Integration & more > Get technology previously reserved for billion-dollar corporations, FREE > http://pubads.g.doubleclick.net/gampad/clk?id=164703151& > iu=/4140/ostg.clktrk > _______________________________________________ > Py4j-users mailing list > Py4...@li... > https://lists.sourceforge.net/lists/listinfo/py4j-users > |