0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Python の REPL が良くなっているという話

0
Posted at

Python の REPL が良くなっているという話

最近 Python3.12 の REPL を起動したら現在(3.14)との違いを感じたので思いついたところを覚え書きする記事。

テストスクリプトは以下のものを使う。複数行あれば内容は何でもいいので読む必要はない。説明もしない。
"""1 Repetition Maximum を伸ばしていくステップをオコナー式で求めるプログラム"""
def one_rm(weight, reps):
    return weight * (1 + reps / 40)

weight = 20
target = 80
reps = 10       # ← 自由に変更可能
step = 0
max_steps = 1000  # 安全装置

# 増加しないケースを事前に排除
if reps <= 0:
    raise ValueError("reps must be > 0 to ensure weight increases")

while weight < target and step < max_steps:
    step += 1
    weight = one_rm(weight, reps)
    print(f"{step}, {round(weight, 1)}")

if step == max_steps:
    print("最大ステップ数に到達したため終了")
else:
    print(f"到達: {step}ステップで {round(weight,1)}")

exit

exitquit()なしで呼び出せるようになった。
いろんな言語・環境で REPL を打ち切ってやめるコマンドが別れている。
例えば Swift では :quit になる。
Node なら .exit、 Gauche なら (exit) のようになっていてなかなか思い出せない。
exit? いや quit ? ああ :q かみたいなことになる。
最近の Python は quitexit どっちでも終了でき () をつけ忘れても終了できるのはかなり便利だ。

履歴モード

F2キーで履歴モードに入りプロンプトを除いた履歴リスト表示できるようになった。

色付け

色つけしてくれるようになった。説明より見たほうが早い。
これが
Screenshot from 2026-04-30 01-26-18.png
こうなった
image.png

構文ごとに色分けされ、可読性がかなり向上している。

ブロック単位操作

ブロック単位でコピペ、アンドゥなどできるようになった。

image.png

カーソルキー1回で複数行まとめてアンドゥできている点に注目。

終わりに

なにか思いついたら追記します。

Link

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?