Codex suggesting outdated Python syntax - how to guide it toward modern patterns? #17197
-
|
Hey all, For example, when I prompt "read a JSON file," it generates: Which works fine, but I'd prefer it to use pathlib.Path for file operations. Is there a way to bias Codex toward modern Python 3.10+ idioms without overly verbose prompts? I've tried adding "using pathlib" to my prompts, but results are inconsistent. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
|
hey @BittuChan, You can fix Codex pretty effectively by including a few lines of example code in your prompt as context. Think of it like "few-shot" prompting. You can try something like: Codex will pick up on the style and continue in that pattern. You can also add a comment at the top like |
Beta Was this translation helpful? Give feedback.
-
|
Hii @Shiven0504 thanks for the quick suggestion! I created a small template file with pathlib examples and included the first few lines in my prompts now. |
Beta Was this translation helpful? Give feedback.
hey @BittuChan, You can fix Codex pretty effectively by including a few lines of example code in your prompt as context. Think of it like "few-shot" prompting. You can try something like:
Codex will pick up on the style and continue in that pattern. You can also add a comment at the top like
# Python 3.10+ with modern idiomsto set expectations.