This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Question about OOSL  RSS feed

 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
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
Posts: 323
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!