![]() |
what is the import command?
the tutorial i used never explain the "import" command
what does it do does it import a .py file into the window? so you dont have to type the whole program again like say i have a program then at the bottom i type import whatever when i go to edit\runscript it would run the first program then the imported one? i have no clue just tell me what the "import command does |
im just correcting my grammar
like say i have a program then at the bottom i type import "apple" when i go to edit\runscript would it run the first program then the imported program "apple" or no? i have no clue just tell me what the "import" command does |
ok
forget everythin i just said when u type something like print,if,elif,else,and,while, and other stuff it turns orange i call those commands what u want to call them u can when you type "import" in the "IDLE (GUI)" what does the import command do it turns orange when i type import |
i have python 2.0 if that helps
|
it turns orange becuase your text editor support syntax highlighting. import just imports a different package, so you can use functions from those packages.
|
There are several ways to use import, here is one example:
[php] # math sqrt() import math print "\nSquare root of integer formatted as float with 4 decimals:" for value in range(10): squareRoot = math.sqrt(value) print "sqrt(%d) = %.4f" % (value, squareRoot) [/php] The squareroot function is in module math. Notice how we used math.sqrt(value) to tie the two together. You can avoid the math prefix by using: from math import sqrt or if you use several other math functions: from math import * |
Quote:
ok you cofused me on that cause im jut a beginer i guess i know y i havent learned the import just yet :o |
all import does is allow you to import other fucntions. like if you want to work with a lot of math functions such as finding the sqareroot, then you would use
:
import mathI know it sounds like a lot, but it really isn't, it just expands the list of basic commands you have to work with. |
so if i was to type
import apple it would make apple a command? or only certain words if it does import apple what would the command do |
Quote:
|
| All times are GMT -5. The time now is 5:31 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC