Conversation
sakzk
reviewed
Jun 7, 2024
|
|
||
| ```python | ||
| from collections import defaultdict | ||
|
|
There was a problem hiding this comment.
全体的にどの回答も読みやすかったです。自分はソートした s をキーにする方法は思いつかなかったのですが、s が小さければソートも重くないと思うのでよいですね。
一点、フォーマッタで自動で整形されそうですが、import のあとの改行が1行だったり2行だったりするのが気になりました。
import 文に続く処理が、import 関連かそうでないものかでも変わると思うのですが、トップレベルの import のあとは2行開けるのものなのかと思いました。(PEP8に、Surround top-level function and class definitions with two blank lines. Method definitions inside a class are surrounded by a single blank line. とあったためです)
https://peps.python.org/pep-0008/#blank-lines
実際どうなっているか chromium と cpython を調べたところ、
- chromium の python ファイルでは、コメントや定数の定義が続く場合は1行だけ改行するのもがありました。
https://source.chromium.org/search?q=.py - cpython の python ファイルでも改行が1行だったり2行だったりしたのですが、1行だけ開ける場合の基準はよくわかりませんでした。
https://github.com/search?q=repo:python/cpython%20path:.py&type=code
Owner
Author
There was a problem hiding this comment.
有難うございます。励みになります!
はい、意図したものではないです。。ご指摘のとおり、PEP8に則り基本的には2行空けるようにしていた(つもり)でした。
chromium と cpythonの調査もして頂き有難うございました!
確認しますね。
import文後の空行を2行に統一
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://leetcode.com/problems/group-anagrams/description/