1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Python - code type flags

Discussão em 'Python' iniciado por Stack, Fevereiro 20, 2025.

  1. Stack

    Stack Membro Participativo

    I was looking at the codetype object, and in particular the co_flags attribute.

    I wrote a tiny function

    def f(a,b,c,*args):
    print a,b,c,args


    Which was compiled to a codetype object. examining the codetype object, the container (the outer codetype) co_flag is set to 64, the function (the inner codetype) is 71

    According to the docs 0x40 (64) is set if the function has variable args (eg *args) and that bit is set on the outer and inner codetype objects.

    I'm just wondering

    • why the container is set to 64 as all it does is set functions up eg there is no variable arguments used?
    • what the other bits in the function codetype co_flags do?

    Is there a comprehensive list of the various flags as the documentation alludes to 'reserved for internal use' but nothing else is mentioned?

    I'm using python 2.7.10

    Continue reading...

Compartilhe esta Página