weird prompting

Johannes Zellner johannes at zellner.org
Fri Jul 7 20:54:58 EDT 2000


Hello,

I just discoverd that the prompt objects are both (also sys.ps2)
only called when printing sys.ps1. Example:

class Prompt:
    def __init__(self, prompt):
        self.count = 0
    def __str__(self):
        self.count = self.count + 1
        return str(self.count)

sys.ps1 = Prompt()
sys.ps2 = Prompt()

then issue at the input prompt a few returns and then
some command (e.g. def) which needs ps2 lines:

1                # <-- both ps1 and ps2 are incremented
2                # <-- both ps1 and ps2 are incremented
3                # <-- both ps1 and ps2 are incremented
4def fred(x):    # <-- both ps1 and ps2 are incremented
4  pass          # <-- neither ps1 nor ps2 are called
4  pass          # <-- neither ps1 nor ps2 are called
4  pass          # <-- neither ps1 nor ps2 are called
5bla

python 1.5.2

does this make sense ? (I think: no)

-- 
   Johannes





More information about the Python-list mailing list