Posts by Rafael Setton • 139 points
6 posts
-
0
votes2
answers312
viewsA: Optimizing Imports in python
A simple way to make Imports is to import all files from the folder: from data.creatures.monster_list import * The problem is that it would import the files and to access the classes would need to…
-
1
votes1
answer147
viewsA: Python Dictionary - Most Common Word Count
Your code does not work because you are selecting one character at a time and comparing it with a two or three letter word. You can try to turn the text into a list using the method split and remove…
-
-1
votes8
answers4052
viewsA: How to generate 200,000 primes as fast as possible in Python?
I think the most efficient way is, for each number test whether it is divisible by any of the smaller cousins than it. Example: primos = [2, 3, 5] ... # Para cada número entre 6 e 200000 define se…
-
0
votes2
answers207
viewsA: Use of multiple keys in Tkinter
You can use a Thread to perform both functions unchangingly. Example: from threading import Thread thread1 = Thread(target=func1) thread1.start() thread2 = Thread(target=func2) thread2.start()…
-
1
votes3
answers362
viewsQ: Functions with optional Python parameters
I want to create a function that has the first optional parameter. For example: the function range([start, ] stop [, step]) Thus, if only one argument is passed it is considered as the second…
-
0
votes3
answers1564
viewsA: Python variable reference return
If you write: a = [] b = a a.append(5) print(a) print(b) 'a' will always be equal to b. no matter what changes are made. To fix this, you can use the copy method(): a = [] b = a.copy() a.append(5)…