Re: Python troubles
Re: Python troubles I used visual studio for a while. Took up way too much memory, I already have Python installed fully. Python 3.8. URL: https://forum.audiogames.net/post/471457/#p471457 -- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
Re: Python troubles
Re: Python troubles Never seen that one. Also, most editors have a smart indentation featue, i.e.: you indent once and they keep indenting each line until you force it to unindent or you deepen the indent. URL: https://forum.audiogames.net/post/471010/#p471010 -- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
Re: Python troubles
Re: Python troubles @8, another common one that i've seen in learning python guides is 5 spaces URL: https://forum.audiogames.net/post/470997/#p470997 -- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
Re: Python troubles
Re: Python troubles Most people don't actually press space four times following each and every statement.Instead, almost all decent editors have a toggle to insert tabs as spaces as well as configurable tab width.You can theoretically use any number of spaces/tabs, but convention is follows (in order from most to least popularity):four spacessingle tab (\t)two spacesone space URL: https://forum.audiogames.net/post/470996/#p470996 -- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
Re: Python troubles
Re: Python troubles @6 not in all cases. Common indenting conventions are 1 tab, 1 space, 2 spaces or 4 spaces with 4 spaces being the most common. It depends on the project you are working in. URL: https://forum.audiogames.net/post/470954/#p470954 -- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
Re: Python troubles
Re: Python troubles Hot Tip: Use the tab key to indent, not the space bar! Part of programming is adhering to code conventions, and this is one that a lot of people mess up. URL: https://forum.audiogames.net/post/470919/#p470919 -- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
Re: Python troubles
Re: Python troubles Hi!I would strongly recommend you check out my python guides found here. While the grammar is not at it's finest, I do get the main points across. URL: https://forum.audiogames.net/post/470814/#p470814 -- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
Re: Python troubles
Re: Python troubles OK, this is real simple, and I think you're not getting it because you're overthinking it. whenever a line of python code ends in a colon, that next line needs to be indented. In truth, Python does not care how much you indent. What it does care about is that you do it consistently, so that each block of code uses the same level of indentation.I think blind programmers just use tab, Python style suggests to use spaces. It really doesn't matter though, unless you're contributing to someone else's project, then you'll want to follow their ways.You'll want an editor of some sort, not a word processor. I'm using Notepad2, but you can use whatever code editor you want. It doesn't need to be fancy or anything, but one nice feature to have is autoindent which carries over the indent from the previous line unless you hit shift tab or backspace.Just to sum up, any line in python that ends in a colon will require a block of code. Blocks of code must use consistent indentation, but it doesn't matter how much to the interpreter. You should consider using a code editor.Here's an example of some python codefrom sys import exit def get_numbers(): """Collect numbers Prompts for numbers and then returns a list.""" numbers = [] # A blank list stop = False # a flag that when flipped will stop the for loop below print("Enter numbers to be summed. After each number, press RETURN. When you're done, press RETURN without entering anything else on that line.") while not stop: #Grab the input ipt = input("> ") # Check if the input is an empty string if ipt == "": # An empty string #We've got to check if the list has at least two numbers in it, if not, we can't sum them so force the loop to start again if len(numbers) < 2: print("You need at least two numbers to sum together.") continue else: #We flip that flag and the loop terminates stop = not stop # simple inversion, stop = True would also have worked else: try: #Try to catch exceptions numbers.append(int(ipt)) # Attempt to append the result of typcasting the string input gives to an int into the list print("{:>}".format(ipt)) except Exception as e: # Whatever the error is, it'll get stored in 'e' if isinstance(e, ValueError): # typecheck e to see if it is an instance of the ValueError class print("That is not a number. Please enter a number or simply press RETURN to finish.") continue else: #Who knows, we'll just print a generic message with the error in it print(f"The program ran into a problem and could not complete. The error was: {e}") # An f-string exit(1) # exit with a failure code return numbers number_list = get_numbers() # call our function and store the list it returns into a variable print("The total is: ", sum(number_list)) # call the builtin sum function, passing in our list of numbers) URL: https://forum.audiogames.net/post/470733/#p470733 -- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
Re: Python troubles
Re: Python troubles Run cmd as admin, so, windows x, a, then pip install pygame. In regards to indenting, are you having trouble knowing when to indent or what?Any time there's a colon at the end of a line, you indent the lines below it, until that function or loop is done. You can do this one of 3 ways1: 4 or 5 spaces for one indent. Like thisdef example(): print("Example")example()2: Tabs, the way I like to do it. 1 tab = 4 spaces, so I use those, because mashing my spacebar can get annoying. Here's the same example, using tabs. And yes, this code does run.def example(): print("Example")example()3: Just 1 spaceYou can also use single spaces instead of 4 or 5Here's the same example code with thatdef example(): print("Example")example()I hope this helped! URL: https://forum.audiogames.net/post/470725/#p470725 -- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
Re: Python troubles
Re: Python troubles If using NVDA, enable the indentation beeps.make sure when installing pygame you are running your command prompt in adminstrative mode. URL: https://forum.audiogames.net/post/470715/#p470715 -- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
Python troubles
Python troubles Dear audiogame devs, So, I've been trying to learn. I've done hours of research concerning Python and all it has. Unfortunately, there are some problems with Python that I'm having that I can't seem to solve. All I'm trying to accomplish is a basic Windows application. Problem is, the white space requirements of Python are holding me back. I can enter code in no problem, but without knowing how much white space/indentation is needed for each block of code, it won't run. All I want to do is make a simple game, nothing too fancy. But those white space requirements are what's keeping me from coding in this supposedly easy language. Also, pip install pygame doesn't seem to work, giving me a syntax error. I've put it in the console when launching Python 3.8. My questions are: I. How do I know how much white space I need to put into a certain amount of code? II: How do I know whether I've put in the right amount? Thanks. . URL: https://forum.audiogames.net/post/470714/#p470714 -- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector