DataSciencePython icon indicating copy to clipboard operation
DataSciencePython copied to clipboard

some erroe fix

Open temp382000 opened this issue 7 months ago • 1 comments

error fix in basic_commands.py.

temp382000 avatar Jun 01 '25 09:06 temp382000

Hi,

Couple ideas:

  1. Itself is one word.
  2. Double-quotation marks?
  3. 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.

  1. 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)]

  1. 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])

  1. 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

File Changes

(1 file https://github.com/ujjwalkarn/DataSciencePython/pull/27/files)

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: @.***>

MarkMoretto avatar Jun 01 '25 18:06 MarkMoretto