-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python tip of the week #4
Comments
I like to use pyflakes for checking my code while testing |
student_tuples = [ ('john', 'A', 15), ('jane', 'B', 12), ('dave', 'B', 10), ] Sort with the lambda function. |
sorting is a great item! especially using lambdas or the operator module for the key parameter. |
More suggestions:
|
example of splitting note sequence into phrases using >>> import itertools
>>> notes = ['sil', 'g', 'g', 'd', 'd', 'e', 'e', 'd', 'sil', 'c', 'c', 'b', 'b', 'a', 'a', 'g', 'sil']
>>> phrases = []
>>> for is_sil, group in itertools.groupby(notes, key=lambda note: note == 'sil'):
... if not is_sil:
... phrases.append(list(group))
...
>>> print(phrases)
[['g', 'g', 'd', 'd', 'e', 'e', 'd'], ['c', 'c', 'b', 'b', 'a', 'a', 'g']] |
Some suggestions of tips to email people about how to do things better in python
[ffont] I have a utility class for this in pymtg based in concurrent.futures. we can talk about that. I guess I could do this tip
+ '/' +
The text was updated successfully, but these errors were encountered: