You will need to provide more information before we can be of use to you here. Are you referring to str.index() in python? If so strpos is probably what you are looking for. Otherwise we need to know more specifically what you want.
def replaceWith(self, replaceWith):
#store old parent
oldParent = self.parent
#get own index in parents contents array
myIndex = self.parent.contents.index(self)
# if mine and replaceWith's parent is same
if hasattr(replaceWith, 'parent') and replaceWith.parent == self.parent:
# We're replacing this element with one of its siblings.
index = self.parent.contents.index(replaceWith)
if index and index < myIndex:
# Furthermore, it comes before this element. That
# means that when we extract it, the index of this
# element will change.
myIndex = myIndex - 1
#delete me; kill me
#insert replacewith at myIndex
in this code index method i wanted to use a method which work same as index in php.
here is the php code what i have written.
if ( $replaceWith->parent==$parent))
if ($index && $index < $myIndex)
$oldParent->insert($myIndex,$replaceWith) //insert function will be developed letter.
I don't know any python, everything I've been getting was from documentation. So I ask again, what are you trying to do? There are multiple contexts in which index is used, before I can help you I need to know which context you are trying to use it in.