CPUFreak91![]() Member Posts: 2337 From: Registered: 02-01-2005 |
I got Learning Python, and am reading it. here's where I'll post my Q's. BTW--What's a floating point? ------------------ |
CPUFreak91![]() Member Posts: 2337 From: Registered: 02-01-2005 |
Also, please talk only in code and python related things. In Changes, D-SIPL mention that the place is a bit slow and boring (that's my own words) so when you post, please post only about python: terms, codes, and definitions. Please, no switching off to other topics (that goes for me too ![]() ------------------ [This message has been edited by CPUFreak91 (edited February 18, 2005).] |
graynod![]() Member Posts: 17 From: richmond, VA, USA Registered: 09-28-2004 |
CPUFreak91, A floating point number, or 'float', is just a number with a decimal, or fractional, part. If the fractional part is 0, it might not be displayed. Python seems actually to be using doubles but that's OK. Also, you hafta remember "Everything's an object!" in Python, so later on I'm sure there will be use made of, for instance, float object attributes. Now compare a float to an integer, which is a number with only a whole part, like 1, 2, 3... What's easy with Python is you really don't have to worry about the type up front (this bothers me no end though as a C++ fan...). Try this in your Python programming: # create a float to use: Have you checked out: It's _really_ simple, not for old hands at all, but should be perfect for newbies (please don't take offense at that, I consider myself a newbie at many things, including Python A little later on it might be time for this one: What are your goals with Python, by the way? I'm just curious about it as a language, and finding many features I do _not_ like a language I have to do a lot of coding in to have (I like to ignore whitespace all I can!). I hope that your curiosity will lead you on to other languages, maybe even Lisp and C++ someday. Happy hacking! May God bless you. ------------------ |
CPUFreak91![]() Member Posts: 2337 From: Registered: 02-01-2005 |
Well my goal is to learn python enough that I could make a game, word proccessor and lotsa ods and ends. Plus it will help me learn C Java and C++ later in the furture. I finished a QBASIC book about 5 months ago so I was looking for a nice "pretty" more complex language. I already have Learning Python (O'Reilly) TIPython, How to think like a computer scientist, A byte of Python and Python in a Nutshell (O'Reilly) ------------------ |
HanClinto![]() Administrator Posts: 1828 From: Indiana Registered: 10-11-2004 |
I've heard that PyGame is a great tool for coding games in Python. You may already be aware of it, but in case you're not, the link is: http://www.pygame.org/ Cheers! ------------------ |
CPUFreak91![]() Member Posts: 2337 From: Registered: 02-01-2005 |
Ah. Will try that. Thanks. ![]() ------------------ |
CPUFreak91![]() Member Posts: 2337 From: Registered: 02-01-2005 |
hmm, I still don't undrstand what doc srtings are for. OOP is new to me, A byte of python says I should use self and not other names. What's up with self and why? Also, I got py2exe, how do you use it? [This message has been edited by CPUFreak91 (edited February 22, 2005).] |
graynod![]() Member Posts: 17 From: richmond, VA, USA Registered: 09-28-2004 |
hmm, I still don't undrstand what doc srtings are for. hey, def test_by_val(x): print '-------------------------------------------------------' The last line accesses the data member __doc__, the DocString stored in the object test_by_val. 'A Byte of Python' kinda glosses over some OOP details, you might wanna check a handy-dandy Java or C++ for a little more depth and understanding. OOP is new to me, A byte of python says I should use self and not other names. What's up with self and why? The 'self pointer' is apparently like the 'this pointer' in C++. It is a pointer (for now, let's just say the location in memory) to the curent object itself, so the object can refer to itself to do stuff. This can be pretty important and nice. For instance, if your object has a print_me method, you can call print_me from any of the object's other methods, and the object will know you're talking about it and not some other object. Here's an example that may be a little clearer: #!/usr/bin/python # object.py ############################################################### # create a point object print 'Done.' In say, p1.set_coords above, p1 uses the self pointer to know to call its print_me method. If you leave off the self keyword, you'll get weird error messages, as poor old p1 thinks you're trying to call a method with global scope to p1, or in other words, p1 thinks you're trying to call a function called 'print_me' that has been declared somewhere else that p1 is expected to see and can't (if you think of scope as 'what something can see' it helps). If you were to pass another point to set_coords for some reason, say to set a point's coordinates to those of the passed point, the self point will help ensure that you, the object, and everyone else will know which point you mean to use, for instance: print '-------------------------------------------------------' And the output: ------------------------------------------------------- Also, I got py2exe, how do you use it? I don't know a thing to say about py2exe, sorry. Hope my other ramblings are helpful, if not I hope someone else can set us both straight. When you get into pointers it can get really hairy, for now you might wanna just consider them as addresses of data in memory. Using such addresses allows fastfast access. This is a _really_ over-simplified view of pointers but will maybe get you over the hump for a little while. Take it easy, may God bless your studies! ------------------ |
graynod![]() Member Posts: 17 From: richmond, VA, USA Registered: 09-28-2004 |
Crud! In the above example, if you happen to try cutting & pasting code, be SURE to indent properly, my nice indenting was eaten when I hit the 'Submit Reply' button. Guess I have to figure out how to turn HTML on & edit the mess... Take care, and may God bless you.
[This message has been edited by graynod (edited February 23, 2005).] |
CPUFreak91![]() Member Posts: 2337 From: Registered: 02-01-2005 |
ok, i'll study it ![]() ------------------ |