def func(self):

        caller = self.caller
        if not self.args:
            caller.msg("Usage: @name <obj> = <newname>[;alias;alias;...]")
            return

        if self.lhs_objs:
            objname = self.lhs_objs[0]['name']
            if objname.startswith("*"):
                # player mode
                obj = caller.player.search(objname.lstrip("*"))
                if obj:
                    if self.rhs_objs[0]['aliases']:
                        caller.msg("Players can't have aliases.")
                        return
                    newname = self.rhs
                    if not newname:
                        caller.msg("No name defined!")
                        return
                    if not obj.access(caller, "edit"):
                        caller.mgs("You don't have right to edit this player %s." % obj)
                        return
                    obj.username = newname
                    obj.save()
                    caller.msg("Player's name changed to '%s'." % newname)
                    return
            # object search, also with *
            obj = caller.search(objname)
            if not obj:
                return
        if self.rhs_objs:
            newname = self.rhs_objs[0]['name']
            aliases = self.rhs_objs[0]['aliases']
        else:
            newname = self.rhs
            aliases = None
        if not newname and not aliases:
            caller.msg("No names or aliases defined!")
            return
        if not obj.access(caller, "edit"):
            caller.msg("You don't have the right to edit %s." % obj)
            return
        # change the name and set aliases:
        if newname:
            obj.name = newname
        astring = ""
        if aliases:
            [obj.aliases.add(alias) for alias in aliases]
            astring = " (%s)" % (", ".join(aliases))
        # fix for exits - we need their exit-command to change name too
        if obj.destination:
            obj.flush_from_cache(force=True)
        caller.msg("Object's name changed to '%s'%s." % (newname, astring))
change the name
dataset/ETHPy150Open evennia/evennia/evennia/commands/default/building.py/CmdName.func