These FLAGS signify different components of a code object. While the other answer points you towards the right answer, I am just adding a little fun to the mix.
You can try importing a subset of FLAGS from dis.
>>> from dis import COMPILER_FLAG_NAMES
>>> COMPILER_FLAG_NAMES
{1: 'OPTIMIZED',
2: 'NEWLOCALS',
4: 'VARARGS',
8: 'VARKEYWORDS',
16: 'NESTED',
32: 'GENERATOR',
64: 'NOFREE',
128: 'COROUTINE',
256: 'ITERABLE_COROUTINE',
512: 'ASYNC_GENERATOR'}
And then you can write a simple function and see what FLAGS show up:
>>> def foo():
return
>>> dis.show_code(foo)
Name: foo
Filename: <ipython-input-138-32384d979b8a>
Argument count: 0
Kw-only arguments: 0
Number of locals: 0
Stack size: 1
Flags: OPTIMIZED, NEWLOCALS, NOFREE
Constants:
0: None
Now, you can start increasing the complexity and see how that changes:
>>> def foo(a, *args, **kwargs):
yield a
>>> dis.show_code(foo)
Name: foo
Filename: <ipython-input-141-56a68ddd064c>
Argument count: 1
Kw-only arguments: 0
Number of locals: 3
Stack size: 1
Flags: OPTIMIZED, NEWLOCALS, VARARGS, VARKEYWORDS, GENERATOR, NOFREE
Constants:
0: None
Variable names:
0: a
1: args
2: kwargs
Here adding *args, **kwargs and yield added VARARGS, VARKEYWORDS, GENERATOR flags respectively.
Now for something a little more:
>>> from asyncio import coroutine
>>> @coroutine
async def foo(a, *args, **kwargs):
yield b
def bar():
return foo(b)
yield bar
>>> dis.show_code(foo)
Name: coro
Filename: C:\Users\sayan\Anaconda3\envs\tensorflow_gpu\lib\asyncio\coroutines.py
Argument count: 0
Kw-only arguments: 0
Number of locals: 4
Stack size: 8
Flags: OPTIMIZED, NEWLOCALS, VARARGS, VARKEYWORDS, NESTED, GENERATOR, ITERABLE_COROUTINE
Constants:
0: None
Names:
0: base_futures
1: isfuture
2: inspect
3: isgenerator
4: isinstance
5: CoroWrapper
6: __await__
7: AttributeError
8: collections
9: abc
10: Awaitable
Variable names:
0: args
1: kw
2: res
3: await_meth
Free variables:
0: func
And there you go, adding @coroutine decorator gives NESTED, async_def + yield gives ITERABLE_COROUTINE and the presence of a freevar, that is the function bar here, removes the NOFREE flag.
dis.show_code(string)is not the flags of the string object. Its the flags of the code object derived from compiling this string as source code.dis.show_codewill "Print detailed code object information for the supplied function, method, source code string or code object (...)". Comparedis.show_code("for for s"). What makes you thinkdiscould disassemble types?dis.show_code()does "Print detailed code object information for the supplied function, method, source code string or code object".