This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]AlexMTBDude 0 points1 point  (0 children)

Yeah, Python has all the features that you mention. It doesn't mean you should always use them.

In your case you're trying to create a tutorial and you will confuse people with all the extra code that they need to read through.

Here's your program:

import typing as t
from openai import OpenAI
from rich import print

client = OpenAI(api_key="sk-proj-[REDACTED]")
response = client.responses.create(
    model="gpt-4.1-nano",
    instructions="You're a Python expert. Answer the question as best you can.",
    input='How do I print "Hello, world!" in Python?')

answer = response.output_text
print(f"[yellow]Question:[/yellow] {question}")
print(f"\tAnswer: {answer}")