Re: [Python-Dev] Python 2.4 won the "Jolt productivity award" last night

2005-03-19 Thread Aahz
On Fri, Mar 18, 2005, Simon Brunning wrote:
> On Thu, 17 Mar 2005 16:01:03 +, Gareth McCaughan
> <[EMAIL PROTECTED]> wrote:
>>
>> http://www.sdmagazine.com/jolts/ ,
>> 
>> but it's not been updated yet and therefore still has last year's
>> winners on it. I haven't found anything with more up-to-date
>> results.
> 
> The 2005 winners are listed here:
> http://www.sdmagazine.com/pressroom/jolt_winners_2005.pdf

I've put this up on the website, but
http://www.sdmagazine.com/pressroom/
claims that press releases are only up for two months, so we'll need a
permanent URL later.
-- 
Aahz ([EMAIL PROTECTED])   <*> http://www.pythoncraft.com/

"The joy of coding Python should be in seeing short, concise, readable
classes that express a lot of action in a small amount of clear code -- 
not in reams of trivial code that bores the reader to death."  --GvR
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] python-dev Summary for 2005-03-01 through 2005-03-15 [draft]

2005-03-19 Thread Brett Cannon
[Nick Coghlan]
-
sum() semantics discussed
-
Guido's blog entry on `the fate of reduce() in Python 3000`_ (which 
reiterated Guido's plan to cut map(), reduce(), filter() and lambdas (what 
about zip()?) caused a huge discussion on whether sum() worked the best way 
possible.  As it stands now, sum() only accepts a sequence of numbers and 
its optional second argument works as an initial value to build off of.
That last sentence isn't quite true. With an appropriate second argument, sum 
can be used to sum any sequence (even one containing strings):

Py> class additive_identity(object):
...   def __add__(self, other):
... return other
...
Py> sum(["a"] * 5, additive_identity())
'a'
That is slightly evil, and here is a simpler example of evilness:
  sum([[1],[2],[3]], [])
Had to look at the source to understand how it was working.  =)  First 
thing learned while at the sprints!

-Brett
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] python-dev Summary for 2005-03-01 through 2005-03-15 [draft]

2005-03-19 Thread Brett Cannon
[Paul Moore]
On Thu, 17 Mar 2005 18:21:33 -0800, Brett C. <[EMAIL PROTECTED]> wrote:

2.4.1 should be out soon

Python 2.4.1c1 is out.  Very shortly c2 will be released.  Assuming no major
issues come up, 2.4 final will be out.
You probably mean something like "2.4.1 final will be out shortly
afterwards" (I don't recall if a date has been confirmed).
Yes I did.  =)  Fixed.
-Brett
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] python-dev Summary for 2005-03-01 through 2005-03-15 [draft]

2005-03-19 Thread Kurt B. Kaiser
Nick Coghlan <[EMAIL PROTECTED]> writes:

> That last sentence isn't quite true. With an appropriate second
> argument, sum can be used to sum any sequence (even one containing
> strings):
>
> Py> class additive_identity(object):
> ...   def __add__(self, other):
> ... return other
> ...

==> setup

> Py> sum(["a"] * 5, additive_identity())
> 'a'
>
> This is fairly abusive of sum, though :)

Python 2.5a0 (#85, Jan 27 2005, 17:41:04) 
[GCC 2.95.3 20010125 (prerelease, propolice)] on openbsd3
Type "copyright", "credits" or "license()" for more information.

IDLE 1.2a0

Py> t = timeit.Timer("sum(('a','bcd', 'e'), ai())", setup)
Py> t.repeat()
[3.3861918449401855, 3.2027261257171631, 3.1891348361968994]

Py> t2 = timeit.Timer("''.join(('a','bcd', 'e'))")
Py> t2.repeat()
[1.1249339580535889, 1.1143810749053955, 1.0990779399871826]

Py> t3 = timeit.Timer("'a' + 'bcd' + 'e'")
Py> t3.repeat()
[0.10233211517333984, 0.099857091903686523, 0.10514688491821289]

-- 
KBK
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] bdist_deb checkin comments

2005-03-19 Thread Sean Reifschneider
I'm hoping to get the bdist_deb patch committed this week.  This is SF
patch 1054967:

   
https://sourceforge.net/tracker/index.php?func=detail&aid=1054967&group_id=5470&atid=305470

Does anyone have any feedback on this before I do so?  I'm imagining
committing it into the Python CVS, but as my first non-RPM commit I'd like
some feedback if that would be the wrong thing to do.

Thanks,
Sean
-- 
 Language is the most important .. uh..  I think you know what I'm trying
 to say.  -- Steve Martin
Sean Reifschneider, Member of Technical Staff <[EMAIL PROTECTED]>
tummy.com, ltd. - Linux Consulting since 1995.  Qmail, Python, SysAdmin

___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Re: Change 'env var BROWSER override' semantics in webbrowser.py

2005-03-19 Thread Oleg Broytmann
On Fri, Mar 18, 2005 at 06:55:09PM -0500, Fred L. Drake, Jr. wrote:
> On Friday 18 March 2005 17:44, Reinhold Birkenfeld wrote:
>  > Additionally, there are several patches on SF that pertain to
>  > webbrowser.py; perhaps you can review some of them...
> 
> Given the time I haven't been able to devote to the webbrowser module, a 
> consolidated set of reviews would be very helpful.
> 
> Patch reviews should be written in the tracker, as always, and a summary of 
> all the webbrowser-related patches in a single email to python-dev.

   I am in game, as one of those patches is mine. I've started to review
patches...

Oleg.
-- 
 Oleg Broytmannhttp://phd.pp.ru/[EMAIL PROTECTED]
   Programmers don't die, they just GOSUB without RETURN.
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] bdist_deb checkin comments

2005-03-19 Thread Kurt B. Kaiser
Sean Reifschneider <[EMAIL PROTECTED]> writes:

> Does anyone have any feedback on this before I do so? 

I made a few comments on the Tracker.
-- 
KBK
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] identity operands (was python-dev Summary for 2005-03-01 through 2005-03-15 [draft])

2005-03-19 Thread Nick Coghlan
Kurt B. Kaiser wrote:
Nick Coghlan <[EMAIL PROTECTED]> writes:
This is fairly abusive of sum, though :)

[snip Kurt's timings]
Even avoiding the object instantiation doesn't help much:
Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Py> setup = """\
... class additive_identity(object):
...   def __add__(self, other):
... return other
...
... ai = additive_identity()
... """
Py> t = timeit.Timer("sum(('a', 'bcd', 'e'), ai)", setup)
Py> t.repeat()
[1.7930380266773089, 1.7397206526577538, 1.7193376076378759]
Py> t = timeit.Timer("''.join(('a', 'bcd', 'e'))")
Py> t.repeat()
[0.58006451058344055, 0.58431742467269032, 0.5788117914319173]
Py> t = timeit.Timer("'a' + 'bcd' + 'e'")
Py> t.repeat()
[0.29404383490157215, 0.29554694930084224, 0.29612594514117063]
(I almost forgot to repeat your other tests to account for the differences in 
machine speed!)

So, using "".join is roughly three times as fast as abusing sum :)
I'm still intrigued by the concept of providing an object or objects (e.g. in 
operator) that work as an identity operand for all cases where it makes sense:

Commutative operations (always return 'other'):
__add__(self, other)
__radd__(self, other)
__mul__(self, other)
__rmul__(self, other)
__xor__(self, other)
__rxor__(self, other)
__and__(self, other)
__rand__(self, other)
__or__(self, other)
__ror__(self, other)
Non-commutative operations with identity on the right (return 'other')
__rsub__(self, other)
__rdiv__(self, other)
__rtruediv__(self, other)
__rfloordiv__(self, other)
__rmod__(self, other)
__rdivmod__(self, other)
__rpow__(self, other)
__rlshift__(self, other)
__rrshift__(self, other)
Other non-commutative operations with a sensible identity:
__sub__(self, other):  return -other
Non-commutative operations without a sensible identity:
__div__(self, other)
__truediv__(self, other)
__floordiv__(self, other)
__mod__(self, other)
__divmod__(self, other)
__pow__(self, other[, modulo])
__lshift__(self, other)
__rshift__(self, other)
If it was done, it would probably be best to do this as at least two objects - 
one for which bool(additive_identity) evaluates to False, and the other for 
which bool(multiplicative_identity) evaluates to True.

Cheers,
Nick.
--
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---
http://boredomandlaziness.skystorm.net
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] Python 2.4 | 7.3 The for statement

2005-03-19 Thread Juan Carlos Rodrigo Garcia
Hi My name is Juan Carlos Rodrigo, and I love Python. 
It is the most impressive and usefull language that
I have ever seen. 

I am studing, at http://www.uoc.edu, an Information 
Technology Postgraduate. And I have programmed some 
REXX applications in my past Jobs (So I love python, 
no more ENDS).

This is my Graduate final project http://ip.xpyro.com 
made in mod_python. I love mod_python too.

Please don't crash my AMD making queries. :|

8<8<8<8<8<8<

Python 2.4 | 7.3 The for statement:
---
 
 for_stmt ::= "for" target_list "in" expression_list ":" 
  suite ["else" ":" suite]
 
 
New for statement:
--
 
for_stmt ::= "for" target_list "in" expression_list
 [ "and" expression ] ":" 
  suite ["else" ":" suite]

  ** If the expression evaluates to False before 
 entering the for, jump else.
  ** If the expression is evaluated to False after 
 the first iteration, break.
 
 
So ¿What we can do with this new for?, 
and ¿It is going to avoid line exceed?:
 
"My second remark is that our intellectual powers are rather
geared to master static relations and that our powers to
visualize processes evolving in time are relatively poorly
developed." [1]
 
 
It is easier if we see it beforehand:
-
 
leave = False
alist = [1,2,3,3,4,5,6,7,8,9]
for item in alist and not leave:
 if item is 1: leave = True
 
 
Avoiding code exceed:
-
 
a = 1
b = 2
c = 3
alist = [1,2,3,4,5,6,7,8,9]
for item in alist and a < 2 and b < 3 and c < 4:
 if item == 3: a += 1
 if item == 2: b += 1
 if item == 1: c += 1
print "%d %d %d" % (a,b,c)
# three lines off (25% less on breaks)

 
Other features and the else:

 
alist = [1,2,3]
enter = False
if list[0] == 4:
 enter = True
for item in alist and enter:
 print item
else:
 print "No account"
 
   
The real problem:
-
  
"The exercise to translate an arbitrary flow diagram more or
less mechanically into a jump-less one, however, is not to be
recommended." [1]
 
Ok, it's not recommended, at large, but Python should make it possible,
and then the people will choose.
 
 
[1] Go To Statement Considered Harmful
Edsger W. Dijkstra
http://www.acm.org/classics/oct95/
 
PD: Your work is impressive, thanks.
-- 

Juan Carlos Rodrigo Garcia.
[EMAIL PROTECTED]
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Python 2.4 | 7.3 The for statement

2005-03-19 Thread Nick Coghlan
Juan Carlos Rodrigo Garcia wrote:
It is easier if we see it beforehand:
-
 
leave = False
alist = [1,2,3,3,4,5,6,7,8,9]
for item in alist and not leave:
 if item is 1: leave = True
Interesting idea, but not really needed given the existence of the break 
statement:
for item in alist:
  if item is 1:
break
Cheers,
Nick.
--
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---
http://boredomandlaziness.skystorm.net
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Python 2.4 | 7.3 The for statement

2005-03-19 Thread Nick Coghlan
Juan Carlos Rodrigo wrote:
Interesting idea, but not really needed given the existence of the break statement:

Goto = break
I'm not interested.
All non-sequential control structures are merely constrained ways of using goto 
(the underlying machine code will devolve into conditional and unconditional 
branches and jumps - i.e. goto's). 'break' is a highly constrained form of goto 
and a fundamental part of structured programming (as is 'continue') - each is 
limited to a local effect on the loop that contains them. This is a far cry from 
the ability to jump to an arbitrary label that gives goto its bad reputation.

I used to share your sentiment regarding break and continue - experience 
(especially Python experience) has convinced me otherwise. Python embraces the 
concept of breaking out of a loop to the point that it even has an 'else' clause 
on loop structures that is executed only if the loop is exited naturally rather 
than via a break statement.

Regardless of whether you personally choose to use break and continue, the 
existence of those statements is the main reason that the addition of a flag 
condition to for loops is highly unlikely. If you want to terminate a for loop 
before the iterable is exhausted, the recommended solution is to use a break 
statement.

To illustrate the point about all control structures being gotos, even a simple 
do-nothing for loop results in a JUMP_ABSOLUTE (goto!) in the generated bytecode:

Py> def f():
...   for item in range(10):
... pass
...
Py> import dis
Py> dis.dis(f)
  2   0 SETUP_LOOP  20 (to 23)
  3 LOAD_GLOBAL  0 (range)
  6 LOAD_CONST   1 (10)
  9 CALL_FUNCTION1
 12 GET_ITER
>>   13 FOR_ITER 6 (to 22)
 16 STORE_FAST   0 (item)
  3  19 JUMP_ABSOLUTE   13
>>   22 POP_BLOCK
>>   23 LOAD_CONST   0 (None)
 26 RETURN_VALUE
Cheers,
Nick.
--
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---
http://boredomandlaziness.skystorm.net
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Python 2.4 | 7.3 The for statement

2005-03-19 Thread Aahz
On Sun, Mar 20, 2005, Juan Carlos Rodrigo Garcia wrote:
>
> Hi My name is Juan Carlos Rodrigo, and I love Python.  It is the most
> impressive and usefull language that I have ever seen.

Glad to hear that!  However, your post is off-topic for python-dev;
you'll have a better discussion posting to comp.lang.python.  Thanks.
-- 
Aahz ([EMAIL PROTECTED])   <*> http://www.pythoncraft.com/

"The joy of coding Python should be in seeing short, concise, readable
classes that express a lot of action in a small amount of clear code -- 
not in reams of trivial code that bores the reader to death."  --GvR
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com