Well, I know I'm preaching to the converted - but Python rocks.
I've been enchanted by the siren calls of Scheme, Lisp and Forth, but in
the end, I find Python much easier. I even tried a little bit of Tcl.
To give a bit of context ... I have recently switched from Windows to OS
X and Linux. I missed MS Money, but couldn't get on with GnuCash. So I
decided to write my own little home-brew money management program that
includes things like downloading share price info from Yahoo Finance.
I picked Chicken Scheme for OS X. Things started well, and even the web
download and regex stuff worked fairly painlessly. I wanted to work with
dates, and decided that I needed the SRFI-19 library. Chicken has
"eggs", which you can download and install. The problem is that it
needed further dependencies. Well, no need to panic just because of
that; but I found that it ultimately depended on gmp, which turned out a
pain to compile.
Other languages seem to have neat ideas; like closures or macros in
Scheme, or ultra-simple syntax like Forth. But what I have generally
found is that other languages seem to require too much pain for too
little return. I just seem to be way more productive in Python than in
any other language. 12 1357
On Jun 2, 12:31 pm, Steve Howell <showel...@yahoo.comwrote:
--- Mark Carter <m...@privacy.netwrote:
Well, I know I'm preaching to the converted - but
Python rocks.
[...]
A few questions from the choir:
As a recent newcomer to the language, did you
encounter any traps or pitfalls while you were
learning?
I had probably stumbled on many/most of the common pitfalls usually
mentioned (e.g. http://www.ferg.org/projects/python_gotchas.html, http://zephyrfalcon.org/labs/python_pitfalls.html) while learning, but
picked them up easily after the first or second time. Off the top of
my head, two errors that keep coming back even years after are:
- Comparing instances of (semantically) incomparable types (http:// http://www.ibm.com/developerworks/li...egance-1.html).
Thankfully this will be fixed in Py3k.
- Strings being iterable; unfortunately this will stay in Py3K.
Also, could you single out anything in
particular about Python that started making you more
productive, or was it just the overall design?
If I were to pick a single feature, this would be the triplet
iterators-generators-itertools, not only for the productivity gains
but perhaps even more for changing the way of thinking about
programming, making Python worth learning [1]. But in general it's the
overall design, making the right tradeoffs in most cases.
George
[1] "A language that doesn't affect the way you think about
programming, is not worth knowing." - Alan Perlis
In article <11**********************@p47g2000hsd.googlegroups .com>,
George Sakkis <ge***********@gmail.comwrote:
> I had probably stumbled on many/most of the common pitfalls usually mentioned (e.g. http://www.ferg.org/projects/python_gotchas.html, http://zephyrfalcon.org/labs/python_pitfalls.html) while learning, but picked them up easily after the first or second time. Off the top of my head, two errors that keep coming back even years after are: - Comparing instances of (semantically) incomparable types (http:// http://www.ibm.com/developerworks/li...egance-1.html). Thankfully this will be fixed in Py3k. - Strings being iterable; unfortunately this will stay in Py3K.
I'll repeat the comment I made on python-3000:
"...string iteration isn't about treating strings as sequences of
strings, it's about treating strings as sequences of characters. The
fact that characters are also strings is the reason we have problems,
but characters are strings for other good reasons."
Thing is, the fact that you can e.g. slice strings just like other
sequence types creates the consequence that you can also iterate over
strings -- moreover, some of us actually do iterate over strings (though
of course we could if necessary create lists/tuples of characters). In
the grand scheme of things, I rarely see people running into problems
with iterating over strings.
--
Aahz (aa**@pythoncraft.com) <* http://www.pythoncraft.com/
"as long as we like the same operating system, things are cool." --piranha
Mark Carter <me@privacy.netwrote:
I picked Chicken Scheme for OS X. Things started well, and even the web
...
that; but I found that it ultimately depended on gmp, which turned out a
pain to compile.
Yes, GMP is a pain to compile (especially on Mac OS X), but I believe
that the Universal Binary library version I've put among the gmpy
downloads (see http://code.google.com/p/gmpy/downloads/list) works fine
(at least it seems to work fine for gmpy, which is my Python extension
that wraps GMP, and gmpy exposes and copiously unit-tests essentially
all of GMP's functionality).
Just mentioning this in case you want to give Scheme another chance
(which it may well deserve, although closures are hardly unique to it; I
wonder if you meant continuations). Python may enjoy better tools and
libraries than Scheme, but then Java enjoys better ones yet, yet I
prefer to stick with Python because I like it better *as a language*...
Alex
Josiah Carlson <jo************@sbcglobal.netwrote:
pitfall of Python is knowing whether an operation is destructive or not.
If it returns None, it probably changes the content of an object.
A reasonable heuristic, but with lots of exceptions, alas:
somedict.get(somekey)
will often return None without performing any change, while
somelist.pop()
does modify somelist but typically returns non-None.
The use of trailing-exclamation-point (by convention) to indicate
"mutating methods" is a nice plus in languages that allow it.
Alex
Alex Martelli wrote:
Mark Carter <me@privacy.netwrote:
Yes, GMP is a pain to compile (especially on Mac OS X), but I believe
Just mentioning this in case you want to give Scheme another chance
Thanks. I'll take a look at it.
I think I've decided to finish off my little in project in Python first,
though. I'd like to actually get it done (!). I may well decide to
reimplement bits in either Scheme, or I might try my hand at Forth. My
app will be small enough to permit re-writes.
I had actually done a small 3-month Java project professionally about 7
years ago. Can't say I was too impressed. IMO, it was too verbose, I'm
not an OO fanatic, and some immutable strings turned out to be not quite
as immutable as I expected.
I had a brief toy around with Java using Xcode very recently, and I was
able to figure out how to download webpages easy enough (I do this to
scrape stock quotes). I felt fairly confident that I could achieve what
I wanted in Java, even though I'm fairly raw with it. I started from a
default project using Xcode, and it seemed to generate a lot of base
code. I quickly abandoned the Java idea, as I'm not gunning to be a Java
developer, and Python seems to do what I want without fuss.
I think that's the key to Python. You can do what you want without fuss,
and it's copiously documented.
Alex Martelli wrote:
Josiah Carlson <jo************@sbcglobal.netwrote:
>>pitfall of Python is knowing whether an operation is destructive or not.
If it returns None, it probably changes the content of an object.
A reasonable heuristic, but with lots of exceptions, alas:
somedict.get(somekey)
will often return None without performing any change, while
somelist.pop()
does modify somelist but typically returns non-None.
The use of trailing-exclamation-point (by convention) to indicate
"mutating methods" is a nice plus in languages that allow it.
Actually, that'd be nice to have in Python. And whilst we're about it,
might as well go the whole hog and allow hyphens in names, too.
Mark Carter <me@privacy.netwrote:
Alex Martelli wrote:
Josiah Carlson <jo************@sbcglobal.netwrote:
>pitfall of Python is knowing whether an operation is destructive or not.
If it returns None, it probably changes the content of an object.
A reasonable heuristic, but with lots of exceptions, alas:
somedict.get(somekey)
will often return None without performing any change, while
somelist.pop()
does modify somelist but typically returns non-None.
The use of trailing-exclamation-point (by convention) to indicate
"mutating methods" is a nice plus in languages that allow it.
Actually, that'd be nice to have in Python. And whilst we're about it,
might as well go the whole hog and allow hyphens in names, too.
Hyphens look the same as minus signs, so that allowing them in names in
a language with infix operator syntax is far from a clear win. Right
now, in Python and all cognate languages, a-b means a minus b; the
tectonic shift to having it be a 3-character identifier instead, in
addition to breaking millions of lines of existing code, would rightly
produce extreme resistance in anybody whose main programming experience
comes from Basic, C, Java, Fortran, C++, PL/I, Perl, C#, and Python
itself (and dozens of other languages, too, of course).
I noticed this effect when I was playing with Dylan (never did anything
"serious" with it, but I did like many aspects of the language): I kept
writing a-b (and for that matter a+b, etc) and getting weird syntax
errors because I had not interposed all needed spaces. (If a-b is not
allowed as an expression, it makes sense that a+b isn't either).
Despite substantial previous experience with Lisp, Scheme, and Forth, in
all of which a-b would "of course" be an identifier, that experience
just didn't guide my fingers -- in those languages operator are prefix
(Lisp, Scheme) or suffix (Forth), so it's "natural" that sticking an
operator sign "between" sequences of letters means nothing special...
but moving to an infix language just shifts my brain in a different
gear. Cobol has preferably-prefix notation too, i.e., the natural way
to express the difference would be "SUBTRACT C FROM B", and the
alternative "algebraic" (infix) notation is and feels very "bolted-on",
so it's kind of an intermediate case, where hyphens are still OK.
Not only is the cost of making a-b an identifier extremely high, but the
gains are tiny: what conventional difference is there supposed to be
between a-b and a_b? Looks like nothing but one more category of easily
confusable identifiers. Big pain, little gain == not so great an idea.
Allowing a trailing ! in method names has no such cost, because in no
language I know is ! used as a "postfix unary operator"; the gain in the
convention "mutators end with !" is not huge, but substantial. So, the
tradeoffs are different: small pain, substantial gain == not a bad idea.
However, this is all quite theoretical, because no more PEPs will be
accepted for Python 3000, so any language change like this would have to
wait for Python 4000, which is no doubt quite a distant prospect:-).
Alex
Mark Carter <me@privacy.netwrote:
Alex Martelli wrote:
Mark Carter <me@privacy.netwrote:
Yes, GMP is a pain to compile (especially on Mac OS X), but I believe
Just mentioning this in case you want to give Scheme another chance
Thanks. I'll take a look at it.
You're welcome.
I think I've decided to finish off my little in project in Python first,
though. I'd like to actually get it done (!). I may well decide to
reimplement bits in either Scheme, or I might try my hand at Forth. My
app will be small enough to permit re-writes.
Excellent situation to play around with many languages, then. If your
app can run on dotNET or Mono, you might also want to try Boo, a
language somewhat inspired by Python but with a different approach to
typing (based on type-inferencing, with an explicit 'duck' type for
those rare cases in which you really _want_ a single variable to take on
values of heterogeneous types during execution).
I had actually done a small 3-month Java project professionally about 7
years ago. Can't say I was too impressed. IMO, it was too verbose, I'm
not an OO fanatic, and some immutable strings turned out to be not quite
as immutable as I expected.
Nolo contendere on the verbosity and the need to stuff _every_thing into
a class, but the non-immutable-strings looks like a serious bug in
whatever JVM you were using at the time. Anyway, what's impressive with
Java today is not the language (maybe a bit better than it was 7 years
ago but still substantially Java:-), it's the array of excellent tools,
libraries and frameworks grown around it; Java's standard library has
arguably surpassed Python's, and third-party offerings for Java are
really great.
I had a brief toy around with Java using Xcode very recently, and I was
Not the best IDE for Java, btw -- Apple doesn't seem to like Java all
that much any more, and it looks to me like it's backpedaling on Java's
integration in MacOSX (in favor of Python, Ruby, etc). BTW, ObjectiveC
is another language worth trying (though its non-Apple implementations
lag far, far behind, alas). Eclipse is probably "the" Java IDE nowadays
(and it's free, cross-platform, and all).
able to figure out how to download webpages easy enough (I do this to
scrape stock quotes). I felt fairly confident that I could achieve what
I wanted in Java, even though I'm fairly raw with it. I started from a
default project using Xcode, and it seemed to generate a lot of base
code. I quickly abandoned the Java idea, as I'm not gunning to be a Java
developer, and Python seems to do what I want without fuss.
I think that's the key to Python. You can do what you want without fuss,
and it's copiously documented.
Yes, excellent points. Although I have a long-time fascination with
many programming languages, Python does still stand out from the crowd
in enabling me to get any given app done "without fuss"!-)
Alex
On Jun 2, 4:58 pm, a...@pythoncraft.com (Aahz) wrote:
In article <1180807432.351720.123...@p47g2000hsd.googlegroups .com>,
George Sakkis <george.sak...@gmail.comwrote:
I had probably stumbled on many/most of the common pitfalls usually
mentioned (e.g.http://www.ferg.org/projects/python_gotchas.html, http://zephyrfalcon.org/labs/python_pitfalls.html) while learning, but
picked them up easily after the first or second time. Off the top of
my head, two errors that keep coming back even years after are:
- Comparing instances of (semantically) incomparable types (http:// http://www.ibm.com/developerworks/li...egance-1.html).
Thankfully this will be fixed in Py3k.
- Strings being iterable; unfortunately this will stay in Py3K.
I'll repeat the comment I made on python-3000:
"...string iteration isn't about treating strings as sequences of
strings, it's about treating strings as sequences of characters. The
fact that characters are also strings is the reason we have problems,
but characters are strings for other good reasons."
No, the reason we have problems is that far more often than not
strings are treated as atomic values, not sequences of smaller strings
or characters. A classic example is flatten(), where most people are
surprised if flatten([1, (3.14, 'hello')]) returns [1, 3.14, 'h', 'e',
'l', 'l', 'o'].
Thing is, the fact that you can e.g. slice strings just like other
sequence types creates the consequence that you can also iterate over
strings -- moreover, some of us actually do iterate over strings (though
of course we could if necessary create lists/tuples of characters). In
the grand scheme of things, I rarely see people running into problems
with iterating over strings.
One class of problems is functions such as flatten() that expect "a
collection or an atom", with strings being typically considered
atomic. A second common pitfall are functions that expect file-like
objects but are given file names instead:
def process_file(input_file):
for line in input_file:
do_stuff(line)
process_file('/home/george/.bashrc') # oops
I now try to remember to write such functions as:
def process_file(input_file):
if isinstance(input_file, basestring):
input_file = open(input_file)
for line in input_file:
...
It's not a huge impediment by any means but it's certainly a gotcha.
George
On Jun 3, 8:56 am, a...@mac.com (Alex Martelli) wrote:
Allowing a trailing ! in method names has no such cost, because in no
language I know is ! used as a "postfix unary operator"; the gain in the
convention "mutators end with !" is not huge, but substantial. So, the
tradeoffs are different: small pain, substantial gain == not a bad idea.
However, this is all quite theoretical, because no more PEPs will be
accepted for Python 3000, so any language change like this would have to
wait for Python 4000, which is no doubt quite a distant prospect:-).
Would it? If it isn't backwards-incompatible, it could even go in 2.6
-Mike
In article <11*********************@p47g2000hsd.googlegroups. com>,
George Sakkis <ge***********@gmail.comwrote:
>On Jun 2, 4:58 pm, a...@pythoncraft.com (Aahz) wrote:
>In article <1180807432.351720.123...@p47g2000hsd.googlegroups .com>, George Sakkis <george.sak...@gmail.comwrote:
>>> - Strings being iterable; unfortunately this will stay in Py3K.
I'll repeat the comment I made on python-3000:
"...string iteration isn't about treating strings as sequences of strings, it's about treating strings as sequences of characters. The fact that characters are also strings is the reason we have problems, but characters are strings for other good reasons."
No, the reason we have problems is that far more often than not strings are treated as atomic values, not sequences of smaller strings or characters. A classic example is flatten(), where most people are surprised if flatten([1, (3.14, 'hello')]) returns [1, 3.14, 'h', 'e', 'l', 'l', 'o'].
Enh. That's not my experience -- the ability to slice, dice, and
concatenate strings is intrinsic to their usefulness.
>Thing is, the fact that you can e.g. slice strings just like other sequence types creates the consequence that you can also iterate over strings -- moreover, some of us actually do iterate over strings (though of course we could if necessary create lists/tuples of characters). In the grand scheme of things, I rarely see people running into problems with iterating over strings.
One class of problems is functions such as flatten() that expect "a collection or an atom", with strings being typically considered atomic. A second common pitfall are functions that expect file-like objects but are given file names instead:
def process_file(input_file):
for line in input_file:
do_stuff(line)
process_file('/home/george/.bashrc') # oops
That's a problem, yes, and it has oddly enough gotten worse since
iterators were introduced into Python. Nevertheless, I have yet to see
anyone suggest a mechanism for fixing this particular gotcha without
creating more problems. Strings are just too useful as sequences.
Moreover, my experience is that these kinds of problems don't show up
all that frequently in practice.
--
Aahz (aa**@pythoncraft.com) <* http://www.pythoncraft.com/
"as long as we like the same operating system, things are cool." --piranha
On Jun 3, 11:56 am, a...@mac.com (Alex Martelli) wrote:
Allowing a trailing ! in method names has no such cost, because in no
language I know is ! used as a "postfix unary operator";
Some math oriented languages use it as the factorial function. E.g.,
Mathematica:
In[1] := 10!
Out[1]= 3628800
(The more you know....)
Carl Banks This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Neuruss |
last post by:
It seems there are quite a few projects aimed to improve Python's
speed and, therefore, eliminate its main limitation for mainstream
acceptance.
I just wonder what do you all think?
Will Python...
|
by: kanzen |
last post by:
I keep telling my friends that Python rocks. Now it's time to put my
money where my mouth is. I'm about to start writing a server for a
phone based game. It needs to handle simlpe requests from...
|
by: John Salerno |
last post by:
I have to say, I'm having a very enjoyable time learning and using
Python. I spent a year playing around with C# and I feel like I
learned/know less about it than I do about Python from just the...
|
by: John & Mary Cook |
last post by:
I just installed Python on Windows XP Pro. When I enter 'python' at the >>>
prompt in Pythonwin IDE I get the following:
Traceback (most recent call last):
File "<interactive input>", line 1,...
|
by: nicolasfr |
last post by:
Hi,
I am a bit disapointed with the current Python online documentation. I
have read many messages of people complaining about the documentation,
it's lack of examples and the use of complicated...
|
by: Scott Smith |
last post by:
To all you vi/vim users out there.....
I am just getting into python and am trying to learn how to use the
python.vim script. I really like the fact that it autoindents for me while
inserting...
|
by: Gabriel Genellina |
last post by:
QOTW: "Stop thinking of three lines as 'extensive coding' and your problem
disappears immediately." - Steve Holden
"Hey, did you hear about the object-oriented version of COBOL? They call
it...
|
by: Ultrus |
last post by:
Hello Python Gurus,
I picked up a book the other day on Python programming. Python rocks!
I'm learning Python as I want to call upon it to handle some intensive
tasks from PHP/web server.
The...
|
by: Frantisek Malina |
last post by:
What is the best way to do the regular bash commands in native python?
- create directory
- create file
- make a symlink
- copy a file to another directory
- move a file
- set permissions
...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
|
by: Aliciasmith |
last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
|
by: tracyyun |
last post by:
Hello everyone,
I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
|
by: NeoPa |
last post by:
Hello everyone.
I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report).
I know it can be done by selecting :...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
|
by: isladogs |
last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, Mike...
|
by: GKJR |
last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
| |