wyc / nxt-python

Automatically exported from code.google.com/p/nxt-python
GNU General Public License v3.0
0 stars 0 forks source link

Refactor mary.py (example) #42

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,
I'm just an nxt beginner, so I just tried the examples.
Everything is ok, I just felt like contributing some minor pythonistic 
enhancements to the mary.py example.
I introduced a loop that makes this file less verbose.

See the attached patch.

Original issue reported on code.google.com by christop...@gmail.com on 29 Jun 2012 at 8:14

Attachments:

GoogleCodeExporter commented 9 years ago
This looks great. Very clever way to fix do this. I applaud you. The only issue 
is that you've missed some "None" elements in that array where the rests should 
be (I see you have accounted for them in play(), they are simply omitted in 
apparent human error). Add those in and you've got it. I won't have time to 
apply this patch for another month (working in borrowed time right now) but 
will do so as soon as I am able. Thanks!

Original comment by marcus@wanners.net on 30 Jun 2012 at 12:21

GoogleCodeExporter commented 9 years ago
Thanks but please don't applaud me since this is programming basics! *You* 
deserve the congrats for nxt-python!
My patch keeps the rests since they do not to be coded as None. 0 is false too 
in Python so I defined R=0 (it could also have been ""). Please note the final 
«R» on each line of the melody. I thought this would make the program more 
readable…
Applying the patch next year is OK, or maybe you have some other commiter in 
the team?
And is it «array» or «list» (sorry for nit-picking!)?

Original comment by christop...@gmail.com on 30 Jun 2012 at 5:44

GoogleCodeExporter commented 9 years ago
Ah, I missed the R bit. Good thinking. If any of the other commiters see this, 
you are welcome to apply this patch to the trunk.

>>> type([])
<type 'list'>

Thanks again!

Original comment by marcus@wanners.net on 1 Jul 2012 at 12:03

GoogleCodeExporter commented 9 years ago
In my humblest opinion, R should be None and not "0".

Original comment by zbuh...@gmail.com on 28 Jul 2012 at 12:26

GoogleCodeExporter commented 9 years ago
Why not. Could be False too!
Le 28 juil. 2012 02:26, <nxt-python@googlecode.com> a �crit :

Original comment by christop...@gmail.com on 28 Jul 2012 at 6:55

GoogleCodeExporter commented 9 years ago
Done in r383. Thanks! I'd suggest checking and testing it as it appears in the 
trunk to make sure it hasn't been mangled somewhere.

Original comment by marcus@wanners.net on 6 Aug 2012 at 8:39