มีหลายวิธีในการใช้คำสั่งหลายบรรทัดใน command line ของ Python ตัวอย่างเช่น bash รองรับ multiline statements ซึ่งใช้ได้ดังนี้
ตัวอย่าง
$ python -c '
> a = True
> if a:
> print("a is true")
> '
ผลลัพธ์
จะได้ผลลัพธ์ดังนี้
a is true
หากต้องการให้คำสั่ง Python อยู่บรรทัดเดียว สามารถใช้ \n newline ระหว่างคำสั่งได้
ตัวอย่าง
$ python -c $'a = True\nif a: print("a is true");'
ผลลัพธ์
จะได้ผลลัพธ์ดังนี้
a is true