I'm just starting out with python, after having a long history with
Java. I was wondering if there were any resources or tips from anyone
out there in Python-land that can help me make the transition as
successfully as possible? Perhaps you've made the transition yourself
or just have experience with folks who have made the transition.
I'm looking for the common types of mistakes that say a Java/C# or
even C++ developer may commonly make. More examples like those
highlighted here http://dirtsimple.org/2004/12/python-is-not-java.html
would be particularly useful. I've already made the static class
method mistake, and been thoroughly confused by packages and
imports/froms and extremely frustrated with attempting to call super
constructors etc. I'm getting the hang of passing around functions
(ala the command pattern), customising the operators and extending
inbuilt classes. All of these concepts I've done before so there
nothing really great and wonderful about using them in another
language. Some of the really powerful ideas of python (eg as suggested
in the link) about creating one function containing a template function
that can cater to all possible implementations sounds really cool and
alien to me at the same time. That's the sort of stuff I'm
interested in.
At this point in time I'd say my python code is more coding Java in
python than doing it in a pythonic way. Perhaps there some good/great
examples of Python scripts or projects that I could look at to get
inspired or learn pythonic implementation ideas? I just don't know of
any. Are there python specific equivalents to the common Patterns,
Anti-Patterns and Refactoring books that are so prevalent as
reccomended reading in C++ and Java? If so what?
Given the rising popularity of Python these days there has got to be a
few of you out there who've made the transition successfully and have
some pearls-of-wisdom to share that you'd wished you'd known about
earlier.
Thanks
Todd 17 1950
In article <11**********************@u72g2000cwu.googlegroups .com>,
"ToddLMorgan" <To*********@gmail.com> wrote: I'm looking for the common types of mistakes that say a Java/C# or even C++ developer may commonly make.
Using subclassing when you don't have to. For instance, you might have a
Java method which takes an argument of type java.io.OutputStream to
which it writes. You might translate this to a Python method to which
you are careful to only pass instances of subclasses of file objects.
But in fact there is no necessity for this: you are free to pass any
object which has appropriate members.
I suppose this is an instance of the more general rule: "using OO when
you don't have to".
In article <11**********************@u72g2000cwu.googlegroups .com>,
"ToddLMorgan" <To*********@gmail.com> wrote: Are there python specific equivalents to the common Patterns, Anti-Patterns and Refactoring books that are so prevalent as reccomended reading in C++ and Java?
I don't think they exist. Such books are targeted more towards
development in a corporate environment, where every proposal has to go
through multiple layers of management, and nothing is ever done by
individuals working alone, always by "teams" working on separate parts
of the project. And also where the end-users don't really get much say
in how things are supposed to work. It's only in such a high-overhead,
top-down, cover-your-ass environment that such books are looked on as
being at all useful. Possibly on the grounds that nobody ever got fired
for buying them.
I'd say languages like Python and Perl are the absolute antithesis of
this sort of development culture.
ToddLMorgan wrote: I'm just starting out with python, after having a long history with Java. I was wondering if there were any resources or tips from anyone out there in Python-land that can help me make the transition as successfully as possible? Perhaps you've made the transition yourself or just have experience with folks who have made the transition.
Some time ago I had to learn a bit of Java in order to be able to write
some signed jython browser applets that I could use while working at a
highly restricted public library computer. So I guess I was coming from
the opposite direction :-) Anyway I wondered why (and how!) very small
jython scripts could replace large blocks of java code.
Maybe looking at it from a jython perspective will be educational for
you. I think it would be a lot of fun realizing how much java code can
actually be 'automatically' generated or filled in by jython traversing
its class system.
Also I'm hoping it would produce an opportunity for an advanced java
coder to write some cool signed java applet in jython that would have
the look and feel of idle.py for python but that would run from a
webbrowser.
I know it can be done because I did write some experimental but still
already very functional things like a jython console webbrowser applet,
a websucker.py running from within a browser, and I hacked some other
jython editor-console (eclipse is good for such things) to add some
functionality and do my own signing and library selection.
Don't ask for my code yet though, it's nowhere near presentable. Anyway,
since then I found a job that gives me access to less locked down
computers which is also fun.
Anton http://dirtsimple.org/2004/12/python-is-not-java.html http://dirtsimple.org/2004/12/java-i...on-either.html http://dirtsimple.org/2004/12/python...-not-java.html
This link seems to be down at the moment. http://naeblis.cx/rtomayko/2004/12/1...c-method-thing
The above articles were really helped me understand the python way of doining
things. In particular they mention language features that may be named the
same and do similar things, but would be used for totally different reasons in
the two languages.
I hope you find them as helpful as I did.
-Chris
On Sat, Apr 22, 2006 at 12:40:51AM -0700, ToddLMorgan wrote: I'm just starting out with python, after having a long history with Java. I was wondering if there were any resources or tips from anyone out there in Python-land that can help me make the transition as successfully as possible? Perhaps you've made the transition yourself or just have experience with folks who have made the transition.
I'm looking for the common types of mistakes that say a Java/C# or even C++ developer may commonly make. More examples like those highlighted here http://dirtsimple.org/2004/12/python-is-not-java.html would be particularly useful. I've already made the static class method mistake, and been thoroughly confused by packages and imports/froms and extremely frustrated with attempting to call super constructors etc. I'm getting the hang of passing around functions (ala the command pattern), customising the operators and extending inbuilt classes. All of these concepts I've done before so there nothing really great and wonderful about using them in another language. Some of the really powerful ideas of python (eg as suggested in the link) about creating one function containing a template function that can cater to all possible implementations sounds really cool and alien to me at the same time. That's the sort of stuff I'm interested in.
At this point in time I'd say my python code is more coding Java in python than doing it in a pythonic way. Perhaps there some good/great examples of Python scripts or projects that I could look at to get inspired or learn pythonic implementation ideas? I just don't know of any. Are there python specific equivalents to the common Patterns, Anti-Patterns and Refactoring books that are so prevalent as reccomended reading in C++ and Java? If so what?
Given the rising popularity of Python these days there has got to be a few of you out there who've made the transition successfully and have some pearls-of-wisdom to share that you'd wished you'd known about earlier.
Thanks Todd
-- http://mail.python.org/mailman/listinfo/python-list
Take a look at the newgroup archives over the last week or two - there
seem to have been a glut of people coming from Java to Python and
asking the same sort of questions. There were some links to a bunch of
Python 'gotcha' pages which will be useful.
For my part, I came from Java to Python, and found that it was useful
to do a load of small scripts in the simplest way possible, or in as
many different ways possible. For example, trying a script involving
creating a new iterable object from a list using for loops, list
comprehensions, generators or functional built-ins (such as map()). The
clearest method usually seems to be considered the most pythonic.
A couple of sites to practice against are: http://www.pythonchallenge.com/ http://mathschallenge.net/
They give a good set of problems which will work various aspects of
Python that aren't familiar to Java guys, and also break the mindset
that everything has to be done in classes.
I'm still making the transition of course ;-)
Lawrence D'Oliveiro wrote: In article <11**********************@u72g2000cwu.googlegroups .com>, "ToddLMorgan" <To*********@gmail.com> wrote:
I'm looking for the common types of mistakes that say a Java/C# or even C++ developer may commonly make.
Using subclassing when you don't have to. For instance, you might have a Java method which takes an argument of type java.io.OutputStream to which it writes. You might translate this to a Python method to which you are careful to only pass instances of subclasses of file objects. But in fact there is no necessity for this: you are free to pass any object which has appropriate members.
I suppose this is an instance of the more general rule: "using OO when you don't have to".
Lawrence, I'm afraid you're confusing OO with "statically-typed
class-based". FWIW, dynamic typing is part of OO since Smalltalk.
--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'o****@xiludom.gro'.split('@')])"
Lawrence D'Oliveiro <ld*@geek-central.gen.new_zealand> writes: In article <11**********************@u72g2000cwu.googlegroups .com>, "ToddLMorgan" <To*********@gmail.com> wrote:
Are there python specific equivalents to the common Patterns, Anti-Patterns and Refactoring books that are so prevalent as reccomended reading in C++ and Java?
I don't think they exist. Such books are targeted more towards development in a corporate environment, where every proposal has to go through multiple layers of management, and nothing is ever done by individuals working alone, always by "teams" working on separate parts of the project. And also where the end-users don't really get much say in how things are supposed to work. It's only in such a high-overhead, top-down, cover-your-ass environment that such books are looked on as being at all useful. Possibly on the grounds that nobody ever got fired for buying them.
I'd say languages like Python and Perl are the absolute antithesis of this sort of development culture.
On "antithesis" comment:
Python can be used for Agile Programming, with the end user there at
the monitor. But it can also be used for heavy duty development
regimens with data models, specifications, development teams working
multiple shifts or working worldwide, separate test-and-release teams,
etc.
On response to the OP:
The most important thing you bring to the table is knowledge of data
formats, algorithms, OO programming, and test-driven design. E.g.,
XML, HTML, LDAP, SQL, pipes, stacks, queues, threads, dictionaries,
lexers, parsers, regular expressions, matrix transformations, GUI
dialogs, etc. Many of us consider Python a secret weapon in learning
new paradigms and technologies
The most important things you need to leave behind:
1. Intuition about what is already available vs what you have to
write. Java tries to reinvent the whole compsci world. Python just
says "Nice C/C++/FORTRAN library; I think I'll use it via a binding."
If it is codable, it is probably scriptable in Python.
2. Temptation to reinvent entire stacks of libraries to replicate the
Java module import structure. This is a real problem in migrating
existing code. You have to take deep breath and ask "What is the
fundamental task, and how would a programmer do that in Python?"
Entire library trees melt away when you do this.
3. Fear you are missing something when you get done. Python takes
c. 1/3 as many LOC as Java for the same task. At first I kept saying:
"This wee bit of code couldn't posssibly do the whole job, could it?"
If you have a good regression test suite, you are done when it works.
If you need help getting on board unittests, see mkpythonproj: http://www.seanet.com/~hgg9140/comp/index.html#L006
--
Harry George
PLM Engineering Architecture
Lawrence D'Oliveiro wrote: "ToddLMorgan" <ToddLMor...@gmail.com> wrote:Are there python specific equivalents to the common Patterns, Anti-Patterns and Refactoring books that are so prevalent as reccomended reading in C++ and Java?
I don't think they exist. Such books are targeted more towards development in a corporate environment, where every proposal has to go through multiple layers of management, and nothing is ever done by individuals working alone, always by "teams" working on separate parts of the project
Hey, patterns are important. They keep people from reinventing the
wheel and banging their head against the wall. Perhaps the best source
for Python patterns is the Python Cookbook. http://www.oreilly.com/catalog/pythoncook/ http://aspn.activestate.com/ASPN/Python/Cookbook/
I recommend at least going through the table of contents so you'll know
where to go when you're wondering, "How do I do X in Python?"
--Mike
In article <11**********************@i40g2000cwc.googlegroups .com>,
"gene tani" <ge*******@gmail.com> wrote: http://www.ferg.org/projects/python_gotchas.html
Amazing. Backslashes are listed as not one, but _two_ items on the list.
The problem is not with Python at all, it is with the MS-DOS foundations
of Windows. When directory hierarchies were added in DOS 2.0, they used
the wrong character, "\" instead of "/", as the directory separator.
I call this "DOSLexia", and it has afflicted DOS/Windows users ever
since.
In article <44***********************@news.free.fr>,
bruno at modulix <on***@xiludom.gro> wrote: Lawrence D'Oliveiro wrote: In article <11**********************@u72g2000cwu.googlegroups .com>, "ToddLMorgan" <To*********@gmail.com> wrote:
I'm looking for the common types of mistakes that say a Java/C# or even C++ developer may commonly make.
Using subclassing when you don't have to. For instance, you might have a Java method which takes an argument of type java.io.OutputStream to which it writes. You might translate this to a Python method to which you are careful to only pass instances of subclasses of file objects. But in fact there is no necessity for this: you are free to pass any object which has appropriate members.
I suppose this is an instance of the more general rule: "using OO when you don't have to".
Lawrence, I'm afraid you're confusing OO with "statically-typed class-based". FWIW, dynamic typing is part of OO since Smalltalk.
I wasn't talking about dynamic typing, I was talking about subclassing,
which is very much a part of OO.
Unless you subscribe to the "OO is whatever looks like a good
programming idea" definition <http://www.paulgraham.com/reesoo.html>.
In article <11*********************@y43g2000cwc.googlegroups. com>,
"Mike Orr" <sl********@gmail.com> wrote: Lawrence D'Oliveiro wrote: "ToddLMorgan" <ToddLMor...@gmail.com> wrote: >Are there python specific equivalents to the common Patterns, >Anti-Patterns and Refactoring books that are so prevalent as >reccomended reading in C++ and Java?
I don't think they exist. Such books are targeted more towards development in a corporate environment, where every proposal has to go through multiple layers of management, and nothing is ever done by individuals working alone, always by "teams" working on separate parts of the project
Hey, patterns are important. They keep people from reinventing the wheel and banging their head against the wall.
If you have to write more than one piece of code from the same
"pattern", then that _is_ "reinventing the wheel and banging their head
against the wall."
The correct way to avoid reinventing the wheel is to reuse code.
For example, in the OO world you hear a good deal about "patterns".
I wonder if these patterns are not sometimes evidence of ...
the human compiler, at work. When I see patterns in my programs, I
consider it a sign of trouble. The shape of a program should reflect
only the problem it needs to solve. Any other regularity in the code
is a sign, to me at least, that I'm using abstractions that aren't
powerful enough....
-- Paul Graham <http://www.paulgraham.com/icad.html>
Lawrence D'Oliveiro wrote: In article <44***********************@news.free.fr>, bruno at modulix <on***@xiludom.gro> wrote:
Lawrence D'Oliveiro wrote:
(snip)I suppose this is an instance of the more general rule: "using OO when you don't have to". Lawrence, I'm afraid you're confusing OO with "statically-typed class-based". FWIW, dynamic typing is part of OO since Smalltalk.
I wasn't talking about dynamic typing, I was talking about subclassing, which is very much a part of OO.
What you wrote implies (well, at least I understand it that way) that
polymorphic dispatch *not* based on subclassing is not OO. Hence my
reaction : the need to use subclassing (inheritance) for subtyping
(polymorphic dispatch) is not a requirement of object orientation and
has never been - it's only a limitation of languages with declarative
static typing (C++, Java, C# etc).
Unless you subscribe to the "OO is whatever looks like a good programming idea" definition <http://www.paulgraham.com/reesoo.html>.
Not really !-)
--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'on***@xiludom.gro'.split('@')])"
Thanks for those ... just by looking at the colour of the links in my
browser I'd only found 4 of those already so I appreciate the heads up
:- )
bruno at modulix a écrit : Lawrence D'Oliveiro wrote:
In article <44***********************@news.free.fr>, bruno at modulix <on***@xiludom.gro> wrote: Lawrence D'Oliveiro wrote:
(snip) I suppose this is an instance of the more general rule: "using OO when you don't have to".
Lawrence, I'm afraid you're confusing OO with "statically-typed class-based". FWIW, dynamic typing is part of OO since Smalltalk.
I wasn't talking about dynamic typing, I was talking about subclassing, which is very much a part of OO.
What you wrote implies (well, at least I understand it that way)
.... but I may just have it totally wrong !-)
In article <44***********************@news.free.fr>,
bruno at modulix <on***@xiludom.gro> wrote: Lawrence D'Oliveiro wrote: In article <44***********************@news.free.fr>, bruno at modulix <on***@xiludom.gro> wrote:
Lawrence D'Oliveiro wrote: (snip)I suppose this is an instance of the more general rule: "using OO when you don't have to".
Lawrence, I'm afraid you're confusing OO with "statically-typed class-based". FWIW, dynamic typing is part of OO since Smalltalk.
I wasn't talking about dynamic typing, I was talking about subclassing, which is very much a part of OO.
What you wrote implies (well, at least I understand it that way) that polymorphic dispatch *not* based on subclassing is not OO. Hence my reaction : the need to use subclassing (inheritance) for subtyping (polymorphic dispatch) is not a requirement of object orientation and has never been - it's only a limitation of languages with declarative static typing (C++, Java, C# etc).
It's nothing to do with OO, because it's also present in non-OO
languages. Unless you subscribe to the "OO is whatever looks like a good programming idea" definition <http://www.paulgraham.com/reesoo.html>.
Not really !-)
One would hope not. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: BlackHawke |
last post by:
Hello!
My name is Nick Soutter, I am the owner of a small game company in San
Diego, CA called Aepox Games (www.aepoxgames.net).
Our first product, Andromeda Online...
|
by: Ville Vainio |
last post by:
I don't know if you have seen this before, but here goes:
http://text.userlinux.com/white_paper.html
There is a jab at Python, though, mentioning that Ruby is more
"refined".
--
Ville...
|
by: Maurice LING |
last post by:
This may be a dumb thing to ask, but besides the penalty for dynamic
typing, is there any other real reasons that Python is slower than Java?
maurice
|
by: asj |
last post by:
awhile back, eBay decided to switch from a Microsoft/.NET/Windows
architecture on the backend to a J2EE one, which might explain why their
java backend will handle up to 1 BILLION page views a day!...
|
by: liorm |
last post by:
Hi everyone,
I need to write a web app, that will support millions of user accounts,
template-based user pages and files upload. The client is going to be
written in Flash. I wondered if I coudl...
|
by: john_sips_tea |
last post by:
I've got a fairly substantial webapp written in Java (plus Tomcat,
Hibernate, Struts, JSP, MySQL) that is a bit of a bear to work with. I
didn't write it. Much of it is only very sparsely...
|
by: Aravind |
last post by:
hi,
some of my friends told that python and java are similar in the idea of
platform independency. Can anyone give me an idea as i'm a newbie to java
and python but used to C++. My idea is to...
|
by: Amir Michail |
last post by:
Hi,
It seems to me that measuring productivity in a programming language
must take into account available tools and libraries.
Eclipse for example provides such an amazing IDE for java that it...
|
by: s0suk3 |
last post by:
Hello, I was hoping to get some opinions on a subject. I've been
programming Python for almost two years now. Recently I learned Perl,
but frankly I'm not very comfortable with it. Now I want to...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |