Helpful Information
 
 
Category: Development Articles
Object Oriented Programming With Python (part 1)

Thanks I enjoyed the Python tutorial and
look forward to the next one. I'm a real
newbie and saw python as an interesting
language to use for any task, I just need
to read more about it. So again thanks for the artical.

Regards,

Steve Drake

At last, something that actually talks about the basis of python. This is exactly what I needed, as I had reached a level where I was just confused with this language. Now I understand Object Orientation, the rest just seems to fall into place.

Thanks again

First, thanks for a great article...I always appreciate what you guys do.

But the thing for me is that I already KNOW that python is a structurally amazing language, but I have seen very little of what it can do from a more pragmatic perspective...Does anybody have an info on this? Does python have an API for windowing? Can it act as an embedded scripting language? Or is the worlds coolest language that is forever damned to CGI and the command prompt?

check out www.zope.org, quite possibly the coolest use of python out there. Devshed seems to have made the migration.

Great Artical looking forward to part II.

I downloaded zope and have started playing with it. Hot damn that's some powerful stuff! I'm thoughouly impressed. Thanks for the link!

The most used windowing toolkit for python is tkinter, which when you check it out is very simple, especially if your used to guis made in java or a more complex language. Check out python.org or www.onlamp.com for some good python info. If you want embedded scripting then check out jython at www.jython.org
Jython is a 100% pure java implementation which allows to use the java api in your python programs and also to quickly generate java classes using jythonc- a compiling tool. I've only recently been playing with python/jython but you can do some cool stuff. Database integration is almost as easy as php, and i've started making some python classes for that purpose. It was quick and easy, just like finding some info on how to use python for that and other purposes.

When will you post the part2? I am a new user in python.
thanks.

Please give us the second part and don't let this turn into the python cgi articles again which never seemed to continue

Python is the No1 pure OOP scripting language and nothing else compares to it. The shortest joke for us Pythoneers is "Object-Oriented Perl"!

>>> alpha = test.veryBigSnake()
>>> veryBigSnake.set_snake_name
(alpha, "Peter Python")
>>> alpha.name
'Peter Python'
>>>

The test. in this snippet threw me off a bit. I am unfamiliar enough with Python that I did not know it was _not_ a method. I am guessing test is just another object and veryBigSnake() is a property of it.

Thanks for your otherwise lucid tutorial on OO,
Chris.

X-No-archive: yes

As a programming newby, I was beginning to think that OOP was beyond me. But this tutorial has fixed that, praise be to devshed!

One small criticism. I found that the examples given didn't quite work in my Windows edition of IDLE. Code like this ......

# some useful methods
def eat(self):
# code goes here

... tended to return an indentation error. In some cases, I actually found it easier to save the script to my lib directory, then import it from the command line.

Other newbies might be completely confounded by this, I daresay.

netvegetable

In the article, the author refers to passing a parameter with a name, something like "Peter Python".

The author makes use of incorrect terminology. One passes arguments to parameters, i.e., one makes an argument to a function. Many people make this mistake, including computer science Ph.D. holders, computer book authors, computer engineers, etc.

Theoretically, a parameter, not to be confused with the word perimeter, is something that bounds the functioning of something else. No doubt, you have heard the expression, "operate within these parameters", or something similar. One passes arguments to a function so that the function will operate within its parameters using the arguments supplied.


A function makes use of parameters that control the operation of the function.

This is great tutorial. It is as simple as that. Thanks!

I couldn't get any of the programs to run from a "script" file...only interactive. I wonder if there is a tutorial that can help you to actually run these programs? Thanks.

Which parts did you try to run in a script? Many of his snippets were just declarations of objects, so by themselves they would have no output (even though they "ran" correctly). Really, it looks like it was all intended to be run interactively, anyway.

Also, notice that when you simply name a variable in the interpreter, its value is returned. This doesn't happen in a script. You would need a print statement (or some such) to output the value from a script.

> the meaning of life in python: int('10'*3,2)

Object Oriented Programming With Python \(part 1\) (http://www.devshed.com/c/a/Python/Object-Oriented-Programming-With-Python-part-1)

As a true object-oriented language, Python is a great place to start learning about OO programming. In this first segment of a two-part article, take your Python skills to the next level with a discussion of classes and class instances. Practical (and not-so-practical) examples included.

Please discuss this article in this thread. You can read the article here (http://www.devshed.com/c/a/Python/Object-Oriented-Programming-With-Python-part-1).










privacy (GDPR)