File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other Languages and the fly likes Question about OOSL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » Other Languages
Bookmark "Question about OOSL" Watch "Question about OOSL" New topic

Question about OOSL

Hussein Baghdadi
clojure forum advocate

Joined: Nov 08, 2003
Posts: 3479

I just started with small examples in Python .
I noted a strange feature about Python (or maybe, about scripting languages) that source files contains no classes declarations about like Java :
public class EchoServer .....
In Python, we can write code without anything like :

Please correct me if I'm wrong..
thanks all.
M Beck
Ranch Hand

Joined: Jan 14, 2005
Posts: 323
Python code does not need to be organized into classes, no. it's possible to write purely procedural Python code, with no class definitions anywhere. but you really shouldn't.

Python does, also, have a perfectly decent OO system, complete with language syntax for defining classes, inheritance, overriding, and so on. you should learn how to use it, because Python is considered to be an OO language and it is held to be good taste and form to write your Python programs in an object-oriented style. see the Python library documentation for a primer on this.

taste and form matter a lot in Python, because Python programs are just about always distributed with source code - or even as source code - so your form and style will be on display to all your users. moreover, peer pressure from the Python community at large is how a lot of the language's standards are enforced. for example, the whole "self" thing is nothing but a shared custom - you could name that reference something other than "self", if you wanted to... but you'd be yelled at quite sternly as soon as you were found out. so don't.
I agree. Here's the link:
subject: Question about OOSL
It's not a secret anymore!