The Artima Developer Community
Sponsored Link

Java Buzz Forum
Reading Thinking in Python: Some Interesting Ideas

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Michael Cote

Posts: 10306
Nickname: bushwald
Registered: May, 2003

Cote is a programmer in Austin, Texas.
Reading Thinking in Python: Some Interesting Ideas Posted: Jan 27, 2004 10:49 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Michael Cote.
Original Post: Reading Thinking in Python: Some Interesting Ideas
Feed Title: Cote's Weblog: Coding, Austin, etc.
Feed URL: https://cote.io/feed/
Feed Description: Using Java to get to the ideal state.
Latest Java Buzz Posts
Latest Java Buzz Posts by Michael Cote
Latest Posts From Cote's Weblog: Coding, Austin, etc.

Advertisement

I've been trying to learn python on and off for some time now. I finished up Learning Python awhile ago, and I've recently started playing around with actual python code. With that little bit of knowledge, I thought I'd finally start reading Bruce Eckel's free Thinking in Python which warns you about 5 times that it's for people who already know the basics of python.

Here are some interesting parts I've read so far, from the introductory and first sections:

You?ll find after you?ve worked with Python for a short while that you?ve been using up a lot of brain cycles parsing semicolons, curly braces, and all sorts of other extra verbiage that was demanded by your non-Python programming language but didn?t actually describe what your program was supposed to do. [One of Eckels most written up likes about python.]

. . .

# create Simple object instance, display message
x = Simple("constructor argument")
x.show()
x.showMsg("A message")

[A]t the bottom of the example [above] you can see that the creation of an object looks just like a function call using the class name. Python?s spare syntax makes you realize that the new keyword isn?t really necessary in C++ or Java, either.

. . .

Because Python is weakly typed, it doesn?t really care about interfaces ? all it cares about is applying operations to objects (in fact, Java?s interface keyword would be wasted in Python). This means that inheritance in Python is different from inheritance in C++ or Java, where you often inherit simply to establish a common interface. In Python, the only reason you inherit is to inherit an implementation ? to re-use the code in the base class.

. . .

Whenever you abstract something you?re isolating particular details, and one of the most compelling motivations behind this is to separate things that change from things that stay the same.... Often, the most difficult part of developing an elegant and cheap-to-maintain design is in discovering what I call "the vector of change." This means finding the most important thing that changes in your system, or put another way, discovering where your greatest cost is. Once you discover the vector of change, you have the focal point around which to structure your design.

. . .

Alex Martelli makes the observation that what we really want with a Singleton is to have a single set of state data for all objects. That is, you could create as many objects as you want and as long as they all refer to the same state information then you achieve the effect of Singleton. He accomplishes this with what he calls the Borg, which is accomplished by setting all the __dict__s to the same static piece of storage.

Read: Reading Thinking in Python: Some Interesting Ideas

Topic: Sending SMS Messages From Your Computer Previous Topic   Next Topic Topic: Event Log Paranoia

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use