As with most things, you have to understand 'why' you want to do something
before you can really understand how it applies.

Ok.  Go to amazon.  They've setup a 'shopping cart'.  That cart is made of
variables, name, cred.card num, items, quantity of items, ship-to address,
state, shipping cost, shipping type, tax (if applicable), etc.  Ok.  If you
have a program and want this info, ok, you could set up variables for all of
them.

What if you now have 2 shopping carts?  How do you double the variables?
What if you now have 1000 shopping carts?  How do you scale your programming
so what works for 1 works for 1000?

OOP allows you to create a 'structure' of the variables, and when someone
enters their name in a field and hits, 'add to cart' , abstractly, you'll
have a structure in your program like:

User = ShoppingCartClass()

Now, you defined User to be an object of ShoppingCartClass.

Now, methods are pre-defined actions.  You might have:
.Checkout()
.DeleteItem()
.AddItem()

and of course inside the parenthesis, you'd have relevent info. for the
routine.

So maybe you'd do:
User = ShoppingCartClass()
User.AddItem(sku=5)
User.DeleteItem(sku=22)
User.CheckOut(State='CT', CredCard='Visa', CredNum='1234-5678-8765-4321')

So, there's the why. This just barely scratches the surface. hope I didn't
confuse you.

-Dave
<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hey yall,
> I'm new to Python and I love it. Now I can get most of the topics
> covered with the Python tutorials I've read but the one thats just
> stumping me is Object Orientation. I can't get the grasp of it. Does
> anyone know of a good resource that could possibly put things in focus
> for me? Thanks.
>
> -- 
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to