- 重要な情報
- はじめに
- 用語集
- ガイド
- エージェント
- インテグレーション
- OpenTelemetry
- 開発者
- API
- CoScreen
- アプリ内
- Service Management
- インフラストラクチャー
- アプリケーションパフォーマンス
- 継続的インテグレーション
- ログ管理
- セキュリティ
- UX モニタリング
- 管理
ID: python-best-practices/avoid-string-concat
言語: Python
重大度: 警告
カテゴリー: パフォーマンス
複数の文字列の連結は効率的ではなく、コードが読みにくく理解しにくくなります。
複数の文字列を連結する代わりに、f-文字列またはフォーマット文字列を使用します。
"my" + awesome + "string"
plop = "super" + "awesome" + "text"
"my {0} string".format(awesome)
f"my {awesome} string"
plop = "superawesometext"
function(
tags = (
user_tags
+ s.get("tags", [])
+ [
f"schedule_id:{s['_id']}",
f"schedule_name:{s['schedule_name']}",
f"git_ref:{schedule_git_ref}",
]
)
)