IBrython, iPython 3 yokumiliselwa kwenkqubo yewebhu esecaleni yabathengi

Mva nje ukukhutshwa kwenguqulelo entsha yeprojekthi yeBrython 3.10 yabhengezwa (Isikhangeli sePython) esiza nefayile ye- ukumiliselwa kolwimi lwenkqubo yePython 3 yolwenziwo kwicala lesikhangeli sewebhu, Ukuvumela ukuba usebenzise iPython endaweni yeJavaScript ukuphuhlisa izikripthi zeWebhu.

Ngokudibanisa ibrython.js kunye brython_stdlib.js iilayibrari, umphuhlisi wewebhu angasebenzisa iPython ukuchaza indawo esecaleni labathengi, esebenzisa iPython endaweni yeJavaScript.

Ukufaka ikhowudi yePython kumaphepha, kuya kufuneka usebenzise ithegi ngo "text / python" mime type, oku kuvumela zombini ukufaka ikhowudi kwiphepha kunye nokulayisha izikripthi zangaphandle ( ). El script proporciona acceso completo a los elementos y eventos DOM.

Ukongeza ukufikelela kumgangatho weThala leencwadi, kukho iilayibrari ezikhethekileyo ukunxibelelana neelayibrari ze-DOM kunye neJavaScript ezinje ngejQuery, D3, Highcharts, kunye neRafael. Ukusetyenziswa kwezakhelo zeCSS Bootstrap3, LESS kunye ne-SASS kuyaxhaswa.

Ukwazi ukuqhuba iPython kwisikhangeli sewebhu kuvumela:

  • Sebenzisa ikhowudi yePython efanayo kwiseva nakwibhrawuza.
  • Sebenza ngee-API ezahlukeneyo zesikhangeli usebenzisa iPython
  • Sebenzisa iModeli yeNqaku loXwebhu (i-DOM) ngePython
  • Sebenzisa iPython ukunxibelelana neelayibrari ezikhoyo zeJavaScript ezinje ngeVue.js kunye ne-jQuery
  • Fundisa uLwimi lwePython kubafundi bePython ngeBrython Editor
  • Gcina imvakalelo yolonwabo ngelixa usenza iprogram yePython

Iziphumo ebecaleni lokusebenzisa iPython kwisikhangeli yilahleko yokusebenza ngokuthelekiswa nekhowudi efanayo kwiJavaScript.

Ukwenza ikhowudi yePython kwiibhloko se realiza mediante la compilación previa de este código yinjineli yaseBrython emva kokuba iphepha lilayishiwe. Ukudityaniswa kuqalwa ngokubiza umsebenzi we-brython (), umzekelo ukongeza « ».

Ngokusekwe kwikhowudi yePython, Umelo lweJavaScript luyenziwa, oluya kuthi emva koko lwenziwe ngumkhangeli osemgangathweni weJavaScript (Thelekisa, iPyPy.js projekthi ibonelela nge-CPython itoliki ehlanganiswe kwi-asm.js ukuqhuba ikhowudi yePython kwisikhangeli, kwaye i-Skulpt isebenzisa itoliki kwiJavaScript.)

Isiza saseBrython siphawula ukuba ukuphunyezwa kwesantya kuthelekiswa neCPython. Kodwa uBrython ubaleka kwisikhangeli kunye nesalathiso kule meko yiJavaScript eyakhelwe ngaphakathi kwinjineli yesikhangeli. Ngenxa yoko, lindela ukuba uBrython acothise kancinci kune-JavaScript ebhalwe ngesandla.

UBrython Yenza ikhowudi ye-python kwi-JavaScript kwaye usebenzise ikhowudi evelisiweyo. La manyathelo anefuthe kwintsebenzo iyonke kwaye iBrython ayinakuhlala ihlangabezana neemfuno zakho zomsebenzi. Ngamanye amaxesha, unokufuna ukuthumela ukwenziwa kweekhowudi kwiJavaScript okanye nakwiWebhu. Uza kubona indlela yokwakha iWebhu yokuHlanganisa kunye nendlela yokusebenzisa ikhowudi ekhokelela kwiPython kwicandelo leWebAssembly.

Nangona kunjalo, musa ukuvumela ukusebenza okubonwayo kukuyekise ukusebenzisa iBrython. Umzekelo, ukungenisa iimodyuli zePython kunokubangela ukhuphelo lwemodyuli ehambelana neseva

Ewe Inguqulelo entsha, ibonakala ngokungqinelana kwayo nePython 3.10, kubandakanya inkxaso yomqhubi wokuthelekisa ipateni (umdlalo / ityala).

Inguqulelo entsha nayo oibonelela ngokusetyenziswa kokuqala komthi ongaziwayo (AST, Abstract Syntax Tree) yolwimi lwePython, olunokuthi emva koko lusetyenziselwe ukwenza ikhowudi yeJavaScript kwi-AST yendalo iphela.

Ukuphumeza iBrython kunokwenziwa ngokongeza le khowudi kwiwebhusayithi:

<script type="text/javascript"
src="https://cdn.jsdelivr.net/npm/brython@3.9/brython.min.js">
</script>
<script type="text/javascript"
src="https://cdn.jsdelivr.net/npm/brython@3.9/brython_stdlib.js">
</script> 

O

<script type="text/javascript"
src="https://cdn.jsdelivr.net/npm/brython@3/brython.min.js">
</script>
<script type="text/javascript"
src="https://cdn.jsdelivr.net/npm/brython@3/brython_stdlib.js">
</script>

Okanye inokufakwa kwicala leseva ngokusebenzisa lo mthetho ulandelayo:

pip install brython

Gqibela ukuba unomdla wokwazi okungakumbi ngayo, ungajonga iinkcukacha Kule khonkco ilandelayo. Ikhowudi yeprojekthi ibhaliwe kwiPython kwaye ihanjiswa phantsi kwelayisensi ye-BSD.


Umxholo wenqaku uyabambelela kwimigaqo yethu imigaqo yokuziphatha yokuhlela. Ukuxela impazamo cofa apha.

Yiba ngowokuqala ukuphawula

Shiya uluvo lwakho

Idilesi yakho ye email aziyi kupapashwa. ezidingekayo ziphawulwe *

*

*

  1. Uxanduva lwedatha: UMiguel Ángel Gatón
  2. Injongo yedatha: Ulawulo lwe-SPAM, ulawulo lwezimvo.
  3. Umthetho: Imvume yakho
  4. Unxibelelwano lwedatha: Idatha ayizukuhanjiswa kubantu besithathu ngaphandle koxanduva lomthetho.
  5. Ukugcinwa kweenkcukacha
  6. Amalungelo: Ngalo naliphi na ixesha unganciphisa, uphinde uphinde ucime ulwazi lwakho.