New answers tagged

2

Instead of creating an empty list and appending the values to it, try using list comprehension. so instead of y_location = [] x_location = [] for each in range(-size, size+1): y_location.append(parabola(each, size)) x_location.append(each) try y_location = [parabola(each,size) for each in range(-size,size+1)] x_location = list(range(-size,size+1))...


3

Your global variable naming violates PEP 8. Names in all upper-case are constants; variables that never change in value. Your globals aren't constant though. Lines like LIVES -= 1 change the value that LIVES holds. Yes, global names should be in uppercase, but only because globals should also ideally only be constants. Global mutable state is a pain to ...


3

It's clear that you're starting to pick up some good habits, but this code still has a way to go. This is a comment Module Docstring: No need to write this - it's obvious from context. Type hints def __init__(self, sf, cho, noa): Those parameters have no documentation, and it isn't clear what type they are. Do a Google for type hinting in Python - that ...


2

Loops are your friend. Much of your function can be replaced with: for row, (name, data) in enumerate(zip(( 'Pilot name', 'AC name', 'COAM (money)', 'FRS Memory' ), read_data(APGD))): tk.Label(window, text=f'{name}: ').grid(row=row) e = tk.Entry(window) e.grid(row=row, column=1) e....


2

It depends what direction you want to go with your program, but my suggestion would be to make small factories for components you use the most often. Here it seems you are building a common UI feature: a form with several fields. Since you only have a single form you don't really benefit from abstracting the form for now, except for clarity, but you benefit ...


1

Firstly I'd suggest following PEP8 and/or using an auto-formatter like black, but if it's just you working on it that is a bit less of an issue than if other people were involved. Suffice to say, most code follows that and it usually gets flagged first thing (because it's so noticeable). Reading the code, is that all there is, you are able to log in via a ...


2

Some improvement, but there's still more :) Don't semicolon-delimit statements self.window = super(); self.window.__init__() There's nearly never a good reason to do this. Just use two lines. .ini support https://docs.python.org/3/library/configparser.html is what you should be using instead of manual parsing for an actual .ini file. Inline functions ...


0

Welcome to CodeReview! Good first post. Comments Having comments is great. Your convention is a little odd - there's no need for triple hashes. A single hash at the beginning is more common. File handling Your intention was good, but the execution could be improved. Firstly, at this level, don't except Exception. It's too broad. Let exceptions be ...


Top 50 recent answers are included