如何中途停止一个class,到运行下一个class,怎么做?

How to stop a class halfway, to run the next class, and how to do so?

我在网上搜索,没有找到解决办法。请帮忙。 比方说...

class A(self):
    def __init__ (self):
        """one chunk of code here"""

    if (condition met):
        print 'access granted'
        """I want to stop the code here and ask it to run class B, instead of just one method from class B"""
    else:
        print 'Stop process'
        break

class B(self):
    def __init__ (self):
        """one more chunk of codes here"""

这可能吗? (请原谅我乱七八糟的代码)

当您 运行 该脚本时,您的 if 条件代码只会 运行 一次。每当您创建 class 的实例时,只有 __init__ 函数是 运行。正如 interjay 提到的,您 运行 没有 class,您 运行 功能。