Python/C4/Writing-python-scripts/Tamil
From Script | Spoken-Tutorial
| Time | Narration |
|---|---|
| 0:01 | "Writing Python scripts" tutorial க்கு நல்வரவு! |
| 0:05 | இந்த டுடோரியலின் முடிவில் செய்ய முடிவது....
|
| 0:19 | இந்த tutorial ஐ ஆரம்பிக்கும் முன், "Using Python modules" டுடோரியலை முடிக்கவும். |
| 0:25 | அடிக்கடி, நாம் எழுதிய code ஐ மறு முறை பயன்படுத்த வேண்டியிருக்கும். |
| 0:29 | அதை functions மூலம் செய்யலாம். |
| 0:31 | Function கள் package களாக bundle செய்யப்பட்டு தேவையானபடி மற்ற script களில் import செய்யப்படும். |
| 0:37 | முதலில் இரண்டு number களின் gcd ஐ கணக்கிடும் function ஐ எழுதி, ஒரு script ஆக சேமிப்போம். |
| 0:44 | editor ஐ திறந்து code ஐ type செய்க: |
| 0:47 | indentation ஐ மறக்க வேண்டாம். |
| 0:51 | type செய்க: def gcd within bracket a comma b colon
while b colon
a comma b = b comma a modulo b
return a |
| 1:49 | script இல் இயங்கும் ஒவ்வொரு முறையும் gcd function சோதிக்கும்படி ஒரு test function ஐ எழுதுவோம். |
| 1:56 | type செய்க:
if gcd within bracket 40 comma 12 == 4 colon print within double quotes Everything OK else colon print within double quotes The GCD function is wrong
|
| 2:53 | அந்த file ஐ gcd underscore script.py என slash home slash fossee slash gcd underscore script.py இல் சேமிப்போம். |
| 3:06 | script ஐ terminal லில் டைப் செய்து இயக்கலாம். |
| 3:11 | python slash home slash fossee slash gcd underscore script.py |
| 3:25 | script execute ஆகிறது, எல்லாம் நலமே! |
| 3:29 | சரி, ஒரு வேளை நம் மற்ற script களில்.... இந்த gcd function ஐ ... பயன்படுத்த நினைத்தால்? |
| 3:35 | இது முடியும். ஏனெனில் ஒவ்வொரு python file ஐயும் ஒரு module ஆக பயன்படுத்தலாம். |
| 3:39 | முதலில், module ஐ import செய்தால் என்ன நடக்கிறது என்று அறிக. |
| 3:43 | terminal இல் type செய்க: ipython |
| 3:52 | IPython ஐ திறந்து type செய்க: import sys (enter செய்க;)
sys.path |
| 4:15 | import statement ஐ சந்திக்கும் போது module க்காக python தேடும் இடங்களின் பட்டியல் இது. |
| 4:19 | நாம் import sys என்னும் போது python sys.py என பெயரிட்ட … ஒரு file ஐ ...
அல்லது sys என பெயரிட்ட ஒரு folder ஐ …. கண்டுபிடிக்கும் வரை, இந்த இடங்களில் எல்லாம் தேடுகிறது. |
| 4:34 | நாம் script ஐ இந்த இடங்கள் ஒன்றில் வைத்தால் import செய்யலாம். |
| 4:38 | list இல் முதல் item ஒரு empty string; இதன் பொருள் …. நடப்பு working directory உம் தேடப்படுகிறது. |
| 4:45 | மாறாக, working script இருக்கும் directory- ரிலேயே module இருக்குமானால் அதை import செய்யலாம். |
| 4:53 | slash home slash fossee, இல் இருப்பதால்... நாம் வெறுமே... |
| 4:58 | terminal இல் import gcd underscore script.py என எழுதலாம். |
| 5:13 | gcd underscore script .... import ஆகிவிட்டதை காணலாம். |
| 5:18 | ஆனால் நாம் file இன் கடைசியில் எழுதிய test code உம் execute ஆகிவிட்டது. |
| 5:23 | நமக்கு வேண்டியது..... file ஐ python script ஆக இயக்கும்போது மட்டுமே test code … execute ஆக வேண்டும். அதை import செய்யும் போது அல்ல. |
| 5:30 | இதை சாதிப்பது underscore underscore name underscore underscore variable. |
| 5:34 | idiom மை எப்படி பயன்படுத்துவது என பார்த்த பின் … அது எப்படி வேலை செய்கிறது என்று புரிந்துகொள்ளலாம். |
| 5:41 | file க்கு சென்று இந்த line ஐ code இன் ஆரம்பத்தில் சேர்க்கவும். பின் code ஐ தகுந்தாற்போல indent செய்க. |
| 5:47 | type செய்க: if underscore underscore name underscore underscore == within double quotes underscore underscore main underscore underscore colon |
| 6:30 | முதலில் code ஐ இயக்குவோம். |
| 6:33 | terminal லில் type செய்க: python gcd underscore script.py |
| 6:45 | நாம் ஒரு |
| 6:48 | error வருவதை காணலாம், அது indentation error. |
| 6:56 | ஆகவே file ஐ edit செய்து indentation ஐ சரி செய்ய வேண்டும். |
| 7:20 | இப்போது test வெற்றிகரமாக இயங்குகிறது. |
| 7:24 | இப்போது file gcd underscore script ஐ import செய்யலாம். |
| 7:29 | type செய்க: import gcd underscore script |
| 7:38 | இப்போது test code execute ஆகவில்லை என்பதை காணலாம்.
underscore underscore name underscore underscore variable என்பது ஒவ்வொரு module க்கும் local ஆகும்; மேலும் அது file script ஆக இயங்கும்போது மட்டும் underscore underscore main underscore underscore என்பதற்கு சமமாகும். |
| 7:54 | ஆகவே, if block க்குள் வரும் எல்லா code உம், if underscore underscore name underscore underscore == within double quotes underscore underscore main underscore underscore colon file ஆனது python script ஆக இயங்கும்போது மட்டும் execute ஆகும். |
| 8:08 | இத்துடன் இந்த டுடோரியல் முடிகிறது. |
| 8:11 | இந்த டுடோரியலில், கற்றவை, 1. ஒரு module ஐ import செய்யும் போது என்ன நடக்கிறது என அறிதல் |
| 8:16 | 2. script ஒன்றை module ஆக பயன்படுத்துதல் |
| 8:18 | 3.test functions ஐ underscore underscore name underscore underscore idiom ஐ பயன்படுத்தி எழுதுதல், |
| 8:22 | தீர்வு காண self assessment கேள்விகள் |
| 8:26 | 1. python module களை தேட இடங்களை பின் வரும் variable களில் எது கொண்டு இருக்கிறது?
|
| 8:38 | 2. ஒரு module இல் function கள் மட்டுமே இருக்க வேண்டும் - True - False |
| 8:43 | 3. script utils.py PYTHONPATH இன் இடங்களில் ஒன்றில் இருக்கிறது. மேலும் பின் வரும் code அதில் இருக்கிறது.“import utils”
செய்த பின் “show” function ஐ எப்படி செய்வது? |
| 9:00 | விடைகள் இதோ |
| 9:04 | 1. python module களை தேட இடங்களை sys.path கொண்டு இருக்கிறது |
| 9:10 | 2. False. |
| 9:13 | ஒரு module க்கு ஒரு பெரிய range இல் function கள் இருக்கலாம். |
| 9:19 | 3. import utils ஐ செய்தபின் நாம் function show() ஐ இப்படி பயன்படுத்தலாம்;
utils.show within bracket double quotes hey |
| 9:32 | இந்த டுடோரியல் சுவாரசியமாகவும் பயனுள்ளதாகவும் இருந்திருக்கும் என நம்புகிறேன். |
| 9:35 | நன்றி! |