Jython returns False to gettattr([alist],'__reversed__') while Python returns True?

It appears as if the __reversed__ attribute of lists in Jython is not implemented. I don't get the results you describe, if I call.

Up vote 0 down vote favorite share g+ share fb share tw.

While debuging why cmd2 won't load in in Jython, I found out that it breaks because Jython returns False to gettattr(alist,'__reversed__') while Python returns True. I would assume that the correct result is True as a list is reversible.. Anyone knows what is going on? My next option is to browse around Jython source.. and I am not looking forward to it ;) BTW, I am using jython 2.5.1 on top of java "1.6.0_18" on ubuntu Thx in advance for any hints jython link|improve this question edited Jan 29 at 21:50Nas Banov2,842823 asked Aug 16 '10 at 7:19AlexFerrer762.

Please edit the question to reflect that you're looking for the __reversed__ attribute and not the reversed attribute (You can escape the underscores or use indented code regions to prevent the underscores from being treated as markdown). – Jason R. Coombs Sep 27 '10 at 13:39.

It appears as if the __reversed__ attribute of lists in Jython is not implemented. I don't get the results you describe, if I call getattr(, '__reversed__') in Python 2.5.2, I get >>> . __reversed__ And in Jython 2.5.1, I get >>> .

__reversed__ Traceback (most recent call last): File "", line 1, in AttributeError: 'list' object has no attribute '__reversed__' If it's returning True or False respectively, then you're probably not using a standard Python list. In any case, it appears as if Jython doesn't support the __reversed__ attribute of lists to indicate that it is reversible. According to the documentation, this feature appears to have been added to the CPython implementation in Python 2.6, which might explain why it doesn't appear in Jython 2.5.1.

I do find that __reversed__ appears in Python 2.5.2, so it may have been back-ported to CPython, but just not officially supported. For now, you can suggest that cmd2 be patched with something like the following: def can_be_reversed(o): "return True if an object can be reversed by reverse()" return hasattr(o, '__reversed__') or \ hasattr(o, '__len__') and hasattr(o, '__getitem__').

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions