Re: [Py4j-users] How to access "class"
Status: Beta
Brought to you by:
barthe
|
From: Peter A <pet...@gm...> - 2015-07-16 04:40:43
|
Just tried that fix and realized I stated the question in correctly. What
I got is a Java function like:
void stuff( Class type ) {
....
}
A python function which converts an int into the appropriate class. I then
invoke Java function.
So it looks something like this in Python:
gateway.jvm.foo.Bar.stuff( lookup_type( a ) )
def lookup_type( type ):
if type == 0:
return THE APPROPRIATE JAVA CLASS
...
For now what I'm doing is:
if type == 0:
obj = gateway.jvm.the.Object()
return obj,getClass()
this seems to be a bit clunky.
On Wed, Jul 15, 2015 at 8:58 PM, Alex Grönholm <ale...@ne...>
wrote:
> The .class is a kludge to access the actual class in Java. In Python,
> simply leave out the ".class".
>
> if object.getClass() == Object:
> # do something
>
>
> 16.07.2015, 03:18, Peter A kirjoitti:
>
> Hi,
>
> I need to access the static member "class" in a Java object. For example
> in Java the code would look something like:
>
> if( object.getClass() == Object.class ) {
> // do something
> }
>
> Now when I try that in py4j I run into issues that "class" is a
> protected keyword. So the following causes it to crash:
>
> gateway.jvm.Object.class
>
>
> On the other hand gateway.jvm.Object.variable works just fine, assuming variable is a static member variable of Object.
>
> My current hack around this issue is to create a new instance of the object then call object.getClass() in python.
>
>
> Is there anyway to access "class" in python?
>
>
> - Peter
>
>
> --
> "Now, now my good man, this is no time for making enemies." — Voltaire
> (1694-1778), on his deathbed in response to a priest asking that he
> renounce Satan.
>
>
> ------------------------------------------------------------------------------
> Don't Limit Your Business. Reach for the Cloud.
> GigeNET's Cloud Solutions provide you with the tools and support that
> you need to offload your IT needs and focus on growing your business.
> Configured For All Businesses. Start Your Cloud Today.https://www.gigenetcloud.com/
>
>
>
> _______________________________________________
> Py4j-users mailing lis...@li...://lists.sourceforge.net/lists/listinfo/py4j-users
>
>
>
>
> ------------------------------------------------------------------------------
> Don't Limit Your Business. Reach for the Cloud.
> GigeNET's Cloud Solutions provide you with the tools and support that
> you need to offload your IT needs and focus on growing your business.
> Configured For All Businesses. Start Your Cloud Today.
> https://www.gigenetcloud.com/
> _______________________________________________
> Py4j-users mailing list
> Py4...@li...
> https://lists.sourceforge.net/lists/listinfo/py4j-users
>
>
--
"Now, now my good man, this is no time for making enemies." — Voltaire
(1694-1778), on his deathbed in response to a priest asking that he
renounce Satan.
|