473,394 Members | 1,879 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

learning python idioms

After several years developing in Java, I've begun to switch to Python
for several of my new projects as I have found the language quite
interesting. I've read several tutorials and implemented a few sample
programs and I've found that Python enables one to program in a variety
of different styles (I'm not sure if this was the original intention or
not). Thus, I find myself occaisionally slipping into the "Java"
mindset when writing Python code and I wonder if this is not optimal.
Python is not Java and there must be more "correct" ways of doing this
in Python that simply writing Java code with different syntax. Is
there a good reference on the internet about Python-specific idioms and
just good Python style in general. Which language constructs are
efficient and which aren't?

Thanks in advance,
Ben

Jun 11 '06 #1
6 1326
> After several years developing in Java, I've begun to switch to Python
for several of my new projects as I have found the language quite
interesting. I've read several tutorials and implemented a few sample
programs and I've found that Python enables one to program in a variety
of different styles (I'm not sure if this was the original intention or
not). Thus, I find myself occaisionally slipping into the "Java"
mindset when writing Python code and I wonder if this is not optimal.
Python is not Java and there must be more "correct" ways of doing this
in Python that simply writing Java code with different syntax. Is
there a good reference on the internet about Python-specific idioms and
just good Python style in general. Which language constructs are
efficient and which aren't?


I completely agree with this. I wish some people would gather and
create a site dedicated to efficient Python idioms. This would be truly
awesome! I hope you get good news on this!

http://vbgunz.blogspot.com

Jun 11 '06 #2
Hi,

If you switched from java to python the best point to start is
http://dirtsimple.org/2004/12/python-is-not-java.html.

Greets,
-Justin

Jun 11 '06 #3

co******@gmail.com wrote:
After several years developing in Java, I've begun to switch to Python
for several of my new projects as I have found the language quite
interesting. I've read several tutorials and implemented a few sample
programs and I've found that Python enables one to program in a variety
of different styles (I'm not sure if this was the original intention or
not). Thus, I find myself occaisionally slipping into the "Java"


i googled "Python idioms":

http://www.gungfu.de/facts/wiki/Main/PythonIdioms

also look at the OReilly Python cookbook and the online repository it's
based on
http://aspn.activestate.com/ASPN/Cookbook/Python

Jun 11 '06 #4

bayerj wrote:
Hi,

If you switched from java to python the best point to start is
http://dirtsimple.org/2004/12/python-is-not-java.html.

Greets,
-Justin


yup, you could spend weeks reading the Language Wars:

http://www.google.com/search?hl=en&q...=Google+Search

http://del.icio.us/tag/python+java

Jun 11 '06 #5
> yup, you could spend weeks reading the Language Wars:

Actually, that link is not about language wars. It's about making the
switch from java to python. Nothing more, nothing less.

Jun 11 '06 #6
co******@gmail.com wrote:
After several years developing in Java, I've begun to switch to Python
for several of my new projects as I have found the language quite
interesting. I've read several tutorials and implemented a few sample
programs and I've found that Python enables one to program in a variety
of different styles (I'm not sure if this was the original intention or
not). Thus, I find myself occaisionally slipping into the "Java"
mindset when writing Python code and I wonder if this is not optimal.
Python is not Java and there must be more "correct" ways of doing this
in Python that simply writing Java code with different syntax. Is
there a good reference on the internet about Python-specific idioms and
just good Python style in general. Which language constructs are
efficient and which aren't?

Thanks in advance,
Ben


As an experiment, I googled 'python idioms' and got a few good hits
right at the top. I probably should have done this a long time ago.

James


--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/
Jun 11 '06 #7

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

Similar topics

0
by: Ron Stephens | last post by:
Woot! I just got my copy of Learning Python 2nd Edition from Amazon this weekend. I am leaving on a business trip to China in a few days, so I can use the long trans-Pacific flights to read the...
58
by: Svein Ove Aas | last post by:
Is anyone working on a python-to-native compiler? I'd be interested in taking a look. Come to think of it, is anyone working on a sexpr-enabled version of Python, or anything similar? I really...
68
by: Lad | last post by:
Is anyone capable of providing Python advantages over PHP if there are any? Cheers, L.
6
by: Kalle Anke | last post by:
Those who have read my posts today have probably understood that I'm not a "true" Python programmer ... but I want to learn more (I think that Python is rather fun). I've read "Learning Python"...
7
by: George Sakkis | last post by:
During the last 18 months or so I have indulged in the joy of learning and using python for almost everything, but I may have to go back to C/C++ at work. Suddenly I found myself transliterating...
6
by: planetthoughtful | last post by:
Hi All, I've written my first piece of practical Python code (included below), and would appreciate some comments. My situation was that I had a directory with a number of subdirectories that...
14
by: Rich | last post by:
Hi, (this is a probably a bit OT here, but comp.lang seems rather desolated, so I'm not sure I would get an answer there. And right now I'm in the middle of learning Python anyway so...) ...
10
by: KDawg44 | last post by:
Hi, I am new to Python and am trying to write a little front end to another application in Python. What I want is to have a gui pop up listing some items with several buttons. The guts of...
30
by: Ivan Reborin | last post by:
Hello everyone, I was wondering if anyone here has a moment of time to help me with 2 things that have been bugging me. 1. Multi dimensional arrays - how do you load them in python For...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.