Re: Python less error-prone than Java

2006-06-04 Thread D H
Christoph Zwerschke wrote:
 
 See the following web page if you dont find it ;-)
 http://googleresearch.blogspot.com/2006/06/extra-extra-read-all-about-it-nearly.html
  

The point of that is that it did fail.  It threw an 
ArrayIndexOutOfBoundsException exception.  But it was just luck that 
happened.  Unfortunately I don't think java and C# have integer overflow 
checking turned on by default.

Take this longArithmetic benchmark here:
http://www.cowell-shah.com/research/benchmark/code
and a story about it here:
http://www.osnews.com/story.php?news_id=5602page=3

The java and C# versions are fast (15 seconds for me), BUT, they
give the incorrect result because of an overflow error.
The python version gives the correct result because it transparently
changes the underlying types to handle the larger numbers, BUT this
causes it to run over 20X slower than Java or C#.  It takes 10 minutes
to complete in python, not 15 seconds.  With psyco, it takes 5 minutes.

So to say the story you pointed out shows that python is superior
is a matter of perspective.  Yes, python gave the correct result
by silently changing the underlying types to longs, and that is
what I would expect of a scripting language.  But the price is
speed.  In both these cases, I would rather be made aware of the
error in the code and fix it so I didn't have to suffer slowdowns.

That is why in boo ( http://boo.codehaus.org/ ) luckily overflow 
checking is enabled by default, and it throws a overflow exception at
runtime to tell you something is wrong with your code.  When you
then fix for that, you get the same 15 second time just like java
and C#.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: C# equivalent to range()

2006-06-01 Thread D H
Neuruss wrote:
 I'm sorry for asking about another language here, but since I only know
 Python and I'm trying to write something in C#, I guess this is the
 best place...
 
 I'd like to know how to write this in C#:
 
 x=[]
 sz = 1000
 x.extend(range(sz))
 
 My question is about range and extend. Is there any equivalent in
 C#?
 
 Thanks in advance,
 Neuruss
 

Listint mylist = new Listint();
for (int i=0; i1000; i++)
{
 mylist.Add(i);
}

You can use AddRange, C# 2.0 anonymous delegates, IEnumerable, yield, 
foreach, and so forth instead, but for your example this is simplest.

Another option is to use boo.  http://boo.codehaus.org/
It uses python's syntax but is as fast as C#.  The only change you'd
have to make in that code is to capitalize the Extend method call.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Can Python format long integer 123456789 to 12,3456,789 ?

2006-06-01 Thread D H
A.M wrote:
 Hi,
 
 Is there any built in feature in Python that can format long integer 
 123456789 to 12,3456,789 ?

Apparently you need to use the locale module.  This is the
example they give online to print a simple number with commas:

import locale
locale.setlocale(locale.LC_ALL, 'English_United States.1252')
print locale.format(%d, 123456789, grouping=True)

Someone should make a module that uses .NET or Java's formmating.
You just use {0:n} or ###,### instead of all the above.
http://blog.stevex.net/index.php/string-formatting-in-csharp/
http://java.sun.com/docs/books/tutorial/i18n/format/decimalFormat.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Go help the perl list instead Fredrik Lundh

2006-05-25 Thread D H
Fredrik Lundh wrote:
 vbgunz wrote:
 
 I have new a list , when it hava large number of values, I wonna to
 delete all the values in it,how to do?

 something like this will probably help.

 x = [1,2,3,4,5,6,7,8,9]
 y = x

 list([x.pop() for z in xrange(len(x))])

 print x, y  # [] []
 
 if you don't know how to do things, you don't need to post.
 
 if you know why this is about the dumbest way to do what you're doing, 
 and you're posted this on purpose, you really need to grow up.
 
 /F

He already posted before your post that he made a mistake.
You obviously ignored that and invented some argument that he
posted with malicious intentions.  That better describes most of
your thousands of annoying posts.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: John Bokma harassment

2006-05-24 Thread D H
Kay Schluehr wrote:
 To make a witty comment: 
  Xah is the star, who undresses his mind.

 But good and sensitive people don't like liking to
 contribute in those nasty battles and believe their time is deserved to
 something less wastefull. 

 I mildly disagree with attitude and tend to
 think that most serious work is a waste of time. 

 Everything in the name of Xah the lord of misrule. 


Dude, pony up for another english class, so you can keep on trolling as 
eloquently as Xah.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python vs. Lisp -- please explain

2006-02-21 Thread D H
Donn Cave wrote:
 I can say Python can serve as a scripting language for some applications,
 but not Python is a scripting language!

bruno at modulix wrote:
  as soon as you say interpreted, scripting, peoples think not
  serious.

Cameron Laird wrote:
  I *think* you're proposing that,
  were Guido more knowledgeable, he would have created a Python
  language that's roughly as we know now, implemented it with
  FASTER software ... and to its own detriment.

Fredrik Lundh wrote:
  define scripting language.
 
  the only even remotely formal definition I've ever seen is language
  with designed to script an existing application, with limited support
  for handling
  its own state.  Early Tcl and JavaScript are scripting languages,
  Python is not.

Kay Schluehr wrote:
  Yes, it's Guidos master-plan to lock programmers into a slow language
  in order to dominate them for decades.

Donn Cave wrote:
  All I'm saying is that Python matches
  what people think of as an interpreted language.  You can deny it, but
  but it's going to look like you're playing games with words, and to no
  real end, since no one could possibly be deceived for very long.

Steven D'Aprano wrote:
  Describing C (or Lisp) as compiled and Python as interpreted is to
  paint with an extremely broad brush, both ignoring what actually
  happens in fact, and giving a false impression about Python. It is
  absolutely true to say that Python does not compile to machine code.
  (At least not yet.) But it is also absolutely true that Python is
  compiled. Why emphasise the interpreter, and therefore Python's
  similarity to bash, rather than the compiler and Python's similarity
  to (say) Java or Lisp?

Paul Boddie wrote:
  Yes, I think that with optional static typing, it's quite likely that
  we would see lots of unnecessary declarations and less reusable code
  (ints everywhere, everyone!), so I think the point about not
  providing people with certain features is a very interesting one,
  since
  people have had to make additional and not insignificant effort to
  optimise for speed. One potential benefit is that should better tools
  than optional static typing be considered and evaluated, the ints
  everywhere! line of thinking could prove to be something of a dead
  end
  in all but the most specialised applications. Consequently, the Python
  platform could end up better off, providing superior tools for
  optimising performance whilst not compromising the feel of the
  language
  and environment.

Torsten Bronger wrote:
  By the way, this is my main concern about optional static typing: It
  may change the target group, i.e. it may move Python closer to those
  applications where speed really matters, which again would have an
  effect on what will be considered Pythonic.

Steven D'Aprano wrote:
  The Python is both interpreted and compiled camp, who
  believe that both steps are equally important, and to
  raise one over the other in importance is misleading.
  That's why Sun doesn't describe Java as interpreted,
  but as byte-code compiled. They did that before they
  had JIT compilers to compile to machine code.

Bruno Desthuilliers wrote:
  It's not a scripting language, and it's not interpreted.


It will all be sorted out once and for all in Python 3000: The Reckoning
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is unique about Python?

2005-12-23 Thread D H
Kay Schluehr wrote:
 gsteff wrote:
 
 
So I'm wondering, what is
innovative about Python, either in its design or implementation?  Or is
its magic really just in combining many useful features of prior
languages in an unusually pleasant way?

Greg
 
 
 The latter.
 
 http://www.python-in-business.org/ep2005/download.cpy?document=8599
 
 As Guido described in his presentation Python is a decendent of ABC
 developed at the university where he studied.
 
 Here is some material about the primary motivations of ABC:
 
 http://homepages.cwi.nl/~steven/abc/language.html
 
 Python seems to proof that eclecticism can be done right. 

Python has as much resemblance to ABC as an airplane does to a car.
The design principles used by ABC (like colons at the end of lines)
may have a certain justification in the context of ABC, but you cannot
simply transfer that justification to python.
ABC is designed specifically and entirely to be beginner-friendly. 
Python is not.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to get started in GUI Programming?

2005-12-23 Thread D H
Kay Schluehr wrote:
 [EMAIL PROTECTED] wrote:
 
I am trying to learn GUI programming in Python, but have to confess I
am finding it difficult.
 
 
 Don't do it if you can prevent it.

What kind of helpful advice is that?

 Conclusion: if you are already familiar with BASIC I would just
 continue writing BASIC apps using VisualBasic dotNet, Windows Forms as
 the underlying GUI toolktit and VisualStudio as IDE. Forget the
 coolness factor of the language. Cool people never care a lot what
 other people think. If you finally want to glue assemblys/controls
 together in Python this is still possible with IronPython or
 Python-dotNet ( which is a CPython binding to the CLR, available at
 Zope.org ).

So you recommend VB.NET on comp.lang.python, and then later publicly 
flame me for mentioning boo a year ago, as well as spew FUD about other
languages you don't like.  Doesn't the python community already have 
enough assholes as it is?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: simple question on optional parameters

2005-12-12 Thread D H
[EMAIL PROTECTED] wrote:
 I am using a toolkit that has a SetFaveNumbers() method. the method
 accepts any number
 of comma-separated numbers.
 
 the following are all valid examples:
 
 FooToolkit.SetFaveNumbers(1,3,5)
 FooToolkit.SetFaveNumbers(2,4,6,8,10)
 FooToolkit.SetFaveNumbers(1)
 
 I do not know how this method is implemented, but I would like to be
 able
 to call the method using a single variable:
 
 MyFaveNumbers = []
 MyFaveNumbers.append(2)
 MyFaveNumbers.append(4)
 
 FooToolkit.SetFaveNumbers(MyFaveNumbers)

See if this works:
FooToolkit.SetFaveNumbers(*MyFaveNumbers)

The asterix unpacks a list or tuple into individual items.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OO in Python? ^^

2005-12-11 Thread D H
Fredrik Lundh wrote:
 Write code, not usenet posts.

QOTW!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Great books on Python?

2005-12-11 Thread D H
Tolga wrote:
 I am not unfamiliar to programming but a newbie in Python. Could you
 recommend me (a) great book(s) to start with? Free online books or
 solid books are welcome.
 


http://www.ibiblio.org/g2swap/byteofpython/read/index.html
http://www.ibiblio.org/obp/thinkCSpy/
http://www.freenetpages.co.uk/hp/alan.gauld/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-09 Thread D H
Fredrik Lundh wrote:
 Zeljko Vrba wrote:
 
 
But look at the following example:

if a:
  some_code1
if b:
  some_code2

If I accidentaly delete if b:, then some_code2 gets under the if a: which is
not intended.
 
 
 not to mention that if you have
 
 if a:
 some_code1
 some_code2
 
 and accidentally remove some_code2, it won't be executed at all !
 
 do you often remove code by accident?  is this some vi-specific problem ?
 

If you had bothered to read the context he was merely showing an example
to prove that this is not entirely true:
Making a mistake in indentation level is precisely analogous to leaving 
out markers in other languages.

He was not suggesting that this is some affliction that he suffers, as 
you are suggesting.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-07 Thread D H
[EMAIL PROTECTED] wrote:
 Some people like it just as it is.  Don't change ANYTHING!

search for NIMPY

 Some people (a lot of the ones that don't give Python a chance) want
 one more choice, braces.  Is that so much to ask for?

If you like curly brace style, there are always other scripting 
languages like javascript (rhino for the jvm) or groovy or others.

If you like end statements style, there is always ruby or one
of the basic dialects like visual basic or gambas, or see rexx dialects 
too like netrexx or oorexx.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: i=2; lst=[i**=2 while i1000]

2005-12-06 Thread D H
Daniel Schüle wrote:
 Hello NG,
 
 I am wondering if there were proposals or previous disscussions in this 
 NG considering using 'while' in comprehension lists
 
 # pseudo code
 i=2
 lst=[i**=2 while i1000]
 
 of course this could be easily rewritten into
 i=2
 lst=[]
 while i1000:
 i**=2
 lst.append(i)

That would loop endlessly since you don't increment i.
You can use i**=2 for i in range(1000) instead
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: iron python exe problem

2005-12-06 Thread D H
[EMAIL PROTECTED] wrote:
 Hello,
 
 I have test.py:
 print 'hello'
 
 I compile using iron python the result is test.exe
 
 I have got error message when I tried to call test.exe telling that
 test.exe is not a valid win32 application.
 
 How can I solve this problem?
 
 Sincerely Yours,
 Pujo
 


drag all the ironpython dlls into the same folder as your generated exe 
and try again.  That error could also be a result of running a .net 2 
app in .net 1.1 or something similar.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: i=2; lst=[i**=2 while i1000]

2005-12-06 Thread D H
[EMAIL PROTECTED] wrote:
You can use i**=2 for i in range(1000) instead
 
 
 I don't think one can use assignment in list comprehension or generator
 expression. The limitation is very much like lambda.
 

i**2
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: iron python exe problem

2005-12-06 Thread D H
Dennis Lee Bieber wrote:
 On 6 Dec 2005 08:25:43 -0800, [EMAIL PROTECTED] [EMAIL PROTECTED]
 declaimed the following in comp.lang.python:
 
 
Hello,

I run exactly inside IronPython-0.9.5\bin where IronPython.dll exist.
I've already uninstalled my .net 1.1 so there is onle .net 2.0

 
   REINSTALL 1.1... Even M$ states that the two releases are supposed
 to co-exist...

IronPython is .net 2 only, I believe, so .NET 1.1 should be unnecessary.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Documentation suggestions

2005-12-06 Thread D H
Ian Bicking wrote:
There are endless minor bugs in the library reference, but that seems
unavoidable.  It documents many different and shifting modules, and
what to document is itself a contentious issue, so I don't think the
stream of small problems will ever cease.
 
 
 Since the topic of php.net-style comments comes up often, I thought I'd
 note I've been working on a comment system:
 http://pythonpaste.org/comment/commentary/ -- this might be useful for
 collecting and managing small updates and fixes to the documentation.


Yes, do it the way php's documentation is done, Xah Lee's recent trolls 
aside.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-05 Thread D H
Rick Wotnaz wrote:
 So, for instance, even a single character (like an opening or 
 closing bracket or a semicolon) is an indication that the design 
 can be improved. 

Or a colon
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-03 Thread D H
Scott David Daniels wrote:
 Tom Anderson wrote:
 So, could someone explain what's so evil about tabs?
 
 
 They appear in different positions on different terminals (older hard-
 copy), do different things on different OS's, and in general do not
 behave nicely.  On many (but not all) systems, they advance to the next
 column that is a multiple of 8, but not all, and people (and editors)
 use them freely to get to those positions, not understanding that they
 are not necessarily going to the same position.  The fact that they
 provide an ambiguous display is enough to make them evil.

How is that a problem that some editors use 8 columns for tabs and 
others use less?  So what?
A bigger problem I see is people using only 2 or 3 spaces for indenting. 
  That makes large amounts of code much less readable.  And of course it 
is a problem if you mix tabs and spaces at the beginning of the same line.
Tabs are easier to type (one keystroke each) and lead to visually better 
results (greater indentation unless you like hitting 8 spaces for each 
indent level).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Underscores in Python numbers

2005-11-20 Thread D H
Steve Holden wrote:
 David M. Cooke wrote:
 One example I can think of is a large number of float constants used
 for some math routine. In that case they usually be a full 16 or 17
 digits. It'd be handy in that case to split into smaller groups to
 make it easier to match with tables where these constants may come
 from. Ex:

 def sinxx(x):
 computes sin x/x for 0 = x = pi/2 to 2e-9
 a2 = -0.1 4
 a4 =  0.00833 33315
 a6 = -0.00019 84090
 a8 =  0.0 27526
 a10= -0.0 00239
 x2 = x**2
 return 1. + x2*(a2 + x2*(a4 + x2*(a6 + x2*(a8 + x2*a10

 (or least that's what I like to write). Now, if I were going to higher
 precision, I'd have more digits of course.

 Right, this is clearly such a frequent use case it's worth changing the 
 compiler for.

Yes it is.
In that one example he used digit grouping 5 more times than I've
used lambda in my life.  Remember people use python as a data format as 
well (see for example JSON).
It's a simple harmless change to the parser: ignore underscores or 
spaces in numeric literals.  As others have mentioned, Ruby supports
this already, as do Ada, Perl, ML variants, VHDL, boo, nemerle, and others.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: want some python ide

2005-11-13 Thread D H
[EMAIL PROTECTED] wrote:
 i want some python ide use pygtk
 eric3 is good for me ,but i like gtk,so i want some pygtk ide look like
 eric3
 wing is a good python ide,but i can not download it
 some other python ide(must use pygtk)
 thx
 

You can just use a text editor like jedit with gazpacho or glade
http://gazpacho.sicem.biz/
They are not as easy to use at QT Designer though for building interfaces.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to avoid f.close (no parens) bug?

2005-11-13 Thread D H
Carsten Haese wrote:
 On Thu, 2 Nov 2006 23:56:22 +0200, o wrote 
 
plez send me 
 
 
 
 Please tell us what bug you're talking about:
 
 A) Python closed the file but you expected it not to.
 B) Python didn't close the file but you expected it to.
 C) Python didn't warn you when you wrote f.close instead of f.close().
 D) Something else. Please elaborate by giving us a code example, a description
 of what you expected to happen, and a description of what happened instead.

It is certainly B  C.  It is a common issue.  There is no way to avoid 
it unless you learn how to avoid it.  Other than that, PyChecker may 
help find this kind of error.  Over a year ago Guido said he wanted to 
include pychecker with python but it still hasn't happened, so you can 
download it from here: http://pychecker.sourceforge.net/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: about python ide

2005-11-13 Thread D H
?? wrote:
 i am use python2.4.2 on my gentoo linux system
 i want to find some ide of python
 but i am using gtk2.8,wxPython has some bug on it.i cant emerge it correctly.
 i want some ide use pygtk or other lib of python gui except 
 wxpython(wxWidgets)

Try Gazpacho or Glade for designing your user interfaces:
http://gazpacho.sicem.biz/
and here is an IDE called Pida: http://pida.berlios.de/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: more than 100 capturing groups in a regex

2005-10-26 Thread D H
Fredrik Lundh wrote:
 Joerg Schuster wrote:
 
 
if you want to know why 100 is a reasonable and non-random choice, I
suggest checking the RE documentation for 99 groups and the special
meaning of group 0.

I have read everything I found about Python regular expressions. But I
am not able to understand what you mean. What is so special about 99?
 
 
 it's the largest number than can be written with two decimal digits.


It's a conflict between python's syntax for regex back references and 
octal number literals.  Probably wasn't noticed until way too late, and 
now it will never change.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: NEWBIE

2005-10-26 Thread D H
[EMAIL PROTECTED] wrote:
 brenden wrote:
 
hey everyonei'm new to all this programming and all this stuff and
i just wanted to learn how to do it...

does anyone think they can teach me how to work with python?
 
 
 Don't waste readers' time with such vague and broad requests. Instead,
 post a specific question, for example showing a small fragment of
 Python code that does not work as you expect. Or ask how to do XYZ in
 Python, if you are unable to find the answer using Google.
 
 Newbie by itself is always a bad subject line. Having a specific
 question should help you form a better title for your message.


As you can see, you won't find help here.  You will get a lot of great 
advice and help on the python-tutor list, which is for beginners such as 
yourself:
http://mail.python.org/mailman/listinfo/tutor
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Hi All - Newby

2005-10-26 Thread D H
Ask wrote:
 
 I found a link to this newsgroup, downloaded 1000 messages, 

You might check out the python-tutor list if you have beginner 
questions: http://mail.python.org/mailman/listinfo/tutor


 I must admit to much confusion regarding some of the basics, but I'm sure 
 time, reading, and good advice will get rid of that. at this stage, it's 
 just working through some examples and getting my head around things. As an 
 example, if I create a window, I've been unable to force it to be a certain 
 size, and put a button (widget) at (say) 20,40 (x  y). Is window formatting 
 possible?

You might also see wxpython: http://www.wxpython.org/  The wiki there 
has some examples and beginner resources.
-- 
http://mail.python.org/mailman/listinfo/python-list


[ANN] Boo Programming Language 0.7 Released

2005-10-20 Thread D H
Boo 0.7 was released by Rodrigo B. de Oliveira. Boo is a statically 
typed programming language for .NET/Mono with a python inspired syntax 
and a special focus on language and compiler extensibility.

Boo is free and open source (MIT/BSD license).

The source and binaries for Boo are available from http://boo.codehaus.org/

Boo 0.7 adds support for by reference parameters, a whitespace-agnostic 
parser, the one's complement operator, and has numerous bug fixes. Boo 
0.7 was also made compatible with .NET 2.0 beta (as well as .NET 1.1 and 
Mono 1.1.9), although boo does not yet consume or generate generics classes.

There are numerous new and updated boo addins for IDEs now available: 
for SharpDevelop 1.1 and 2.0, Eclipse, MonoDevelop, and two IDEs 
developed in boo called Boodle and Boox.

Differences with Python:
http://boo.codehaus.org/Gotchas+for+Python+Users
Differences with C#:
http://boo.codehaus.org/Differences+with+Csharp
Tutorials:
http://boo.codehaus.org/Tutorials
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


Re: New project coming up...stay with Python, or go with a dot net language??? Your thoughts please!

2005-10-04 Thread D H
Istvan Albert wrote:
 Disclaimer: this is not a flame against Boo.
 
 It just boggles my mind that a language that describes itself as
 python inspired syntax keeps being touted as:
 
 
Luis M. Gonzalez wrote:
Boo (which could be considered almost an static version of Python for .NET)
 
 
 Boo is *nothing* like a static version of Python. Stop perpetuating
 this nonsense.


There is no static version of python, only a proposal[1] which was 
quickly stomped on and revised to be about slower runtime type-checking:

def gcd(a: int, b: int) - int:
 while a:
 a, b = b%a, a
 return b

The boo equivalent is: (http://boo.codehaus.org/)

def gcd(a as int, b as int) as int:
 while a:
 a, b = b%a, a
 return b

Looks nearly identical to me.

(Istvan has been a long spewer of anti-boo FUD on this list)

[1] http://www.artima.com/weblogs/viewpost.jsp?thread=85551
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New project coming up...stay with Python, or go with a dot net language??? Your thoughts please!

2005-10-03 Thread D H
spiffo wrote:
 Ok, I LOVE python, so that is not the issue, but, I am getting very worried
 about it's growth. I recently re-visted the web looking at alot of projects
 I assumed would be up and running by now from over a year ago, such as Boa
 Constructor, Iron Python etc... it seems all these projects get started, but
 never finished.
 
 Also, more and more I need *complete* control of ms sql from my apps, which
 is simply not available from the adodbapi module I got off the internet...
 also, ms sql 2005 is getting ready to come out... what if the guy that wrote
 adodbapi.py does not feel like upgrading it so it even works with MS SQL
 SERVER 2005? Yeesh... you get the picture...

If everything revolves tightly around a microsoft product (ms sql 2005, 
which isn't even released yet), you probably are boxed in more towards 
other microsoft products.  That's vendor lock-in for you.  You might try 
VS.NET 2005 and see if C# or VB.NET and the ADO.NET api work well for 
you:  http://lab.msdn.microsoft.com/vs2005/
Of course that plus ms sql 2005 will end up costing a great deal of 
money.  Plus none of it is cross-platform, but you already said you do 
not need that.

There are free .NET alternatives like Mono, Sharpdevelop, boo ( 
http://boo.codehaus.org/ ) and nemerle, but they are not caught up with 
.NET 2 stuff yet.  Again, it hasn't even been released yet, and there 
are still bugs in their beta versions.
So it wouldn't surprise me if the python libraries can't handle ms sql 
2005-specific stuff yet either.

So, if you need a short answer now, I'd say go with vs.net 2005, but if 
you can afford to wait a while, free python and .net alternatives will 
catch up.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: no variable or argument declarations are necessary.

2005-10-02 Thread D H
James A. Donald wrote:
 I am contemplating getting into Python, which is used by engineers I
 admire - google and Bram Cohen, but was horrified to read
 
 no variable or argument declarations are necessary.
 
 Surely that means that if I misspell a variable name, my program will
 mysteriously fail to work with no error message.
 
 If you don't declare variables, you can inadvertently re-use an
 variable used in an enclosing context when you don't intend to, or
 inadvertently reference a new variable (a typo) when you intended to
 reference an existing variable.
 
 What can one do to swiftly detect this type of bug?

It's a fundamental part of python, as well as many other scripting 
languages.
If you're not comfortable with it, you might try a language that forces 
you to declare every variable first like java or C++.
Otherwise, in python, I'd recommend using variable names that you can 
easily spell.  Also do plenty of testing of your code.  It's never been 
an issue for me, although it would be nicer if python were 
case-insensitive, but that is never going to happen.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Parrot Python ?

2005-10-02 Thread D H
Do Re Mi chel La Si Do wrote:
 Hi !
 
 On the site of Amber :  http://xamber.org/index.html
 We can to view the sentence : Parrot version of Python
 Question :  what is Parrot version of Python ?
 

Parrot is a virtual machine runtime, like the java vm or .NET CLR.
http://www.parrotcode.org/
People are working on making various scripting languages run on top of 
the parrot vm, like the Amber language you found, and python 
http://pirate.tangentcode.com/ and Lua 
http://members.home.nl/joeijoei/parrot/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Django Vs Rails

2005-09-25 Thread D H
Jaroslaw Zabiello wrote:
 Dnia 24 Sep 2005 22:48:40 -0700, [EMAIL PROTECTED] napisał(a):
 
 
You should give TurboGears a try.
 
 This project is good only for fun and  playing not for enterprise.

That's my kind of project :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: cElementTree clear semantics

2005-09-25 Thread D H
Igor V. Rafienko wrote:
 This gave me the desired behaviour, but:
 
 * It looks *very* ugly
 * It's twice as slow as version which sees 'end'-events only.
 
 Now, there *has* to be a better way. What am I missing?
 

Try emailing the author for support.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: cElementTree clear semantics

2005-09-25 Thread D H
Reinhold Birkenfeld wrote:
 D H wrote:
 
Igor V. Rafienko wrote:

This gave me the desired behaviour, but:

* It looks *very* ugly
* It's twice as slow as version which sees 'end'-events only.

Now, there *has* to be a better way. What am I missing?


Try emailing the author for support.
 
 
 I don't think that's needed. He is one of the most active members
 of c.l.py, and you should know that yourself.
 

I would recommend emailing the author of a library when you have a 
question about that library.  You should know that yourself as well.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: cElementTree clear semantics

2005-09-25 Thread D H
Reinhold Birkenfeld wrote:

 
 Well, if I had e.g. a question about Boo, I would of course first ask
 here because I know the expert writes here.
 
 Reinhold

Reinhold Birkenfeld also wrote:
  If I had wanted to say you have opinions? fuck off!, I would have said
 you have opinions? fuck off!.


Take your own advice asshole.
-- 
http://mail.python.org/mailman/listinfo/python-list


Reinhold Birkenfeld [was Re: cElementTree clear semantics]

2005-09-25 Thread D H
D H wrote:
 Reinhold Birkenfeld wrote:
 

 Well, if I had e.g. a question about Boo, I would of course first ask
 here because I know the expert writes here.

 Reinhold
 
 
 Reinhold Birkenfeld also wrote:
   If I had wanted to say you have opinions? fuck off!, I would have said
  you have opinions? fuck off!.
 
 
 Take your own advice asshole.

-- 
http://mail.python.org/mailman/listinfo/python-list


Reinhold Birkenfeld [Re: Re: cElementTree clear semantics]

2005-09-25 Thread D H
Reinhold Birkenfeld wrote:
 D H wrote:
 
D H wrote:

Reinhold Birkenfeld wrote:


Well, if I had e.g. a question about Boo, I would of course first ask
here because I know the expert writes here.

Reinhold


Reinhold Birkenfeld also wrote:
  If I had wanted to say you have opinions? fuck off!, I would have said
 you have opinions? fuck off!.


Take your own advice asshole.
 
 
 And what's that about?

I think it means you should fuck off, asshole.
-- 
http://mail.python.org/mailman/listinfo/python-list


Reinhold Birkenfeld [Re: Re: cElementTree clear semantics]

2005-09-25 Thread D H
Reinhold Birkenfeld wrote:
 D H wrote:
 
Reinhold Birkenfeld wrote:

D H wrote:


D H wrote:


Reinhold Birkenfeld wrote:



Well, if I had e.g. a question about Boo, I would of course first ask
here because I know the expert writes here.

Reinhold


Reinhold Birkenfeld also wrote:

If I had wanted to say you have opinions? fuck off!, I would have said
you have opinions? fuck off!.


Take your own advice asshole.


And what's that about?

I think it means you should fuck off, asshole.
 
 
 I think you've made that clear.
 
 *plonk*
 
 Reinhold
 
 PS: I really wonder why you get upset when someone except you mentions boo.

You're the only one making any association between this thread about 
celementree and boo.  So again I'll say, take your own advice and fuck off.
-- 
http://mail.python.org/mailman/listinfo/python-list


Fredrik Lundh [Re: Reinhold Birkenfeld [Re: Re: cElementTree clear semantics]]

2005-09-25 Thread D H
Fredrik Lundh wrote:
 Doug Holton wrote:
 
 
You're the only one making any association between this thread about
celementree and boo.
 
 
 really?  judging from the Original-From header in your posts, your internet
 provider is sure making the same association...

You seriously need some help.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: cElementTree clear semantics

2005-09-25 Thread D H
Grant Edwards wrote:
 On 2005-09-25, D H [EMAIL PROTECTED] wrote:
 
Igor V. Rafienko wrote:


This gave me the desired behaviour, but:

* It looks *very* ugly
* It's twice as slow as version which sees 'end'-events only.

Now, there *has* to be a better way. What am I missing?

Try emailing the author for support.

I don't think that's needed. He is one of the most active
members of c.l.py, and you should know that yourself.

I would recommend emailing the author of a library when you
have a question about that library.  You should know that
yourself as well.
 
 
 Why??

Please tell me I don't have to explain to you why the author of a 3rd 
party library might be able to answer a question specific to that library.


 For the things I support, I much prefer answering questions
 in a public forum.  

Right, which is exactly why we have sourceforge, tigris, google groups, 
and numerous other free resources where you can set up a mailing list to 
publicly ask and answer questions about your software.
Of course it may not get you as many paypal hits as spamming larger 
forums with your support questions will, but it is the decent thing to do.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: cElementTree clear semantics

2005-09-25 Thread D H
Fredrik Lundh wrote:
 Paul Boddie wrote:
 
 
Regardless of anyone's alleged connection with Boo or newsgroup
participation level, the advice to contact the package
author/maintainer is sound. It happens every now and again that people
post questions to comp.lang.python about fairly specific issues or
packages that would be best sent to mailing lists or other resources
devoted to such topics. It's far better to get a high quality opinion
from a small group of people than a lower quality opinion from a larger
group or a delayed response from the maintainer because he/she doesn't
happen to be spending time sifting through flame wars amidst large
volumes of relatively uninteresting/irrelevant messages.
 
 
 well, for the record, I strongly recommend people to post questions in
 public forums.  google is far more likely to pick up answers from mailing
 list archives and newsgroups than from the I really should do something
 about all the mails in my support folder part of my brain.

You run your own server and get plenty of paypal donations.  Why not run 
your own mailing list for support?  If not, see sourceforge or google 
groups: http://groups.google.com/groups/create?lnk=lhl=en
-- 
http://mail.python.org/mailman/listinfo/python-list


Grant Edwards [Re: cElementTree clear semantics]

2005-09-25 Thread D H
Grant Edwards wrote:
 On 2005-09-25, D H [EMAIL PROTECTED] wrote:
 
 
I would recommend emailing the author of a library when you
have a question about that library.  You should know that
yourself as well.

Why??

Please tell me I don't have to explain to you why the author
of a 3rd party library might be able to answer a question
specific to that library.
 
 
 Of course not.  And when that author reads this group, why not
 post questions here so that everybody can benefit from the
 information?

When did I ever argue against that?  I was suggesting a resource to use 
to support your own software.  I think you have assumed that I suggested 
posting here about celementree was off-topic.  Tell me where I ever said 
that.  I said to the first guy that he should ask the author for help, 
meaning that he could get help that way as well.  Furthermore, I believe 
that is the more efficient way to get help, by contacting the author 
directly, especially if that author is too lazy to set up their own 
support forum or list.


For the things I support, I much prefer answering questions
in a public forum.  

Right, which is exactly why we have sourceforge, tigris,
google groups,
 
 
 Exactly how do you think c.l.p on google groups differs from
 c.l.p on the rest of Usenet?

Who the fuck said that?  Are you pulling this shit out of your ass?


and numerous other free resources where you can set up a
mailing list to publicly ask and answer questions about your
software. Of course it may not get you as many paypal hits as
spamming larger forums with your support questions will,
 
 
 WTF are you on about?  What the hell is a Paypal hit?  How is
 posting a single, on-topic, question to c.l.p spamming?

Fredrik Lundh gets money via paypal on his site where his software is 
located.  That's what I meant.  Where did I say this particular post is 
a spam?  Again, your ass?  where do you get this shit?

 
but it is the decent thing to do.
 
 
 You sir, are a loon.
 

You're a funny ass.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Alternatives to Stackless Python?

2005-09-22 Thread D H
[EMAIL PROTECTED] wrote:
 After recently getting excited about the possibilities that stackless
 python has to offer
 (http://harkal.sylphis3d.com/2005/08/10/multithreaded-game-scripting-with-stackless-python/)
 and then discovering that the most recent version of stackless
 available on stackless.com was for python 2.2 I am wondering if
 Stackless is dead/declining and if so, are there any viable
 alternatives that exist today?
 
 I found LGT http://lgt.berlios.de/ but it didn't seem as if the
 NanoThreads module had the same capabilites as stackless.
 

See also greenlets, which work with regular cpython:
http://codespeak.net/py/current/doc/greenlet.html
http://agiletesting.blogspot.com/2005/07/py-lib-gems-greenlets-and-pyxml.html

You'll probably need to get it via an svn client (such as tortoisesvn on 
windows): http://codespeak.net/py/current/doc/getting-started.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why doesn't IDLE editor windows have horizontal scrollbars?

2005-09-17 Thread D H
chuck wrote:
 Well I don't want to start yet another thread on IDE's.  I've googled
 and all of that an am aware of most of the IDE's that are out there.  I
 am curious if there is someplace where statistics have been captured on
 what IDE's most people are using.  Since IDLE ships with Python I
 assume a lot of people use it.  I've been a PythonWin user for years
 but it has shortcomings, isnt' being developed further and doesn't run
 on FreeBSD, my other platform.
 

I like the JEdit editor, which is free and cross-platform ( 
http://www.jedit.org/ ), and for the interpreter if you ever use that, 
there is the normal console (cmd.exe in windows) or see also IPython. 
There is also a console plugin for JEdit.

But if you want a more full-featured IDE with project management, etc., 
there is a Python addin for the Eclipse IDE called pydev I believe.  I 
haven't tried it myself though.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: multiple replaces

2005-09-16 Thread D H
You can use python's re.sub function.  But also look into full fledged 
template engines like Cheetah.

import re

txt=
html
body
pwhatever/p
!--tree--
pthe machine with bing/p
!--house--
p10% of boo is foo/p
/html

h1=txt.replace(%,%%)
h3 = re.sub(!--(\w+)--, %(\\1)s, h1)

house=something awfull
tree=something beautifull
print h3 % locals()

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Rendering HTML

2005-09-16 Thread D H
Harlin Seritt wrote:
 I am looking for a module that will render html to console but
 formatted much like one might see with Lynx. Is there such a module
 already out there for this?

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52297
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python linear algebra module -- requesting comments on interface

2005-09-10 Thread D H
Terry Reedy wrote:
 [EMAIL PROTECTED] wrote in message 
 news:[EMAIL PROTECTED]
 
The module will be public domain.
 
 
 Various lawyers have suggested that either you cannot do that (is US) or 
 that you should not do that.  (You know the joke -- ask two lawyers and you 
 get three opinions -- but all depends on your country of residence.)

Well he can do it, but you are right, it is best not too.
If anything, using an open source license will encourage people to share 
back any additions or bug fixes they make.
ANTLR for example was public domain (still is for version 2), but 
switched to BSD for version 3: http://www.antlr.org/license.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Django Vs Rails

2005-09-06 Thread D H
flamesrock wrote:
 D H,
 'flamesrock' refers to the Calgary Flames, not the act of flaming.
 

It was just a joke about your statement and your name.  I thought it was 
obvious enough that a smiley wasn't necessary.  I don't care though, 
flames happen on comp.lang.python all the time.
Go with Rails.  Django is only like a month old.  Unless you are more 
comfortable using python than ruby.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Django Vs Rails

2005-09-06 Thread D H
bruno modulix wrote:
 D H wrote:
 
 (snip)
 
Go with Rails.  Django is only like a month old.  
 
 
 Please take time to read the project's page. Django has in fact three
 years of existence and is already used on production websites, so it's
 far from pre-alpha/planning stage.
 

Don't make any assumptions about what I have and haven't read.  Django 
was only publicly released in mid-July.  Less than two months ago.
I never implied it was pre-alpha or in a planning stage.
The Ruby framework is also more mature and much much more tested than 
Django.  But even then I am not stating one is inherently better than 
the other.  Both seem very well designed.  But if you have no clue about 
either project like the original poster, then I'd recommend Rails, 
unless you are already comfortable with Python (and not used to Ruby), 
which case go with Django.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Django Vs Rails

2005-09-05 Thread D H
flamesrock wrote:
 Firstly, this topic is NOT intended for trolling or starting any flame
 wars.

Whatever you say, flamesrock.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 'isa' keyword

2005-09-05 Thread D H
Colin J. Williams wrote:
 Could you elaborate on that please?

See my earlier post in this thread, this link:
http://www.canonical.org/~kragen/isinstance/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 'isa' keyword

2005-09-01 Thread D H
talin at acm dot org wrote:
 Although I realize the perils of even suggesting polluting the Python
 namespace with a new keyword, I often think that it would be useful to
 consider defining an operator for testing whether or not an item is a
 member of a category.

It's a good idea but not likely to be added to python, at least not til 
python 3000 comes out with type checking.  The default way is if 
isinstance(image, jpeg).
Also there is if image |isa| jpeg: using one of the various python 
hacks out there:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/384122

But since Python doesn't have interfaces or type checking today, there 
really is not much need for isa or isinstance anyway, but you might use 
hasattr or try/except instead: http://www.canonical.org/~kragen/isinstance/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The ONLY thing that prevents me from using Python

2005-08-24 Thread D H
Paul Rubin wrote:
 Richie Hindle [EMAIL PROTECTED] writes:
 
I can't speak for linode.org, but I have a Xen VPS from rimuhosting.com
and it's early days but so far I've been very impressed.  It's $19/mo
(normally $20 but they kindly gave me a 5% Open Source Developer discount)
 
 
 Do you get enough resources in that minimal-cost configuration to run
 significant Python applications?

Yes, you get more than enough to run python apps.  You have to know how 
to run your own linux box though, including installing and configuring 
any extra software you want (with debian it's very easy using 'sudo 
apt-get').  Mod_python for example and apache2.

I would look for a minimum 64mb ram, 3 gigs hd space, and minimum 15 
gigs transfer/mo.  At $20/mo, rimuhosting gives you 96mb ram, 4gig 
space, and 30gigs transfer/mo.  So that does look like a good deal.

(I don't use or work with any UML hosting provider.  I used to have 
Bytemark, and it was great, although it looks like rimu and others may 
offer more for your buck now)

The catch is the RAM restriction, which you might run into if you have 
huge mysql databases or whatever, and hard drive access is a slower than 
on a dedicated server.  But I never noticed any slowdowns or ran into 
ram limitations.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: loop in python

2005-08-22 Thread D H
km wrote:
 Hi all,
 
 Why is it that the implementation of empty loop so slow in python when 
 compared to perl ? 
 
 #i did this in python (v 1.5)
 for x in xrange(1000):
 print x
 # this took 0.017 seconds 
 --
 #similar code in perl (v 5.6): 
 for $x (0..1000)
 {
 print $x;
 }
 # this took 0.005 seconds only  !!!
 
 Is python runtime slow at all aspects when compared to perl ? 
 I really wonder what makes python slower than perl ? 

Yeah but the python version took 2.1 less seconds to type.
Python runs as fast as Perl.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Sandboxes

2005-08-22 Thread D H
42 wrote:
 Or is this a hopeless cause? 
 
 Finally, either way, would anyone recommend a different script engine 
 that might be more suitable for what I'm trying to accomplish that I 
 might not have looked at. I don't need much; it needs to work with C#, 
 and be able to easily interact with 'published' interface. I'd also like 
 to leverage a popular language instead of something obscure.

You need a scripting language that is completely implemented in .NET 
(i.e. managed).  Try Boo: http://boo.codehaus.org/
And then from your C# host, use the .NET security API for restricting 
what the script is allowed to do.  See the example below, as well as 
msdn docs on SecurityPermissionFlag, PermissionSet, SetAppDomainPolicy...
http://www.gamedev.net/community/forums/topic.asp?topic_id=264462whichpage=1#1620355
And here are docs on using boo as an embedded scripting language:
http://boo.codehaus.org/Boo+as+an+embedded+scripting+language
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python's Exception, and Capitalization

2005-08-12 Thread D H
Ray wrote:
 Hello guys,
 
 OK, I've been reading some more about Python. There are some things
 about Python exception that I haven't been able to grasp:
 
 1. This is a small thing, but why is object spelled object, and the
 mother of all exception Exception (with capital E)? Why is not object
 spelled Object then? 

I would guess that object is considered a primitive/basic type like int 
or float or string.


 I mean, in Java,
 it's Object. Whereas in C++, they're quite consistent, standard stuff
 are usually all lowercaps (basic_string, iostream, etc.). Python seems
 to have a mix of both.

Yeah java capitalizes anything that is a class like String, Object, 
Integer, and lowercases its primitives like int, byte.


 By the way, what's the convention for functions? It's a bit confusing
 because when I see Python builtins, it seems that they follow C++ style
 (e.g.: has_key, readline). So... does it mean that when I write my own
 function, customarily I'd say myFunction() (or MyFunction()?)

Yeah, the python standard library has been built by lots of different 
people.  It wasn't designed by one entity using one standard like the 
java standard library or .NET/Mono class library.


 2. I'm quite baffled that you either have try/except, or try/finally.

Apparently that will be fixed sometime:
http://python.miscellaneousmirror.org/peps/pep-0341.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Replacement for keyword 'global' good idea? (e.g. 'modulescope' or 'module' better?)

2005-08-06 Thread D H
[EMAIL PROTECTED] wrote:
 I'm not saying 'modulescope' and 'module' are the only alternatives or
 even
 the best anyone can come up with.
 
 'global' has the connotation of being visible *EVERYWHERE*
 where in Python it is just visible in one module's space.
 
 Can you think of a better alternative or do you believe
 'global' is the best possible?
 

When designing a language meant to be easy to use as well as powerful 
feature-wise, you have to weighh between things like technical accuracy 
of a term (which you are focusing on), how much typing it takes, how 
easy it is to remember and spell correctly, and how the term is commonly 
understood and used.
Sometimes python takes one of those considerations to the extreme (like 
def) or has a uncommon view of common understanding (like lambda).
But global is the best term I can think of for the way it is used, and 
it is by far the most common term used for these kind of variables in 
numerous other languages including vb, php, ruby, etc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The ONLY thing that prevents me from using Python

2005-08-05 Thread D H
I would highly recommend user-mode linux (UML) hosting, like bytemark or 
Linode: http://user-mode-linux.sourceforge.net/uses.html

Starting around the same price as average shared hosting, you get your 
own virtual linux box (i recommend debian), on which you can install 
java, mod_python, php, mono, jabber, or whatever you need.  You are no 
longer subject to the whims of the hosting provider, with respect to 
things like which version of PHP they support, or how many mysql 
databases you can create.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Replacement for keyword 'global' good idea? (e.g. 'modulescope' or 'module' better?)

2005-08-05 Thread D H
[EMAIL PROTECTED] wrote:
 I've heard 2 people complain that word 'global' is confusing.
 
 Perhaps 'modulescope' or 'module' would be better?
 
 Am I the first peope to have thought of this and suggested it?
 
 Is this a candidate for Python 3000 yet?

It is likely that more people would find module or modulescope confusing.

Plus module has a different customary meaning already:

import module
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A replacement for lambda

2005-07-30 Thread D H
Mike Meyer wrote:
 Rewriting a canonical abuse of lambda in this idiom gives:
 
 myfunc = def @(*args):
  return sum(x + 1 for x in args)

Nice proposal.  Technically you don't need the @ there, it is 
superfluous.  But then again so is the colon, so whatever floats your boat.


 class Spam(object):
   myprop = property(fget = def @(self):
return self._properties['myprop']
,
 fset = def @(self, value):
self._properties['myprop'] = value
,
 fdel = def @(self)
del self._properties['myprop']
,
 doc = Just an example)

I think the anonymous lambdas need to be outside the parentheses to be 
parsable.  Maybe like this:

class Spam(object):
myprop = property(fget, fset, fdel, doc=just an example):
where fget = def (self):
.
where fset = def (self):
 .
where fdel = def (self):
 ...

As you can see, it doesn't save much over the traditional way since you 
have to name the anonymous lambdas anyway.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Rich Graphics?

2005-07-27 Thread D H
Cairo is an option, for Linux only though at the moment.  There is a 
python binding: http://cairographics.org/bindings
You can use it in combination with pygtk:
http://cvs.cairographics.org/pycairo/examples/svg/
See also the backends used by matplotlib, a python plotting module.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: goto

2005-07-18 Thread D H
Mike Meyer wrote:
 rbt [EMAIL PROTECTED] writes:
 
Many of the world's most profitable software companies (MS for example)
have thousands of goto statements in their code... oh the horror of it
all. Why aren't these enlightened-by-the-gods know-it-alls as profitable
as these obviously ignorant companies?
 
 
 Because profitability has *nothing* to do with code quality, and
 everything to do with marketing. MS, in particular, has done an
 excellent job of divorcing code quality from their bottom line by
 shuffling the bulk of the support work off to other companies:
 hardware vendors who bundle MS software, system integrators, and
 customers friends and family being very high on the list.
 
 That they felt the need to do this speaks volumes about their code
 quality.

whoa whoa whoa!  Discussing goto statements and Microsoft together is 
like mixing dynamite and gasoline.  We don't want this to explode into 
some interminable argument; that's not the kind of thing people like to 
see on comp.lang.python.

Oh by the way, boo has goto statements:
http://svn.boo.codehaus.org/trunk/tests/testcases/integration/goto-1.boo?view=auto

KABOOM
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: HTML expect in python

2005-07-15 Thread D H
WGW wrote:
 I would like to automate some simple browser navigating using python. 
 Ideally, I would like a package like pyexpect, but that can handle a 
 browser in much the same way as pyexpect handles a terminal (tall 
 order!). In short, I want a macro language for a browser (I know about 
 the commercial packages such as Easy Bee and Internet macros, but I want 
  more programmability and less cost!)

See the mechanize module: http://wwwsearch.sourceforge.net/mechanize/
Or else you can use win32com stuff to automate internet explorer if you 
really need to do it that way.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: f*cking re module

2005-07-04 Thread D H
Gustavo Niemeyer wrote:
 That's what I love in that news group. Someone comes with a
 stupid and arrogant question, and someone else answers in a
 calm and reasonable way.

...and then someone else comes along and calls the first person stupid 
and arrogant, which is deemed QOTW. :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Which kid's beginners programming - Python or Forth?

2005-06-27 Thread D H
BORT wrote:
 So, that said...   In ~simplest~ terms for the stated goal -- Forth or
 Python?
 ...the goal is NOT the spelling tutor... it is learning how to use a
 tool to solve a problem.  I am asking which tool is more suited to an
 otherwise arbitrary direction of spelling tutor program.

Python is easier to learn that most other popular programming languages.

For a games approach, check out this online book targeted to kids: 
http://staff.easthighschool.net/lee/computers/book/
It uses pygame and Lee Harr's pygsear.

For another graphical approach, playing around with images and sound 
files, see the Jython Environment for Students (JES).  Jython is python 
running on top of java's virtual machine.
http://coweb.cc.gatech.edu/mediaComp-plan/94
http://coweb.cc.gatech.edu/mediaComp-plan/27
http://coweb.cc.gatech.edu/mediaComp-plan

For text-to-speech, if you are using Windows and python, see the pyTTS 
module and this link: http://www.cs.unc.edu/~parente/tech/tr02.shtml
If you are using jython, see FreeTTS instead: 
http://freetts.sourceforge.net/docs/index.php

But since your son is only 10 years old, I'd really recommend first some
non-python development environments that are even more geared to kids:
- Lego Mindstorms, which has a graphical programming environment to 
control robots you build (you connect a flow chart to describe the 
program instead of having to type and indent everything perfectly).  It 
is targetted specifically for kids his age, but it is a bit expensive.
- http://agentsheets.com/ - Very neat java-based authoring tool, but 
unfortunately costs money too.  Trial version only lasts 10 days, but 
you can learn a lot in that time using this tool.
- NetLogo (and the older version StarLogo): 
http://ccl.northwestern.edu/netlogo/  Uses Logo to script hundreds of 
turtles in parallel.  This is a free tool.
- http://e-slate.cti.gr/ really awesome authoring tool, but hasn't been 
updated in a couple of years because I guess the funding ran out.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A strange and annoying restriction, possibly a bug. A glance by a more experienced would be nice.

2005-06-25 Thread D H
Elmo Mäntynen wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1
 
 This is the case:
 
 
n=(100,) tuple(*n)
 
 
 Traceback (most recent call last):
   File pyshell#31, line 1, in -toplevel-
 tuple(*n)
 TypeError: iteration over non-sequence

The star (*n) means you are essentially calling tuple(100).  And 100 
alone isn't a sequence.  The star explodes or expands the sequence, like 
in this example:

def doit(x, y, z):
 print x, y, z

vals = (1,2,3)

doit(*vals)  #see the star symbol
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Thoughts on Guido's ITC audio interview

2005-06-25 Thread D H
Dave Benjamin wrote:
  One thing Guido mentions in his comparison of ABC (Python's 
predecessor) and
  Python is how ABC was inextricably tied to its environment (a la 
Smalltalk),

What surprised me was that this was the only thing he really mentioned. 
  He didn't mention anything about the theoretical underpinnings of ABC, 
he was only involved in the implementation of ABC, and others did all 
the language design.  And his main criticism is a pragmatic issue with 
using the ABC in real tasks like reading external files.  It explains 
why sometimes Python's features seem to be more implementation-driven 
rather than design-driven.  Such as perhaps the use of self, but a 
counter-example is slicing syntax, borrowed from the language Icon 
apparently.
I think when you borrow some features from a language but not all, you 
have to re-evaluate every part of the language design.  Colons at the 
end of lines for example help readability in the ABC language because 
keywords are all uppercase (unlike python).  So the colons in effect 
counteract some of the negative impact uppercase words place on 
readability.  In Python however, I don't see how colons really are 
needed to help readability at all.  And there are other issues too such 
as changing python to be case-insensitive or making 7/4 == 1.75 instead 
of 1 which even Guido wanted at one point (
http://www.linuxjournal.com/article/5028 ), but only the latter was 
implemented (yet not enabled by default yet).


  I find that a similar comparison can be made between Python and Java. 
Java's
  startup time is so long that it is not practical for writing small 
tools for
  use in command-line scripts, and the propensity toward application 
servers
  and integrated development environments suggests a strong preference 
for a
  monolithic, self-contained, single-language environments.

That's a very good point.  Yeah you never hear of people using java for 
making quick little scripts, which python and php are really great for 
(among other things).


 Guido makes a funny jab at Paul Graham about Graham's nine things that make
 Lisp Lisp (available here: http://www.paulgraham.com/icad.html) - I had read
 this essay many times but never saw the subtle irony behind claims of
 Greenspunning: in order to claim that a language is approaching Lisp, you
 have to define what it is about Lisp that other languages are purportedly
 emulating, and this begs the question of why you have the authority to
 declare which 9 (or n) attributes of Lisp are most important. I like Paul
 Graham and his essays a lot, but I must admit I had to laugh too when I
 heard the way Guido framed this argument. I'm not so sure that Python has 8
 out of 9, though: the statement/expression dichotomy rules out #6, and the
 lack of macros rules out #9. These are arguable, depending on how you define
 things, but I think the most obvious thing that Python lacks compared with
 Lisp and Scheme (and also Ruby) is a symbol type (#7). I'm in the process of
 trying to understand what symbols are good for, outside the context of Lisp
 and its nested lists of symbols as executable code. Ruby seems to have come
 up with some creative uses for symbols within Python-like syntax, though I
 haven't seen anything terribly compelling so far.

Other python extensions and descendants I mentioned in this note are 
exploring the two main things lisp has but python doesn't - #6 
eliminating the expression/statement distinction (at least in some cases 
like assignments), and #9 macros:
http://groups-beta.google.com/group/comp.lang.python/msg/360c99b7ab7b839c?dmode=printhl=en


   - Java: the usual static vs. dynamic, static analysis vs. unit testing
 arguments. Guido says that there's such a small amount of problems that
 can be caught at compile time, and even the smallest amount of unit
 testing would also catch these problems. The blindness of that [static]
 position... escapes me.

As pointed out elsewhere, type declarations also help with documenting 
your code, as well as dramatically speeding up your program.


 I think Python's decision to use reference counting was an instance of 
 worse-is-better: at the time, reference counting was already known not to be
 the right thing, but it worked, and the implementation was simple.
 Likewise with dynamic typing versus type inference. It seems that Guido
 shares Alan Kay's viewpoint that type inference is really the right thing,
 but modern language technology is really not ready to make it mainstream,
 whereas dynamic typing works today, and is arguably a better worse
 solution than explicit/manifest static typing due to its verbosity.

That's very interesting.  Type inference isn't always perfect though. 
There are some cases where it can't infer the type, or it infers the 
wrong type that you really want.  Type inference + dynamic typing is a 
good combination that can speed up your code without slowing down your 
coding.

 Type inferencing is 

Re: Is there something similar to ?: operator (C/C++) in Python?

2005-06-24 Thread D H
Peter Hansen wrote:
 D H wrote:
 
 Peter Hansen wrote:

 Bo Peng wrote:

 I need to pass a bunch of parameters conditionally. In C/C++, I can do
 func(cond1?a:b,cond2?c:d,.)

 Is there an easier way to do this in Python?


 Please read the FAQ to learn the answer and much other useful ...


 The answer is no.  Use if statements.
 
 
 Actually that's just one possible answer.  Whether it's _the_ answer is 
 obviously again a matter of opinion, and as usual we differ.

Quit being such an idiot and refuting everything I say.  The answer is 
simply no, just use an if statement instead.


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: webserver application (via Twisted?)

2005-06-24 Thread D H
flupke wrote:
 I need to program and setup serveral webservices.
 If i were still using jsp, i would use Tomcat to make the several
 applications available on a given port.
 How can i accomplish this in Python?
 I was thinking about Twisted but it's not clear to me what parts i need 
 to make a webserver listen on a certain port and having it serve 
 different application based on the url that i received.

See mod_python: http://www.modpython.org/
but there are literally dozens of other options in Python though:
http://wiki.python.org/moin/WebProgramming

If you want to it in your own standalone server, then I second the 
recommendation for Karrigell (which also can be run in mod_python as well).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Favorite non-python language trick?

2005-06-24 Thread D H
Joseph Garvin wrote:
 I'm curious -- what is everyone's favorite trick from a non-python 
 language? And -- why isn't it in Python?

You can try out new features yourself now using various python 
extensions or descendants:
http://livelogix.net/logix/
- macros, no statement/expression distinction
http://students.ceid.upatras.gr/~sxanth/pyc/
- assignments are expressions, you can try other features never added
python like a ternary operator (x ? true action:false action)
http://boo.codehaus.org/
assignments are expressions, macros, static typing, no more self
required, ...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is there something similar to ?: operator (C/C++) in Python?

2005-06-24 Thread D H
Dave Brueck wrote:
 Please keep the discussion civil; please help keep c.l.py a nice place 
 to visit.

You didn't see Peter Hansen's previous post to which I made my reply, so 
I'd like to extend your recommendation to *everyone* here.

Peter Hansen wrote:
  Doug, please stop making an idiot of yourself ...[snipped more flames]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Favorite non-python language trick?

2005-06-24 Thread D H
infidel wrote:
def class Colour:
def __init__(self, blue=0, green=0, red=0):
# pseudo-Python code borrowing concept with from Pascal
with self:
blue = blue
green = green
red = red

And now you can see why Python doesn't support this idiom.
 
 
 Maybe it would make more sense if it was done a la Visual Basic
 
 with self:
 .blue = blue
 .green = green
 .red = red
 
 requiring a dot to be typed removes the ambiguity and gives the IDEs a
 chance to Intellisense-ify your coding.

Some made a python recipe emulating this I believe.  The python cookbook 
search engine is down though so I cannot find the link.
At one point Guido van Rossum was advocating this use of with as well, 
I believe: 
http://mail.python.org/pipermail/python-dev/2004-March/043545.html

But I don't think it is being considered now.  I think now with is 
being proposed for something more like VB and C#'s using statement. 
It automatically disposes of a resource when done with it: 
http://wiki.python.org/moin/WithStatement
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Favorite non-python language trick?

2005-06-24 Thread D H
Roy Smith wrote:
 Tom Anderson  [EMAIL PROTECTED] wrote:
 
The one thing i really do miss is method overloading by parameter
type.  I used this all the time in java
 
 
 You do things like that in type-bondage languages like Java and C++
 because you have to.  Can you give an example of where you miss it in
 Python?

Well it's coming to a future Python version, so apparently there are 
many who can use it:
http://wiki.python.org/moin/Python3.0Suggestions#head-7df9d7035174644fdae024ed4a5ea0960a003ef5
I don't know if you'll have method overloading, but there will be type 
checking.  It's not actually compile-time static typing though.  The 
type checking still happens at run-time similar to your isinstance 
example, making code run slightly slower than a normal python method:
Type checking is going to slow down your code. -GVR 2005 keynote, 
http://www.sauria.com/%7Etwl/conferences/pycon2005/20050324/The%20State%20of%20Python.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is there something similar to ?: operator (C/C++) in Python?

2005-06-24 Thread D H
Riccardo Galli wrote:
 On Fri, 24 Jun 2005 09:00:04 -0500, D H wrote:
 
 
Bo Peng wrote:


I need to pass a bunch of parameters conditionally. In C/C++, I can
do func(cond1?a:b,cond2?c:d,.)

Is there an easier way to do this in Python?


The answer is simply no, just use an if statement instead.
 
 
 That's not true.
 One used form is this:
 result = cond and value1 or value2

So anywhere someone uses x?y:z you recommend they use x and y or z 
instead, or else [y,z][x], but not:

if x:
val = y
else:
val = z

I still would recommend just using an if statement, even though it is 
not easier to type than a ternary expression.  It is the most readable 
and understandable equivalent in Python.  And since his question was 
about an easier way to do it in Python, and I don't believe your 
alternative are any easier either, I believe the answer is still no.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is there something similar to ?: operator (C/C++) in Python?

2005-06-24 Thread D H
Steven D'Aprano wrote:
 On Fri, 24 Jun 2005 12:54:34 -0500, D H wrote:
 
 
Riccardo Galli wrote:

On Fri, 24 Jun 2005 09:00:04 -0500, D H wrote:



Bo Peng wrote:



I need to pass a bunch of parameters conditionally. In C/C++, I can
do func(cond1?a:b,cond2?c:d,.)

Is there an easier way to do this in Python?


The answer is simply no, just use an if statement instead.


That's not true.
One used form is this:
result = cond and value1 or value2

So anywhere someone uses x?y:z you recommend they use x and y or z 
instead, or else [y,z][x], but not:

if x:
val = y
else:
val = z
 
 
 That's not what he said at all. Nowhere did Riccardo suggest that one or
 the other method was better than if..else. The *most* he did was to
 suggest a personal opinion that cond and value1 or value2 was nice.

He said that's not true, when I suggested that there is not something 
easier than ? ternary expressions in Python, and that the original 
poster should use if statements instead.  So yes, that is what he said 
by refuting my suggestion.  He must have misinterpreted my response as 
if statements are the only way to do something like ternary 
expression, which is not what I said.  Again, I said there is *nothing* 
that is as easy as to use as ternary expressions in Python - use if 
statements instead.


I still would recommend just using an if statement, even though it is
not easier to type than a ternary expression.
 
 
 That's fine. Recommend it all you like. But it isn't the only way, and it
 isn't even arguably the best or easiest or simplest way.

You have assumed the same mistaken interpretation of my remarks as he 
did.   When did I ever say an if statement is the *only* way?  In the 
very note to which you responded, I even acknowledged two other ways of 
doing this.  If statements are in the best and easiest and simplest way 
to do conditionals, however, which is exactly what I was arguing.


 
It is the most readable
and understandable equivalent in Python.
 
 
 To you maybe. Actually, to me also. But easier doesn't just mean
 easier to read -- it also means easier to write, 

I explicitly stated in the very note you replied to that if statements 
are easier to understand and read, yet not easier to write than ? 
ternary conditionals.  So thanks for duplicating my own point.


 Until then, the question is at least partly a matter of personal taste,
 and as such, there is no justification for such sweeping generalities as
 the answer is simply no, just use an if statement instead.

Except that is the right answer.  It's too bad diehard Python 
evangelists (to borrow another one of Peter Hansen's flames) don't give 
people straight answers when they are looking for a feature that python 
just doesn't have and likely will never have, such as the ? ternary 
operator.  The answer is no, there is nothing as easy to use as that in 
Python, and I suggested using if statements instead.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Favorite non-python language trick?

2005-06-24 Thread D H
Terry Reedy wrote:
 D H [EMAIL PROTECTED] wrote in message
 
 
Roy Smith wrote:
 
 
Tom Anderson  [EMAIL PROTECTED] wrote:

The one thing i really do miss is method overloading by parameter
type.  I used this all the time in java
 
 
You do things like that in type-bondage languages like Java and C++
because you have to.  Can you give an example of where you miss it in
Python?

Well it's coming to a future Python version,
 
 
 The 'it' under discussion is 'method overloading by parameter type'.  While 
 a few people have requested it, I have seen no indication that 'it' is 
 coming. 

Did you not see the very next sentence I wrote which exactly clarified 
my point that I was referring to type checking and not method 
overloading?  Way to quote me out of context.  Type checking IS coming 
to python in all likelihood -

 I don't know if you'll have method overloading, but there will be type
 checking.


 Type checking is going to slow down your code. -GVR 2005 keynote,
 http://www.sauria.com/%7Etwl/conferences/pycon2005/20050324/The%20State%20of%20Python.html
 
 
  You left out NOTE: Nothing's settled yet and 
  Reminder and Disclaimer
  Nothing's settled yet!

I also left out the dozens of angry rants that people wrote after Guido 
first proposed static typing, leading him to change the proposal to 
runtime type checking, which by definition will slow down the code. 
Static typing is almost certainly not going to come to Python, but the 
typing annotations (def method(x : int) - bool) can be used by other 
tools perhaps to do optimizations at compile time.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Favorite non-python language trick?

2005-06-24 Thread D H
Terry Reedy wrote:
 Tom Anderson [EMAIL PROTECTED] wrote in message 
 news:[EMAIL PROTECTED]
 
 
sometimes in python. No, it's not really possible in a typeless language,
and yes, there are implementations based on decorators, but frankly,
they're awful.
 
 
 Python has strongly typed objects.  Only names are typeless.

Again, you are splitting hairs.  His point still stands that it is not 
possible to do method overloading in python (unless you use decorator 
hacks).  It may be possible to add this feature when type declarations 
and type checking are added to a future version of python.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is different with Python ?

2005-06-19 Thread D H
Peter Hansen wrote:
 D H wrote:

 So you say he has done relatively little serious development and 
 that he may not even know about Python.  I didn't see any evidence 
 from those pages to draw either conclusion.  In fact the 4th paragraph 
 quite contradicts them both.
 
 
 Clearly this is a matter of opinion.  

You're kidding right?  Did you even read the about page you cited?  The 
guy has been doing C++ development for decades, he wrote a book on it, 
and yet you say he has done little serious development???  That's 
absurd.  And he was the president of ACCU, which if you look on the ACCU 
page at the very top is a mention of Python.  And yet you suggested that 
he hasn't even heard of Python before.  Again, absurd.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: case/switch statement?

2005-06-19 Thread D H
Peter Hansen wrote:
 D H wrote:
 
 Peter Hansen wrote:
 
 [some stuff Doug didn't like]
 

Actually, this is what you snipped, stuff you didn't like, because the 
very mention of boo causes you such fits:

  Since you and Steve Holden agree that a case statement is useful, why
  don't you propose it for python, or add it to the wiki page for Python
  3000.
 
  Here is the syntax the developers of your favorite language boo (
  http://boo.codehaus.org/ ) are using:
 
  given x:
  when 1:
  ...
  when 2:
  ...
  otherwise:
  ...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is there something similar to ?: operator (C/C++) in Python?

2005-06-19 Thread D H
Peter Hansen wrote:
 Bo Peng wrote:
 
 I need to pass a bunch of parameters conditionally. In C/C++, I can do
 func(cond1?a:b,cond2?c:d,.)

 Is there an easier way to do this in Python?
 
 
 Please read the FAQ to learn the answer and much other useful ...

The answer is no.  Use if statements.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Loop until condition is true

2005-06-19 Thread D H
Joseph Garvin wrote:
 Peter Otten wrote:
 
 I found 136 occurrences of do { versus 754 of while ( and 1224 of 
 for
 ( in the Python 2.4 source, so using these rough estimates do-while 
 still
 qualifies as rarely used.

 Peter

  

 That's 136 times you'd have to use an ugly hack instead. I definitely 
 wouldn't mind an until or do/while.

Yeah a do while loop was proposed over 2 years ago, but nothing ever 
came of it:
http://www.python.org/peps/pep-0315.html
It's been discussed for many many years, and again recently:
http://mail.python.org/pipermail/python-dev/2005-June/054167.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: calling subclass constructor question

2005-06-19 Thread D H
In Han Kang wrote:
 So each of the sub classes plots a different type of graph.  The 
 superclass defines methods that are the same for all the plots.  I want 
 to be able to pick some points and be able to generate a more plots.  
 What I was wondering if I could define in a method in the superclass of 
 an object the ability to make a brand new subclass (new plot).  So 
 basically, one plot makes another plot, but it'd be nice if i could put 
 all the code in the superclass.

Right, I agree with Steven, that you are probably wanting something like 
the factory pattern.  Here's something modified from Steven's example 
more like what you are asking for:

class Plot(object): #you need to subclass object to get __subclasses__

 @staticmethod
 def getplot(name):
 return [plot for plot in
 Plot.__subclasses__() if plot.__name__ == name][0]()


class LinePlot(Plot):
 pass

class BarGraph(Plot):
 pass

lp = Plot.getplot(LinePlot)

bar = Plot.getplot(BarGraph)

See also: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/86900
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: case/switch statement?

2005-06-17 Thread D H
Peter Hansen wrote:
 D H wrote:
 
 Peter Hansen wrote:

 With a case statement, on the other hand, you *know* that it must be 
 just simple conditionals (a series of x == some_constant tests), so 
 you don't need to look at all the cases, just the one that interests 
 you.


 Since you and Steve Holden agree that a case statement is useful, why 
 don't you propose it for python, or add it to the wiki page for Python 
 3000.
 
 
 Two simple reasons.
 
 1. You forgot my previous comment that in current Python the equivalent 
 approach is, of course, a dictionary of some kind, though it's arguable 
 whether this is as clean in many cases as a case statement would be.

I didn't forget that.  I never read it, and I don't see the relevance to 
my suggestion.  Now that I've read it, I would hardly call using a 
dictionary as a switch statement, the equivalent.  The fact that 
people use a dictionary as a conditional is a python wart.

 2. Just because something is useful doesn't mean it should be added to 
 Python.  The bar should be set much higher, and should include at least 
 and significantly better than any existing alternative way of doing the 
 same thing.  Now go read point 1 again... ;-)

Now go read my message again.  I made a suggestion to you.  I didn't say 
that a switch statement should be added myself.  I would never propose 
that because the chances of it being added are microscopic.


 My point was not to suggest that I want a case statement in Python, nor 

Neither was the MY point, which you seem to have inferred.

 even that a case statement is a good thing to have in a language (though 
 it might be... it's not my place to say).  My point was simply to point 
 out that performance is not the only reason to use a case statement.

I don't think you could have misread my simple suggestion to you any 
more completely than you did.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is different with Python ?

2005-06-17 Thread D H
Peter Hansen wrote:
 But apparently some guru I greatly respect thinks so
 (I'm not kidding, http://www.spellen.org/youcandoit/).
 
 
 With respect to the author, and an understanding that there is probably 
 much that didn't go into his self-description (add about.htm to the 
 above URL), it sounds as though he knows primarily, perhaps solely, C 
 and C++, and has done relatively little serious development since he 
 seems to have spent most of his time either teaching or writing (words, 
 not source code).
 
 Does he even *know* any real high level languages such as Python?


So you say he has done relatively little serious development and that 
he may not even know about Python.  I didn't see any evidence from those 
pages to draw either conclusion.  In fact the 4th paragraph quite 
contradicts them both.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Back to the future - python to C++ advice wanted

2005-06-17 Thread D H
George Sakkis wrote:
 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 (or translating
 at least) common python idioms and patterns, looking for libraries to
 replace python's included batteries or writing my own from scratch,
 (over)using templates in an attempt to mimic duck typing, and so on.
 Still, I am not sure if this is a good idea in general since every
 language has its own idiosyncrasies, and this is obvious when one sees
 python code looking like C or Java. OTOH, bringing python's higher
 level of expressiveness to C/C++ might actually be a good thing,
 leading to cleaner, safer code.
 
 So, I wonder what have others who have gone the same path done and
 learned in similar situations. How one can avoid the frustration of
 having to work with a low level language once he has seen the Light ?

That's why so many people have switched to Java or C# (or Python and 
other langugages of course).  You might talk to them about using Python, 
since Python and C/C++ fit together very nicely (with tools like BOOST, 
SWIG, Pyrex,...).  But me personally I like to avoid C++ altogether when 
possible, and use Java or C# instead, both of which also can be combined 
with python or python-like languages such as jython, groovy, or boo.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: case/switch statement?

2005-06-13 Thread D H
Peter Hansen wrote:
 With a case statement, on the other hand, you *know* that it must be 
 just simple conditionals (a series of x == some_constant tests), so you 
 don't need to look at all the cases, just the one that interests you.

Since you and Steve Holden agree that a case statement is useful, why 
don't you propose it for python, or add it to the wiki page for Python 3000.

Here is the syntax the developers of your favorite language boo ( 
http://boo.codehaus.org/ ) are using:

given x:
 when 1:
 ...
 when 2:
 ...
 otherwise:
 ...


must-stop-hyphenating-ly y'rs
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The need to put self in every method

2005-06-13 Thread D H
Steve Holden wrote:
 Fernando M. wrote:
 
 Hi,

 i was just wondering about the need to put self as the first
 parameter in every method a class has because, if it's always needed,
 why the obligation to write it? couldn't it be implicit?

 Or is it a special reason for this being this way?

 Thanks.

One reason is because of the dynamic nature of Python classes.  You can 
attach new methods to a class after it is instantiated, or remove 
methods.  The language boo (http://boo.codehaus.org/) has classes 
defined at compile time, and there self is not needed at all.  If you 
want to use the duck typing features in boo, however, and re-implement 
python-like dynamic classes that can have methods removed or added at 
any time, then your methods need some kind of self parameter so they 
can access the context of their class instance, because really there is 
no special relationship between the methods and the class unless you 
explicitly specify it.

 The reason can be found in the output from the python statement import 
 this. Explicit is better than implicit.

Like those invisible yet explicit scope indicators, tabs and spaces.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is different with Python ?

2005-06-13 Thread D H
Philippe C. Martin wrote:
 Yet for the first time I get (most) of my questions answered by a language I
 did not know 1 year ago.
^^
You're in the Python honeymoon stage.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is different with Python ?

2005-06-13 Thread D H
Andrea Griffini wrote:
 On Sat, 11 Jun 2005 21:52:57 -0400, Peter Hansen [EMAIL PROTECTED]
 wrote:
 
 
I think new CS students have more than enough to learn with their 
*first* language without having to discover the trials and tribulations 
of memory management (or those other things that Python hides so well).
 
 
 I'm not sure that postponing learning what memory
 is, what a pointer is and others bare metal
 problems is a good idea. Those concept are not
 more complex at all, they're just more *concrete*
 than the abstract concept of variable.
 Human mind work best moving from the concrete to
 the abstract, 

You're exactly right that people learn better going from concrete to 
abstract, but you're examples (pointers and memory management) are not 
what is typically meant by concrete in learning contexts.

Starting concretely would mean using programming to solve real problems 
and develop useful tools.  In programming it is often good to start with 
examples - some common ones I've seen in informal learning of 
programming include a calculator, an RSS viewer or aggregator, a video 
game, etc.

But what you are getting at is more akin to our mental model of what the 
computer is doing when we write and run a program.  Without a 
fundamental understanding of memory and addresses, a programmer can make 
certain mistakes that reveal this lack of understanding.  But that 
doesn't mean they have to learn about memory management at the very 
beginning of their instruction.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is different with Python ?

2005-06-13 Thread D H
Andrea Griffini wrote:
 On Mon, 13 Jun 2005 22:23:39 +0200, Bruno Desthuilliers
 [EMAIL PROTECTED] wrote:
 
 
Being familiar with 
fondamental *programming* concepts like vars, branching, looping and 
functions proved to be helpful when learning C, since I only had then to 
focus on pointers and memory management.
 
 
 If you're a good programmer (no idea, I don't know
 you and you avoided the issue) then I think you
 wasted a lot of energy and neurons learning that way.
 Even high-level scripting languages are quite far
 from a perfect virtualization, and either the code
 you wrote in them was terrible *OR* you were able
 to memorize an impressive quantity of black magic
 details (or you were just incredibly lucky ;-) ).

The best race driver doesn't necessarily know the most about their car's 
engine.  The best baseball pitcher isn't the one who should be teaching 
a class in physics and aerodynamics.  Yes, both can improve their 
abilities by learning about the fundamentals of engines, aerodynamics, 
etc., but they aren't bad at what they do if they do not know the 
underlying principles operating.

If you want to understand what engineers like programmers, and 
scientists approach their work, look up the structure-behavior-function 
framework.  Engineers work from function (the effect something has on 
its environment, in this case the desired effect), to structure - how to 
consistently constrain behavior to achieve that desired function. 
Scientists, on the other hand, primarily work from structure and 
behavior to function.  Here is an unknown plant - why does it have this 
particular structure or behavior?  What is its function, or what in its 
environment contributed to its evolution?  See descriptions of SBF by 
Cindy Hmelo and others.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Best Web dev language

2005-06-11 Thread D H
Jon Slaughter wrote:
 I'm trying to get into web development for creating a professional web site 
 and I'm confused on which language I should use.  I've read some comparisons 
 between the major languages and I was thinking that python might be the way 
 to go for the most powerful and general language but I am not sure.  Does 
 anyone know of any detailed and objective comparisons between the major 
 languages(perl, php, java, javascript, etc...) that might help me get a 
 clearer picture?

The one that is most popular and has by far the most open source example 
applications out there is PHP (plus MySQL for databases).  It's been 
that way for many years now.  It is also much cheaper and easier to find 
PHP/MySQL hosting.  Search sourceforge.net for many example PHP web 
applications.

I hope you realize that by posting your question on the Python newsgroup 
instead of a general web development newgroup, you're going to get 
extremely biased answers.  If you do go with Python, check out the 
mod_python module for the Apache web server.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Case Sensitive, Multiline Comments

2005-05-30 Thread D H
Roy Smith wrote:
 In article [EMAIL PROTECTED], D H [EMAIL PROTECTED] wrote:
 
 
Elliot Temple wrote:

Hi I have two questions.  Could someone explain to me why Python is
case sensitive?  I find that annoying.  

I do too.  As you've found, the only reason is because it is, and it is 
too late to change (it was even too late back in 1999 when it was 
considered by Guido).  I guess the most popular case-insensitive 
language nowadays is visual basic (and VB.NET).

  Also, why aren't there

multiline comments?  Would adding them cause a problem of some sort?

Again, just because there aren't and never were.  There is no technical 
reason (like for example a parsing conflict) why they wouldn't work in 
python.  That's why most python editors have added a comment section 
command that prepends # to consecutive lines for you.
 
 
 If it really bothers you that there's no multi-line comments, you could 
 always use triple-quoted strings.

Where did I say that?

 I actually don't like multi-line comments.  They're really just syntactic 
 sugar, and when abused, they can make code very difficult to understand.  
 Just wait until the day you're trying to figure out why some C++ function 
 is behaving the way it is and you don't notice that a 50-line stretch of 
 code is commented out with /* at the top and */ at the bottom.

Same with triple quotes, btw.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Case Sensitive, Multiline Comments

2005-05-29 Thread D H
Elliot Temple wrote:
 Hi I have two questions.  Could someone explain to me why Python is
 case sensitive?  I find that annoying.  

I do too.  As you've found, the only reason is because it is, and it is 
too late to change (it was even too late back in 1999 when it was 
considered by Guido).  I guess the most popular case-insensitive 
language nowadays is visual basic (and VB.NET).

  Also, why aren't there
 multiline comments?  Would adding them cause a problem of some sort?

Again, just because there aren't and never were.  There is no technical 
reason (like for example a parsing conflict) why they wouldn't work in 
python.  That's why most python editors have added a comment section 
command that prepends # to consecutive lines for you.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fredrik Lundh

2005-05-09 Thread D H
Sakesun Roykiattisak wrote:
 IMHO, Pythonware.com does not have to be about python. It can be 
 anything the maintainer want it to be.
 
 Get the point ?

You successfully repeated my own argument, so yes, I get the point.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fredrik Lundh

2005-05-09 Thread D H
Robert Kern wrote:
 The Daily Python-URL isn't obligated to link to *anything*.

I never suggested it was.
-- 
http://mail.python.org/mailman/listinfo/python-list


Fredrik Lundh

2005-05-08 Thread D H
Fredrik Lundh wrote:
 D H [EMAIL PROTECTED] wrote:
 
 
Why do you think you need a regular expression?

If another approach that involved no regular expressions worked much
better, would you reject it for some reason?

A regular expression will work fine for his problem.
Just match the digits separated by underscores using a regular
expression, then afterward check if the values are valid.
 
 
 you forgot to mention Boo here, Doug.  nice IronPython announcement,
 btw.  the Boo developers must be so proud of you.
 
 /F

You never learn, do you Fredrik.  I guess that explains why Boo will 
never be mentioned on the python daily site your pythonware business 
controls.

Here are some of Fredrik's funnier crazy rants right here:
http://www.oreillynet.com/pub/wlg/6291

Any that you perceive as competition and threatening to your consulting 
business really draws out your true nature.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: annonymous functions -- how to

2005-05-05 Thread D H
Peter Hansen wrote:
 Jason Mobarak wrote:
 
 What's wrong with:

 def blah():
   def _ (a, b, c):
 a = a + 2
 print stmt 2
 return a+b/c
   return doSomethingWith(_)

 It's basically anonymous, it just uses a name that you don't care
 about. AFAIK, it can be immediately clobbered later if need be.
 Otherwise, the function shouldn't be anonymous.
 
 
 Or even better:

Python doesn't have anonymous functions.
See http://boo.codehaus.org/Closures
and the closures examples here:
http://svn.boo.codehaus.org/trunk/tests/testcases/integration/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to write this regular expression?

2005-05-05 Thread D H
Peter Hansen wrote:
 could ildg wrote:
 
 I need a regular expression to check if a string matches it.
 
 
 Why do you think you need a regular expression?
 
 If another approach that involved no regular expressions worked much 
 better, would you reject it for some reason?
 
 -Peter

A regular expression will work fine for his problem.
Just match the digits separated by underscores using a regular 
expression, then afterward check if the values are valid.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Calling a Perl Module from Python ( future direction of Python)

2005-04-06 Thread D H
gf gf wrote:
Really!  That's a pity... Instead of trying to
recreate a repository the size of CPAN, a Python
interface to Perl modules is really called for.
CPAN modules are designed for Perl though.  There's pyperl like they 
mentioned but it's like speaking two languages at once.
It's not like the Java standard library or the .NET/Mono standard 
library that can be used easily with different languages.  For Python, 
see PyPI and the Vaults of Parnassus: http://www.python.org/pypi 
http://www.vex.net/parnassus/

Instead of fretting over decorator syntax and
lispiness, might I suggest that development efforts be
directed to this?  Developers, are you listening? 
Guido?
They are actually focusing more on the python standard library lately.
--
http://mail.python.org/mailman/listinfo/python-list


  1   2   >