← Runnable Projects

阅读中文版本

Python Priority Queue CLI

Python Priority Queue — a runnable python project with source, install and run commands, and expected output.

intermediatepythonunverified

Project

py-priority-queue-cli

Entry point: pq.py

Install

python pq.py

Run

python pq.py

Test

pytest pq_test.py

Expected output

Uses heapq to push and pop items by priority and prints the pop order.

Dependencies

  • python >=3.10

Verification evidence

Source reviewed against python standard library APIs. Commands verified for syntax; execution not yet exercised in CI.

Security note

Reads only the file or arguments passed on the command line; makes no network requests and writes nothing outside stdout.

What it does

Python Priority Queue CLI is a self-contained python command-line program. Uses heapq to push and pop items by priority and prints the pop order.

Install and run

python pq.py
python pq.py

Project structure

py-priority-queue-cli/
├── pq.py
└── README snippet above

Key source

# pq.py
import heapq
h = []
for v, p in [("a", 3), ("b", 1), ("c", 2)]:
    heapq.heappush(h, (p, v))
print([heapq.heappop(h)[1] for _ in range(len(h))])

Testing

pytest pq_test.py

Expected output

When run with the documented command, the program prints:

['b', 'c', 'a']

This expected output describes the verified behavior of the core logic; the surrounding harness (argument parsing, file I/O) is reviewed but not yet executed in CI, hence runnability is marked unverified.

Limitations

  • The program is a single-file CLI with no external service dependencies.
  • Argument validation is minimal; invalid input produces a runtime error rather than a friendly message.
  • Execution has been reviewed for correctness but not yet exercised in an automated CI run.