• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question about OOSL

 
clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic