The Artima Developer Community
Sponsored Link

Weblogs Forum
What Matters About Python?

19 replies on 2 pages. Most recent reply: Oct 3, 2007 6:55 PM by Steve Holden

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 19 replies on 2 pages [ 1 2 | » ]
Steve Holden

Posts: 42
Nickname: holdenweb
Registered: Apr, 2003

What Matters About Python? (View in Weblogs)
Posted: Aug 6, 2007 11:27 PM
Reply to this message Reply
Summary
Steve has just agreed to become a correspondent for Python Magazine. What do people need to know?
Advertisement

I return to this forum after a lengthy absence because it offers access to a community of well-informed, not to say opinionated, software technologists. I have just accepted an invitation to write a monthly column for the forthcoming Python Magazine, and I don't want to write only for existing Python users.

Other writers will doubtless handle the technical side of the language, though I expect I will have a hand in that area as well. But I am interested in providing a rounded source of information to a broad readership, and would like to address philosophical and social as well as technical issues.

So, what information about Python is the average reader looking for? Are Python users smug or self-effacing? Is there enough documentation? What are the warts, and what have you found Python to be especially good or bad for?


James Watson

Posts: 2024
Nickname: watson
Registered: Sep, 2005

Re: What Matters About Python? Posted: Aug 7, 2007 7:09 AM
Reply to this message Reply
> Is there enough documentation?

I find it hard to get at what I am looking for. For example, trying to find out what all the expected methods for emulating a list took a while. It seems like there should be a central location for this kind of thing given that duck-typing is such a big deal in Python. Maybe there is and I just don't know where.

> What are the warts,

self.Well, self.I self.can't self.think self.of self.any self.at self.the self.moment.

> and what
> have you found Python to be especially good or bad
> for?

I really like it for code generation. Yield and literal strings simplify things greatly.

Daniel Jimenez

Posts: 40
Nickname: djimenez
Registered: Dec, 2004

Re: What Matters About Python? Posted: Aug 7, 2007 7:29 AM
Reply to this message Reply
Python's "executable pseudocode" is beautiful. After years of reading (and writing :( ) curly braces and long strings of modifiers it's a pleasure to read and write code that doesn't make you go far around everything you're trying to say.

Please, include plenty of code examples.

Larry Bugbee

Posts: 13
Nickname: bugbee
Registered: Dec, 2004

Re: What Matters About Python? Posted: Aug 7, 2007 11:37 AM
Reply to this message Reply
I like several things...
- economy of expression without being terse (just right)
- the natural blending of procedural and object code
- a really friendly community

Warts?
- lack of optional typing
- interpreter not natively installed on ALL platforms making program distribution problematic
- really easy-to-use GUI tools (yeah, true of most/all languages)

Keith Ray

Posts: 658
Nickname: keithray
Registered: May, 2003

Re: What Matters About Python? Posted: Aug 9, 2007 6:20 AM
Reply to this message Reply
There is no "average" user. We are all individuals. (Repeat after me: "we are all individuals").

I would be interested in learning how to use Python to parse and process a complex languages like C++ or Objective-C for (1) gathering metrics, (2) implementing pre-parsers [turning a few "new" keywords into several lines of output code, in context], or (3) implementing editor-independent editing and refactoring tools.

Eli Courtwright

Posts: 14
Nickname: eliandrewc
Registered: Jan, 2006

Re: What Matters About Python? Posted: Aug 10, 2007 6:14 AM
Reply to this message Reply
Whatever you do, make sure to provide code examples. What got me hooked on Python was being able to read small code snippets and see how much more expressive it was than most other languages.

When evaluating a new Python module/framework/etc I always look for small code snippets that demonstrate how it's used. I love websites like CherryPy.org which put a code snippet front and center on the home page to show what your programs will look like.

So whatever topics you cover, make sure to show some code.

Merriodoc Brandybuck

Posts: 225
Nickname: brandybuck
Registered: Mar, 2003

Re: What Matters About Python? Posted: Aug 13, 2007 2:21 PM
Reply to this message Reply
> <p>I return to this forum after a lengthy absence because
> it offers access to a community of well-informed, not to
> say opinionated, software technologists. I have just
> accepted an invitation to write a monthly column for the
> forthcoming <em>Python Magazine</em>, and I don't want to
> write only for existing Python users.</p>
> <p>Other writers will doubtless handle the technical side
> of the language, though I expect I will have a hand in
> that area as well. But I am interested in providing a
> rounded source of information to a broad readership, and
> would like to address philosophical and social as well as
> technical issues.</p>
> <p>So, what information about Python is the average reader
> looking for? Are Python users smug or self-effacing? Is
> there enough documentation? What are the warts, and what
> have you found Python to be especially good or bad
> for?</p>

I think if you are going to be talking about things other than the technical side, a big thing to think about is "why do I like this language?" or "why would somebody want to pick up yet another language and if they do, why python?"

Personally, I have several comments or observations with no particular theme. I do like the language and it is the one I hack in at home most of the time.

1. I really, really like the array slicing and list comprehensions. I miss them in other languages. These two things make working with collections of data pretty simple. One I threw together the other day for comparing files in two directories was the following. Assume the file names are loaded in two arrays and that the path names have been lopped off


import string

[x.lower() for x in linesSource if x.lower() not in map(string.lower, linesTarget)]


2. self has already been pointed out. I see the reason for it, it makes things painfully obvious, but it is, at times, ugly and having to spend plenty of time in C++, C#, VB(pick a flavor) and a couple other languages, I, along with others, sometimes for get to type self since just about every other language does not require self's equivalent.

3. I have found the community generally helpful. Lots of smart people and many of them are willing to answer questions and not sound too much like pedantic windbags.

4. Lots of libraries and interfaces into almost everything. If you have something to write, there is probably a python interface available for it at this point.

5. I think the whinging about the GIL is overdone. Yes it is a problem in some instances. There are also many solutions to the problem. And if massive performance and parallelism on a single processor is your goal, python probably isn't what you are writing in anyway. http://www.parallelpython.com/ is one such solution that offers an erlang like method of handling the problem.

6. Variable scoping and the 'global' keyword have caused me some annoyances in the past. In general practice it doesn't seem to be a problem, but when it bites you, it really bites you.

7. Array slicing and python's list based approach to strings makes it real handy for crunching strings. It may not be perl-powerful because regex is not built into the language, but I find it very handy for a multitude of file handling problems with logs, source code, etc.

8. cross platform support is good and I think, generally speaking, python users are, as a group, the most platform agnostic bunch. As a group I see much less of the windows vs. linux vs. OSX idiocy that seems to be more pervasive in other language communities. As a group I think pythonistas are a rather pragmatic bunch.

9. It would be nice to hear more about some commercial successes of python. python.org has the success page and bittorrent gets a bit of press, but I would imagine there are other instances where the language is used that would make people go 'wow' that we just don't know about.

John M Camara

Posts: 15
Nickname: camara
Registered: Dec, 2004

Re: What Matters About Python? Posted: Aug 14, 2007 11:28 AM
Reply to this message Reply
Keith - Take a look at the ply module http://www.dabeaz.com/ply/. It's an implementation of Lex and Yacc in Python.

Joe Cheng

Posts: 65
Nickname: jcheng
Registered: Oct, 2002

Re: What Matters About Python? Posted: Aug 15, 2007 3:11 PM
Reply to this message Reply
Merriodoc, sorry to be a code pedant, but...

[x.lower() for x in linesSource if x.lower() not in map(string.lower, linesTarget)]

Will that execute map(string.lower, linesTarget) once per line in linesSource? If so... yuck!

Here's what I would do in Ruby (I can't find the Python function for list subtraction, and the - operator doesn't seem to work):

linesSource.map{|x|x.downcase} - linesTarget.map{|x|x.downcase}

Merriodoc Brandybuck

Posts: 225
Nickname: brandybuck
Registered: Mar, 2003

Re: What Matters About Python? Posted: Aug 16, 2007 7:04 AM
Reply to this message Reply
> Merriodoc, sorry to be a code pedant, but...
>
> [x.lower() for x in linesSource if x.lower() not in
> map(string.lower, linesTarget)]

>
> Will that execute map(string.lower, linesTarget) once per
> line in linesSource? If so... yuck!
>

I hope not. Hadn't even thought of that. That would be, well, not good.


> Here's what I would do in Ruby (I can't find the Python
> function for list subtraction, and the - operator doesn't
> seem to work):
>
> linesSource.map{|x|x.downcase} -
> linesTarget.map{|x|x.downcase}


There isn't a list subtraction function or operator I'm aware of. Mathematically speaking, that is treating an array like a set (with the exception that duplicates are allowed) and if you want to do something like that, you can use the set data type in python


>>> a = set(['a','b','c'])
>>> b = set(['a','f','x'])
>>> a - b
set(['c', 'b'])
>>>

James Watson

Posts: 2024
Nickname: watson
Registered: Sep, 2005

Re: What Matters About Python? Posted: Aug 16, 2007 7:15 AM
Reply to this message Reply
> > Merriodoc, sorry to be a code pedant, but...
> >
> > [x.lower() for x in linesSource if x.lower() not
> in
> > map(string.lower, linesTarget)]

> >
> > Will that execute map(string.lower, linesTarget) once
> per
> > line in linesSource? If so... yuck!
> >
>
> I hope not. Hadn't even thought of that. That would be,
> well, not good.

It does not:

>>> def list():
... print "in list"
... return [1,2,3]
...
>>> for i in [x for x in list()]:
... print i
...
in list
1
2
3
>>>

James Watson

Posts: 2024
Nickname: watson
Registered: Sep, 2005

Re: What Matters About Python? Posted: Aug 16, 2007 10:56 AM
Reply to this message Reply
> > I hope not. Hadn't even thought of that. That would be,
> > well, not good.
>
> It does not:

Oops. I missed the point. Sorry. It actually looks like it does.

Elizabeth Wiethoff

Posts: 89
Nickname: ewiethoff
Registered: Mar, 2005

Re: What Matters About Python? Posted: Aug 16, 2007 1:40 PM
Reply to this message Reply
I don't know what an "average reader" is looking for, but I'll mention something almost trivial that this out-of-the-average reader really appreciates about Python: "the whitespace thing."

My vision is lousy. Hence, I work with huge fonts and screen real estate is at a premium. The fact that whitespace delimits Python blocks means I don't have to waste a line typing "end" (as in Ruby) or "}" (as in several Algol family languages). Typing, of course, is not the problem, but reading is. Without those silly delimiters, I can see more lines of executable code in my editor and hold less code in my head.

Merriodoc Brandybuck

Posts: 225
Nickname: brandybuck
Registered: Mar, 2003

Re: What Matters About Python? Posted: Aug 16, 2007 2:52 PM
Reply to this message Reply
> > Merriodoc, sorry to be a code pedant, but...
> >
> > [x.lower() for x in linesSource if x.lower() not
> in
> > map(string.lower, linesTarget)]

> >
> > Will that execute map(string.lower, linesTarget) once
> per
> > line in linesSource? If so... yuck!
> >
>
> I hope not. Hadn't even thought of that. That would be,
> well, not good.
>
>
> > Here's what I would do in Ruby (I can't find the Python
> > function for list subtraction, and the - operator
> doesn't
> > seem to work):
> >
> > linesSource.map{|x|x.downcase} -
> > linesTarget.map{|x|x.downcase}

>
> There isn't a list subtraction function or operator I'm
> aware of. Mathematically speaking, that is treating an
> array like a set (with the exception that duplicates are
> allowed) and if you want to do something like that, you
> can use the set data type in python
>
>
> >>> a = set(['a','b','c'])
> >>> b = set(['a','f','x'])
> >>> a - b
> set(['c', 'b'])
> >>>
>


Hopefully to put an end to the code pedantics, not that I mind them :-)


set(map(string.lower, linesSource)) - set(map(string.lower, linesTarget))


lower is mapped only once to each array and set allows you the pretty use of the '-' operator.

I used to cringe a little at the whitespace thing. Now I just don't care. Almost everybody I know who cringes ends up not caring. But, I think, that topic has gotten beaten to death. The only syntax flakiness that I even think about sometimes is that trailing ':' after if statements, for loops, etc.

James Watson

Posts: 2024
Nickname: watson
Registered: Sep, 2005

Re: What Matters About Python? Posted: Aug 17, 2007 7:36 AM
Reply to this message Reply
> I used to cringe a little at the whitespace thing. Now I
> just don't care. Almost everybody I know who cringes ends
> up not caring. But, I think, that topic has gotten beaten
> to death. The only syntax flakiness that I even think
> about sometimes is that trailing ':' after if statements,
> for loops, etc.

I think Elizabeth was in favor of the 'whitespace thing'. I too find it odd that this is considered by many to be a deficiency in Python because I think it's great. At first, I was a little skeptical but when I realized that I can't stand when people don't indent properly, I reconsidered.

I would even like to use this idea to create a simplified form of XML equivalent documents. When I've suggested this in the past, people have claimed that whitespace is 'dangerous' because it's too easy to change.

Has anyone ever had this occur to them in Python where reformatting the code changing the meaning? It seems kind of like a theoretical problem.

Flat View: This topic has 19 replies on 2 pages [ 1  2 | » ]
Topic: What Matters About Python? Previous Topic   Next Topic Topic: One Laptop Per Child

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use