Dr. Dobb's Python-URL! - weekly Python news and links (Jan 18)

2006-01-18 Thread Magnus Lycka
QOTW: *what* the value is is defined by the operations that the object 
supports (via its type).

*how* the value is represented inside the object is completely 
irrelevant; a Python implementation may use electric charges in small 
capacitors, piles of rocks, diapers,or an endless supply of small guys 
in odd costumes to encode the value inside an object.  Changes to the 
value may be carried out by CPU instructions, caterpillars, toddlers 
with gasmasks, or an endless supply of small guys in odd costumes. The 
only thing that's important is that you can, in your Python program, 
access an objects value via its type, and get other objects back when 
you do. - Fredrik Lundh

I have never seen a case where a dictionary didn't improve the design. - Ivan
Van Laningham


PyCon Early bird registration ends, FrOSCon 2006 issues
a Call for Papers and OSCON 2006 (Python 14 Conference)
issues a Call for Proposals:

http://groups.google.se/group/comp.lang.python.announce/browse_frm/thread/3e139769821f7e6e

http://groups.google.se/group/comp.lang.python.announce/browse_frm/thread/a5704ce3f09c4f01

http://groups.google.se/group/comp.lang.python.announce/browse_frm/thread/8f520f85326bf7de

With release 0.6, OSAF's Python based PIM Chandler includes
an experimentally usable calendar, with support for
recurring events, time-zones and the ability to share
calendars with others: 
http://chandler.osafoundation.org/

Fynali asks How to remove subset from a file efficiently?.
Follow-ups, as has happened so often before, reduce his runtime
from a few minutes to a few seconds:

http://groups.google.se/group/comp.lang.python/browse_frm/thread/929fcdf0ff9731dc

Tim Peters explains why you shouldn't expect much from atexit + threads:

http://groups.google.se/group/comp.lang.python/browse_frm/thread/fe9e426650764ed9

Scott David Daniels suggests use of decorators to handle unit
tests that are known to fail:

http://groups.google.se/group/comp.lang.python/browse_frm/thread/7ea0762494ef96ff

Robin Becker requests some smart/fast way to flatten a level one list
and receives a number of suggestions:

http://groups.google.se/group/comp.lang.python/browse_frm/thread/383aab2c3467eb59

A discussion of the draft for a new Python.org web site leads
to a conclusion of general happiness with the new look:
http://beta.python.org

Brian Blais asks how do 'real' python programmers work? and
receives a sample of development processes that Pythonistas use,
focused on what kind of windows people have on their screen, but
also including such important aspects as test driven development:

http://groups.google.se/group/comp.lang.python/browse_frm/thread/82b4f2f90b9def56

Michael Galvin receives a few suggestions on how to get both
text and graphics to a printer from Python:

http://groups.google.se/group/comp.lang.python/browse_frm/thread/bc0742534da994d2

Duncan Booth and others explain how to make a dictionary
aware of its own changes:

http://groups.google.se/group/comp.lang.python/browse_frm/thread/eeca4df10529f7e0



Everything Python-related you want is probably one or two clicks away in
these pages:

Python.org's Python Language Website is the traditional
center of Pythonia
http://www.python.org
Notice especially the master FAQ
http://www.python.org/doc/FAQ.html

PythonWare complements the digest you're reading with the
marvelous daily python url
 http://www.pythonware.com/daily  
Mygale is a news-gathering webcrawler that specializes in (new)
World-Wide Web articles related to Python.
 http://www.awaretek.com/nowak/mygale.html 
While cosmetically similar, Mygale and the Daily Python-URL
are utterly different in their technologies and generally in
their results.

For far, FAR more Python reading than any one mind should
absorb, much of it quite interesting, several pages index
much of the universe of Pybloggers.
http://lowlife.jp/cgi-bin/moin.cgi/PythonProgrammersWeblog
http://www.planetpython.org/
http://mechanicalcat.net/pyblagg.html

comp.lang.python.announce announces new Python software.  Be
sure to scan this newsgroup weekly.

http://groups.google.com/groups?oi=djqas_ugroup=comp.lang.python.announce

Steve Bethard, Tim Lesher, and Tony Meyer continue the marvelous
tradition early borne by Andrew Kuchling, Michael Hudson and Brett
Cannon of intelligently summarizing action on the python-dev mailing
list once every other week.
http://www.python.org/dev/summary/

The Python Package Index catalogues packages.
http://www.python.org/pypi/

The somewhat older Vaults of Parnassus ambitiously collects references
to all 

ANN: AsciiDoc 7.1.0 released

2006-01-18 Thread Stuart Rackham
This release introduces a2x(1), an AsciiDoc DocBook toolchain wrapper to
automate the generation and sequencing of toolchain commands (see also
http://www.methods.co.nz/asciidoc/CHANGELOG.html).

What is it?
---
AsciiDoc is an uncomplicated text document format for writing articles,
short documents, books and UNIX man pages.

AsciiDoc files can be translated to HTML, XHTML (with CSS2) and DocBook
(articles, books and refentry documents) using the asciidoc(1) command.

AsciiDoc is configurable: both the AsciiDoc source file syntax
and the backend output markups (which can be almost any type of
SGML/XML markup) can be customized and extended by user.

Requisites
--
Python 2.3 or higher.

Obtaining AsciiDoc
--
The latest AsciiDoc version, examples and online documentation can be
downloaded from http://www.methods.co.nz/asciidoc/

AsciiDoc is also hosted at the SourceForge at
http://sourceforge.net/projects/asciidoc/


Regards, Stuart
-- 
Stuart Rackham [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

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


ANN: PyLucid 0.6.0 stable released

2006-01-18 Thread jens

It is finally done! The v0.6.0 version is stable. (I think.)


About:
--
PyLucid is a lightweight, OpenSource (GPL 2.x or newer) content 
management system written in pure Python CGI. Nearly all output can be 
customized. No shell account is needed. To run PyLucid you need a 
standard Webserver with Python (at least v2.2.1) CGI and MySQL.



Changes:

* major changes
o NEW: Module/Plugin Administration available.
o NEW: Basic User Management
o The Module-Manager is complete rewritten.
o Plugin-Config now in a seperate File.
o Plugins can have own SQL-Tables, internal_pages and stylesheets.
o NEW: internal_pages can be written in simpleTAL

* minor / internal changes
o Rewritten internal_pages: Used CSS instead of tables.
o enhanced: manual encoding from data base
o bugfixes in tinyTextile Markup
o Tables plugin and plugindata where now in use ;)
o page_internals with no markup use SQL-'NULL' instand of ID 1


http://pylucid.org/index.py?p=/Download/History



Download:
http://sourceforge.net/project/showfiles.php?group_id=146328package_id=161206



how to install PyLucid:
http://www.pylucid.org/index.py?p=/Download/install+PyLucid

update instructions:
http://www.pylucid.org/index.py?p=/Download/update+instructions




-- 
Mfg.

Jens Diemer



CMS in pure Python CGI: http://www.pylucid.org
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

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


Re: OT: excellent book on information theory

2006-01-18 Thread Steve Holden
Terry Hancock wrote:
 On Tue, 17 Jan 2006 13:28:15 +
 Steve Holden [EMAIL PROTECTED] wrote:
 
Grant Edwards wrote:

Very interesting.  And rather sad that editors think the
average Amermican reader too dim-witted to figure out
(in context, even) that a car park is a parking lot
and a dustbin is a trash can.


They know that the average American could work it out.
They also know  that the average American doesn't like to
do anything remotely like hard  thinking, hence they make
these changes so the books don't read like  foreign
literature.
 
 
 I'll pass on the snobbery.
 
I don't know what snobbery is involved: the same is true of the average 
English reader, but the book was written in English.

 The real reason is that it was an expensively promoted
 book. Customizing it for an American audience was a way to
 suck money out of that flow into the pockets of the
 American publisher. In order to justify that expense, they
 have to have something to show for their efforts.
 
 Or if you want to put it another way, if you pay somebody
 to fiddle with the prose, fiddle they will.
 
If you say so. Stranger things have happened.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: Arithmetic sequences in Python

2006-01-18 Thread Antoon Pardon
Op 2006-01-17, Steven Bethard schreef [EMAIL PROTECTED]:
 Antoon Pardon wrote:
 Why don't we give slices more functionality and use them.
 These are a number of ideas I had. (These are python3k ideas)
 
 1) Make slices iterables. (No more need for (x)range)
 
 2) Use a bottom and stop variable as default for the start and
stop attribute. top would be a value that is greater than
any other value, bottom would be a value smaller than any
other value.

 Just checking your intent here.  What should these do?

 (2:5)# should give me 2, 3, 4

Yes.

 (2:5:-1) # infinite iterator 2, 1, 0, ...?

No it would give nothing, think xrange(2,5,-1)


 (:5) # start at -infinity?  what does that even mean?

I'm still thinking abouth this. My preffered idea now it
it would be an endless loop returning bottom elements.

 (:5:-1)  # start at -infinity and go backwards?!!

This would give nothing. The idea is that if the step is negative
the iteration stops when the (hidden) index is equal or smaller
than the stop value. This is true here from the start.

 I suspect you should be raising some sort of exception if the start 
 isn't defined.

That is a possibility too.

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


Re: New Python.org website ?

2006-01-18 Thread Shalabh Chaturvedi
Steve Holden wrote:
 http://beta.python.org

Hm. Am I the only one not particularly impressed? Sure the front page is 
'slick' but a few clicks reveal a fairly shallow facade of marketing 
material, with no real content. In general gives the impression of 
'phony' company trying to make a big impression. Most good non-tech 
managers are very wary of such organizations/companies.

My gripes with the whole thing:

1. Learn why.., Learn why.., Learn more..? Unless each one takes you 
directly to a great success story, these should be removed.

2. There is no (published) Python success story for Google. So link to 
google.com looks phony. What does 'Google written in Python' mean 
anyway? The google.com server is Python? One backend script is in 
Python? Without more information, this just seems likes a shameless 
attempt to create credibility. (Sure I know Google uses Python 
extensively, but I'm not the one who needs to be sold on Python).

3. What is PyXP? Windows XP? Extreme Programming? Again, there is 
nothing underneath. Where is the NASA success story?

4. I have a lot of respect for GvR, but there ought to be more 
advertising of the fact that the language is not supported by just one 
person. There is an great dev team behind it and a stable PSF 
organization. Anyone reading 'developed by one person' is not left with 
the fuzzy feeling of a mature, well-supported product that is here to stay.

5. A 'more..' link under Written in Python is sorely missing. It appears 
only 5-6 apps are written in Python. Where is a link to the cheese shop?

Managers are looking for maturity, stability, support and unique 
strengths, not coolness or flashy sites (though presentation definitely 
helps).

Hopefully most of these will get fixed as people 'convert' the site and 
fill in content. I would urge people to do some 'user' testing - get 
persons not very familiar with Python and get their honest opinion on 
the site.

The only think I liked was the 'Using Python For' section on the home page.

That's all for now.

Cheers,
Shalabh

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


Re: magical expanding hash

2006-01-18 Thread Steve Holden
Steven Bethard wrote:
 Steve Holden wrote:
 
Steven Bethard wrote:

Agreed.  I really hope that Python 3.0 applies Raymond Hettinger's 
suggestion Improved default value logic for Dictionaries from
 http://wiki.python.org/moin/Python3%2e0Suggestions

This would allow you to make the setdefault() call only once, instead 
of on every lookup:

 class meh(dict):
 def __init__(self, *args, **kwargs):
 super(meh, self).__init__(*args, **kwargs)
 self.setdefault(function=meh)

STeVe


In fact, why not go one better and also add a default keyword 
parameter to dict()?
 
 
 It's not backwards compatible:
 
   dict(default=4)
 {'default': 4}
 
 And I use the **kwargs form of the dict constructor often enough to hope 
 that it doesn't go away in Python 3.0.
 
Nyargle. Thanks, you're quite right, of course: I was focussing on the 
list-of-pairs argument style when I wrote that. So the best we could do 
is provide a subtype, defaultdict(default, *args, *kw).

It still seems to me that would be better than having to call a method 
(though I don't object to the method for use if the defaut must change 
dynamically). Maybe I just liked Icon tables too much.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: The Python cross? Was New Python.org website

2006-01-18 Thread Steve Holden
Obaid R. wrote:
 Bugs wrote:
 
I thought I read here that a new website design was in the works for
python.org in time for the new year?  Is that still true and of so,
anyone know what is it's status?
Thanks!
 
 
 
 I googled around and found no background on how the new Python logo
 came to be selected. Does any one know why or how the logo shown in the
 upper left corner of the beta.python.org site was choosen? Which other
 logos were rejected? Is there a particular reason why it is shaped like
 a cross?
 
 Thanks
 
The history of this choice is lost in the mists of time. Many other 
proposals were made and discussed at around the same time, to the extent 
that it became clear no one choice could win universal approval.

You are the first person to my knowledge to point out that it is shaped 
like a cross. There is no significance in this shape.

Is there, I ask with some trepidation, a specific point to this question?

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: The Python cross? Was New Python.org website

2006-01-18 Thread Steve Holden
Obaid R. wrote:
 Bugs wrote:
 
I thought I read here that a new website design was in the works for
python.org in time for the new year?  Is that still true and of so,
anyone know what is it's status?
Thanks!
 
 
 
 I googled around and found no background on how the new Python logo
 came to be selected. Does any one know why or how the logo shown in the
 upper left corner of the beta.python.org site was choosen? Which other
 logos were rejected? Is there a particular reason why it is shaped like
 a cross?
 
 Thanks
 
One further point: adding pydotorg to your search might yield relevant 
information, including references to articles that can be found in

   http://mail.python.org/pipermail/pydotorg-redesign/

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: Arithmetic sequences in Python

2006-01-18 Thread Antoon Pardon
Op 2006-01-17, Gregory Petrosyan schreef [EMAIL PROTECTED]:
 Hey guys, this proposal has already been rejected (it is the PEP 204).


No it isn't. In my proposal [1, 2:8, 8] would be equivallent to
[1, slice(2,8), 8]. If someone would want the list [1,2,3,4,5,6,7,8]
with this notation, I would propose a flatten function witch would
work with iterators too, so that flat([1, 2:8, 8]) would be the
same as flat([1, range(2,8), 8])

In my view python already has slice literals. You are only limited
in using this literals an index in subscription. I think this is
a rathter pointless limitation and that literal slices could be
very usefull when made into literals and usable as parameters.

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


Re: 10060, 'Operation timed out'

2006-01-18 Thread Steve Holden
Sumit Acharya wrote:
 I am using following script to connect to the server and i try the
 connection for 1000 times. Some times it succeeds for all the 1000
 times,but some times it fails with error:-
 10060, 'Operation timed out'. When it fails with the abover error, it
 seems timed out time is 20 seconds. Is there a way I can increase the
 timedout time for FTP?
 
 from ftplib import FTP
 import time
 import sys
 
 host = sys.argv[1]
 port = sys.argv[2]
 
 for x in range(1000):
 try:
y = time.time()
 ftp = FTP()
 ftp.connect(host,port)
 ftp.login('a','a')
 try:
 print ftp.sendcmd('pass x')
 except:
 print sys.exc_value
 ftp.close()
 except:
 print sys.exc_value
 r = time.time()
 print Timeout %d %d %((r-y),x)
 
 when there is error in connecting, it comes to the outer except and
 prints the value of r-y as 21. How i can increase this timeout time? or
 this error indicates something else?
 
 Please let me know asap,
 
In a single-threaded program you can import the socket module and then 
use the socket.setdefaulttimeout() function to establish a longer timeout.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: New Python.org website ?

2006-01-18 Thread Tim N. van der Leeuw
Shalabh,

You've managed very well to express the same things I feel about the
new Python website.

What I especially dislike about the new website are the flashy pictures
on the front-page with no content and no purpose -- purely boasting but
nothing to back up your claims.

(I wouldn't mind some sleek pictures there if they weren't desperatly
trying to advertise success-stories but instead would link to real
content!)

I do like to overall look-and-feel of the beta site but I hope the bad
bits get fixed before launch!

cheers,

--Tim

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


Re: Arithmetic sequences in Python

2006-01-18 Thread Antoon Pardon
Op 2006-01-18, Tom Anderson schreef [EMAIL PROTECTED]:
 On Tue, 17 Jan 2006, Antoon Pardon wrote:

 Op 2006-01-16, Alex Martelli schreef [EMAIL PROTECTED]:
 Paul Rubin http://[EMAIL PROTECTED] wrote:

 Steven D'Aprano [EMAIL PROTECTED] writes:
 For finite sequences, your proposal adds nothing new to existing
 solutions like range and xrange.

 Oh come on, [5,4,..0] is much easier to read than range(5,-1,-1).

 But not easier than reversed(range(6)) [[the 5 in one of the two
 expressions in your sentence has to be an offbyone;-)]]

 Why don't we give slices more functionality and use them.
 These are a number of ideas I had. (These are python3k ideas)

 1) Make slices iterables. (No more need for (x)range)

 2) Use a bottom and stop variable as default for the start and
   stop attribute. top would be a value that is greater than
   any other value, bottom would be a value smaller than any
   other value.

 3) Allow slice notation to be used anywhere a value can be
   used.

 4) Provide a number of extra operators on slices.
   __neg__ (reverses the slice)
   __and__ gives the intersection of two slices
   __or__ gives the union of two slices

 5) Provide sequences with a range (or slice) method.
   This would provide an iterator that iterates over
   the indexes of the sequences. A slice could be
   provided

 +5

  for i, el in enumerate(sequence):

 would become

  for i in sequence.range():
el = sequence[i]

 That one, i'm not so happy with - i quite like enumerate; it communicates 
 intention very clearly. I believe enumerate is implemented with iterators, 
 meaning it's potentially more efficient than your approach, too. And since 
 enumerate works on iterators, which yours doesn't, you have to keep it 
 anyway. Still, both would be possible, and it's a matter of taste.

 But the advantage is that this would still work when someone subclasses 
 a list so that it start index is an other number but 0.

 It would be possible to patch enumerate to do the right thing in those 
 situations - it could look for a range method on the enumerand, and if it 
 found one, use it to generate the indices. Like this:

 def enumerate(thing):
   if (hasattr(thing, range)):
   indices = thing.range()
   else:
   indices = itertools.count()
   return itertools.izip(indices, thing)

Fine by me. I'm not against enumerate.

 If you only wanted every other index one could do the following

  for i in sequence.range(::2):

 which would be equivallent to

  for i in sequence.range()  (::2):

 Oh, that is nice. Still, you could also extend enumerate to take a range 
 as an optional second parameter and do this with it. Six of one, half a 
 dozen of the other, i suppose.

Yes you could probably do so and I'm not against it, I just think that
range would be a better base on which you can build enumerate and other
things than that enumenrate can be a base. e.g. __len__ could be eliminated
and len would be defined as:

  def len(seq):
rng = seq.range()
return rng.stop - rng.start
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: XML Writer in wxPython

2006-01-18 Thread Marco Meoni
i have to put the XML in a string. Is there a module with the XML
writing funcion?

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


Re: The Python cross? Was New Python.org website

2006-01-18 Thread Neil Hodgson
Steve Holden:

 The history of this choice is lost in the mists of time. Many other 
 proposals were made and discussed at around the same time, to the extent 
 that it became clear no one choice could win universal approval.

The two snakes have just been arguing (over decorator syntax, the 
GIL, and the pressing need to merge the dictionary and list types), are 
feeling very +cross+, and have turned their backs on each other.

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


Re: New Python.org website ?

2006-01-18 Thread Tim Golden
[Shalabh Chaturvedi]

| Hm. Am I the only one not particularly impressed? Sure the
| front page is
| 'slick' but a few clicks reveal a fairly shallow facade of marketing
| material, with no real content. In general gives the impression of
| 'phony' company trying to make a big impression. Most good non-tech
| managers are very wary of such organizations/companies.

[... snip similar stuff highlighting the relative
lightweightness of the content ...]

Ummm. I might have missed the point, and certainly what I'm about
to say is based on no more than my reading between the lines of
Steve's original announcement, but... I see the current beta
site as a layout/display/look-and-feel beta, *not* a content
beta, at least no more than is absolutely necessary to support
the look-and-feel.

Now I might be wrong, in which case your comments are pretty
much justified. But it looks to me as though most of the
content was banged in a year or so ago (or more, maybe) to
give a this-kind-of-blurb feel, some or all of which would
be replaced with current and agreed blurb before the thing
went live.

You might argue that the beta shouldn't have been unveiled
without suitable text etc. But I would say: well done to
the people who've made the effort and put the beta
together. It's been mentioned that the whole thing is
downloadable and open to contributions, so maybe that's
the way forward for you: make or implement your suggestions
and send them back to the maintainers.

TJG

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


Re: search multiple dictionaries efficiently?

2006-01-18 Thread Duncan Booth
George Sakkis wrote:

 It's not the *most* efficient way because value is looked up twice if
 it is contained in the dictionary; if you absolutely need it to be as
 efficient as possible and can't figure it out on your own, ask again
 and someone will help you out.
 
How do you *know* it is not the *most* efficient way? Have you tried timing 
different ways of approaching this problem and found that looking up the 
value twice is slow?

I've tried timing dictionary lookups in the past, and the three obvious 
solutions roughly come out as follows:

try/except is fastest when the value is in the dictionary, but it is a 
*lot* slower if the exception gets thrown. If missing values are a very 
rare occurrence this might be a good way to do it, but usually the code 
doesn't read as well so its best to avoid. [0.26/4.11]

Test with the 'in' operator and then retrieving the value is the fastest 
solution when the value isn't in the dictionary (it only does a single 
lookup then), and is still fast when it is. [0.36/0.2]

Using the get method of the dictionary with a default value to be retrieved 
if the key is not present is slower than using the 'in' operator in all 
cases (it does beat try/except when an exception is thrown) [0.49/0.54]

The numbers above are the times produced in each case for a key present/key 
missing using a simple test with timeit.py.

Part of the reason, BTW, that calling d.get(key,default) is slow is that is 
also requires two dictionary lookups: one to find the get method and then 
another to access the key in the dictionary, plus it has other overheads (a 
method call) which testget avoids.

These figures could of course be invalidated if the actual use is too far 
from the simple string lookup I tried. For example if the key has a slow 
hash function saving the second lookup would be worthwhile.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 10060, 'Operation timed out'

2006-01-18 Thread Sumit Acharya
can u please modify the script that i have posted with your suggestion,
it will help me to a certain extent.

Thanks

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


Re: New Python.org website ?

2006-01-18 Thread Steve Holden
Tim N. van der Leeuw wrote:
 Shalabh,
 
 You've managed very well to express the same things I feel about the
 new Python website.
 
 What I especially dislike about the new website are the flashy pictures
 on the front-page with no content and no purpose -- purely boasting but
 nothing to back up your claims.
 
 (I wouldn't mind some sleek pictures there if they weren't desperatly
 trying to advertise success-stories but instead would link to real
 content!)
 
 I do like to overall look-and-feel of the beta site but I hope the bad
 bits get fixed before launch!
 
 
What we are desperately missing is people to roll up their sleeves and 
help with the process of content conversion and its onward maintenance. 
The current beta site content is *far* from complete, and nobody is 
married to the particular images on the front-page mock-up (which is 
what that is).

The intention of the new system is to allow a much larger group of 
people to assist in generating and maintaining the content. If we (the 
PSF) don't succeed in recruiting content maintainers then the only 
return on the time and money that's been spent will be a new look.

Remarks about the current content of the beta site are inappropriate. If 
you want Python success stories to publicize there are plenty of them at

   http://www.pythonology.org/success

The content needs responsible people to maintain it, not a slagging 
before it's complete!

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: search multiple dictionaries efficiently?

2006-01-18 Thread Ben Sizer
Duncan Booth wrote:
 Test with the 'in' operator and then retrieving the value is the fastest
 solution when the value isn't in the dictionary (it only does a single
 lookup then), and is still fast when it is. [0.36/0.2]

 Using the get method of the dictionary with a default value to be retrieved
 if the key is not present is slower than using the 'in' operator in all
 cases (it does beat try/except when an exception is thrown) [0.49/0.54]

Assuming those statistics are replicatable, it's quite unfortunate that
the obvious and concise way to do things works out more slowly than the
approach that you'd expect to take twice as long. Thankfully there
doesn't seem to be too many of these problems in Python.

-- 
Ben Sizer

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


Re: Arithmetic sequences in Python

2006-01-18 Thread Antoon Pardon
Op 2006-01-16, Gregory Petrosyan schreef [EMAIL PROTECTED]:
 Please visit http://www.python.org/peps/pep-0204.html first.

 As you can see, PEP 204 was rejected, mostly because of not-so-obvious
 syntax. But IMO the idea behind this pep is very nice. So, maybe
 there's a reason to adopt slightly modified Haskell's syntax? Something
 like

 [1,3..10]  --  [1,3,5,7,9]
 (1,3..10)  --  same values as above, but return generator instead of
 list
 [1..10] --  [1,2,3,4,5,6,7,8,9,10]
 (1 ..)--  'infinite' generator that yield 1,2,3 and so on
 (-3,-5 ..)   --  'infinite' generator that yield -3,-5,-7 and so on

 So,
 1) [] means list, () means generator
 2) the start is required, step and end are optional.

 Also, this can be nicely integrated with enumerations (if they will
 appear in python). Haskell is also example of such integration.

With some abuse of the language one can already do a number of things
in python2.4 now.

import sys
from types import SliceType

class vslice(object):

def __init__(self, fun):
self.fun = fun

def __getitem__(self, inx):
if not isinstance(inx, tuple):
  inx = inx,
return self.fun(*inx)

@vslice
def rnglst(*arg):
lst = []
for el in arg:
if type(el) is SliceType:
start = el.start or 0
stop = el.stop or sys.maxint
step = el.step or 1
if step  0:
while start  stop:
lst.append(start)
start += step
else:
while start  stop:
lst.append(start)
start += step
else:
lst.append(el)
return lst
 
rnglst[3,4,5] -- [3, 4, 5]
rnglst[1, 2:8] -- [1, 2, 3, 4, 5, 6, 7]
rnglst[3:9:2, 21:6:-3] -- [3, 5, 7, 21, 18, 15, 12, 9]

-- 
Antoon Pardon

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


Re: New Python.org website ?

2006-01-18 Thread Fredrik Lundh
Shalabh Chaturvedi wrote:

 Hm. Am I the only one not particularly impressed?

no.

the design is alright (if a bit too bland business), but the little I've seen 
of the
information architecture and the backend infrastructure feels like 1998 (which,
I suppose, was when the project started...)

on the other hand, I haven't tracked the discussions that resulted in the 
current
architecture, so I'm probably missing something...

/F 



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


Re: Find and slice problem

2006-01-18 Thread Juho Schultz
[EMAIL PROTECTED] wrote:
 Hi guys, been going around in circles with this so I hope you can help!
 
 My current situation is I'm using Grinder and Jython to test pages, but
 the log on process is giving me some headaches. After entering the
 correct username and password, you then need to enter 3 characters from
 the security phrase. I'm attempting to read the HTML to find out with
 characters I need (e.g. 1st, 3rd and 6th char) then look up those
 values in the security phrase, but I'm getting stuck on the following
 function:
 
 code
 
 def getValue(page,delimEnd) :
 EndVar = page.find(delimEnd)
 thisVar =  page[EndVar-1:EndVar]
 return thisVar
 
 /code
 
 What I'm attemping to pass in is some multiline HTML(above) and pick up
 the proceeding character, but it seems to be reading from the end of
 the HTML instead!

page.find(delimEnd) returns -1 if delimEnd is not found, and after that 
you take page[-2:-1], i.e. second last character.

So you could add a test for that, if EndVar == -1 etc.
but I recommend using page.index(delimEnd) which raises an error if 
delimEnd is not found.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 10060, 'Operation timed out'

2006-01-18 Thread Steve Holden
Sumit Acharya wrote:
 can u please modify the script that i have posted with your suggestion,
 it will help me to a certain extent.
 
 Thanks
 
from ftplib import FTP
import time
import sys
import socket

socket.setdefaulttimeout(60)
host = sys.argv[1]
port = sys.argv[2]

for x in range(1000):
try:
y = time.time()
 ftp = FTP()
 ftp.connect(host,port)
 ftp.login('a','a')
 try:
 print ftp.sendcmd('pass x')
 except:
 print sys.exc_value
 ftp.close()
except:
 print sys.exc_value
 r = time.time()
 print Timeout %d %d %((r-y),x)



-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: New Python.org website ?

2006-01-18 Thread Steve Holden
Tim Golden wrote:
[...]
 You might argue that the beta shouldn't have been unveiled
 without suitable text etc. But I would say: well done to
 the people who've made the effort and put the beta
 together. It's been mentioned that the whole thing is
 downloadable and open to contributions, so maybe that's
 the way forward for you: make or implement your suggestions
 and send them back to the maintainers.
 
Your surmise is correct, Tim. Anyone wishing to get involved will also 
have the joy of working on a subversion-maintained master - this is 
remarkably easy in Windows using Tortoise as well as through the 
hair-shirt commands line preferred by Linux types :-)

Checkins to subversion cause an automated update in the site content.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: New Python.org website ?

2006-01-18 Thread Tim N. van der Leeuw
 Checkins to subversion cause an automated update in the site content.

Good :) What's the subversion URL where I can fetch the site? ;)

regards,

--Tim

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


Re: New Python.org website ?

2006-01-18 Thread Steve Holden
Tim N. van der Leeuw wrote:
Checkins to subversion cause an automated update in the site content.
 
 
 Good :) What's the subversion URL where I can fetch the site? ;)
 
The URL is

   https://svn.python.org/www/trunk/beta.python.org

but I don't know whether anonymous access is enabled. Maybe you can let 
me know ...

You'll also need the notes from

   http://psf.pollenation.net/cgi-bin/trac.cgi

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: New Python.org website ?

2006-01-18 Thread Tim Golden
[Steve Holden]

|   https://svn.python.org/www/trunk/beta.python.org

| but I don't know whether anonymous access is enabled. Maybe you can
let
 |me know ...

Doesn't look like it. Asking me for authentication.

TJG

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


Re: New Python.org website ?

2006-01-18 Thread Tim N. van der Leeuw
Steve,

My apologies if this apppeared to be 'slagging'. I was trying to give
some feedback but I do realize that I don't have anything better to
offer yet to replace the pictures I dislike.

Perhaps I should have withheld my criticisms until I could offer an
alternative. (Still thinking about what could be there instead of those
3 pictures. But I'd like there to be some actual real Python content,
or links to events from the Python Events Calender; or perhaps links to
large python projects like Zope -- something that links to the major
parts of Python. Perhaps 1 picture that links to Python Web Development
including things like Zope, Django, etc; another picture that links to
a page giving overview of major IDEs for Python; and 3d picture that
links to page with Python Event calender... Something along those
lines. But I don't have any graphics for you.)

regards,

--Tim

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


Re: New Python.org website ?

2006-01-18 Thread Steve Holden
Tim N. van der Leeuw wrote:
 Steve,
 
 My apologies if this apppeared to be 'slagging'. I was trying to give
 some feedback but I do realize that I don't have anything better to
 offer yet to replace the pictures I dislike.
 
That's absolutely fine, the redevelopment of the site is intended to be 
an open process. I just didn't want creativity wasted in criticizing 
content that was only there as a placeholder.

You also gave me a chance to recruit further content editors, which is 
something we really need to do.

 Perhaps I should have withheld my criticisms until I could offer an
 alternative. (Still thinking about what could be there instead of those
 3 pictures. But I'd like there to be some actual real Python content,
 or links to events from the Python Events Calender; or perhaps links to
 large python projects like Zope -- something that links to the major
 parts of Python. Perhaps 1 picture that links to Python Web Development
 including things like Zope, Django, etc; another picture that links to
 a page giving overview of major IDEs for Python; and 3d picture that
 links to page with Python Event calender... Something along those
 lines. But I don't have any graphics for you.)
 
Keep thinking!

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: New Python.org website ?

2006-01-18 Thread Steve Holden
Tim Golden wrote:
 [Steve Holden]
 
 |   https://svn.python.org/www/trunk/beta.python.org
 
 | but I don't know whether anonymous access is enabled. Maybe you can
 let
  |me know ...
 
 Doesn't look like it. Asking me for authentication.
 
Rats, thanks for letting me know. As a first step I'd like to open up 
anonymous access to both the content and the site generation software, 
so that people can experiment with local content generation.

Then once someone knows how to use the system they can get a login for 
the SVN system and start editing site content.

I'll get back to the list with instructions ASAP. It may take a while 
due to inter-continental time differences and general overwork.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: New Python.org website ?

2006-01-18 Thread Tim N. van der Leeuw
I need to supply a username/password before I can look at the SVN
repository in my webbrowser; I tried username/pwd 'anonymous' but that
don't work.

cheers,

--Tim

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


Re: magical expanding hash

2006-01-18 Thread Steven D'Aprano
On Tue, 17 Jan 2006 18:00:00 -0700, Steven Bethard wrote:

 Steve Holden wrote:
 Steven Bethard wrote:
 Agreed.  I really hope that Python 3.0 applies Raymond Hettinger's 
 suggestion Improved default value logic for Dictionaries from
  http://wiki.python.org/moin/Python3%2e0Suggestions

 This would allow you to make the setdefault() call only once, instead 
 of on every lookup:

  class meh(dict):
  def __init__(self, *args, **kwargs):
  super(meh, self).__init__(*args, **kwargs)
  self.setdefault(function=meh)

 STeVe

 In fact, why not go one better and also add a default keyword 
 parameter to dict()?
 
 It's not backwards compatible:
 
   dict(default=4)
 {'default': 4}
 
 And I use the **kwargs form of the dict constructor often enough to hope 
 that it doesn't go away in Python 3.0.

I don't like the idea of all dicts having default values. Sometimes you
don't want a default value, you want an exception when the key isn't in
the dict.

And even if you do want defaults, sometimes you want a default which is
global to the dict, and sometimes you want a default which depends on the
key. More of a missing value than a default.

I vote to leave dict just as it is, and add a subclass, either in a module
or as a built in (I'm not fussed either way) for dicts-with-defaults.



-- 
Steven.

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


Re: New Python.org website ?

2006-01-18 Thread Roel Schroeven
Tim N. van der Leeuw schreef:
 Shalabh,
 
 You've managed very well to express the same things I feel about the
 new Python website.

FWIW, I don't like the new site at all. It tries to look slick (but 
fails to do so in my opinion), and buries the useful information in all 
kinds of misplaced eye candy.

In fact I like the old one better: short, clear and to the point.

-- 
If I have been able to see further, it was only because I stood
on the shoulders of giants.  -- Isaac Newton

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


Being unjust

2006-01-18 Thread Kay Schluehr
I'd be interested in what people think about bundling one of the
diverse Python webframeworks with the Python distribution which will be
just there as like Tcl/Tk+Tkinter for GUI-programming. Its not that I
don't trust people to make qualified decisions on their own or that I
actually believe in one single best solution. It's more a symbolic
action of bundling forces and attention.

Kay

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


Re: check to see if value can be an integer instead of string

2006-01-18 Thread Steven D'Aprano
On Tue, 17 Jan 2006 18:02:52 -0800, nephish wrote:

 Hello there,
 i need a way to check to see if a certain value can be an integer. I
 have looked at is int(), but what is comming out is a string that may
 be an integer. 

Not in Python it isn't. int(value) returns an int, not a string.

 i mean, it will be formatted as a string, but i need to
 know if it is possible to be expressed as an integer.
 
 like this
 
 var = some var passed to my script
 if var can be an integer :
 do this
 else:
 change it to an integer and do something else with it.


So, let's see if I understand your problem: 

if var can be an integer, you do this (whatever this is).

If var *can't* be an integer, you change it to an integer anyway.



 whats the best way to do this ?


try:
int(var)
except ValueError:
raise
else:
do_this()


Or even simpler:

int(var)
do_this()


-- 
Steven.

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


Re: Being unjust

2006-01-18 Thread Fredrik Lundh
Kay Schluehr wrote:

 I'd be interested in what people think about bundling one of the
 diverse Python webframeworks with the Python distribution which will be
 just there as like Tcl/Tk+Tkinter for GUI-programming.

if you can find one that's relatively stable, simple enough to enable beginners 
to
do simple things with just a little python code, can do simple stuff without 
needing
a full-blown DB, and can run as an ordinary CGI if necessary, I'm definitely +1.

(hmm.  maybe web.py fits the spec?  but that's more a library than a frame-
work, of course...)

/F 



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


Re: On Numbers

2006-01-18 Thread Steven D'Aprano
On Tue, 17 Jan 2006 23:34:40 +, Tom Anderson wrote:

...

 So I don't really know what point you are making. What solution(s) for 
 1**0.5 were you expecting?

 He's probably getting at the fact that if you're dealing with complex 
 numbers, square root get a lot more complicated:

  http://mathworld.wolfram.com/SquareRoot.html

 But still, that doesn't change the fact that x**0.5 as is meant here is 
 the principal (positive) real square root, and that can be true whether 
 your hierarchy of numeric types includes a complex type or not.
 
 Er, actually, i meant to write -1, but evidently missed a key, and failed 
 to check what i'd written.

Since exponentiation has higher priority than negation, -1**0.5 is -1.0 in
both Python and ordinary mathematics. 

Perhaps you meant to write (-1)**0.5, in which case Python developers have
a decision to make: should it assume real-valued maths unless explicitly
told differently, and hence raise an exception, or coerce the result to
complex?

In this case, Python raises an exception, as it should, unless you
explicitly uses complex numbers. That's the best behaviour for the
majority of people: most people don't even know what complex numbers are,
let alone want to deal with them in their code. Python, after all, is not
Mathematica.


-- 
Steven.

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


Re: Being unjust

2006-01-18 Thread Steven D'Aprano
On Wed, 18 Jan 2006 03:27:56 -0800, Kay Schluehr wrote:

 I'd be interested in what people think about bundling one of the
 diverse Python webframeworks with the Python distribution which will be
 just there as like Tcl/Tk+Tkinter for GUI-programming. Its not that I
 don't trust people to make qualified decisions on their own or that I
 actually believe in one single best solution. It's more a symbolic
 action of bundling forces and attention.

So long as I don't have to listen to the hordes of people arguing about
which framework gets preferred status, it sounds like a good move to me.


-- 
Steven.

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


Re: On Numbers

2006-01-18 Thread Erik Max Francis
Steven D'Aprano wrote:

 Perhaps you meant to write (-1)**0.5, in which case Python developers have
 a decision to make: should it assume real-valued maths unless explicitly
 told differently, and hence raise an exception, or coerce the result to
 complex?
 
 In this case, Python raises an exception, as it should, unless you
 explicitly uses complex numbers. That's the best behaviour for the
 majority of people: most people don't even know what complex numbers are,
 let alone want to deal with them in their code. Python, after all, is not
 Mathematica.

Note that cmath.sqrt returns the expected complex result for 
cmath.sqrt(-1.0).

-- 
Erik Max Francis  [EMAIL PROTECTED]  http://www.alcyone.com/max/
San Jose, CA, USA  37 20 N 121 53 W  AIM erikmaxfrancis
   Our purpose is to make the agony of decision-making so intense that
   you can escape only by thinking. -- Fred W. Friendly
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Being unjust

2006-01-18 Thread Fuzzyman

Fredrik Lundh wrote:
 Kay Schluehr wrote:

  I'd be interested in what people think about bundling one of the
  diverse Python webframeworks with the Python distribution which will be
  just there as like Tcl/Tk+Tkinter for GUI-programming.

 if you can find one that's relatively stable, simple enough to enable 
 beginners to
 do simple things with just a little python code, can do simple stuff without 
 needing
 a full-blown DB, and can run as an ordinary CGI if necessary, I'm definitely 
 +1.

 (hmm.  maybe web.py fits the spec?  but that's more a library than a frame-
 work, of course...)


web.py has the great advantage that (allegedly) you can migrate apps
from CGI to FastCGI, mod_python, WSGI.

It hardly counts as stable of course - having just been released. +1 on
including it though ;-)

To be fair, it would be better to incldue a library rather than a
framework in the standard library.

There are a few fundamental philosophy differences in web apps which
makes it a bit of a religious war. This means getting something into
the standard library is likely to be the cause of intractable
discussions. *sigh*

I think Ian Bickings approach (ius this WSGI or paste ??) is to develop
a framework that componentizes the elements of web applications. (I
geuss it's a protocol as much as a framework). This means that you're
not locked into design decisions at the start of the game - and
components developed that follow the protocol can be easily re-used in
other projects.

Unfortuantely they (he ?) have made the API a blocking API (WSGI at
least is blocking) - this means it can't be used without threads. So
there is still a fundamental philosophy question here.

Other frameworks like Django and turbogears can't (as easily) share
parts of applications designed for the other framework. It would be
very difficult to jsutify including one over the other to include in
the standard library.

All the best,

Fuzzyman
http://www.voidspace.org.uk/python/index.shtml

 /F

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


making objects unassignable read-only (especially when extending)

2006-01-18 Thread Johannes Zellner
Hi,

can I make an object read-only, so that

x = new_value

fails (and x keeps it's orginal value)?

This would be especially of interest for me for an object created by
a c extension.

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


Re: Newcomer question wrt variable scope/namespaces

2006-01-18 Thread Magnus Lycka
Florian Daniel Otel wrote:
 Do I understand it correctly
 that actually the rule has to be refined as pertaining  to the (so
 called) immutable types (like e.g.  integers, tuples/strings)
 whereas lists and dictionaries are mutable types and the said
 scoping rule does not apply ?

No! The only difference between mutable and immutable
objects are that the value of mutable objects can be
changed after object creation.

The thing you need to understand is how variables, objects
and assignments work in Python! We are always dealing with
references to objects in Python.

In e.g. C, the code int c; c=1; c=2; roughly means:
Make a place for an integer in memory, and let's refer
to that place as c. Then place the value 1 in c.
Finally, replace the value 1 with the value 2 in c.

This isn't at all how Python works. I think of C variables
as differently shaped (typed) boxes with a label glued onto
the side, but I think of Python variables as a tag or label
tied to a string (string as in thin rope, not text). The
other end of that string is tied to an object in a big,
shared storage room.

C assignments mean that you make a copy of some data and
put in a box, discarding whatever was previously in that
box. Python assignment means that you untie a string from
an object and tie it to another (possibly newly created)
object. When an object no longer has any strings attached,
it's (usually) considered to be garbage.

So, in Python, c=1; c=2 means that you have a variable
(or name) called c in the current namespace. That's not a
place for some kind of object as in C, it's just a name
that can be bound to some object in that shared storage
room that we nerds call the heap. First, c will be bound
to, or refer to, an integer object on the heap containing
the value 1. Then c will be rebound to another object, 2.

In C, you have your different boxes neatly stacked in
various namespaces. In Python the boxes are all in one place,
but your labels are neatly organized in various namespaces.

You can make strings like this in C too, they are called
pointers, but it's not automatic as in Python, and C
pointers are much more difficult and error prone.

So, returning to your question, scoping rules are just
the same. The issue with mutable object are that they can
be mutated. Different variables in different namespaces
can refer to the same object. E.g.

  l = [1,2]
  def addToList1(aList, value):
... aList.append(value)
... return aList
...
  def addToList2(aList, value):
... newList = aList + [value]
... return newList
...
  print l
[1, 2]
  print id(l)
182894638800
  l1=addToList1(l,3)
  print l, l1
[1, 2, 3] [1, 2, 3]
  print id(l), id(l1)
182894638800 182894638800
  l2=addToList2(l,4)
  print l, l2
[1, 2, 3] [1, 2, 3, 4]
  print id(l), id(l2)
182894638800 182894638736

You see? Calling addToList1 caused the list object that was
passed in to be modified. This modification is obviously
seen by all variables that are bound to that object, whatever
namespace they exist in.

Calling addToList2 doesn't cause any modification of the
objects that the parameters are bound to. Instead a new object
is created.

With immutable objects, you can't possibly do something along
the lines of addToList1. This means that if x is bound to an
immutable object, x will always have the same value before and
after a call to f(x), whatever code function f contains. If
x is mutable, you have no such guarantees. It depends on f...

It's not only variables that can be bound to objects. E.g:
  l1 = []
  l2 = [l1]
  t1 = [l1]
  print l1, l2, t1
[] [[]] [[]]
  t1[0].append(1)
  print l1, l2, t1
[1] [[1]] [[1]]

l1, position 0 in l2 and position 0 in t1 are all bound to the
same object, an initially empty list.


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


Debugging python 2.2 code with Pydev

2006-01-18 Thread coujou
It's all in the title. Is there a way (using Pydev) to debug code
written for and executed by python 2.2 ?

I have only the 2.2 interpreter installed. The run command works fine
but the debugger tells me : Unexpected error setting up the debugger.
(More info below).

I'm working under windowsXP with Eclipse 3.1 and PyDev 0.9.8.7. I can
install another interpreter if needed but the program I'm working on
must still be executed by 2.2

Any help is greatly appreciated.
Thank you,
Coujou

--

Traceback (most recent call last):
  File C:\Program
Files\eclipse\plugins\org.python.pydev.debug_0.9.8.7\pysrc\pydevd.py,
line 68, in ?
import pydevd_vars
  File C:\Program
Files\eclipse\plugins\org.python.pydev.debug_0.9.8.7\pysrc\pydevd_vars.py,
line 38, in ?
from org.python import core
ImportError: No module named org.python

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


extending python: which python code calls the c iterator methods?

2006-01-18 Thread Johannes Zellner
Hello,

when extending python there are type methods tp_iter and tp_iternext. 
Which python code calls the c iterator methods?

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


[OT] Nit: please don't user it's unless you can substitute it is without changing your inteded meaning.

2006-01-18 Thread Bengt Richter
Typos happen to all of us, but in case you hadn't realized what it's
is a contraction for (it is), now you do, and you can save yourself further
embarrassment (assuming you care ;-).
If your friends won't tell you, who will ;-)

Write the contraction it's only when you want its meaning
to be it is, otherwise it's wrong ;-)

OTOH, how does one punctuate the posessive of a word per se?
E.g., the first letter of it is i, but can one write that
as it's first letter is i, or it's first letter is i ? ;-)
And how many its (?) are there in the previous sentence?

I wonder if Eats Leaves and Shoots (a book on punctuation) has something on 
that.
(vs, Eats, Leaves, and Shoots -- panda vs gunslinger).

Regards,
Bengt Richter
-- 
http://mail.python.org/mailman/listinfo/python-list


Can a simple a==b 'hang' in and endless loop?

2006-01-18 Thread Claudio Grondi

In the process of learning about some deeper details of Python I am 
curious if it is possible to write a 'prefix' code assigning to a and b 
something special, so, that Python gets trapped in an endless loop in a 
line with:

if a==b: print 'OK'

I mean, it would be of much help to me on my way to understanding Python 
to know how such prefix code leading to an endless loop can look like 
and if it is eventually not possible to write such code, to know why it 
is not possible?

My own first rough idea was to create generators which never end and use 
them in the '==' comparison, but I have not well understood how to write 
and use generators yet, so I expect from studying this special case to 
come to some enlightenment.

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


Re: making objects unassignable read-only (especially when extending)

2006-01-18 Thread Simon Brunning
On 18 Jan 2006 11:59:23 GMT, Johannes Zellner [EMAIL PROTECTED] wrote:
 Hi,

 can I make an object read-only, so that

 x = new_value

 fails (and x keeps it's orginal value)?

This works for me:

http://groups.google.com/group/comp.lang.python/msg/2b1785397358ff90

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: chi-squared tests in python?

2006-01-18 Thread Michael Anthony Maibaum

On 17 Jan 2006, at 20:32, Rob Cowie wrote:

 Matthew
 ps: given the batteries included philosphy, there's a  
 remarkable dearth
 of stats in python...

 I think Chi^2 tests fall distinctly in the third-party library  
 category, myself.

 I don't know... I've often thought the Standard Library should include
 a stats package.

Coming from the scientific community I agree. A relatively shallow  
selection of standard statistical methods would be very useful to  
avoid requiring people to install a relatively large external package  
(e.g. scipy) for a few simple stats methods.

cheers,
Michael
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Can a simple a==b 'hang' in and endless loop?

2006-01-18 Thread Fredrik Lundh
Claudio Grondi wrote:

 In the process of learning about some deeper details of Python I am
 curious if it is possible to write a 'prefix' code assigning to a and b
 something special, so, that Python gets trapped in an endless loop in a
 line with:

 if a==b: print 'OK'

 I mean, it would be of much help to me on my way to understanding Python
 to know how such prefix code leading to an endless loop can look like

since == can be overridden by the objects involved, == can do anything:

http://docs.python.org/ref/customization.html

__lt__ __div__ F __gt__ 



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


Re: Nit: please don't user it's unless you can substitute it is without changing your inteded meaning.

2006-01-18 Thread Fuzzyman

Bengt Richter wrote:
 Typos happen to all of us, but in case you hadn't realized what it's
 is a contraction for (it is), now you do, and you can save yourself further
 embarrassment (assuming you care ;-).
 If your friends won't tell you, who will ;-)


Making grammatical errors in the subject of a post on gramamtical
errors must be embarrasing. ;-)

 Write the contraction it's only when you want its meaning
 to be it is, otherwise it's wrong ;-)

 OTOH, how does one punctuate the posessive of a word per se?
 E.g., the first letter of it is i, but can one write that
 as it's first letter is i, or it's first letter is i ? ;-)
 And how many its (?) are there in the previous sentence?


Don't recall an answer to this one in Eats, Shoots and Leaves.

The first one is clearer :

it's first letter is i

All the best,


Fuzzyman
http://www.voidspace.org.uk

 I wonder if Eats Leaves and Shoots (a book on punctuation) has something on 
 that.
 (vs, Eats, Leaves, and Shoots -- panda vs gunslinger).
 
 Regards,
 Bengt Richter

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


Re: check to see if value can be an integer instead of string

2006-01-18 Thread nephish
it isn't really that i will want to change it to an integer anyway. the
script uses a table to reference a value to a key, if the key is a
group of letters, that code tells the script to do something. if the
value is a number, it means an equipment failure. The thing is, all the
values come out as strings (they are read from a text file).
so what you put first with the try/except looks like my best answer.

thanks,
shawn

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


Re: On Numbers

2006-01-18 Thread Steve Holden
Erik Max Francis wrote:
 Steven D'Aprano wrote:
 
 
Perhaps you meant to write (-1)**0.5, in which case Python developers have
a decision to make: should it assume real-valued maths unless explicitly
told differently, and hence raise an exception, or coerce the result to
complex?

In this case, Python raises an exception, as it should, unless you
explicitly uses complex numbers. That's the best behaviour for the
majority of people: most people don't even know what complex numbers are,
let alone want to deal with them in their code. Python, after all, is not
Mathematica.
 
 
 Note that cmath.sqrt returns the expected complex result for 
 cmath.sqrt(-1.0).
 
   import cmath
   cmath.sqrt(-1)
1j
  

Indeed. But even exponentiation can come respectably close:

   (-1+0j)**0.5
(6.123233995736766e-17+1j)

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: Nit: please don't user it's unless you can substitute it iswithout changing your inteded meaning.

2006-01-18 Thread Fredrik Lundh
Fuzzyman wrote:

 Making grammatical errors in the subject of a post on gramamtical
 errors must be embarrasing. ;-)

http://linuxmafia.com/~rick/lexicon.html#moenslaw-corrections

/F 



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


Re: extending python: which python code calls the c iterator methods?

2006-01-18 Thread Fredrik Lundh
Johannes Zellner wrote:

 when extending python there are type methods tp_iter and tp_iternext.
 Which python code calls the c iterator methods?

iter(obj), for-in obj, etc.

/F 



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


Re: New Python.org website ?

2006-01-18 Thread Tim Parkin
Shalabh Chaturvedi wrote:
 Hm. Am I the only one not particularly impressed? Sure the front page is 
 'slick' but a few clicks reveal a fairly shallow facade of marketing 
 material, with no real content. In general gives the impression of 
 'phony' company trying to make a big impression. Most good non-tech 
 managers are very wary of such organizations/companies.
Well apart from the front page and a couple of pages providing content
specific to different types of usersm the whole site is the same as it
was before. Do you have a problem with marketing python or with the
content of the python site? Could you expand on why you think the beta
site looks 'phony'?

 
 My gripes with the whole thing:
 
 1. Learn why.., Learn why.., Learn more..? Unless each one takes you 
 directly to a great success story, these should be removed.
These will link directly to success stories.

 2. There is no (published) Python success story for Google. So link to 
 google.com looks phony. What does 'Google written in Python' mean 
 anyway? The google.com server is Python? One backend script is in 
 Python? Without more information, this just seems likes a shameless 
 attempt to create credibility. (Sure I know Google uses Python 
 extensively, but I'm not the one who needs to be sold on Python).
Python has been an important part of Google since the beginning, and
remains so as the system grows and evolves. Today dozens of Google
engineers use Python, and we're looking for more people with skills in
this language. said Peter Norvig, director of search quality at Google,
Inc. 

thats what it says on the old site right at the top of the page...

 3. What is PyXP? Windows XP? Extreme Programming? Again, there is 
 nothing underneath. Where is the NASA success story?
That particular graphic will probably be updated. The Nasa success story
is at

http://www.python.org/Quotes.html


 4. I have a lot of respect for GvR, but there ought to be more 
 advertising of the fact that the language is not supported by just one 
 person. There is an great dev team behind it and a stable PSF 
 organization. Anyone reading 'developed by one person' is not left with 
 the fuzzy feeling of a mature, well-supported product that is here to stay.
So you think we should add some copy that creates a more positive
impression of python? Thanks for your suggestion to rewrite the copy
regarding the team behind python. Could you come up with some
alternative for this?

 5. A 'more..' link under Written in Python is sorely missing. It appears 
 only 5-6 apps are written in Python. Where is a link to the cheese shop?
Yep... at the moment content is being migrated across. If you want to
add your assistance it would be of great benefit.



 Managers are looking for maturity, stability, support and unique 
 strengths, not coolness or flashy sites (though presentation definitely 
 helps).
Could you tell me what about the site makes you think it looks 'cool' or
'flashy'?


 Hopefully most of these will get fixed as people 'convert' the site and 
 fill in content. I would urge people to do some 'user' testing - get 
 persons not very familiar with Python and get their honest opinion on 
 the site.
We have done... The feedback was that some pictures would help engage
people who view the website for the first time. This was especially true
of non-programmers who may be assessing python as part of a business
decition (who will probably not get further than the home page).

Most developers tended to want to jump straight into bookmarked parts of
the site or just check the updated news. People wanting to learn about
python would try to find a 'for beginners' link (hence the prominence of
this).

Currently, it is more important to get existing copy across than create
the few new pages that are needed to support the home page. If we had
more volunteers then we could write this new content sooner.

A summary of questions whose answers may help us:

Do you have a problem with the way we are trying to 'market' python?
Which content in particular do you have an objection to?
Could you expand on why you think the beta site looks 'phony'?
Could you tell me what about the site makes you think it looks 'cool' or
'flashy'?
Could you come up with some alternative for the intro copy about python?

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


Re: New Python.org website ?

2006-01-18 Thread Tim Parkin
Tim N. van der Leeuw wrote:
 Shalabh,
 
 You've managed very well to express the same things I feel about the
 new Python website.
 
 What I especially dislike about the new website are the flashy pictures
 on the front-page with no content and no purpose -- purely boasting but
 nothing to back up your claims.
Thats because the content hasn't been written yet. We're concentrating
on getting the existing copy over first.

 
 (I wouldn't mind some sleek pictures there if they weren't desperatly
 trying to advertise success-stories but instead would link to real
 content!)
 
 I do like to overall look-and-feel of the beta site but I hope the bad
 bits get fixed before launch!
Can you give me a list of bad bits to fix (or you could add them to the
trac site at psf.pollenation.net)

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


Re: On Numbers

2006-01-18 Thread Erik Max Francis
Steve Holden wrote:

import cmath
cmath.sqrt(-1)
 1j
   
 
 Indeed. But even exponentiation can come respectably close:
 
(-1+0j)**0.5
 (6.123233995736766e-17+1j)

Oh, no doubt.  I was just pointing out that cmath.sqrt is what you want 
if you really do want the complex result rather than the principal real one.

-- 
Erik Max Francis  [EMAIL PROTECTED]  http://www.alcyone.com/max/
San Jose, CA, USA  37 20 N 121 53 W  AIM erikmaxfrancis
   Dear World: I am leaving because I am bored.
   -- George Sanders (in his suicide note)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 10060, 'Operation timed out'

2006-01-18 Thread Sumit Acharya
Hi Steve,

It didnt help, i am getting same error.

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


Re: New Python.org website ?

2006-01-18 Thread Tim Parkin
Roel Schroeven wrote:
 Tim N. van der Leeuw schreef:
 
Shalabh,

You've managed very well to express the same things I feel about the
new Python website.
 
 
 FWIW, I don't like the new site at all. It tries to look slick (but 
 fails to do so in my opinion), and buries the useful information in all 
 kinds of misplaced eye candy.
 
 In fact I like the old one better: short, clear and to the point.

Can you make some specific comments about which 'eye candy' that you
find objectionable and which parts of the navigation structure you find
confusing?

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


mod_python apache directives

2006-01-18 Thread jacob . miles
Hello.  I want to create a catch-all python script, that gets called
for any file request in a certain directory.  I thought this apache
setup would do it, but it doesn't:

Directory /Users/jake/www/mydir
SetHandler mod_python
PythonHandler handler
PythonDebug On

Options -MultiViews -Indexes
/Directory

For example, I have a handler.py in that directory, but when I go to
the url 'http://127.0.0.1/mydir/handler.py', it delivers the text of
handler.py - not my intention.  And if I enter any other filename, it
gives me a 404 Not found.

Does anyone know how to do what I'm trying to do?

- Jake

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


Re: Newcomer question wrt variable scope/namespaces

2006-01-18 Thread Florian Daniel Otel
Mike, Gary, Magnus

First of all, thanks to you all for the clarifications.

On 1/14/06, Mike Meyer [EMAIL PROTECTED] wrote:
 Python variables are just names. They refer to (are bound to)
 objects. An assignment statement doesn't change a value. It rebinds
 the variable (or lvalue) to the value on the right side of the
 statement.

 The Python rule is that you can only bind a local variable or a
 variable declared global. It doesn't say anything at all about what
 you can do to the objects so bound.

Based on Mike explanation and Gary and Magnus illustrative examples
(and a perusal of the  Chapter 4 from my current bible -- Python in a
Nutshell) I now understood the way Python handles varialbles, objects
(mutable or not) and the bindings between the two.

As Mike figured it out, coming from a low-level language (e.g. C,
where call by value and call by reference are like nightday and
memory mngmnt is to be handled explicitely)  was a bit of a challenge.
Even if I am not exactly new to programming it wasn't quite obvious in
the first place how Python handles the mapping btw lvalues and rvalues
(the s.c. variable binding) and how object and (respectively)
variable scoping works.  One can only wish that various python texts
(like e.g. the official Python tutorial) would be more forthcoming on
this fundamental paradigm shift.

Anyway, thanks Mike, Gary and Magnus for the very useful hints and
illustrations.

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


RE: New Python.org website ?

2006-01-18 Thread Leeuw van der, Tim
Hi Tim,

-Original Message-
From: Tim Parkin [mailto:[EMAIL PROTECTED] 
Sent: woensdag 18 januari 2006 13:45

 
 That sounds fine.. I think having a link to a high profile user of
 python would be very useful though. I agree the XP link is a bit
shite.
 Hopefully we'd get the photos and links to success
 stories/events/software changing every now and again..

I think that in general, I don't like the fact that links to
high-profile users are featured so prominently. That row of pictures
there looks good to me 'as such' but linking there to 'success stories'
feels, dunno, perhaps a bit cheesy to me. (That might be just my dutch
upbringing)
I would certainly want to see such links somewhere on the front page,
just not so prominently.


 how about

 1) High profile user of Python
 2) Link to upcoming python event
 3) Link to web development uses of python

 the only problem is

 1) people will argue over which user of python to put up
 2) This will probably just be pycon and europython.. which is no bad
 thing.. until we get more than two conferences at similar times..
which
 one should we show?
 3) python isn't just about web development..

 Suffice it to say we'll have some content and the example images will
 change every now and again.

 btw do you have a problem with using nasa or astrazeneca as example
high
 profile users?

As I said, I don't like them. We're not a commercial company trying to
promote itself to potential buyers. But that's too a large degree a
matter of taste.
I do actually think, though, that if the Python website *is* going to
feature such big names with such prominence, some sort of approval from
these organizations should be requested? That they don't mind being used
a a Python reference story?


About what could be there... Link to the even calender, or
recent/upcoming event.. That is one to stay, I think.
I think it would be good to have a link there too development
environments that can be used for Python: editors, debuggers, IDEs / IDE
extenstions, etc

A third item could perhaps be a link to the Python Package Index --
another thing that Python developers are likely to need.

These things are, of course, rather developer-centered (well,
Python-user centered...)
Being a software developer that uses Python, I wouldn't really know what
else to put there ;-)
But many people might have other things they wish to put in the centre
of attention on the front page.


 Tim


Regards,

--Tim

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


Puzzled by py.test output

2006-01-18 Thread Jan Decaluwe
I'm seeing a strange difference between error reporting
on local versus global variables, when using py.test.
Upon error, the actual value of a local is reported, but
not of a global. Does anyone know why? I'm using
the latest development version of py.test (from subversion).

Example code in file test.py:

--
def test_h():
 h = 0
 assert h == 1

g = 0
def test_g():
 assert g == 1
--

py.test output:

= test process starts 
testing-mode: inprocess
executable:   /usr/local/bin/python  (2.4.2-final-0)
using py lib: /usr/local/lib/python2.4/site-packages/py rev unknown

test.py[2] FF

__
_ entrypoint: test_h __

 def test_h():
 h = 0
E   assert h == 1
assert 0 == 1

[/home/jand/project/myhdl/example/cookbook/stopwatch/test.py:3]

_ entrypoint: test_g __
 def test_g():
E   assert g == 1
assert g == 1

[/home/jand/project/myhdl/example/cookbook/stopwatch/test.py:7]
_
== tests finished: 2 failed in 0.02 seconds ==

Regards,

Jan

-- 
Jan Decaluwe - Resources bvba - http://www.jandecaluwe.com
Losbergenlaan 16, B-3010 Leuven, Belgium
 From Python to silicon:
 http://myhdl.jandecaluwe.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Nit: please don't user it's unless you can substitute it is without changing your inteded meaning.

2006-01-18 Thread BartlebyScrivener
The pronominal possessives hers, its, theirs, yours, and oneself have
no apostrophe.

Strunk  White, The Elements of Style. Section II.1

The Elements is a classic masterpiece of concision and lucidity, unlike
Eats, Shoots, Sells Books, and Leaves.

rpd

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


Re: New Python.org website ?

2006-01-18 Thread Tim Parkin
Tim N. van der Leeuw wrote:
 Steve,
 
 My apologies if this apppeared to be 'slagging'. I was trying to give
 some feedback but I do realize that I don't have anything better to
 offer yet to replace the pictures I dislike.
 
 Perhaps I should have withheld my criticisms until I could offer an
 alternative. (Still thinking about what could be there instead of those
 3 pictures. But I'd like there to be some actual real Python content,
 or links to events from the Python Events Calender; or perhaps links to
 large python projects like Zope -- something that links to the major
 parts of Python. Perhaps 1 picture that links to Python Web Development
 including things like Zope, Django, etc; another picture that links to
 a page giving overview of major IDEs for Python; and 3d picture that
 links to page with Python Event calender... Something along those
 lines. But I don't have any graphics for you.)
 

That sounds fine.. I think having a link to a high profile user of
python would be very useful though. I agree the XP link is a bit shite.
Hopefully we'd get the photos and links to success
stories/events/software changing every now and again..

how about

1) High profile user of Python
2) Link to upcoming python event
3) Link to web development uses of python

the only problem is

1) people will argue over which user of python to put up
2) This will probably just be pycon and europython.. which is no bad
thing.. until we get more than two conferences at similar times.. which
one should we show?
3) python isn't just about web development..

Suffice it to say we'll have some content and the example images will
change every now and again.

btw do you have a problem with using nasa or astrazeneca as example high
profile users?

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


Re: New Python.org website ?

2006-01-18 Thread Tim Parkin
Leeuw van der, Tim wrote:

I think that in general, I don't like the fact that links to
high-profile users are featured so prominently. That row of pictures
there looks good to me 'as such' but linking there to 'success stories'
feels, dunno, perhaps a bit cheesy to me. (That might be just my dutch
upbringing)
I would certainly want to see such links somewhere on the front page,
just not so prominently.
  

Possibly so... however in my experience, selling python to people is
made a lot easier by being able to say 'look these guys are using it'.
This may not help sell it to programmers, but as a businessman trying to
sell my programming services, it's exceptionally important.


btw do you have a problem with using nasa or astrazeneca as example


high
  

profile users?



As I said, I don't like them. We're not a commercial company trying to
promote itself to potential buyers. But that's too a large degree a
matter of taste.
  

Well I'd have to disagree with yout on one point.. 'We' may not
be a commercial company (when you talk about python as a singular unit)
but as python developers, we should be in the process of trying to
'sell' python wherever we can. Because we aren't a commercial company,
our only 'sales' channels are the website and the developers/consultants
that use python. (I'm talking about selling in the terms of 'promoting'
or trying to persuade someone that using python is a good thing).

I do actually think, though, that if the Python website *is* going to
feature such big names with such prominence, some sort of approval from
these organizations should be requested? That they don't mind being used
a a Python reference story?
  

The approval is already there (see pythonology success stories).

About what could be there... Link to the even calender, or
recent/upcoming event.. That is one to stay, I think.
I think it would be good to have a link there too development
environments that can be used for Python: editors, debuggers, IDEs / IDE
extenstions, etc

  

It's difficult to summarise this in a single image. The XP image was
intended as a 'catch all' for the development environment. A different
image and title would probably achieve better results but coming up with
one or two words to sumarise that list is quite difficult.

A third item could perhaps be a link to the Python Package Index --
another thing that Python developers are likely to need.

  

The home page isn't intended to target existing python users.. and the
home page photos are mostly targetted at the sort of people that respond
well to photos. It's a dilemma that the home page has to serve two
masters, however if we have a 'developer home page' which can be
dedicated to development issues, news, planetpython links, package
libraries etc, we would have a single page that developers could bookmark.

The only alternative was to create a separate 'marketing python' website
but it would just get ignored, especially by the people we really need
to see the 'marketing' content.

These things are, of course, rather developer-centered (well,
Python-user centered...)
Being a software developer that uses Python, I wouldn't really know what
else to put there ;-)
But many people might have other things they wish to put in the centre
of atte

Yep,

Thats probably why a dedicated page for developers would make more sense.

Tim

p.s. thanks for the comments btw..
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: On Numbers

2006-01-18 Thread Tom Anderson
On Wed, 18 Jan 2006, Steven D'Aprano wrote:

 On Tue, 17 Jan 2006 23:34:40 +, Tom Anderson wrote:

 So I don't really know what point you are making. What solution(s) for
 1**0.5 were you expecting?

 He's probably getting at the fact that if you're dealing with complex
 numbers, square root get a lot more complicated:

 http://mathworld.wolfram.com/SquareRoot.html

 But still, that doesn't change the fact that x**0.5 as is meant here is
 the principal (positive) real square root, and that can be true whether
 your hierarchy of numeric types includes a complex type or not.

 Er, actually, i meant to write -1, but evidently missed a key, and failed
 to check what i'd written.

 Since exponentiation has higher priority than negation, -1**0.5 is -1.0 in
 both Python and ordinary mathematics.

 Perhaps you meant to write (-1)**0.5,

Yes.

[FX: bangs head on keyboard]

I'm still getting this wrong after all these years.

 in which case Python developers have a decision to make: should it 
 assume real-valued maths unless explicitly told differently, and hence 
 raise an exception, or coerce the result to complex?

Precisely.

 In this case, Python raises an exception, as it should, unless you 
 explicitly uses complex numbers. That's the best behaviour for the 
 majority of people: most people don't even know what complex numbers 
 are, let alone want to deal with them in their code. Python, after all, 
 is not Mathematica.

I think i agree with you, as a matter of practical value. However, this 
does go against the whole numeric unification thing we were discussing.

Hmm. What happens if i say (-1) ** (0.5+0j)? Ah, i get the right answer. 
Well, that's handy - it means i don't have to resort to cmath or sprinkle 
complex() calls all over the place for complex maths.

tom

-- 
Biochemistry is the study of carbon compounds that wriggle.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Can a simple a==b 'hang' in and endless loop?

2006-01-18 Thread Claudio Grondi
Steve Holden wrote:
 Claudio Grondi wrote:
 
 In the process of learning about some deeper details of Python I am 
 curious if it is possible to write a 'prefix' code assigning to a and 
 b something special, so, that Python gets trapped in an endless loop 
 in a line with:

 if a==b: print 'OK'

 I mean, it would be of much help to me on my way to understanding 
 Python to know how such prefix code leading to an endless loop can 
 look like and if it is eventually not possible to write such code, to 
 know why it is not possible?

 My own first rough idea was to create generators which never end and 
 use them in the '==' comparison, but I have not well understood how to 
 write and use generators yet, so I expect from studying this special 
 case to come to some enlightenment.

 Well, you could try this:
 
   class thing:
  ...   def __eq__(self, other):
  ...  return other == self
  ...
   a = thing()
   b = thing()
   a == b
 Traceback (most recent call last):
   File stdin, line 1, in ?
   File stdin, line 3, in __eq__
   File stdin, line 3, in __eq__
   File stdin, line 3, in __eq__
 ...
   File stdin, line 3, in __eq__
   File stdin, line 3, in __eq__
 RuntimeError: maximum recursion depth exceeded
  
 
 Was that what you meant? Or something more like:
 
   class thing:
  ...   def __eq__(self, other):
  ... import time; time.sleep(100)
  ...
   a = thing()
   b = thing()
   a == b
 
 regards
  Steve
Thanks for the quick reply.

I see, that I have overseen, that as Fredrik also stated, one can 
directly manipulate __eq__() as the easiest way to achieve what I 
requested.

To explain why I am not happy with it, I will try here to give some more 
background information. Sorry for not doing it directly, but as already 
stated I have forgot about the possibility to use __eq__().

In Python the built in '==' operator (when not manipulated in own code) 
behaves not as the '==' operator e.g. in C or Javascript, because it 
iterates over arrays (i.e. lists) doing many comparisons instead of 
comparing only two 'values'. Coming from C or Javascript one would 
expect '==' to compare the 'pointers' to the arrays and not to iterate 
over all elements of the lists.
With the solution to the question above I intended to have an example of 
Python code which outcome is an endless loop and the problem causing it 
very hard to find if one thinks in terms of C or Javascript when 
considering lists (as arrays) and the function of '==' operator.

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


Re: Nit: please don't user it's unless you can substitute it is without changing your inteded meaning.

2006-01-18 Thread Fuzzyman

BartlebyScrivener wrote:
 The pronominal possessives hers, its, theirs, yours, and oneself have
 no apostrophe.

 Strunk  White, The Elements of Style. Section II.1

 The Elements is a classic masterpiece of concision and lucidity, unlike
 Eats, Shoots, Sells Books, and Leaves.


Which is however eminently more readable, except perhaps for the
overlong introduction...

All the best,


Fuzzyman
http://www.voidspace.org.uk/python/index.shtml

 rpd

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


ldap passwd need help

2006-01-18 Thread Sells, Fred
I've got the python-ldap version 2.0.11 with python 2.4 under Linux

I've got the ldap stuff working for groups, but now I'm trying to use it to
change a user password.  I get a return of 2 and no error messages but it
does not change ldap.

I've tried it with uid = 'joeblow' and with oldpw=whatever it was with the
same result.

Anyone know what I'm missing?

class LdapUser:
def __init__(self, uri=uri, binddn=BINDDN, password=):
self.ldap = ldap.initialize(uri)
self.ldap.simple_bind(binddn, password)

def chg_pw(self,uid,oldpw,newpw):
print self.ldap.passwd_s(uid,oldpw,newpw)


if __name__==__main__:
Ldap = LdapUser(password=secret)
Ldap.chg_pw(uid=joeblow,ou=abc,ou=def,dc=ghi,dc=org,, new.pass)

---
The information contained in this message may be privileged and / or
confidential and protected from disclosure. If the reader of this message is
not the intended recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited. If you
have received this communication in error, please notify the sender
immediately by replying to this message and deleting the material from any
computer.
---
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 10060, 'Operation timed out'

2006-01-18 Thread Steve Holden
Sumit Acharya wrote:
 Hi Steve,
 
 It didnt help, i am getting same error.
 
After 20 seconds or 60?

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: Convert Active Directory Object to string

2006-01-18 Thread Dirk Hagemann
Hi Fredrik!

I think this will help me. I just have to do the same for danish
encoding and may be some further encondings...

Thanks!
Dirk

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


Re: Can a simple a==b 'hang' in and endless loop?

2006-01-18 Thread Fuzzyman

Claudio Grondi wrote:
[snip..]
 Thanks for the quick reply.

 I see, that I have overseen, that as Fredrik also stated, one can
 directly manipulate __eq__() as the easiest way to achieve what I
 requested.

 To explain why I am not happy with it, I will try here to give some more
 background information. Sorry for not doing it directly, but as already
 stated I have forgot about the possibility to use __eq__().

 In Python the built in '==' operator (when not manipulated in own code)
 behaves not as the '==' operator e.g. in C or Javascript, because it
 iterates over arrays (i.e. lists) doing many comparisons instead of
 comparing only two 'values'. Coming from C or Javascript one would
 expect '==' to compare the 'pointers' to the arrays and not to iterate
 over all elements of the lists.

In Python the equality operator ('==') compares values. For sequence
and mapping type objects this can be a (relatively) expensive
operation.

You are probably looking for the identity operator which just
(effectively) compares pointers ('is').

   a is b

does more what you would expect.

This is a better system than the ones you describe. :-)

All the best,

Fuzzyman
http://www.voidspace.org.uk/python/index.shtml

 With the solution to the question above I intended to have an example of
 Python code which outcome is an endless loop and the problem causing it
 very hard to find if one thinks in terms of C or Javascript when
 considering lists (as arrays) and the function of '==' operator.
 
 Claudio

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


Re: Converting TIFF files to PDF and/or JPEG

2006-01-18 Thread sophie_newbie
Hmm, does anyone know if there is a way to uncompress Tiff files in
python itself without having to make an os call.

This is because the script is kind of supposed to run on windows
also...

Sophie.

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


Re: [OT] Nit: please don't user it's unless you can substitute it is without changing your inteded meaning.

2006-01-18 Thread Peter Hansen
Bengt Richter wrote:
 Typos happen to all of us, but in case you hadn't realized what it's
 is a contraction for (it is), now you do, and you can save yourself further
 embarrassment (assuming you care ;-).
 If your friends won't tell you, who will ;-)

Maybe we can also hold forth on which vs. that, proper use of I 
versus me (usually the opposite of what many do), each vs. all, 
and when to use whom.  Also throw in the old stand-bys they're and 
their and other homonyms, but consider that often the mistake is not 
cause by a poor grasp of grammar but simply by writing too quickly, as 
one sometimes hears the words incorrectly in one's mind as one types, 
and then not proofreading adequately. (That's my excuse: I always catch 
their swapped with they're when proofreading, but I do sometimes use 
the wrong one when I write quickly.)

Of course, even the best of us make such mistakes, and holding everyone 
to task for it is probably not going to help.  This is a problem which 
only constant and instrusive reminders would cure, and the cure would be 
far worse than the disease.

 OTOH, how does one punctuate the posessive of a word per se?
 E.g., the first letter of it is i, but can one write that
 as it's first letter is i, or it's first letter is i ? ;-)

When a construction is awkward, pick a different one.  '''The first 
letter of the word it is i''' should be just fine.

 I wonder if Eats Leaves and Shoots (a book on punctuation) has something on 
 that.
 (vs, Eats, Leaves, and Shoots -- panda vs gunslinger).

Eats Shoots and Leaves: less cowardly than leaving _then_ shooting... 
also the actual name of the book. ;-)

-Peter

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


Re: 10060, 'Operation timed out'

2006-01-18 Thread Sumit Acharya
After 20 seconds only.

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


Re: Can a simple a==b 'hang' in and endless loop?

2006-01-18 Thread Steve Holden
Claudio Grondi wrote:
 Steve Holden wrote:
 
Claudio Grondi wrote:


In the process of learning about some deeper details of Python I am 
curious if it is possible to write a 'prefix' code assigning to a and 
b something special, so, that Python gets trapped in an endless loop 
in a line with:

if a==b: print 'OK'

I mean, it would be of much help to me on my way to understanding 
Python to know how such prefix code leading to an endless loop can 
look like and if it is eventually not possible to write such code, to 
know why it is not possible?

My own first rough idea was to create generators which never end and 
use them in the '==' comparison, but I have not well understood how to 
write and use generators yet, so I expect from studying this special 
case to come to some enlightenment.


Well, you could try this:

  class thing:
 ...   def __eq__(self, other):
 ...  return other == self
 ...
  a = thing()
  b = thing()
  a == b
Traceback (most recent call last):
  File stdin, line 1, in ?
  File stdin, line 3, in __eq__
  File stdin, line 3, in __eq__
  File stdin, line 3, in __eq__
...
  File stdin, line 3, in __eq__
  File stdin, line 3, in __eq__
RuntimeError: maximum recursion depth exceeded
 

Was that what you meant? Or something more like:

  class thing:
 ...   def __eq__(self, other):
 ... import time; time.sleep(100)
 ...
  a = thing()
  b = thing()
  a == b

regards
 Steve
 
 Thanks for the quick reply.
 
 I see, that I have overseen, that as Fredrik also stated, one can 
 directly manipulate __eq__() as the easiest way to achieve what I 
 requested.
 
 To explain why I am not happy with it, I will try here to give some more 
 background information. Sorry for not doing it directly, but as already 
 stated I have forgot about the possibility to use __eq__().
 
 In Python the built in '==' operator (when not manipulated in own code) 
 behaves not as the '==' operator e.g. in C or Javascript, because it 
 iterates over arrays (i.e. lists) doing many comparisons instead of 
 comparing only two 'values'. Coming from C or Javascript one would 
 expect '==' to compare the 'pointers' to the arrays and not to iterate 
 over all elements of the lists.
 With the solution to the question above I intended to have an example of 
 Python code which outcome is an endless loop and the problem causing it 
 very hard to find if one thinks in terms of C or Javascript when 
 considering lists (as arrays) and the function of '==' operator.
 
If your assertiona about C and Java are correct you would, of course, 
describing a deficiency of those languages, where a variable refers to a 
reserved area of storage intended to hold a value of a specific type (or 
a specific uinion of types).

To the Python user C and Java appear to be confusing equality with 
identity. The == operator in C, certainly, compares identity (whether 
of values or of pointers to structured values). Frankly I don't choose 
to remember enough Java to determine the correctness of your assertion 
in that language.

In Python a name is intended to be bound as a reference to an object of 
any type whatsoever (the type pf the object is stored as a part of the 
value). Equality is generally defined as has the same value, hence the 
ability to define it specifically for user-defined types.

In Python you test for is the same object with the is operator. As in

   a = {1:2, 3:4}
   b = {1:2, 3:4}
   a == b
True
   a is b
False
  

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Is there a maximum length of a regular expression in python?

2006-01-18 Thread olekristianvillabo
I have a regular expression that is approximately 100k bytes. (It is
basically a list of all known norwegian postal numbers and the
corresponding place with | in between. I know this is not the intended
use for regular expressions, but it should nonetheless work.

the pattern is
ur'(N-|NO-)?(5259 HJELLESTAD|4026 STAVANGER|4027 STAVANGER|8305
SVOLVÆR)'

The error message I get is:
RuntimeError: internal error in regular expression engine

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


Re: New Python.org website ?

2006-01-18 Thread Tim Parkin
Tim Golden wrote:

[Shalabh Chaturvedi]

| Hm. Am I the only one not particularly impressed? Sure the
| front page is
| 'slick' but a few clicks reveal a fairly shallow facade of marketing
| material, with no real content. In general gives the impression of
| 'phony' company trying to make a big impression. Most good non-tech
| managers are very wary of such organizations/companies.

[... snip similar stuff highlighting the relative
lightweightness of the content ...]

Ummm. I might have missed the point, and certainly what I'm about
to say is based on no more than my reading between the lines of
Steve's original announcement, but... I see the current beta
site as a layout/display/look-and-feel beta, *not* a content
beta, at least no more than is absolutely necessary to support
the look-and-feel.
  

Hi Tim,

Yep, the most effort has gone into deciding what level of change is
really necessary . Which is not a lot. The navigation has been
rearranged very slightly so that there is a consistent left hand
navigation throughout the site. The layout of the site has been changed
from table based to css based. The templates should be valid xhtml. etc.

As I've mentioned, new content needs writing and some content needs
updating but the biggest job is migrating the old content over. We'd
also like to get content from the wiki into the website (so it can be
mirrored).

Now I might be wrong, in which case your comments are pretty
much justified. But it looks to me as though most of the
content was banged in a year or so ago (or more, maybe) to
give a this-kind-of-blurb feel, some or all of which would
be replaced with current and agreed blurb before the thing
went live.

  

Most of the content that is currently on beta.python.org was added in
the last three months. Most of the top level content is about 9 months old.

You might argue that the beta shouldn't have been unveiled
without suitable text etc. But I would say: well done to
the people who've made the effort and put the beta
together. It's been mentioned that the whole thing is
downloadable and open to contributions, so maybe that's
the way forward for you: make or implement your suggestions
and send them back to the maintainers.

  

If we never put it up as a beta, I would have had to finish the whole
job on my own (which is a bit tough whilst trying to run my own company,
although the psf have helped out in this).

I'm looking forward to getting the current content over and then helping
contribute to the content more...

Thanks for the comments..

Tim

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


Re: Can a simple a==b 'hang' in and endless loop?

2006-01-18 Thread Claudio Grondi
Fuzzyman wrote:
 Claudio Grondi wrote:
 [snip..]
 
Thanks for the quick reply.

I see, that I have overseen, that as Fredrik also stated, one can
directly manipulate __eq__() as the easiest way to achieve what I
requested.

To explain why I am not happy with it, I will try here to give some more
background information. Sorry for not doing it directly, but as already
stated I have forgot about the possibility to use __eq__().

In Python the built in '==' operator (when not manipulated in own code)
behaves not as the '==' operator e.g. in C or Javascript, because it
iterates over arrays (i.e. lists) doing many comparisons instead of
comparing only two 'values'. Coming from C or Javascript one would
expect '==' to compare the 'pointers' to the arrays and not to iterate
over all elements of the lists.
 
 
 In Python the equality operator ('==') compares values. For sequence
 and mapping type objects this can be a (relatively) expensive
 operation.
 
 You are probably looking for the identity operator which just
 (effectively) compares pointers ('is').
 
a is b
 
 does more what you would expect.
 
 This is a better system than the ones you describe. :-)
 
 All the best,
 
 Fuzzyman
 http://www.voidspace.org.uk/python/index.shtml
 
 
With the solution to the question above I intended to have an example of
Python code which outcome is an endless loop and the problem causing it
very hard to find if one thinks in terms of C or Javascript when
considering lists (as arrays) and the function of '==' operator.

Claudio
 
 
Yes, I know about 'is',

but I mean, that it is not possible to use 'is' as replacement for '==' 
operator to achieve in Python same behaviour as it is the case in C and 
Javascript when comparing values with '=='.
'is' does the C, Javascript job when comparing lists, but I mean it 
fails to give fully predictable results when applied to elements of 
lists in case there exist duplicate objects with same 'value' i.e. e.g. 
there are two different objects storing the integer value 1, what I mean 
can happen when there is enough other code between the Python code lines 
assigning the integer value 1 to a list element or any other identifier.
Or is there in Python a 100% reliable mechanism assuring, that there is 
one and _only one_ object carrying a given 'value' (at least for the 
built in types as integer, long integer, string, float) and if this 
value is to be assigned to a list element or any other literal the 
already existing object (if any) will be found and used/referenced?

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


How to set a wx.textctrl can editable or readonly?

2006-01-18 Thread Hako
Hello All,


I have  a function to set readonly or editable of a textctrl. I'd like
to make the textctrl initial set readonly and use other event funciton
to set editable of the textctrl but it always can editable. How to set
a textctrl can editable or readonly?

Any Ideas? (see short snippet below)
Thanks.
---
self.tcFirstName = wx.TextCtrl(id=wxID_FRAME1TCFIRSTNAME,
  name=u'tcFirstName', parent=self.panel2, pos=wx.Point(16,
32),
  size=wx.Size(168, 24), style=0, value=u'')
self.setForm()

def setForm(self):
  self.Readonly(ro)

def Readonly(self, flag):
if flag==ro:
self.tcFirstName.style=wx.TE_READONLY
self.tcFirstName.Refresh()

self.tcFirstName.SetBackgroundColour(self.panel1.GetBackgroundColour())

else:
self.tcFirstName.style=0
self.tcFirstName.Refresh()
self.tcFirstName.SetBackgroundColour((255,255,255))

# Other event function set textctrl can editable
def OnBAddButton(self, event):
self.Readonly(o)
---
end

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


Uncompressing TIFF files directly in Python

2006-01-18 Thread sophie_newbie
Hey guys,

OK this is a long shot but does anyone know of a way to uncompress tiff
files directly in python. I know it can be done with an os call but
that'll only work on unix and only if the right software is installed!

I need to convert tiff images downloaded from uspto.gov to pdf, these
images are compressed using G4, so I dunno if anyone knows of a method
of doing this witout the os call! Surely there is a utility out there
somewhere?

Sophie

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


Re: Is there a maximum length of a regular expression in python?

2006-01-18 Thread Steve Holden
[EMAIL PROTECTED] wrote:
 I have a regular expression that is approximately 100k bytes. (It is
 basically a list of all known norwegian postal numbers and the
 corresponding place with | in between. I know this is not the intended
 use for regular expressions, but it should nonetheless work.
 
 the pattern is
 ur'(N-|NO-)?(5259 HJELLESTAD|4026 STAVANGER|4027 STAVANGER|8305
 SVOLVÆR)'
 
 The error message I get is:
 RuntimeError: internal error in regular expression engine
 
And I'm not the least bit surprised. Your code is brittle (i.e. likely 
to break) and cannot, for example, cope with multiple spaces between the 
number and the word(s). Quite apart from breaking the interpreter :-)

I'd say your test was the clearest possible demonstration that there 
*is* a limit.

Wouldn't it be better to have a dict keyed on the number and containing 
the word (which you can construct from the same source you constructed 
your horrendously long regexp)?

Then if you find something matching the pattern (untested)

ur'(N-|NO-)?((\d\d\d\d)\s*([A-Za-z ]+))'

or something like it that actually works (I invariably get regexps wrong 
at least three times before I get them right) you can use the dict to 
validate the number and name.

Quite apart from anything else, if the text line you are examining 
doesn't have the right syntactic form then you are going to test 
hundreds of options, none of which can possibly match. So matching the 
syntax and then validating the data identified seems like a much more 
sensible option (to me, at least).

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Retaining Unix EOL when reading/writing in windows

2006-01-18 Thread Nick Wain
Hello All,

I'm relatively new to PYTHON, using PYTHON 2.4 on Windows XP. I'm having a 
problem as below. I've asked some other people in my office who are more 
experienced in PYTHON, but they can't help.

I have a number of files created in UNIX that have the UNIX end of line 
(EOL) character.

I want to read these files in python, modify some lines, and then write them 
to a new file. This appears to work fine, however I find that the output 
files have Windows EOL characters. This is a pain, as I want to compare the 
before and after files to see if my changes are correct.

I've simplified my code down to something that just reads a file and then 
writes it to a different file. I'm currently doing this with a bit of code 
that looks something like this:

filename = test.lwc
outfile = open(test_out.lwc, 'w' )
readfile = open(filename,'r').readlines()

for line in readfile:
outfile.write(line)
outfile.close()

Is there a way I can do this, but retain the UNIX EOL characters?

Cheers,
Nick

_
Are you using the latest version of MSN Messenger? Download MSN Messenger 
7.5 today! http://messenger.msn.co.uk

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


Re: New Python.org website ?

2006-01-18 Thread Markus Wankus
Well I think the new site is definitely a step in the right direction. 
The old site is definitely utilitarian and is quite functional, but 
not sexy.  And I think the whole point is to (hopefully) have a good 
first impression of the language and community by impressing (if you 
will) new users with a cool website.

So, while I agree that the beta site does have a definite nineties 
corporate feel to it, I think it is better than the old site and would 
like to throw some kudos to whoever spent the time on it.  I'm sure it 
wasn't a small job.

At any rate, opinions will always differ.  You are always going to get 
the people who want a cool flash-based animated site with 3D stereo 
surround sound, and the other end of the spectrum where you will be 
flamed if you do anything more than hand-code the html, on Unix machines 
only, using Vim or Emacs, ensuring it has a gray or neutral beige 
background, *and* uses the default font giving that classic 1981 
university professor who refuses to use anything except Netscape 
Navigator feel.

I use Eclipse a lot in my day-job and there are debates like this all 
the time whenever a change is made in the UI, but usually sanity (and 
quite nice-looking software, BTW) are the result.  FWIW - they have just 
re-done the LF of their website as well.  I must admit I like it 
(eclipse.org), but others do not - I'm sure we'll hear from them shortly 
- ;-).  To each his own.

I think it would definitely be cool to use a Python-based web app for 
the site.  Plone is alright, but has a definite Plone approach that can 
be hard to shoe-horn your stuff into (although I think these guys have 
done an *awesome* job on their site: http://www.schooltool.org/).  Zope 
is flexible but a beast to learn.  And, well...there are just so many 
others. ;o)  I'm still looking, myself...

Markus.


Tim Parkin wrote:
 Leeuw van der, Tim wrote:
 
 I think that in general, I don't like the fact that links to
 high-profile users are featured so prominently. That row of pictures
 there looks good to me 'as such' but linking there to 'success stories'
 feels, dunno, perhaps a bit cheesy to me. (That might be just my dutch
 upbringing)
 I would certainly want to see such links somewhere on the front page,
 just not so prominently.
  

 Possibly so... however in my experience, selling python to people is
 made a lot easier by being able to say 'look these guys are using it'.
 This may not help sell it to programmers, but as a businessman trying to
 sell my programming services, it's exceptionally important.
 
 btw do you have a problem with using nasa or astrazeneca as example


 high
  

 profile users?


 As I said, I don't like them. We're not a commercial company trying to
 promote itself to potential buyers. But that's too a large degree a
 matter of taste.
  

 Well I'd have to disagree with yout on one point.. 'We' may not
 be a commercial company (when you talk about python as a singular unit)
 but as python developers, we should be in the process of trying to
 'sell' python wherever we can. Because we aren't a commercial company,
 our only 'sales' channels are the website and the developers/consultants
 that use python. (I'm talking about selling in the terms of 'promoting'
 or trying to persuade someone that using python is a good thing).
 
 I do actually think, though, that if the Python website *is* going to
 feature such big names with such prominence, some sort of approval from
 these organizations should be requested? That they don't mind being used
 a a Python reference story?
  

 The approval is already there (see pythonology success stories).
 
 About what could be there... Link to the even calender, or
 recent/upcoming event.. That is one to stay, I think.
 I think it would be good to have a link there too development
 environments that can be used for Python: editors, debuggers, IDEs / IDE
 extenstions, etc

  

 It's difficult to summarise this in a single image. The XP image was
 intended as a 'catch all' for the development environment. A different
 image and title would probably achieve better results but coming up with
 one or two words to sumarise that list is quite difficult.
 
 A third item could perhaps be a link to the Python Package Index --
 another thing that Python developers are likely to need.

  

 The home page isn't intended to target existing python users.. and the
 home page photos are mostly targetted at the sort of people that respond
 well to photos. It's a dilemma that the home page has to serve two
 masters, however if we have a 'developer home page' which can be
 dedicated to development issues, news, planetpython links, package
 libraries etc, we would have a single page that developers could bookmark.
 
 The only alternative was to create a separate 'marketing python' website
 but it would just get ignored, especially by the people we really need
 to see the 'marketing' content.
 
 These things are, of course, rather developer-centered 

Re: Is there a maximum length of a regular expression in python?

2006-01-18 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote:

 I have a regular expression that is approximately 100k bytes. (It is
 basically a list of all known norwegian postal numbers and the
 corresponding place with | in between. I know this is not the intended
 use for regular expressions, but it should nonetheless work.

 the pattern is
 ur'(N-|NO-)?(5259 HJELLESTAD|4026 STAVANGER|4027 STAVANGER|8305
 SVOLVÆR)'

 The error message I get is:
 RuntimeError: internal error in regular expression engine

you're most likely exceeding the allowed code size (usually 64k).

however, putting all postal numbers in a single RE is a horrid abuse of the RE
engine.  why not just scan for (N-|NO-)?(\d+) and use a dictionary to check
if you have a valid match?

postcodes = {
5269: HJELLESTAD,
...
: ØSTRE FJORDVIDDA,
}

for m in re.finditer((N-|NO-)?(\d+) , text):
prefix, number = m.groups()
try:
place = postcodes[number]
except KeyError:
continue
if not text.startswith(place, m.end()):
continue
# got a match!
print prefix, number, place

/F 



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

Re: 10060, 'Operation timed out'

2006-01-18 Thread Steve Holden
Sumit Acharya wrote:
 After 20 seconds only.
 
Of course I now realise there's no default timeout on sockets anyway, so 
that likely wasn't the problem.

Which statement is failing?

You would actually get much more information without the try/except 
clauses, as they are stopping the traceback from being printed - if the 
error is occurring deep in the ftplib you will actually see what and 
where with a full traceback. Your loop should read:

for x in range(1000):
 ftp = FTP()
 ftp.connect(host,port)
 ftp.login('a','a')
 print ftp.sendcmd('pass x')
 ftp.close()

Try running the script without both try/excepts and then post the full 
traceback, please. You can forget about the timings for now. It may well 
be an FTP server loading issue, but a traceback will give more information.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: Is there a maximum length of a regular expression in python?

2006-01-18 Thread Roy Smith
In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] wrote:

 I have a regular expression that is approximately 100k bytes. (It is
 basically a list of all known norwegian postal numbers and the
 corresponding place with | in between. I know this is not the intended
 use for regular expressions, but it should nonetheless work.
 
 the pattern is
 ur'(N-|NO-)?(5259 HJELLESTAD|4026 STAVANGER|4027 STAVANGER|8305
 SVOLVÆR)'
 
 The error message I get is:
 RuntimeError: internal error in regular expression engine

I don't know of any stated maximum length, but I'm not at all surprised 
this causes the regex compiler to blow up.  This is clearly a case of regex 
being the wrong tool for the job.

I'm guessing a dictionary, with the numeric codes as keys and the city 
names as values (or perhaps the other way around) is what you want.
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: New Python.org website ?

2006-01-18 Thread Tim Chase
 At any rate, opinions will always differ.  You are always going to get 
 the people who want a cool flash-based animated site with 3D stereo 
 surround sound, and the other end of the spectrum where you will be 
 flamed if you do anything more than hand-code the html, on Unix machines 
 only, using Vim or Emacs, ensuring it has a gray or neutral beige 
 background, *and* uses the default font giving that classic 1981 
 university professor who refuses to use anything except Netscape 
 Navigator feel.

Hmmm...I fall into that second camp, mostly because I often do 
python coding via ssh, and it's handy to use 
lynx/links/links2/elinks/w3m (whatever happens to be available on 
the machine in question) to browse the site.

The beta.python.org site is easily navigated in Lynx, has the 
search function right up at the top (okay, link #6, when 
numbered-links are turned on, but that beats #50 down in the 
downloads section).  I can give it a whirl accessibility-wise, 
using VoiceOver and Safari when I get back to my Mac.

[EMAIL PROTECTED]







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


Re: how do real python programmers work?

2006-01-18 Thread kpd
I have a python file type setup in Vim.  When I hit F9, it saves the
file and executes it in a python shell.

My _vimrc:

filetype on
autocmd FileType python call FileType_Python()

 Python coding
function! TryPython()
:w!
:!python %
endfunction

function! FileType_Python()
map F9:call TryPython()cr
map! F9esc:call TryPython()cr
set makeprg=python\ %
set errorformat=\ \ File\ \%f\,\ line\ %l,
so ~/vimfiles/indent/python.vim
so ~/vimfiles/bike.vim
so ~/vimfiles/python_calltips.vim
endfunction

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


Re: How to set a wx.textctrl can editable or readonly?

2006-01-18 Thread Frank Millman

Hako wrote:
 Hello All,


 I have  a function to set readonly or editable of a textctrl. I'd like
 to make the textctrl initial set readonly and use other event funciton
 to set editable of the textctrl but it always can editable. How to set
 a textctrl can editable or readonly?


Here is one way.

Create a subclass of wx.TextCtrl, with an attribute called 'readonly'.
Set the attribute to True or False to represent the desired state.

In the subclass, create a wx.EVT_SET_FOCUS handler to be called
whenever the text control receives focus. Then do something like this -

def onGotFocus(self,evt):
if readonly:
self.Navigate()

This causes the control to react as if the user press 'tab'. By default
it always tabs forwards, but it takes an optional 'IsForward' argument
- set it to False to tab backwards.

HTH

Frank Millman

ps You will get a better response to questions like this if you post
them to the wxPython mailing list - [EMAIL PROTECTED]

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


Re: How to set a wx.textctrl can editable or readonly?

2006-01-18 Thread Frank Millman

Frank Millman wrote:

 def onGotFocus(self,evt):
 if readonly:
 self.Navigate()
 

Oops - I meant 'if self.readonly' ...

Frank

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


Re: Can a simple a==b 'hang' in and endless loop?

2006-01-18 Thread Steve Holden
Claudio Grondi wrote:
[...]

 Yes, I know about 'is',
 
 but I mean, that it is not possible to use 'is' as replacement for '==' 
 operator to achieve in Python same behaviour as it is the case in C and 
 Javascript when comparing values with '=='.
 'is' does the C, Javascript job when comparing lists, but I mean it 
 fails to give fully predictable results when applied to elements of 
 lists in case there exist duplicate objects with same 'value' i.e. e.g. 
 there are two different objects storing the integer value 1, what I mean 
 can happen when there is enough other code between the Python code lines 
 assigning the integer value 1 to a list element or any other identifier.

Perhaps you could try again in English? :-) Sorry, that's a very complex 
sentence and it isn't clear what yo mean.

In C, of course, a == b requires that a and b be of compatible types and 
that they have the same value. This means that if they are pointers they 
must point to the same thing (which is exactly what is tests for).

 Or is there in Python a 100% reliable mechanism assuring, that there is 
 one and _only one_ object carrying a given 'value' (at least for the 
 built in types as integer, long integer, string, float) and if this 
 value is to be assigned to a list element or any other literal the 
 already existing object (if any) will be found and used/referenced?
 
No more than there is in C or, presumably, Java.

If you want to test for identity, use is. If you want to test for 
equality, use ==. Of you want to test for something else, kindly 
explain what you want to test for.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: Retaining Unix EOL when reading/writing in windows

2006-01-18 Thread Steve Holden
Nick Wain wrote:
 Hello All,
 
 I'm relatively new to PYTHON, using PYTHON 2.4 on Windows XP. I'm having a 
 problem as below. I've asked some other people in my office who are more 
 experienced in PYTHON, but they can't help.
 
 I have a number of files created in UNIX that have the UNIX end of line 
 (EOL) character.
 
 I want to read these files in python, modify some lines, and then write them 
 to a new file. This appears to work fine, however I find that the output 
 files have Windows EOL characters. This is a pain, as I want to compare the 
 before and after files to see if my changes are correct.
 
 I've simplified my code down to something that just reads a file and then 
 writes it to a different file. I'm currently doing this with a bit of code 
 that looks something like this:
 
 filename = test.lwc
 outfile = open(test_out.lwc, 'w' )
 readfile = open(filename,'r').readlines()
 
 for line in readfile:
 outfile.write(line)
 outfile.close()
 
 Is there a way I can do this, but retain the UNIX EOL characters?
 
Yup. Try

outfile = open(test_out.lwc, 'wb' )

to write the file in binary mode. That way the file handling code won;t 
ferkle with what you write.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: How to set a wx.textctrl can editable or readonly?

2006-01-18 Thread Tim Chase
 def onGotFocus(self,evt):
 if readonly:
 self.Navigate()
 
 This causes the control to react as if the user press 'tab'. By default
 it always tabs forwards, but it takes an optional 'IsForward' argument
 - set it to False to tab backwards.

Just a pedantic query, not having wx under my fingertips at the 
moment...what happens if you three controls, A (r/w), B 
(read-only), and C (r/w) in that focus order...if use shift+tab 
in control C, does it properly go back to A, or does it move you 
forward again to control C.

Additionally, you should be able to copy text from a read-only 
control, so ousting the focus may not be quite the right thing to do.

Just a few random thoughts,

[EMAIL PROTECTED]





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


Dr. Dobb's Python-URL! - weekly Python news and links (Jan 18)

2006-01-18 Thread Magnus Lycka
QOTW: *what* the value is is defined by the operations that the object 
supports (via its type).

*how* the value is represented inside the object is completely 
irrelevant; a Python implementation may use electric charges in small 
capacitors, piles of rocks, diapers,or an endless supply of small guys 
in odd costumes to encode the value inside an object.  Changes to the 
value may be carried out by CPU instructions, caterpillars, toddlers 
with gasmasks, or an endless supply of small guys in odd costumes. The 
only thing that's important is that you can, in your Python program, 
access an objects value via its type, and get other objects back when 
you do. - Fredrik Lundh

I have never seen a case where a dictionary didn't improve the design. - Ivan
Van Laningham


PyCon Early bird registration ends, FrOSCon 2006 issues
a Call for Papers and OSCON 2006 (Python 14 Conference)
issues a Call for Proposals:

http://groups.google.se/group/comp.lang.python.announce/browse_frm/thread/3e139769821f7e6e

http://groups.google.se/group/comp.lang.python.announce/browse_frm/thread/a5704ce3f09c4f01

http://groups.google.se/group/comp.lang.python.announce/browse_frm/thread/8f520f85326bf7de

With release 0.6, OSAF's Python based PIM Chandler includes
an experimentally usable calendar, with support for
recurring events, time-zones and the ability to share
calendars with others: 
http://chandler.osafoundation.org/

Fynali asks How to remove subset from a file efficiently?.
Follow-ups, as has happened so often before, reduce his runtime
from a few minutes to a few seconds:

http://groups.google.se/group/comp.lang.python/browse_frm/thread/929fcdf0ff9731dc

Tim Peters explains why you shouldn't expect much from atexit + threads:

http://groups.google.se/group/comp.lang.python/browse_frm/thread/fe9e426650764ed9

Scott David Daniels suggests use of decorators to handle unit
tests that are known to fail:

http://groups.google.se/group/comp.lang.python/browse_frm/thread/7ea0762494ef96ff

Robin Becker requests some smart/fast way to flatten a level one list
and receives a number of suggestions:

http://groups.google.se/group/comp.lang.python/browse_frm/thread/383aab2c3467eb59

A discussion of the draft for a new Python.org web site leads
to a conclusion of general happiness with the new look:
http://beta.python.org

Brian Blais asks how do 'real' python programmers work? and
receives a sample of development processes that Pythonistas use,
focused on what kind of windows people have on their screen, but
also including such important aspects as test driven development:

http://groups.google.se/group/comp.lang.python/browse_frm/thread/82b4f2f90b9def56

Michael Galvin receives a few suggestions on how to get both
text and graphics to a printer from Python:

http://groups.google.se/group/comp.lang.python/browse_frm/thread/bc0742534da994d2

Duncan Booth and others explain how to make a dictionary
aware of its own changes:

http://groups.google.se/group/comp.lang.python/browse_frm/thread/eeca4df10529f7e0



Everything Python-related you want is probably one or two clicks away in
these pages:

Python.org's Python Language Website is the traditional
center of Pythonia
http://www.python.org
Notice especially the master FAQ
http://www.python.org/doc/FAQ.html

PythonWare complements the digest you're reading with the
marvelous daily python url
 http://www.pythonware.com/daily  
Mygale is a news-gathering webcrawler that specializes in (new)
World-Wide Web articles related to Python.
 http://www.awaretek.com/nowak/mygale.html 
While cosmetically similar, Mygale and the Daily Python-URL
are utterly different in their technologies and generally in
their results.

For far, FAR more Python reading than any one mind should
absorb, much of it quite interesting, several pages index
much of the universe of Pybloggers.
http://lowlife.jp/cgi-bin/moin.cgi/PythonProgrammersWeblog
http://www.planetpython.org/
http://mechanicalcat.net/pyblagg.html

comp.lang.python.announce announces new Python software.  Be
sure to scan this newsgroup weekly.

http://groups.google.com/groups?oi=djqas_ugroup=comp.lang.python.announce

Steve Bethard, Tim Lesher, and Tony Meyer continue the marvelous
tradition early borne by Andrew Kuchling, Michael Hudson and Brett
Cannon of intelligently summarizing action on the python-dev mailing
list once every other week.
http://www.python.org/dev/summary/

The Python Package Index catalogues packages.
http://www.python.org/pypi/

The somewhat older Vaults of Parnassus ambitiously collects references
to all 

Re: New Python.org website ?

2006-01-18 Thread JW
On Wed, 18 Jan 2006 00:33:06 -0800, Tim N. van der Leeuw wrote:

 What I especially dislike about the new website are the flashy pictures
 on the front-page with no content and no purpose -- purely boasting but
 nothing to back up your claims.
 
 (I wouldn't mind some sleek pictures there if they weren't desperatly
 trying to advertise success-stories but instead would link to real
 content!)

Tim the Taller (I presume he's taller; he's Dutch) and the other critics
fail to realize is that no one reads content.

I'm assured that in print ads the only content anyone reads is in
picture captions, and you damn well better make sure your message is
conveyed there. Any other content only wastes space. I see no reason to
think that a web page should be designed using any other assumption.

If anything, Tim the Shorter (I presume he's shorter; he's not Dutch) has
too much content and too few images.  The beta page is a great
improvement over the current content-intensive page.

I recommend David Ogilvy's Ogilvy on Advertising for a enthusiastic but
somewhat cynical view of the subject.  It is a very old book, but nothing
about human nature has changed since it was written.

Jim Wilson
Gainesville, FL


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


Re: Can a simple a==b 'hang' in and endless loop?

2006-01-18 Thread Fuzzyman

Claudio Grondi wrote:
[snip..]
 Yes, I know about 'is',

 but I mean, that it is not possible to use 'is' as replacement for '=='
 operator to achieve in Python same behaviour as it is the case in C and
 Javascript when comparing values with '=='.
 'is' does the C, Javascript job when comparing lists, but I mean it
 fails to give fully predictable results when applied to elements of
 lists in case there exist duplicate objects with same 'value' i.e. e.g.
 there are two different objects storing the integer value 1, what I mean

Hmmm... :

  a = 1
  b = 1
  a is b
True

Doesn't work with arbitrary longs of course...

 can happen when there is enough other code between the Python code lines
 assigning the integer value 1 to a list element or any other identifier.
 Or is there in Python a 100% reliable mechanism assuring, that there is
 one and _only one_ object carrying a given 'value' (at least for the
 built in types as integer, long integer, string, float) and if this
 value is to be assigned to a list element or any other literal the
 already existing object (if any) will be found and used/referenced?


So the Java/C '==' operator sometimes works like '==' in Python and
sometimes works like 'is' ? (It switches between equality and identity
depending on the types being compared IIUC).

My understanding is that you can't use '==' in Java to compare strings,
because it is an identity test not an equality test. You have to use a
string method to compare strings. This bites quite a few people...

Anyway, AFAICT your problem only matters in the abstract (where you are
theoretically comparing objects you haven't specified the type of and
*might* want to use '==' and *might* want to use 'is').

For practical purposes '==' will do what you want, unless you
deliberately create buggy code to cause a problem when you use it...

Unless you can post an example of *non-buggy* code that doesn't behave
how you expect ?

All the best,

Fuzzyman
http://www.voidspace.org.uk/python/index.shtml

 Claudio

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


Re: Can a simple a==b 'hang' in and endless loop?

2006-01-18 Thread Fuzzyman

Claudio Grondi wrote:
 Steve Holden wrote:
[snip..]
 The problem here is, that I mean, that in Python it makes no sense to
 talk about a value of an object, because it leads to weird things when
 trying to give a definition what a value of an object is.


You're saying that C and Java get round that problem by sometimes
defining value to mean 'the memory address and object is stored at'.
That hardly seems to clarify what value *really* means, and can lead to
some interesting confusions.

Anyway - for the basic datatypes 'value' seems quite clear. It's only
not clear what this might mean in user defined classes - where value
means whatever you define it to mean.

By overloading the comparison and rich comparison methods of user
defined classes, you have the opportunity to *precisely* define the
meaning of value...

 It seems, that in Python there is a lack of operator able to compare
 values as it is the case in C and Javascript, simply because in Python
 there are no really such things as values, so there is no need to
 compare them.


Can you provide an example to clarify what you mean ?

All the best,

Fuzzyman
http://www.voidspace.org.uk/python/index.shtml

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


  1   2   3   4   >