Re: [Py4j-users] Using copy.deepcopy() with Java Objects
Status: Beta
Brought to you by:
barthe
From: Barthelemy D. <ba...@cs...> - 2011-03-16 11:35:38
|
Hi Nicolò, as Alex says, it is not possible to use deepcopy with a Java object in Python and I'm not sure it makes sense anyway. Are you trying to dynamically duplicate a Java object graph from Python or...? With more information about what you are trying to do, we may be able to find an alternative. Barthélémy On 03/16/2011 06:50 AM, Alex Grönholm wrote: > 16.03.2011 12:24, Nicolò Perino kirjoitti: >> Hi, >> I was experimenting with your library P4JS and I was wandering how to create a copy of a Java object in Python environment. So I tried with the Python copy module, starting from your "stack" example: >> >>>>> stack = gateway.entry_point.getStack() >>>>> stack >> JavaObject id=o0 >>>>> import copy >>>>> a = copy.deepcopy(stack) >> Traceback (most recent call last): >> File "<stdin>", line 1, in<module> >> File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/copy.py", line 173, in deepcopy >> y = copier(memo) >> File "/Library/Python/2.6/site-packages/py4j/java_gateway.py", line 343, in __call__ >> args_command = ''.join([get_command_part(arg, self.pool) for arg in new_args]) >> File "/Library/Python/2.6/site-packages/py4j/protocol.py", line 208, in get_command_part >> command_part = REFERENCE_TYPE + parameter._get_object_id() >> AttributeError: 'dict' object has no attribute '_get_object_id' >> >> Is there a way to success in coping objects? > You'll have to do it on the Java side. The exact method depends on what > type you are trying to copy. >> Thank you. >> Bye >> >> >> Nicolò Perino >> ______ >> PhD Student @ USI - Faculty of Informatics >> http://www.people.usi.ch/perinon/ >> >> >> ------------------------------------------------------------------------------ >> Colocation vs. Managed Hosting >> A question and answer guide to determining the best fit >> for your organization - today and in the future. >> http://p.sf.net/sfu/internap-sfd2d >> _______________________________________________ >> Py4j-users mailing list >> Py4...@li... >> https://lists.sourceforge.net/lists/listinfo/py4j-users > > > ------------------------------------------------------------------------------ > Colocation vs. Managed Hosting > A question and answer guide to determining the best fit > for your organization - today and in the future. > http://p.sf.net/sfu/internap-sfd2d > _______________________________________________ > Py4j-users mailing list > Py4...@li... > https://lists.sourceforge.net/lists/listinfo/py4j-users |