Print content of the java.lang.string class objects in python

I’m very new to prorgamming in general and I have almost no experience in Python and I never did anything with Java. However, I started to play with the example code to discover snappy., mostly by reading and printing each statement, and discover what it gives out. What I came across is that if I print some specified objects to get their attributes it just gives me this :

[Ljava.lang.String;@… (where … is about 6, 7 or 8 signs long, which is a mix from numbers and low letters).

From reading I got that this is actually a java object, not a python object and as such the attributes behind this objects cannot be given out in a human-readable manner by applying a python operation on this object. If this is wrong, please provide me with the correct information!

So, is it possible to get the attributes anyway? If yes, how?

I read about a python module javaobj-py3, and I installed it (even though it needed some corrections in its source code to be correctly imported into the script)…however, I really don’t understand what it does, e.g. what is marshalling or bit-streaming (I started to read, but as i’m not even sure if it is what I want, my motivation to really dive in was too low).

Might be tough to say, but I’d recommend getting your head around basic programming concepts in either Java or Python first.

I’m a seasoned Software Engineer and using snappy (which is a Python wrapper around Java) is quite tough to use at the easiest of times.

I definitely wouldn’t recommend trying to use snappy before you can comfortably write small applications in Java/Python.

Dear Ciaran,
Yes, I know that snappy is not easy, I just play around with, in fact to learn more on Python. It fits to the task I try to handle currently.
Further, I did not know that it is needed to be able to know Java for it, i thought basic knowledge in Python would be sufficient .
Was the question I had just too basic? How to actually get the information from the java object? Is there a way to get there?

I’d definitely say basic python will be a push to figure out snappy just due to the way it’s interfacing a completely different language.

As you said, printing out an object will only give up its memory location.

Try print(yourObject.toString()) this may give you more information about its public accessible variables.

Again, I’d recommend trying to get comfortable in Python before diving into snappy.

Thank you for answering! And you are right, I’m in the middle of learning Python anyway, but snappy fits in the task I want to accomplish in a couple of months, and so I need to start to look into it, while also reading a book and write basic Python script.
And yes, in the meantime I understood that the number in the java object is its memory location. Sorry!

I will come back when I know a little more.

1 Like