Page 6 sur 8

Re: Le Python et la Nspire enfin réunis grâce à "Micro Pytho

Message non luPosté: 26 Jan 2015, 17:19
de Lionel Debroux
En effet.

Dans le détail: https://github.com/micropython/micropython mentionne actuellement explicitement
Micro Python implements the entire Python 3.4 syntax (including exceptions, "with", "yield from", etc.). The following core datatypes are provided: str (no Unicode support yet), bytes, bytearray, tuple, list, dict, set, array.array, collections.namedtuple, classes and instances. Builtin modules include sys, time, and struct. Note that only subset of Python 3.4 functionality implemented for the data types and modules.


Le projet python-on-a-chip (p14p, PyMite), plus ancien, n'implémentait pas tout.

Re: Le Python et la Nspire enfin réunis grâce à "Micro Pytho

Message non luPosté: 27 Sep 2015, 11:12
de Vogtinator
Here is a beta version of micropython, based on upstream version v1.4.6-30-g3ab40ba-dirty.
There might be some new bugs, some fixes and some other horrible and nice things included.
If you encounter any issues, please report them on GitHub.
If you want to check out the source code, it's on GitHub as well, branch "next": https://github.com/Vogtinator/micropython/tree/next

Re: Le Python et la Nspire enfin réunis grâce à "Micro Pytho

Message non luPosté: 27 Sep 2015, 12:55
de Bisam
Wow, the new file is half-sized ! Did you remove anything ?

Why didn't you include the "randomizer" I saw as an example in some func ? Random functions clearly are missing, for example if one wants to make any game.

Will there be any more existing modules included later (e.g. "os", "random", "time", "functools") ?

PS : As for now, I tested all the files I had on calc and didn't find any bug.

Re: Le Python et la Nspire enfin réunis grâce à "Micro Pytho

Message non luPosté: 27 Sep 2015, 13:29
de Vogtinator
Bisam a écrit:Wow, the new file is half-sized ! Did you remove anything ?

Nope, I even enabled some new upstream features, like uzlib, ujson, ure, uheapq, uhashlib, ubinascii and probably most useful, machine,
which makes direct memory read/writes possible. I had to enable Zehn compression as the resulting tns was almost a MiB in size...

Why didn't you include the "randomizer" I saw as an example in some func ? Random functions clearly are missing, for example if one wants to make any game.

How should it be implemented?

Will there be any more existing modules included later (e.g. "os", "random", "time", "functools") ?

There is https://github.com/micropython/micropython-lib, but porting that (or even parts) would be a huge amount of work.

PS : As for now, I tested all the files I had on calc and didn't find any bug.

Great, thanks for testing!

Re: Le Python et la Nspire enfin réunis grâce à "Micro Pytho

Message non luPosté: 27 Sep 2015, 13:39
de Bisam
Vogtinator a écrit:How should it be implemented ?

Well, a "rand" function added to the "nsp" module, for example (this function returning a random number in ]0,1[ ). It would be enough, I think.
The one implemented here should make it...

Re: Le Python et la Nspire enfin réunis grâce à "Micro Pytho

Message non luPosté: 27 Sep 2015, 15:36
de Ti64CLi++
Comment utiliser le module nsp?
Est-ce que la fonction help() existe?
Comment savoir la liste des fonctions dans un module?
Merci d'avance

Re: Le Python et la Nspire enfin réunis grâce à "Micro Pytho

Message non luPosté: 27 Sep 2015, 15:52
de Bisam
1) Import nsp
2) pas de fonction "help"
3) dir(module)

Re: Le Python et la Nspire enfin réunis grâce à "Micro Pytho

Message non luPosté: 27 Sep 2015, 15:53
de Ti64CLi++
Merci beaucoup Bisam
Pour le 1), je voulais en fait savoir comment utiliser les fonctions ;)
Et comment je peux savoir la syntaxe d'une fonction, et comment générer des nombres pseudos-aléatoires?

Re: Le Python et la Nspire enfin réunis grâce à "Micro Pytho

Message non luPosté: 27 Sep 2015, 21:44
de Bisam
Une fois que tu as importé un module nommé "machin" en faisant import machin, tu utilises la fonction "truc" du module en faisant machin.truc(..).
Pour savoir comment l'utiliser, y'a pas vraiment le choix : il faut avoir un exemple ou bien faire des tests car l'interpréteur n'a pas d'autocomplétion, et les attributs __doc__ ne semblent pas fonctionner.

Re: Le Python et la Nspire enfin réunis grâce à "Micro Pytho

Message non luPosté: 28 Sep 2015, 12:31
de Ti64CLi++
Merci beaucoup Bisam pour tes réponses ;)
Dommage, il faudrait reporter cette amélioration a faire a Vogtinator :D