def dbref(dbref, reqhash=True):
 if (reqhash and (not (isinstance(dbref, basestring) and dbref.startswith('#')))):
  return None
 if isinstance(dbref, basestring):
  dbref = dbref.lstrip('#')
 try:
  if (int(dbref) < 0):
   return None
 except Exception:
  return None
 return dbref

def dbref ( dbref , reqhash = True ) : if ( reqhash and ( not ( isinstance ( dbref , basestring ) and dbref . startswith ( '#' ) ) ) ) : return None if isinstance ( dbref , basestring ) : dbref = dbref . lstrip ( '#' ) try : if ( int ( dbref ) < 0 ) : return None except Exception : return None return dbref
valid forms of dbref are either a string #n or an integer n .