What are other pass applications?

4

In the documentation the statement pass is defined

  

pass is a null operation. When executed, nothing happens. It is useful as a placeholder when syntactically a statement is required, but no code needs to be executed.

That's it, it's useful when I have something like this:

if aprovou_pagamento(p):
    pass
    # TODO(efetivar transação)
else:
    desefetivar_transacao(p.transacao)

as this would generate a syntax error:

if aprovou_pagamento(p):
    # TODO(efetivar transação)
else:
    desefetivar_transacao(p.transacao)

Otherwise, I can not see any practical application, except under these conditions.

Are there other applications for pass ? In what other contexts would it be useful?

    
asked by anonymous 19.10.2017 / 23:47

1 answer

4

That's all there is to it, of course you can use it in many places, not just a if .

An interesting case is when you want to create an abstract method, that is, without implementation in that type, probably to be implemented in an inherited type, so as not to give error puts pass in its body.     

19.10.2017 / 23:51