boardbreaker Posted December 31, 2008 Share Posted December 31, 2008 hey does anyone no the best way of learning python? i really want to learn it Quote Link to comment Share on other sites More sharing options...
webjockey Posted December 31, 2008 Share Posted December 31, 2008 http://wiki.python.org/moin/BeginnersGuide I am trying to learn python myself :) , and what I found is that you need to learn the basics of python syntax and functions, but if you really want to do stuff with python you need to get the APIs for the various modules you import into your programmes. You learn them as you go. Modules are pretty much a bunch of functions, so, if I had a module called 'helloworld' with code like this: def print(check): if check == 1: return "Hello World!" then I had another python file called 'hell~2.py' with this code: import helloworld print helloworld.print(1) If I ran hell~2.py it would produce this: >>Hello World! Quote Link to comment Share on other sites More sharing options...
boardbreaker Posted December 31, 2008 Author Share Posted December 31, 2008 but were exactly do you enter this info Quote Link to comment Share on other sites More sharing options...
geekdba Posted January 1, 2009 Share Posted January 1, 2009 A text editor of your choice save the file as say test.py then from the command line : python test.py Quote Link to comment Share on other sites More sharing options...
ls Posted January 1, 2009 Share Posted January 1, 2009 I started with python using this excellent tutorial : http://hetland.org/writing/instant-hacking.html Quote Link to comment Share on other sites More sharing options...
boardbreaker Posted January 1, 2009 Author Share Posted January 1, 2009 ok thanks i will check it out Quote Link to comment Share on other sites More sharing options...
webjockey Posted January 2, 2009 Share Posted January 2, 2009 boardbreaker, you have to install python first, the latest version is 2.6.1, you can download it from here: http://www.python.org/download/ When you have installed python, you enter what I told you to enter into a text editor, and save it with a '.py' extension. With the example I gave you, you need to keep the names the same and for simplicity's sake, keep the files in the same directory, because they are referred to in the code. Python's 'default' IDE (that comes with the installation) is called IDLE, its quite good, it has syntax highlighting, and the interactive console provides a sandbox environment for you to test and run things, it also handles errors quite well, and unlike many languages, Python errors are *usually* quite easy to understand. Quote Link to comment Share on other sites More sharing options...
ivyl Posted January 4, 2009 Share Posted January 4, 2009 http://diveintopython.org/ From installing Python, through simple apps and OOP to advanced techniques. It describes most of useful stuff from standard library. I recommend installation of IPython http://ipython.scipy.org/moin/ which is much better than standard python interactive shell (completion, colorization, etc.). Quote Link to comment Share on other sites More sharing options...
boardbreaker Posted January 4, 2009 Author Share Posted January 4, 2009 i downloaded python and i will try out the code you gave me but what is it going to do? Quote Link to comment Share on other sites More sharing options...
snakey Posted January 5, 2009 Share Posted January 5, 2009 i hated python :P but that might be just me :P Quote Link to comment Share on other sites More sharing options...
webjockey Posted January 5, 2009 Share Posted January 5, 2009 the code I gave you was just a complicated way of making you get >>Hello World! in the console. It was to show you how modules and functions work. Just to explain again: a function is a bit of code that takes some variables in, manipulates them and returns a variable or a number or something. Its a simple Input>>Process>>Output system, and it works quite well. Quote Link to comment Share on other sites More sharing options...
boardbreaker Posted January 5, 2009 Author Share Posted January 5, 2009 ok i will try it out what else could i do with it Quote Link to comment Share on other sites More sharing options...
boardbreaker Posted January 5, 2009 Author Share Posted January 5, 2009 ok i entered the code you gave me in notepad and saved it as hello.py to my desktop but i went to go run it and it flashed a command promp and nothing else happened what was supposed to happen? Quote Link to comment Share on other sites More sharing options...
ls Posted January 5, 2009 Share Posted January 5, 2009 Your code probably worked, it printed "hello world" and closed immediately try something like this: print "hello, world" raw_input() this will print hello world and when you press enter it will close Quote Link to comment Share on other sites More sharing options...
webjockey Posted January 6, 2009 Share Posted January 6, 2009 Basically, by default, python scripts in windows run through the command prompt, which of course closes after it has executed everything you told it to. I recommend that you use IDLE instead (You will find it in your Program Files) Because it doesn't close when it finished executing code. Quote Link to comment Share on other sites More sharing options...
boardbreaker Posted January 6, 2009 Author Share Posted January 6, 2009 i am not sure but i dont think it worked what codes could i try in IDLE to see if it works rite? Quote Link to comment Share on other sites More sharing options...
X3N Posted January 6, 2009 Share Posted January 6, 2009 open a command prompt and run the python command from the command prompt instead of double clicking it... then the prompt will stay open. Quote Link to comment Share on other sites More sharing options...
Hushed Posted January 7, 2009 Share Posted January 7, 2009 Go to programs and open up IDLE. Then go up to file, and then new. You can type, and save code there. Remember to add .py to your saved files, otherwise syntax coloring will turn off. IDLE is just where it is interpreted / a place to test code. In IDLE you can type: a = "Hello World!" print a It should print Hello World in the IDLE. I like this Python Tutorial series Python Tutorial Quote Link to comment Share on other sites More sharing options...
boardbreaker Posted January 7, 2009 Author Share Posted January 7, 2009 ok thanks i need to play around with it until i get it right but i will get it Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.