some erroe fix
error fix in basic_commands.py.
Hi,
Couple ideas:
- Itself is one word.
- Double-quotation marks?
- How about tuples? Something like,
a = "a", "b", "c", "d", "e",
The above becomes an immutable tuple by the compiler. In general, tuples should perform a little better than lists, at least in terms of memory usage.
- This is confusing. Why use x twice?
Matrix = [[0 for x in range(5)] for x in range(5)]
Use an underscore if the index isn't needed.
Matrix = [[0 for _ in range(5)] for _ in range(5)]
- It's okay to put comments above the expression being referred to. No need for inline comments in most places.
No - print(Matrix[0][0]) # prints 1
Yes -
out: 1
print(Matrix[0][0])
- Good to check if exists first.
Current - def column(matrix, i): return [row[i] for row in matrix]
Suggested - def column(matrix, i): if len(matrix) == 0 or len(matrix[0]) >= i: return return [row[i] for row in matrix]
Etc.
Really, just a terrible file that could use a lot more improvement. Sorry if that comes across as rough as it's not a personal attack.
Best,
Mark M.
On Sun, Jun 1, 2025, 2:42 AM temp382000 @.***> wrote:
error fix in basic_commands.py.
You can view, comment on, or merge this pull request online at:
https://github.com/ujjwalkarn/DataSciencePython/pull/27 Commit Summary
- 8452907 https://github.com/ujjwalkarn/DataSciencePython/pull/27/commits/8452907f61b3d8ef91841be93816d5ae94540d77 some erroe fix
File Changes
(1 file https://github.com/ujjwalkarn/DataSciencePython/pull/27/files)
- M basic_commands.py https://github.com/ujjwalkarn/DataSciencePython/pull/27/files#diff-5e6cfe1c2dacb0bb9ba922163e6195eb3545dc5fe158f3e58470eca8afc0f289 (54)
Patch Links:
- https://github.com/ujjwalkarn/DataSciencePython/pull/27.patch
- https://github.com/ujjwalkarn/DataSciencePython/pull/27.diff
— Reply to this email directly, view it on GitHub https://github.com/ujjwalkarn/DataSciencePython/pull/27, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF62TY3PUVIBPAXJ5Q3XVWT3BLDHTAVCNFSM6AAAAAB6K4VMS6VHI2DSMVQWIX3LMV43ASLTON2WKOZTGEYDMOJWGQYTOOI . You are receiving this because you are subscribed to this thread.Message ID: @.***>