{"id":24562,"date":"2021-10-21T10:07:15","date_gmt":"2021-10-21T04:37:15","guid":{"rendered":"https:\/\/python-programs.com\/?p=24562"},"modified":"2021-11-05T19:38:07","modified_gmt":"2021-11-05T14:08:07","slug":"python-compile-function-with-examples","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-compile-function-with-examples\/","title":{"rendered":"Python compile() Function with Examples"},"content":{"rendered":"

In the previous article, we have discussed Python Program for bytes() Function<\/a>
\ncompile() Function in Python:<\/strong><\/p>\n

The compile() function returns the specified source as a ready-to-execute code object.<\/p>\n

Syntax:<\/strong><\/p>\n

compile(source,\u00a0filename,\u00a0mode,\u00a0flag,\u00a0dont_inherit,\u00a0optimize)<\/pre>\n

Parameters:<\/strong><\/p>\n

source:<\/strong> This is Required. A String, a Bytes object, or an AST object can be used as the source to compile.<\/p>\n

filename:<\/strong> Required. The name of the file from which the source was obtained. If the source is not a file, you can type whatever you want.<\/p>\n

mode:<\/strong> This is Required. Legal principles:<\/p>\n