473,770 Members | 2,630 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

python without OO

Is it possible to write purely procedural code in Python, or the OO
constructs in both language and supporting libraries have got so
embedded that it's impossible to avoid them? Also, is anyone aware of
any scripting language that could be considered as "Python minus OO
stuff"? (As you can see I'm completely new to Python and initially
believed it's a nice&simple scripting language before seeing all this
OO stuff that was added in over time)
Thanks,
Davor

Jul 18 '05 #1
63 5177
Davor wrote:
Is it possible to write purely procedural code in Python, or the OO
constructs in both language and supporting libraries have got so
embedded that it's impossible to avoid them?


Hmmm... sorta depends on how you define write procedural code... If
you mean, can you write Python code without accessing object attributes
(e.g. lst.sort()), then the answer's probably almost certainly no. If
you mean can you write Python code without ever writing a class, the
answer's probably yes. It'll make some things harder, and it'll
probably make some modules off-limits, but it's doable.

Could you clarify what you mean by "write purely procedural code"?

Steve
Jul 18 '05 #2
Davor wrote:
Is it possible to write purely procedural code in Python, or the OO
constructs in both language and supporting libraries have got so
embedded that it's impossible to avoid them?
Sure, but you will got problem with libraries. Some of them are in fact
frameworks and need some subclassing or other OO fluff.
Also, is anyone aware of
any scripting language that could be considered as "Python minus OO
stuff"? (As you can see I'm completely new to Python and initially
believed it's a nice&simple scripting language before seeing all this
OO stuff that was added in over time)


Icon, the language for OO haters.

May I ask why you do you hate OO so much?

--
Jarek Zgoda
http://jpa.berlios.de/ | http://www.zgodowie.org/
Jul 18 '05 #3
"Davor" <da*****@gmail. com> wrote in message
news:11******** *************@c 13g2000cwb.goog legroups.com...
Is it possible to write purely procedural code in Python, ... Of course!
or the OO
constructs in both language and supporting libraries have got so
embedded that it's impossible to avoid them?
You can always *write your own* purely procedure code.
A tougher problem would be living without the wealth of supporting library
code that is written OO.
Also, is anyone aware of
any scripting language that could be considered as "Python minus OO
stuff"? Anyone aware? Not I!
(As you can see I'm completely new to Python and initially
believed it's a nice&simple scripting language before seeing all this
OO stuff that was added in over time)


Over time ???
Someone can correct me if I'm wrong but I do believe that all that dirty,
rotten OO stuff was incorporated in the language right from the start.
But
If you can live without coding OO, you can do it in Python.

I'm not sure what it is, exactly, you are trying to avoid.
Much "nice&simpl e scripting " simply has no need to create and use objects.
Of course, the entire structure of Python and all of it's built in data
structures are object oriented. But, if you wish to live within the
confines of your own strictly procedural code, I don't think you need to
deal with the issue.

On the other hand, this does beggar for a reason to bother with Python at
all. It seems you could be happy doing BASH scripts for Linux or DOS batch
files for Windows. Both are "nice&simpl e" scripting languages free of
object oriented contamination.

Why would you use an object oriented language if you don't want to?
Thomas Bartkus

Jul 18 '05 #4
Thanks,

I do not hate OO - I just do not need it for the project size I'm
dealing with - and the project will eventually become open-source and
have additional developers - so I would prefer that we all stick to
"simple procedural" stuff rather than having to deal with a developer
that will be convincing me that his 50 layers inheritance hierarchy is
good since it exists in some weird pattern that he saw somewhere on
some Java design patterns discussion board :-) and other "proper" OO
design issues... Once I opted for C++ in a very small project and
believed everyone will stick with C subset + better type checking
offered through C++ - but I simply could not manage to keep them off
using OO stuff which was just making program more complicated than it
should have been. (note, I am not an experienced developer, nor the
others I'll be working with (even though some think they are:-)), so I
prefer preemptively dealing with issue of everyone showing off their OO
design skills)

Davor

Jul 18 '05 #5
> On the other hand, this does beggar for a reason to bother with Python at
all. It seems you could be happy doing BASH scripts for Linux or DOS batch
files for Windows. Both are "nice&simpl e" scripting languages free of
object oriented contamination.


not really, what I need that Python has and bash&dos don't is:

1. portability (interpreter runs quite a bit architectures)
2. good basic library (already there)
3. modules for structuring the application (objects unnecessary)
4. high-level data structures (dictionaries & lists)
5. no strong static type checking
6. very nice syntax

so initially I was hoping this is all what Python is about, but when I
started looking into it it has a huge amount of additional (mainly OO)
stuff which makes it in my view quite bloated now... anyhow, I guess
I'll have to constrain what can be included in the code through
different policies rather than language limitations...
Thanks
Davor
Jul 18 '05 #6
Wrap your head around Python, don't wrap the Python around your head!
This is NOT Java, or C++ or C , it IS Python.
Davor wrote:
(note, I am not an experienced developer, nor the
others I'll be working with (even though some think they are:-)) Don't worry we didn't get confused, it was quite clear ;)
Mostly you are just so off base I just say go *READ* and write more
Python, look at the standard library.
You will only see one or two levels of inheritance as the norm and it
is not that difficult.
Also you are telling me you don't have an OO problem, you have a
problem with your managment and communication skills. so I prefer preemptively dealing with issue of everyone showing off their OO design skills)

Work on that micro-management just a little bit more, that gets the
code flowing ;)
hth,
M.E.Farmer

Jul 18 '05 #7
M.E.Farmer wrote:
Wrap your head around Python, don't wrap the Python around your head!
This is NOT Java, or C++ or C , it IS Python.
that's interesting hypothesis that behavior will vary due to the use of
different language - actually most python scripts that I have seen do
not even use OO which is quite understandable (same with perl, php,..)
and I'm not even sure why all these languages have incorporated OO at all...
(note, I am not an experienced developer, nor the
others I'll be working with (even though some think they are:-))


Don't worry we didn't get confused, it was quite clear ;)


:-)
Also you are telling me you don't have an OO problem, you have a
problem with your managment and communication skills.


yeah, it's really tough telling them to write code so I can understand
it without having to know about all these patterns of theirs.

Davor
Jul 18 '05 #8
Davor wrote:
Thanks,

I do not hate OO - I just do not need it for the project size I'm
dealing with - and the project will eventually become open-source and
have additional developers - so I would prefer that we all stick to
"simple procedural" stuff rather than having to deal with a developer
that will be convincing me that his 50 layers inheritance hierarchy is
good since it exists in some weird pattern that he saw somewhere on
some Java design patterns discussion board :-) and other "proper" OO
design issues... Once I opted for C++ in a very small project and
believed everyone will stick with C subset + better type checking
offered through C++ - but I simply could not manage to keep them off
using OO stuff which was just making program more complicated than it
should have been. (note, I am not an experienced developer, nor the
others I'll be working with (even though some think they are:-)), so I
prefer preemptively dealing with issue of everyone showing off their OO
design skills)

Davor

Perhaps pylint (http://www.logilab.org/projects/pylint) or its ilk can help you
enforce a coding style

Michael

Jul 18 '05 #9
Davor wrote:
M.E.Farmer wrote:
Wrap your head around Python, don't wrap the Python around your head!
This is NOT Java, or C++ or C , it IS Python.


that's interesting hypothesis that behavior will vary due to the use of
different language - actually most python scripts that I have seen do
not even use OO which is quite understandable (same with perl, php,..)
and I'm not even sure why all these languages have incorporated OO at
all...


Of course, *all* Python programs (whether you call them scripts or
otherwise) are using objects. Strings, numbers, files, lists,
dictionaries ... they're all objects. You *can't* write a Python program
without objects, but you can do so without a single "class" declaration.

The point that M.E.Farmer was trying to make is that you should not judge OO
by Java or C++. Those languages make OO a burden, with on the one hand
excessive requirements to subclass, and on the othe hand ... well, C++ is
just a burden all round really :)
Richard

Jul 18 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
3691
by: Andrew Dalke | last post by:
Is there an author index for the new version of the Python cookbook? As a contributor I got my comp version delivered today and my ego wanted some gratification. I couldn't find my entries. Andrew dalke@dalkescientific.com
68
5896
by: Lad | last post by:
Is anyone capable of providing Python advantages over PHP if there are any? Cheers, L.
99
4677
by: Shi Mu | last post by:
Got confused by the following code: >>> a >>> b >>> c {1: , ], 2: ]} >>> c.append(b.sort()) >>> c {1: , ], 2: , None]}
0
1571
by: Fuzzyman | last post by:
It's finally happened, `Movable Python <http://www.voidspace.org.uk/python/movpy/>`_ is finally released. Versions for Python 2.3 & 2.4 are available from `The Movable Python Shop <http://voidspace.tradebit.com/groups.php>`_. The cost is £5 per distribution, payment by PayPal. £1 from every distribution goes to support the development of `SPE <http://pythonide.stani.be/>`_, the Python IDE.
0
325
by: Kurt B. Kaiser | last post by:
Patch / Bug Summary ___________________ Patches : 398 open ( +5) / 3334 closed (+19) / 3732 total (+24) Bugs : 904 open ( -4) / 6011 closed (+36) / 6915 total (+32) RFE : 222 open ( -1) / 231 closed ( +2) / 453 total ( +1) New / Reopened Patches ______________________
206
8372
by: WaterWalk | last post by:
I've just read an article "Building Robust System" by Gerald Jay Sussman. The article is here: http://swiss.csail.mit.edu/classes/symbolic/spring07/readings/robust-systems.pdf In it there is a footprint which says: "Indeed, one often hears arguments against building exibility into an engineered sys- tem. For example, in the philosophy of the computer language Python it is claimed: \There should be one|and preferably only one|obvious...
0
9602
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9439
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10237
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9882
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8905
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7431
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6690
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5326
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5467
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.