Re: Indentation/whitespace

2005-12-23 Thread bonono

James Tanis wrote:
>Honestly I wonder how so many coders actually came to be
> interested in the field -- one that pretty much thrives in part on its
> neverending ability to vary, grow, and change -- if something so small
> can warrant so much attention.
>
That is what a "cafe" type newsgroup is for, nothing but time killing
:-)

For those who really cannot stand it, they would have moved on to
whatever other language that they feel better(or more tolerable in
whatever sense).

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


Re: Indentation/whitespace

2005-12-23 Thread James Tanis
On 23 Dec 2005 15:22:39 -0800, thakadu <[EMAIL PROTECTED]> wrote:
> It is not really unique to Python as I have pointed out on this or
> other forums before. The Occam (OCCAM?) language also uses significant
> whitespace in much the same way as Python and there may also be others.
>

Your right of course, but I don't think it really even needs to be
said. I mean whether or not Python is the only language that uses
white space in a significant manner doesn't change the fact that..
well Python can do whatever the heck Python wants to do with its
syntax. Honestly I wonder how so many coders actually came to be
interested in the field -- one that pretty much thrives in part on its
neverending ability to vary, grow, and change -- if something so small
can warrant so much attention.

--
James Tanis
[EMAIL PROTECTED]
http://pycoder.org
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Xah's Edu Corner: Responsible Software Licensing

2005-12-23 Thread Pascal Bourguignon

"Xah Lee" <[EMAIL PROTECTED]> writes:
> As i've indicated in the Responsible Licensing article, that today's
> software come with disclaimers that essentially say the producer is not
> liable even if the software don't work at all. It will be hard to
> change this zero responsibility stance to a 100% responsibility stance.
> However, we can start in small ways. Suppose, if you write a piece of
> email program, although there are a myriad scenarios that it will have
> problems sending email and in reality such problem happens often, but a
> responsible software programer can at least GUARANTEE, that the
> software WILL work to some extent of its described utility. In the
> email program example, a responsible author can say “We GUARANTEE
> that this software will send out emails in a normal setting. If not, we
> will refund the money you have paid, or, send you $1 USD.” Although
> this may seem fuzzy and silly, but it is a start. By giving a very safe
> minimal guarantee of functionality, possibly with a nominal liability
> assurance, the author will have made a _Responsible License_.

You have a problem of definition of the meaning of "normal setting".  

This problem is easily resolved with the source of the program: the
source of the program IS the CONTRACT.  If you respect the language
(the semantics, or underlying virtual machine expected by the
program), and if you respect the pre-conditions embedded in the
program, then you get the guarantee plainly written in the program as
post-conditions.  You cannot get it more explicitely than from the
sources of the program (and the specifications of its programming
language).

So wanting more than the mere sources, you are wanting to reject
programming language not formally specified, and programs provided
without the sources.  We can do better on the programming language
formal specifications side, but on the program sources side, I don't
know what we can do more than GPL or BSD...


Actually, the whole point is to let the _user_ of the program to take
_responsibility_ for the program he uses,  and not to cowardly 
discharge his (the user's) responsability to somebody else.


When you compute the tip to add to your invoice at the restaurant, you
don't ask the inventor of the multiplication algorithm or your
teachers to take any responsibility for your wrong or right
application of the operation.  Let the users be responsible!


-- 
__Pascal Bourguignon__ http://www.informatimago.com/
Our enemies are innovative and resourceful, and so are we. They never
stop thinking about new ways to harm our country and our people, and
neither do we. -- Georges W. Bush
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Some errors when running code in diveintopython: (

2005-12-23 Thread iclinux
thanks all ! I've solved this problem:

Let me show my net environment first. My pc is in a local network, and
through a proxy server can  I reach the Internet, so I changed my
Internet Settings.

It seems that everything goes well, I can surf Internet, etc,  but what
a pity, I can't resolve a host's address by its name by gethostbyname()
in C Language; in python, socket.getaddrinfo() will fail.

So today, I installed MSFireWallClient which will connect to the ISA
server. and after that, everything works: )

Thanks again, Merry Christmas and a Happy New Year!!

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


Re: Guido at Google

2005-12-23 Thread russnelson
Steve Holden wrote:

> Far answers to this and all other (as far as I can determine)
> hypothetical questions please refer to the license.

But note that no OSI certified open source license will grant the right
to use a trademark.  You gain trademark rights by having control over
the quality of the described quantity.  If you give up control (which
the OSD requires), you cannot grant the right to use the trademark, or,
if you do, then you will lose the ability to enforce the trademark.

In the case of derived names like JPython, or IronPython, the PSF would
have to claim in court that "everyone knows that Python is only and
exactly Python, and that anything with prefixes or suffixes may be
derived from the PSF-copyrighted work, but is not an official product
of the PSF."  That's reasonable, but harder to prove than insisting
that no computer language may contain Python in its name without being
the PSF-copyrighted work.

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


program with raw_input prompt behaves differently after compile

2005-12-23 Thread tim
I want to write a program that looks into a given folder, groups files 
that have a certain part of the filename in common and then copy those 
groups one at a time to another place, using the raw_input prompt to 
continue or break.

here's what I have:

###
def makegroepen():
global p
import os
from longestcommonprefix import longestcommonprefix
p = raw_input('path')
l = os.listdir(p)
l.sort()
groepen=[]
groep=[]
basenames=[]
for r in l:
if r.find('_poly16.mp3'):
 baselist = r.split('_')
 mopobasename = baselist[0]
 if mpbasename not in basenames:

basenames.append(mpbasename)
for s in l:

if 
longestcommonprefix([s,mpbasename])==mpbasename:
print mpbasename
if s not in groep:
groep.append(s)
if len(groep)==6:
groepen.append(groep)
groep=[]
print groepen
return groepen
def movegr():
global p, groepen
for t in groepen:
contprompt=raw_input('continue? (n to stop)')
if contprompt=='n':
break
for curr in t:
if os.path.isfile(p+'\\'+curr):
tempfile = open(p+'\\'+curr, 'rb')
tempfile.seek(0)
tempfilecont = tempfile.read()
dircondition = os.path.exists('c:\\content\\workfolder')
if dircondition == False:
os.makedirs('c:\\content\\workfolder')
destfile = open('c:\\content\\workfolder\\'+curr, 'wb')
destfile.write(tempfilecont)
destfile.close()
if __name__=='__main__':
global groepen
groepen = makegroepen()
movegr()


(I renamed 'commonprefix' to 'longestcommonprefix', it is actually just 
the 'binary search version' I found at 
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/252177 )

It works fine when I run this from PythonWin IDE, but after compiling an 
executable from it (py2exe) it exits whatever I type in the 'continue?' 
prompt.
What am I doing wrong?
Thanks,
Tim



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


Xah's Edu Corner: Responsible Software Licensing

2005-12-23 Thread Xah Lee
Responsible Software Licensing & Free Software Foundation

Xah Lee, 2005-07

Dear Programers,

I have always respected the Free Software Foundation (FSF) and its
community.

when i wrote the article a couple years ago on Responsible Software
Licensing, i thought it might not be welcomed by the free software
community, because in a way responsibility is implicitly a antithesis
against the free software community.

I have high respect for the Free Software Foundation, even though i do
not believe their tenet and dedication that ALL software MUST be
“Free”. Nevertheless, i respect its founder Richard Stallman and
the community on the whole. I think it is a very good group in a
capitalistic software environment, as i'm also a strong advocate and
believer in the goodness of laissez-faire system.

So, as i was thinking that a movement towards Responsible Software
Licensing may be opposed by the free software community in general, in
principle and in practice. In principle because FSF's ethics focuses on
the goodness of individuals, as opposed to some forced regulations such
as licenses and contracts. In practice because most people in the free
software camp are there because they are poor students and are totally
ignorant of sociology, economics, business, law. As a class of the
young, they are OpenSourcing fanatics for the thiefing and gratis and
noise-making parts.

In a commpercial software, where money are paid to acquire, it is
reasonable to demand workability from the sold goods. However, in Free
Software, almost always it is never a commercial item (i.e. practically
it is always free of charge), therefore demanding that the software
hold some responsibility for its consumers may seem inappropriate. We
cannot stipulate warranties and insurances from gifts. (Nor can we, for
some conceived ethics, to force some behavior by law, as history shows
us that is not going to work well.)

However, i think the free software community can in fact advocate
responsible software licensing, and be a pioneer in this movement.

As i've indicated in the Responsible Licensing article, that today's
software come with disclaimers that essentially say the producer is not
liable even if the software don't work at all. It will be hard to
change this zero responsibility stance to a 100% responsibility stance.
However, we can start in small ways. Suppose, if you write a piece of
email program, although there are a myriad scenarios that it will have
problems sending email and in reality such problem happens often, but a
responsible software programer can at least GUARANTEE, that the
software WILL work to some extent of its described utility. In the
email program example, a responsible author can say “We GUARANTEE
that this software will send out emails in a normal setting. If not, we
will refund the money you have paid, or, send you $1 USD.” Although
this may seem fuzzy and silly, but it is a start. By giving a very safe
minimal guarantee of functionality, possibly with a nominal liability
assurance, the author will have made a _Responsible License_.

The Free Software Foundation's GNU project has been a pioneer in many
aspects. It is a pioneer in the concept of Free Software with its GPL
license, which is the main force behind the success and ubiquity of
Linux and a massive collection of freely available software and
components. It in fact has made a major impact in society, even beyond
the realm of software industry. (for instance, the massive grass-roots
online info-encyclopedia Wikipedia.org is a indirect consequence FSF
and GPL) Free Software community also has done pioneering leads in
software technology. For example, its emacs text editor, is a
all-encompassing, self-documented, self-sustaining software, and a
quality work at that. It embodies the LISP programing language, and in
fact emacs is mainly responsible for spreading the quality concepts
that is functional programing to most industrial programers. The GNU C
Compiler (now GNU Compiler Collection), is critical in starting Linux
and a massive collection of software in the unix industry.

This is why i think Free Software Foundation can be a leader towards
responsible software licensing. There are a huge number of Free
Software followers. Many of us also publish our programs, big or small.
By starting with a very small, nominal statement in the license, we can
spread the attitude of responsible software. Gradually, this practice
can spread to commercial software, and to such a degree of competing
offers of liabilities and guarantees as we have in for example USA's
consumer products.

Please think about this. If you agree, please spread the idea.

--
This post is archived at:
http://xahlee.org/UnixResource_dir/writ/responsible_license_FSF.html

 Xah
 [EMAIL PROTECTED]
 ∑ http://xahlee.org/

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

Re: Herds of cats

2005-12-23 Thread Aahz
In article <[EMAIL PROTECTED]>, Mike Meyer  <[EMAIL PROTECTED]> wrote:
>
>CA pretty clearly got screwed on this deal. They have since
>open-sourced the Ingres product.

YM "CA screwed themselves in this deal."  HTH. HAND.

(That's my take based on the history of Computer Associates and a few
casual conversations with other ex-Ingres people.)
-- 
Aahz ([EMAIL PROTECTED])   <*> http://www.pythoncraft.com/

"Don't listen to schmucks on USENET when making legal decisions.  Hire
yourself a competent schmuck."  --USENET schmuck (aka Robert Kern)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to check if a string "is" an int?

2005-12-23 Thread Alex Martelli
Paul Rubin  wrote:

> "Fredrik Lundh" <[EMAIL PROTECTED]> writes:
> > A: are there any blue cars on the street?
> > B: no.  not a single one.
> > A: you're wrong! all cars on the street are blue!
> 
> B and A are both correct.  It's just logic ;-).

Charles Lutwidge Dodgson spent his professional life arguing against
this, as I mentioned in
 --
but, mostly, "mainstream" logic proceeded along the opposite channel you
mention.  Good thing he had interesting hobbies (telling stories to
children, and taking photographs), or today he perhaps might be
remembered only for some contributions to voting-theory;-).

I don't know of any "complete and correct" logic (or set-theory) where
there is more than one empty-set, but I'm pretty sure that's because I
never really dwelled into the intricacies of modern theories such as
modal logic (I would expect modal logic, and intensional logic more
generally, would please Dodgson far better than extensional logic...
but, as I said, I don't really understand them in sufficient depth)... 


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


Gurus'Network

2005-12-23 Thread yawgmoth7
gurusnetwork.org is a great place to learn about programming. And a
lot of the admins are Python Pro's and they are willing to help and
share info. Just thought I'd mention this fairly new site.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pyQt for windows

2005-12-23 Thread Bill
relativity wrote:
> I have downloaded and installed pyQt 3.14 educational but when I run any of
> the examples I get an error saying qt-mtedu333.dll was not found. I have
> also installed the qt4 opensource version for windows but I am not sure
> everything was set up correctly. When I run configure it complains about
> file or folder not found (mingw32-make). I installed mingw with qt. Anyway
> any help would be appreciated. All i want is to be able to use QT on windows
> with python.

Look at http://pythonqt.vanrietpaap.nl

It worked for me.

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


Re: sorting with expensive compares?

2005-12-23 Thread Alex Martelli
Tim Peters <[EMAIL PROTECTED]> wrote:

> [Steven D'Aprano]
> > ...
> > As others have pointed out, Python's sort never compares the same objects
> > more than once.
> 
> Others have pointed it out, and it's getting repeated now, but it's
> not true.  Since I wrote Python's sorting implementation, it's
> conceivable that I'm not just making this up ;-)
   ...
> could possibly save in general.  It's true that the workhorse binary
> insertion and merge sorts never compare the same elements more than
> once, but there is some potential duplication between those and
> comparisons done to identify natural runs.

Since I probably was the first one to point out the erroneous factoid in
question, I apologize -- obviously, my memories of the inner workings of
sort were faulty, and didn't consider that potential duplication.

In this case, the tricks I already (though dubiously;-) suggested in
order to avoid any avoidable comparisons might pay for themselves and
then some, if comparisons are indeed extremely costly.


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


Re: sorting with expensive compares?

2005-12-23 Thread Paul Rubin
Steven D'Aprano <[EMAIL PROTECTED]> writes:
> > There are also known ways of deliberately constructing md5 collisions
> > (i.e. md5 is broken).  Whether the OP should care about that depends
> > on the application.
> 
> Sure, but I don't he is deliberately trying to sabotage his own files :-)

He might have downloaded a file created by a saboteur to have the same
md5 as some popular music file, but which contains a subliminal
hypnotic message which will brainwash him if played.  Using a stronger
hash, such as sha256, should protect him from this fate.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: sorting with expensive compares?

2005-12-23 Thread Tim Peters
[Steven D'Aprano]
> ...
> As others have pointed out, Python's sort never compares the same objects
> more than once.

Others have pointed it out, and it's getting repeated now, but it's
not true.  Since I wrote Python's sorting implementation, it's
conceivable that I'm not just making this up ;-)

Here's the shortest counter-example:  [10, 30, 20].

The first thing sort() does is compute the length of the longest
natural run (whether increasing or decreasing) starting at index 0. 
It compares 10 and 30, sees that the list starts with an increasing
run, then compares 30 and 20 to see whether this run can be extended
to length 3.  It can't.  Since the list has only 3 elements, it
decides to use a binary insertion sort to move the 3rd element into
place.  That requires 2 comparisons, the first of which _again_
compares 30 and 20.

This doesn't bother me, and it would cost more to avoid this than it
could possibly save in general.  It's true that the workhorse binary
insertion and merge sorts never compare the same elements more than
once, but there is some potential duplication between those and
comparisons done to identify natural runs.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: sorting with expensive compares?

2005-12-23 Thread Steven D'Aprano
On Fri, 23 Dec 2005 21:07:57 -0800, Paul Rubin wrote:

> Steven D'Aprano <[EMAIL PROTECTED]> writes:
>> http://www.iusmentis.com/technology/encryption/pgp/pgpattackfaq/hash/
>> 
>> the expected number of random unique files you would need to compare
>> before finding a single collision in the MD5 hashes is (very roughly)
>> 10**70, or ten billion trillion trillion trillion trillion trillion.
> 
> That's not right, the right number is around 2**64 or 2e19.  See the
> section of that page about the birthday attack.  It's still an awful lot.

Oh poot, a stupid typo! I entered 1e60 in my calculation instead of 1e6,
which is doubly embarrassing because the correct number to use is 1e9:

[quote]
In MD5's case, 2**64 messages need to be tried. This is not a feasible
attack given today's technology. If you could try 1,000,000 messages per
second, it would take 584,942 years to find a collision. A machine that
could try 1,000,000,000 messages per second would take 585 years, on
average.
[end quote]

So the expected number of files (messages) needed to check to find a
collision is:

585*365*24*60*60*1e9 = 1.8e19

or more than ten million million million, which of course equals 2**64.




> There are also known ways of deliberately constructing md5 collisions
> (i.e. md5 is broken).  Whether the OP should care about that depends
> on the application.

Sure, but I don't he is deliberately trying to sabotage his own files :-)


-- 
Steven.

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


Re: sorting with expensive compares?

2005-12-23 Thread Paul Rubin
Steven D'Aprano <[EMAIL PROTECTED]> writes:
> http://www.iusmentis.com/technology/encryption/pgp/pgpattackfaq/hash/
> 
> the expected number of random unique files you would need to compare
> before finding a single collision in the MD5 hashes is (very roughly)
> 10**70, or ten billion trillion trillion trillion trillion trillion.

That's not right, the right number is around 2**64 or 2e19.  See the
section of that page about the birthday attack.  It's still an awful lot.

There are also known ways of deliberately constructing md5 collisions
(i.e. md5 is broken).  Whether the OP should care about that depends
on the application.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: sorting with expensive compares?

2005-12-23 Thread Steven D'Aprano
On Fri, 23 Dec 2005 17:10:22 +, Dan Stromberg wrote:

> I probably should've been more specific.
> 
> I'm wanting to sort a large number of files, like a bunch of output files
> from a large series of rsh or ssh outputs on a large series of distinct
> machines, a music collection in .ogg format (strictly redistributable and
> legally purchased music), a collection of .iso cdrom images (strictly
> redistributable and legally purchased software), and so forth.
> 
> I'm not sorting the content of each file individually.
> 
> I'm treating each file as a potentially very large string, and "sorting
> the strings".

Which is a very strange thing to do, but I'll assume you have a good
reason for doing so.

> I've been using the following compare function, 

My first suggestion is that you invest a bit of time in building a
small-scale set of data that you can test your sorting on, if you haven't
already done so. On multi-megabyte files, taking the MD5 hash or comparing
the content byte by byte is quite slow. So I would spend a few minutes
populating a directory with a dozen or so fake iso and ogg files, only a
few bytes in length each, and run my tests on them.

> which in short checks, in order:
> 
> 1) device number
> 2) inode number
> 3) file length
> 4) the beginning of the file
> 5) an md5 hash of the entire file
> 6) the entire file
> 
> (If #1 and #2 are identical, then the file must be a hardlink to the
> other file.  Also, files that do not have the same length can never be
> identical.  And of course these items are generated on demand, making it
> frequently possible to avoid doing full-file-length compare on a lot of
> files)

My second suggestion is to encapsulate vigorously, at least for testing.
At the moment, you have a single __cmp__ function that does everything
in-line. I would do something like this:

def __cmp__(self, other):
result = compare_by_device_number_and_inode(self, other)
if result is None:
result = compare_by_file_length(self, other)
if result is None:
... 
return result

You can always unroll the function calls later, but for now it helps in
debugging: you only need to think about one type of comparison at a time,
and makes it easier to think about what each function needs to do.


> However, my program is still doing more #6 comparisons than seems
> strictly necessary when I could just toss all the filenames describing
> identical files into a list, and avoid re-comparing files with identical
> content over and over - I don't want to compare them to each other again
> and again), when there are a lot of identical files in the input list.

As others have pointed out, Python's sort never compares the same objects
more than once.

Some more comments follow interleaved with your code:


> def __cmp__(self,other):
> # sys.stderr.write('Comparing %s and %s\n' % (self.name, 
> other.name))

Are you sure you don't want to just sort by file name? That would be much
simpler *wink*

>   if verbosity >= 1:
>   sys.stderr.write('Comparing file_class objects %s and 
> %s\n' %
>   (self.name, other.name))
>   if self.device == -1:
>   if verbosity:
>   sys.stderr.write('Getting stat data for file 
> %s\n' % self.name)
>   result = os.stat(self.name)
>   self.device = result[stat.ST_DEV]
>   self.inode = result[stat.ST_INO]
>   self.size = result[stat.ST_SIZE]

Since you need to compare stat data for all these objects, why not
simply pre-fetch them when you create the object? That way you can
simplify your __cmp__ function significantly.

[snip]

>   if self.device == other.device and self.inode == other.inode:
>   # same device, same inode, must be identical files 
> return 0

At first I thought that my news client had mangled your function, but
going back to the original post, either *your* client has mangled it, or
I've found a bug in your code. "return 0" is commented out.

Is it possible that all the excess file comparisons are being done only
for hard links?

[snip]


>   if verbosity:
>   sys.stderr.write('Getting prefix for file %s\n' 
> % self.name)
>   file = open(self.name, 'r')
>   self.prefix = file.read(self.max_prefix_length) 
> file.close()

"prefix" is probably not the best name. Maybe "header" (as in "file
header")?

If the prefix/header is short enough, don't worry about fetching on
demand, at least not while you are still debugging. Just pre-fetch it, get
your code working, and then convert back to fetching the header on demand.


>   if other.prefix == -1:
>   if verbosity:
>   sys.stderr.write('Getting prefix for file %s\n' 
> % other.name)
> 

Re: Indentation/whitespace

2005-12-23 Thread Alex Martelli
thakadu <[EMAIL PROTECTED]> wrote:

> It is not really unique to Python as I have pointed out on this or
> other forums before. The Occam (OCCAM?) language also uses significant
> whitespace in much the same way as Python and there may also be others.

Haskell.  Rules not identical to Python (they have something called "the
offside rule" which is at least as subtle as the one in soccer;-) but
practical effects that are quite close.


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


Re: What is unique about Python?

2005-12-23 Thread skip

>> > that's not really what I'm looking for.  So I'm wondering, what is
>> > innovative about Python, 

>> The letter 'y'.  Before Python, it was woefully underused in the
>> names of programming languages...

Roy> Yacc has been around for a long time.

Sure, but it's capitalized there.  Python innovated the use of lower-case
'y'.

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


Re: Vaults of Parnassus hasn't been updated for months

2005-12-23 Thread Kent Johnson
Wolfgang Grafen wrote:
>  > Everybody is using the cheeseshop now:
>  >
>  > http://cheeseshop.python.org/pypi?%3Aaction=browse
>  >
> 
> Everybody excluding me. Looks like a huge pile of cheese thrown above
> a table. Sorry, I don't find what I am looking for. Can somebody
> explain the improvement over Parnassus for me?
> 
> It is not only that Parnassus (http://py.vaults.ca/apyllo.py?a=tree) has
> 2000+ Entries compared to 673 at the cheeseshop
> (http://cheeseshop.python.org/pypi?:action=browse&asdf=214) but its
> appearence and user interface is also much better. Where is the
> search button, where can I find the latest additions?

If you go to the main cheeseshop page
http://cheeseshop.python.org/pypi?%3Aaction=home
there is a search link, you can view by categories, and it shows the 
last 20 additions. There is also an RSS feed.

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


Re: What is unique about Python?

2005-12-23 Thread Alex Martelli
Roy Smith <[EMAIL PROTECTED]> wrote:

> In article <[EMAIL PROTECTED]>,
>  [EMAIL PROTECTED] (Alex Martelli) wrote:
> 
> > gsteff <[EMAIL PROTECTED]> wrote:
> >...
> > > that's not really what I'm looking for.  So I'm wondering, what is
> > > innovative about Python, 
> > 
> > The letter 'y'.  Before Python, it was woefully underused in the names
> > of programming languages.  Now, of course, there's also Ruby, but then
> > we know Ruby did get some ideas from Python (and the letter 'y' is one
> > of them).
> > 
> 
> Yacc has been around for a long time.

...but is not a programming language...


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


Re: What is unique about Python?

2005-12-23 Thread Roy Smith
In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Alex Martelli) wrote:

> gsteff <[EMAIL PROTECTED]> wrote:
>...
> > that's not really what I'm looking for.  So I'm wondering, what is
> > innovative about Python, 
> 
> The letter 'y'.  Before Python, it was woefully underused in the names
> of programming languages.  Now, of course, there's also Ruby, but then
> we know Ruby did get some ideas from Python (and the letter 'y' is one
> of them).
> 
> 
> Alex

Yacc has been around for a long time.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Indentation/whitespace

2005-12-23 Thread Steven D'Aprano
On Fri, 23 Dec 2005 15:22:39 -0800, thakadu wrote:

> It is not really unique to Python as I have pointed out on this or
> other forums before. The Occam (OCCAM?) language also uses significant
> whitespace in much the same way as Python and there may also be others.

Python doesn't have any more significant whitespace than any other
language:

x=12*sum([3,5,7,9,2][1:4])+3#comment

means the same thing as:

x = 12   * sum ( [   3 ,   5 , 7 , 9 , 2 ]  [ 1  : 4 ] ) + 3 # comment

(although there are recommendations for where you should use whitespace).
You can mix spaces and tabs between tokens.

Like most computer languages, line breaks are significant in Python.
Nobody worries about that except maybe Forth programmers.

Also, *indentation* is significant, unlike most languages which treat
indentation as syntactically optional but enforce it via coding standards,
code beautifiers, pretty-printers, etc.


-- 
Steven.

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


Weekly Python Patch/Bug Summary

2005-12-23 Thread Kurt B. Kaiser
Patch / Bug Summary
___

Patches :  379 open ( -4) /  3002 closed (+12) /  3381 total ( +8)
Bugs:  914 open (-13) /  5452 closed (+37) /  6366 total (+24)
RFE :  204 open ( +0) /   193 closed ( +1) /   397 total ( +1)

New / Reopened Patches
__

Some fixes for the binary distribution builder  (2005-12-14)
   http://python.org/sf/1380777  opened by  Ronald Oussoren

Fix bug read() would hang on ssl socket if settimeout() used  (2005-12-15)
   http://python.org/sf/1380952  opened by  Arkadiusz Miskiewicz

bind() for netlink sockets  (2005-12-15)
   http://python.org/sf/1381398  opened by  Timo Metsälä

list.count() patch for feature request 1370948  (2005-12-15)
CLOSED http://python.org/sf/1382087  opened by  Mike Fondo

Expose Subversion revision number  (2005-12-16)
CLOSED http://python.org/sf/1382163  opened by  Barry A. Warsaw

Specify new reference return value for PyObject_Call  (2005-12-17)
CLOSED http://python.org/sf/1383115  opened by  Farshid Lashkari

Make unittest.TestCase easier to subclass  (2005-12-22)
   http://python.org/sf/1388073  opened by  Collin Winter

add more readline support  (2005-12-22)
   http://python.org/sf/1388440  opened by  Sebastien Boving

Patches Closed
__

PyXxx_Check() speed-up  (2005-02-27)
   http://python.org/sf/1153056  closed by  arigo

[PATCH] mmap fails on AMD64  (2005-11-24)
   http://python.org/sf/1365916  closed by  nnorwitz

list.count() patch for feature request 1370948  (2005-12-15)
   http://python.org/sf/1382087  closed by  gvanrossum

Expose Subversion revision number  (2005-12-16)
   http://python.org/sf/1382163  closed by  bwarsaw

fix description of format_exc in traceback doc  (2005-12-09)
   http://python.org/sf/1376914  closed by  birkenfeld

xml.parsers.expat documentation fix  (2005-12-10)
   http://python.org/sf/1377848  closed by  birkenfeld

correct display of pathnames in SimpleHTTPServer  (2005-11-18)
   http://python.org/sf/1360443  closed by  birkenfeld

PEP 341 - Unification of try/except and try/finally  (2005-11-13)
   http://python.org/sf/1355913  closed by  nnorwitz

Specify new reference return value for PyObject_Call  (2005-12-17)
   http://python.org/sf/1383115  closed by  effbot

LibRef: reworked chapter organization  (2005-12-07)
   http://python.org/sf/1375417  closed by  akuchling

cookielib LWPCookieJar and MozillaCookieJar exceptions  (2005-02-06)
   http://python.org/sf/1117398  closed by  nnorwitz

cookielib mis-handles RFC 2109 cookies in Netscape mode  (2005-03-04)
   http://python.org/sf/1157027  closed by  nnorwitz

New / Reopened Bugs
___

split() description not fully accurate  (2005-12-14)
   http://python.org/sf/1380970  opened by  K.C.

csv.reader endless loop   (2005-12-15)
   http://python.org/sf/1381476  opened by  Christian Harms

mode 't' not documented as posssible mode for file built-in  (2005-12-15)
   http://python.org/sf/1381717  opened by  Simo Salminen

cElementTree only supports a few encodings  (2005-12-15)
CLOSED http://python.org/sf/1381939  opened by  Fredrik Lundh

MacRoman Encoding Bug (OHM vs. OMEGA)  (2005-12-16)
CLOSED http://python.org/sf/1382096  opened by  Sean B. Palmer

Tutorial section 9.5.1 ignores MRO for new-style classes  (2005-12-16)
   http://python.org/sf/1382213  opened by  GaryD

--install-base not honored on win32  (2005-12-16)
   http://python.org/sf/1382562  opened by  John Ehresman

len() on class broken  (2005-12-16)
   http://python.org/sf/1382740  reopened by  kquick

len() on class broken  (2005-12-16)
   http://python.org/sf/1382740  opened by  Kevin Quick

len() on class broken  (2005-12-16)
CLOSED http://python.org/sf/1382815  opened by  Kevin Quick

MacOS.WMAvailable() doesn't launch Python.app properly  (2005-12-17)
CLOSED http://python.org/sf/1383644  opened by  has

random module - Provider DLL failed to initialize correctly  (2005-12-18)
   http://python.org/sf/1384175  opened by  Greg Hazel

exec statement link in index broken  (2005-12-19)
   http://python.org/sf/1385004  opened by  Harri Pasanen

compiler module does not detect a syntax error  (2005-12-19)
   http://python.org/sf/1385040  opened by  Harri Pasanen

execfile anomaly with "from __future__ import division"  (2005-12-19)
CLOSED http://python.org/sf/1385055  opened by  Harri Pasanen

_winreg specifies EnvironmentError instead of WindowsError  (2005-12-21)
   http://python.org/sf/1386675  opened by  Tony Meyer

sys.path[0] when executed thru a symbolic link  (2005-12-21)
CLOSED http://python.org/sf/1387483  opened by  Tomasz Kowaltowski

weird behavior when assigning locals() to a variable  (2005-12-22)
CLOSED http://python.org/sf/1387650  opened by  Samuel Bayer

Minor error in md5 docs  (2005-12-22)
CLOSED http://python.org/sf/1388141  opened by  Kent Johnson

bug in rstrip & lstrip  (2005-12-23)
CLOSED http://python.

Re: File object question

2005-12-23 Thread Ben Hutchings
S. D. Rose <[EMAIL PROTECTED]> wrote:
> "Kent Johnson" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
>> S. D. Rose wrote:
>> > Hello all.
>> >   If I read a binary file:
>> >
>> > file = open('c:\\logo.gif', 'rw'') # Read from FS as one way to get the
>> > object, d/l from website another...
>> > file.read()
>> >
>> > is there anyway I can determine the 'size' of the object file? (Without
>> > going to the filesystem and reading the filesize from the directory ...)
>>
>> Once you have read the data you can get the size of that:
>> d = file.read()
>> print len(d)
>>
>> Is that what you mean? Otherwise I don't know how you can get the size of
>> a file without
>> asking the filesystem...
>
> Yes, len() will do what I want.  I didn't realize it would work with binary,

The read() function returns a string (object of type str), whether the
file was opened in binary or text mode.  Such objects are really a
series of bytes which may or may not represent text in some encoding. 
(By contrast, objects of type unicode definitely do represent text in
some Unicode encoding.)

> I thought it was good only for variables, lists, etc.

Variables?  Do you mean tuples?  len() works with any kind of sequence,
and strings behave as a sequence of 1-byte strings.

-- 
Ben Hutchings
It is easier to write an incorrect program than to understand a correct one.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Find out the schema with psycopg?

2005-12-23 Thread Ben Hutchings
Steve Holden <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
>> I am trying to discover the schema of a PostgreSQL database
>> programatically at runtime.
>> 
>> I'm using psycopg (I assume that's still the best library).  Is there a
>> way to query the schema other than opening a system pipe like "psql -d
>> '\d'", "psql -d '\d tablename'", etc.?
>> 
>> DBIAPI 2.0 shows that the Cursor object has a .description method that
>> describes rows, and there's the Type object.  But neither of these
>> appear to give you table names.
>> 
>> Is there something else I should look at?
>
> Yes, but as with so many of these things you'll have to accept it's a 
> platform-specific (i.e. non-portable) solution, and it requires that you 
> are running PostgreSQL 7.4 or higher. Under those circumstances you can 
> query the metadata through the information schema.


It's not *that* non-portable - information_schema is a standard part
of ANSI SQL and is supported by several RDBMSes.

-- 
Ben Hutchings
It is easier to write an incorrect program than to understand a correct one.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bad people management

2005-12-23 Thread Alex Martelli
<[EMAIL PROTECTED]> wrote:
   ...
> Not really in the same vein but " Bad people management must be close
> to the #1 cause of failure of promising ..." software projects.
> Mind you, sometimes that just mean, minding one's self.

Hmmm, I'm not too sure -- though managing software projects is a huge
challenge, yet I would place the #1 cause of failure at *bad specs*...
doing SW that doesn't really meet the target audience's needs, no matter
how well it might be executed...


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


Bad people management (Was Herds of cats)

2005-12-23 Thread jmdeschamps

Alex Martelli wrote:
> Mike Meyer <[EMAIL PROTECTED]> wrote:
>
> > Steve Holden <[EMAIL PROTECTED]> writes:
> > > Alex Martelli wrote:
> > >> Not a bad point at all, although perhaps not entirely congruent to
> > >> open
> > >> source: hiring key developers has always been a possibility (net of
> > >> non-compete agreements, but I'm told California doesn't like those).
> >
> > California places pretty strict limits on non-compete agreements. I
>
> Yep, this is roughly what I'd heard, and what I meant above.
>
> > was at Ingres when their parent company - ASK - got bought by CA. CA
> > required people choosing to leave the company to sign an agreement
> > that included *their* standard non-compete clause before getting the
> > separation cash. Enough people left that found this clause irritating
> > that it got take to multiple lawyers. Every last one of them declared
> > it unenforceable in CA.
>
> Tx for the anecdote, which does appear to reinforce the point.  I assume
> CA's non-compete clause was fine in NY (I'm guessing that's where their
> lawyers would be) and they didn't consider the state differences...
>
>
> > > The essential difference, it seems to me, is that buying the company
> > > gets you control over the company's proprietary technologies, whereas
> > > hiring the developer only gets you access to the development skills of
> > > the people who've been involved open source developments.
> >
> > But it's not at all clear which of these is the more desirable
> > outcome.
>
> Good point.  I guess the only real answer is, "it depends".  But because
> of this SH's point should be rephrased as, "buying the company ONLY gets
> you control", etc, to emphasize the paralellism.  Even where non-compete
> agreements ARE enforced, by buying a company you're still not assured of
> getting *access to the development skills* -- even if those developers
> are forced to keep working for you, if they feel they're doing it under
> duress because you're legally twisting their arm, it seems very unlikely
> that you'll get much of anything USEFUL out of them (and I would be
> astonished if strict non-compete agreements still applied if you FIRED a
> developer, rather than the developer choosing to leave...).
>
> > CA bought ASK to get control of Ingres, which their Unicenter
> > product used as a database. The *entire* server software development
> > group left, meaning CA had all the sources and technologies, but none
> > of the talent that created them. We called this the $300 million
> > source license.
> >
> > CA pretty clearly got screwed on this deal. They have since
> > open-sourced the Ingres product.
>
> I'm not sure the two sentences in your last paragraphs are really as
> causally connected as one might think;-).  After all, didn't SAP also
> opensource their own DB (I believe they now have a partnership with
> MySQL to try to commercialize it), although in different circumstances?
>
> IOW, it seems to me that, apart from Oracle, nobody's making money on
> databases any more (I believe Microsoft is now giving away SQL Server
> for free, although maybe not the largest "enterprise" edition and surely
> not in open-source form -- of course, MS can afford a *lot* of money
> losing ventures, because Windows and Office bankroll the entire company
> to a highly "ca-ching" degree;-); so, companies whose money making
> depends on applications sitting on top of the DB (true to some extent of
> CA, to an even larger one of SAP) may opensource it both to (they hope)
> get some free support for it AND to minimally undermine Oracle (who uses
> its DB revenues to bankroll multipronged attacks and acquisitions into
> the field of enterprise applications).
>
> Still, I'm not disputing that CA "got screwed"... though it looks like
> they did it to themselves -- they didn't stop to consider the need to
> WOO developers to actually get them onboard as a part of the overall
> deal, just sort of assumed they "came with the package"!-)  Bad people
> management must be close to the #1 cause of failure of promising mergers
> and acquisitions (and I'm not sure the qualifying part of this sentence,
> after "failure", is needed;)...
>
>
> Alex
Not really in the same vein but " Bad people management must be close
to the #1 cause of failure of promising ..." software projects.
Mind you, sometimes that just mean, minding one's self.

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


Re: Herds of cats

2005-12-23 Thread Alex Martelli
Mike Meyer <[EMAIL PROTECTED]> wrote:

> Steve Holden <[EMAIL PROTECTED]> writes:
> > Alex Martelli wrote:
> >> Not a bad point at all, although perhaps not entirely congruent to
> >> open
> >> source: hiring key developers has always been a possibility (net of
> >> non-compete agreements, but I'm told California doesn't like those).
> 
> California places pretty strict limits on non-compete agreements. I

Yep, this is roughly what I'd heard, and what I meant above.

> was at Ingres when their parent company - ASK - got bought by CA. CA
> required people choosing to leave the company to sign an agreement
> that included *their* standard non-compete clause before getting the
> separation cash. Enough people left that found this clause irritating
> that it got take to multiple lawyers. Every last one of them declared
> it unenforceable in CA.

Tx for the anecdote, which does appear to reinforce the point.  I assume
CA's non-compete clause was fine in NY (I'm guessing that's where their
lawyers would be) and they didn't consider the state differences...


> > The essential difference, it seems to me, is that buying the company
> > gets you control over the company's proprietary technologies, whereas
> > hiring the developer only gets you access to the development skills of
> > the people who've been involved open source developments.
> 
> But it's not at all clear which of these is the more desirable
> outcome.

Good point.  I guess the only real answer is, "it depends".  But because
of this SH's point should be rephrased as, "buying the company ONLY gets
you control", etc, to emphasize the paralellism.  Even where non-compete
agreements ARE enforced, by buying a company you're still not assured of
getting *access to the development skills* -- even if those developers
are forced to keep working for you, if they feel they're doing it under
duress because you're legally twisting their arm, it seems very unlikely
that you'll get much of anything USEFUL out of them (and I would be
astonished if strict non-compete agreements still applied if you FIRED a
developer, rather than the developer choosing to leave...).

> CA bought ASK to get control of Ingres, which their Unicenter
> product used as a database. The *entire* server software development
> group left, meaning CA had all the sources and technologies, but none
> of the talent that created them. We called this the $300 million
> source license.
> 
> CA pretty clearly got screwed on this deal. They have since
> open-sourced the Ingres product.

I'm not sure the two sentences in your last paragraphs are really as
causally connected as one might think;-).  After all, didn't SAP also
opensource their own DB (I believe they now have a partnership with
MySQL to try to commercialize it), although in different circumstances?

IOW, it seems to me that, apart from Oracle, nobody's making money on
databases any more (I believe Microsoft is now giving away SQL Server
for free, although maybe not the largest "enterprise" edition and surely
not in open-source form -- of course, MS can afford a *lot* of money
losing ventures, because Windows and Office bankroll the entire company
to a highly "ca-ching" degree;-); so, companies whose money making
depends on applications sitting on top of the DB (true to some extent of
CA, to an even larger one of SAP) may opensource it both to (they hope)
get some free support for it AND to minimally undermine Oracle (who uses
its DB revenues to bankroll multipronged attacks and acquisitions into
the field of enterprise applications).

Still, I'm not disputing that CA "got screwed"... though it looks like
they did it to themselves -- they didn't stop to consider the need to
WOO developers to actually get them onboard as a part of the overall
deal, just sort of assumed they "came with the package"!-)  Bad people
management must be close to the #1 cause of failure of promising mergers
and acquisitions (and I'm not sure the qualifying part of this sentence,
after "failure", is needed;)...


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


Re: Enumeration idioms: Values from different enumerations

2005-12-23 Thread Steven D'Aprano
On Fri, 23 Dec 2005 23:51:22 +0200, Max wrote:

> Steven D'Aprano wrote:
>> 
>>>They certainly don't look much further from being integers than
>>>booleans do. 
>> 
>> 
>> You think?
>> 
>> hamburger, steak, fish, chicken, pizza
>> 
>> What meaning do you give to steak**fish? Should that meaning change if I
>> happened to have written pizza first instead of last?
> 
> What meaning do you give to True**False?

Given that True == 1 and False == 0 in Python (which in my opinion is
unfortunate), then it is obviously 1.

True booleans don't support arithmetic operators like **, and neither
should enums.



-- 
Steven.

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


Re: What is unique about Python?

2005-12-23 Thread Alex Martelli
gsteff <[EMAIL PROTECTED]> wrote:
   ...
> that's not really what I'm looking for.  So I'm wondering, what is
> innovative about Python, 

The letter 'y'.  Before Python, it was woefully underused in the names
of programming languages.  Now, of course, there's also Ruby, but then
we know Ruby did get some ideas from Python (and the letter 'y' is one
of them).


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


Re: GUI and graph

2005-12-23 Thread questions?
Thanks all you guys for the help.

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


Re: Indentation/whitespace

2005-12-23 Thread BartlebyScrivener
The PEP is not a joke. It's a sensible set of guidelines. The blog post
advocating enforcement is, shall we say, a sportive modest proposal?

rpd
www.dooling.com

"There is no human problem which could not be solved if people would
simply do as I advise."--Gore Vidal

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


Re: What is unique about Python?

2005-12-23 Thread KraftDiner
I like python.. Its ok.. One thing that I find a bit dangerous it the
use
of the tab character for indentation.. I've had copy and pasts loose
indentation on me and its theoretically impossible to really figure out
what the indentation should be.  I think for the extra effort it would
have
taken to put brackets in the language it would increase a lot of
peoples
confidence in using it for codeing...

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


Re: What is unique about Python?

2005-12-23 Thread Robert J. Hansen
> [w]hat is innovative about Python, either in its design or implementation?

This is probably the wrong approach to take.

What Python brings to the table isn't a new capability, but an elegant
and straightforward notation.  It's not as beautiful as LISP, but it's
close.  Sell it on that, not on any unique or rare capabilities.

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


Re: pyQt for windows

2005-12-23 Thread Phil Thompson
On Friday 23 December 2005 8:39 pm, relativity wrote:
> I have downloaded and installed pyQt 3.14 educational but when I run any of
> the examples I get an error saying qt-mtedu333.dll was not found. I have
> also installed the qt4 opensource version for windows but I am not sure
> everything was set up correctly. When I run configure it complains about
> file or folder not found (mingw32-make). I installed mingw with qt. Anyway
> any help would be appreciated. All i want is to be able to use QT on
> windows with python.

The educational version of PyQt requires the educational version of Qt. As 
your address is obviously bogus I can't say whether or not you would qualify 
for this - ask Trolltech.

The GPL version of PyQt4 for Windows has not yet been released - it will be in 
the next few weeks.

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


Re: Indentation/whitespace

2005-12-23 Thread rbt
Gary Herron wrote:
> rbt wrote:
> 
>> BartlebyScrivener wrote:
>>  
>>
>>> What's needed is STRICTER whitespace enforcement, especially on April
>>> Fools Day. Some call it whitespace fascism.
>>>
>>> http://www.artima.com/weblogs/viewpost.jsp?thread=101968
>>>
>>>   
>>
>> I've only been coding Python for about 3 years now. C is the only 
>> other language I'm moderately good with. Most of the people on 
>> comp.lang.python have _much_ more coding experience than I do. I don't 
>> know who came up with this PEP, but I like it a lot. To me, it makes 
>> sense, just like Python makes sense. Any time-line on implementing this?
>>  
>>
> Look at the date. That was an April Fools joke.
> 
> Gary Herron
> 

I still think it makes sense :) ... perhaps I'm a fool.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Indentation/whitespace

2005-12-23 Thread Gary Herron
rbt wrote:

>BartlebyScrivener wrote:
>  
>
>>What's needed is STRICTER whitespace enforcement, especially on April
>>Fools Day. Some call it whitespace fascism.
>>
>>http://www.artima.com/weblogs/viewpost.jsp?thread=101968
>>
>>
>>
>
>I've only been coding Python for about 3 years now. C is the only other 
>language I'm moderately good with. Most of the people on 
>comp.lang.python have _much_ more coding experience than I do. I don't 
>know who came up with this PEP, but I like it a lot. To me, it makes 
>sense, just like Python makes sense. Any time-line on implementing this?
>  
>
Look at the date. That was an April Fools joke.

Gary Herron

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


Re: Indentation/whitespace

2005-12-23 Thread Gary Herron
Joe wrote:

>Is Python going to support s syntax the does not use it's infamous
>whitespace rules? I recall reading that Python might include such a
>feature. Or, maybe just a brace-to-indentation preprocessor would be
>sufficient.
>  
>
Only over our dead bodies! ("our" = the large and 
always growing Python
community.)

>Many people think Python's syntax makes sense. There are strong
>feelings both ways. It must depend on a person's way of thinking,
>because I find it very confusing, even after using with Python for some
>time, and trying to believe the advice that I would learn to like it.
>The most annoying thing is that multiple dedents are very unreadable. I
>still don't understand how anybody can think significant-but-invisible
>dedentation is a good thing.
>  
>
You've got the visible/invisible aspect of things 
*exactly* backwards.
The point on a line of text where things change 
from white space to
non-white space is *highly* visible. The several 
pixels that represent a
{ or } are nearly invisible within a line of text. 
(So one usually
compensates by putting them alone on a line, 
making them somewhat more
visible.)

Try this experiment: Print out a page of C++ code, 
tape it to the wall,
and start walking backwards. You will still be 
able to discern the
structure of the code *long* after you can no 
longer identify the
curly-braces. (Provided you properly indented you 
C++ code -- you *do*
indent you C++ code don't you?)

Gary Herron

>Note: No need to follow up with long opinions of why indentation is
>good -- they have been posted hundreds of times. It just seems that
>Python developers think the whitespace thing is only an issue for
>newbies. I think that many experienced users don't learn to like it,
>but instead just learn to live with it.
>
>  
>


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


Re: Indentation/whitespace

2005-12-23 Thread thakadu
I consider myself a fairly experienced Python coder and although I am
not "uncomfortable" with significant whitespace there are a few places
where I do find it annoying and I wouldnt mind an alternate block
delimitation syntax.  I would prefer something like the ruby "end"
though rather than '{' and '}'. The place I find it annoying is in
pasting snippets of code from say web pages. I very often google for a
piece of code and then paste it into my editor and almost always the
pasted piece of code has different indentation and causes a compiler
error. Sometimes in vim "100==" fixes it but very often not. It would
be nice if you could use an "end" delimiter for quick experimentation
with code and then later on go and remove the "end" and fix the
indentation.

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


Re: Indentation/whitespace

2005-12-23 Thread rbt
BartlebyScrivener wrote:
> What's needed is STRICTER whitespace enforcement, especially on April
> Fools Day. Some call it whitespace fascism.
> 
> http://www.artima.com/weblogs/viewpost.jsp?thread=101968
> 

I've only been coding Python for about 3 years now. C is the only other 
language I'm moderately good with. Most of the people on 
comp.lang.python have _much_ more coding experience than I do. I don't 
know who came up with this PEP, but I like it a lot. To me, it makes 
sense, just like Python makes sense. Any time-line on implementing this?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Indentation/whitespace

2005-12-23 Thread thakadu
It is not really unique to Python as I have pointed out on this or
other forums before. The Occam (OCCAM?) language also uses significant
whitespace in much the same way as Python and there may also be others.

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


Re: Indentation/whitespace

2005-12-23 Thread James Tanis
On 23 Dec 2005 10:01:37 -0800, Joe <[EMAIL PROTECTED]> wrote:
> It just seems that
> Python developers think the whitespace thing is only an issue for
> newbies. I think that many experienced users don't learn to like it,
> but instead just learn to live with it.

I disagree, I don't think you can be an experienced python programmer
and not be comfortable with its syntax. On the other hand you *can* be
an experienced programmer, but that's not the same thing. I don't care
how much code you've written in Python, if your not comfortable with
the syntax then you clearly don't use it with enough consistency to
bring yourself to that point where you "own" it. There's nothing wrong
with that, for whatever reason, maybe Python isn't for you.. but
certainly don't blame it on something as small as significant
indention, because we've all been there and its just not that hard to
make the change. There are quite a few good high-level languages out
there these days. This may be out of place, but I'd suggest checking
out Ruby if you want something as powerful and "fun" to code in as
Python but with more Perl-like syntax. It doesn't quite have as much
of a diverse module selection as Python and Perl but that will change
with time. Open source gives us an unprecendented amount of choices,
try them all out.. I have, and I came up with Python because for me it
is the "best fit." That may not be true in your case, which is
perfectly fine.

--
James Tanis
[EMAIL PROTECTED]
http://pycoder.org
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Some errors when running code in diveintopython: (

2005-12-23 Thread Heiko Wundram
beryan wrote:
> El Fri, 23 Dec 2005 05:18:30 -0800, iclinux escribió:
>> gaierror: (11001, 'getaddrinfo failed')
> Take a look over firewall settings and give Python rights for accesing
> port 80

Well, rather he should take a look at allowing Python to resolve host names.
That's what this error is about.

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


Re: Vaults of Parnassus hasn't been updated for months

2005-12-23 Thread kpd
No offense intended to the cheesemakers, but I miss the vaults too.

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


Re: Indentation/whitespace

2005-12-23 Thread BartlebyScrivener
What's needed is STRICTER whitespace enforcement, especially on April
Fools Day. Some call it whitespace fascism.

http://www.artima.com/weblogs/viewpost.jsp?thread=101968

rpd

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


Re: Enumeration idioms: Values from different enumerations

2005-12-23 Thread Max
Steven D'Aprano wrote:
> 
>>They certainly don't look much further from being integers than
>>booleans do. 
> 
> 
> You think?
> 
> hamburger, steak, fish, chicken, pizza
> 
> What meaning do you give to steak**fish? Should that meaning change if I
> happened to have written pizza first instead of last?

What meaning do you give to True**False?

> 
> The fact that they can be counted shouldn't fool you into thinking they
> are numbers. 
> 
> 
> 

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


Re: sorting with expensive compares?

2005-12-23 Thread Paul Rubin
Dan Stromberg <[EMAIL PROTECTED]> writes:
> I've been using the following compare function, which in short checks, in
> order:
> 
> 1) device number
> 2) inode number
> 3) file length
> 4) the beginning of the file
> 5) an md5 hash of the entire file
> 6) the entire file
> 
> (If #1 and #2 are identical, then the file must be a hardlink to the other
> file.  Also, files that do not have the same length can never be
> identical.  And of course these items are generated on demand, making it
> frequently possible to avoid doing full-file-length compare on a lot of
> files)
> 
> However, my program is still doing more #6 comparisons than seems

Just don't do any #6 comparisons.  If the hashes are identical, the
files are identical--that's the point of a cryptographic hash.  OK, to
be pedantic:

   1) there's a microscopic chance of an accidental collision, but
   it's much lower than the chance of a hardware failure making your
   comparison function give the wrong answer.

   2) there are known cryptanalytic attacks against md5 that can let
   someone deliberately construct two distinct files with the same
   hash, with a fair amount of efort.  If you care about this, use
   sha-1 instead, or better yet, sha-256.  (sha-1 has an attack
   similar to the md5 attack, but the amount of work required is not
   really practical today, unlike the md5 attack).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is unique about Python?

2005-12-23 Thread Max
gsteff wrote:
> I'm a computer science student, and have recently been trying to
> convince the professor who teaches the programming language design
> course to consider mentioning scripting languages in the future.  Along
> those lines, I've been trying to think of features of Python, and
> scripting languages in general, that can't be found in older languages,
> and have been having a surprising amount of trouble.  Dynamic typing
> can be found in Smalltalk, the module concept can be found in Ada,
> functional parameters and the dynamic creation of functions can be
> found in Lisp.  The indentation-based syntax seems to be unique, but
> that's not really what I'm looking for.  So I'm wondering, what is
> innovative about Python, either in its design or implementation?  Or is
> its magic really just in combining many useful features of prior
> languages in an unusually pleasant way?
> 
> Greg
> 

I find that development in python is much faster than anything else. But 
one of the noticeable features, for me and presumably computer science 
students, is the pseudocode-python translation: I've been working 
through a CS textbook to train for the IOI, and noticed how much my 
python implementations look like the textbook's pseudocode (whereas the 
C++ versions look nothing like the pcode).

If anything, python is _more_ expressive - where list comprehensions and 
generators are the natural way of doing things, the textbook has to 
kludge because its target audience is C++, Java and Pascal programmers.

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


Re: Logging: Formatter: name of the function

2005-12-23 Thread Sylvain Defresne
Le vendredi 23 décembre 2005 à 16:23 +0100, Gregor Horvath a écrit :
> Hi,
> 
> Is there a possibility to format a log message to give the function name 
> where the log appears?
> 
> Example
> 
> import logging
> 
> def aTestFunction():
>logger.debug("This is a message")
> 
> The log should read:
> 
> aTestFunction  This is a message.

You can use the currentframe of the inspect module. For example :

>>> import inspect
>>> def debug(string):
... frame = inspect.currentframe(1)
... print frame.f_code.co_name, string
>>> def a_test_function():
... debug("This is a message")
>>> a_test_function()
a_test_function This is a message

But please take note that this is not recommended. As stated in the
documentation of inspect.currentframe : "[t]his function should be used
for internal and specialized purposes only."
-- 
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?

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

Re: print UTF-8 file with BOM

2005-12-23 Thread Martin v. Löwis
John Bauman wrote:
> UTF-8 shouldn't need a BOM, as it is designed for character streams, and 
> there is only one logical ordering of the bytes. Only UTF-16 and greater 
> should output a BOM, AFAIK. 

Yes and no. Yes, UTF-8 does not need a BOM to identify endianness. No,
usage of the BOM with UTF-8 is explicitly allowed in the Unicode specs
(so output of the BOM doesn't *have* to be restricted to UTF-16 and
greater), and the BOM has a well-defined meaning for UTF-8 (namely,
as the UTF-8 signature).

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


Re: sorting with expensive compares?

2005-12-23 Thread Steven D'Aprano
On Fri, 23 Dec 2005 19:26:11 +0100, Peter Otten wrote:

> Dan Stromberg wrote:
> 
>> I'm wanting to sort a large number of files, like a bunch of output files
>> from a large series of rsh or ssh outputs on a large series of distinct
>> machines, a music collection in .ogg format (strictly redistributable and
>> legally purchased music), a collection of .iso cdrom images (strictly
>> redistributable and legally purchased software), and so forth.
> 
> Are you really trying to establish an order or do want to eliminate the
> duplicates?
> 
 File("perfectly_legal.ogg") < File("free_of_charge.mp3")
> True
> 
> doesn't make that much sense to me, regardless of what the comparison may
> actually do.

If I have understood the poster's algorithm correctly, it gets even
weirder:


Sorted list of files ->

[parrot.ogg, redhat.iso, george.log, fred.log, rhino.ogg, cat.ogg,
debian.iso, sys_restore.iso, adrian.log, fox.ogg, ...]

It seems to this little black duck that by sorting by file contents in
this way, the effect to the human reader is virtually to randomise the
list of file names.

Even if you limit yourself to (say) a set of ogg files, and sort by the
binary contents ->

# album-track
[parrot-6.ogg, rhino-1.ogg, cat-12.ogg, fox-2.ogg, parrot-3.ogg, ...]

most people looking at the list would guess it had been shuffled, not
sorted. So I too don't know what the original poster hopes to accomplish
by sorting on the content of large binary files.



-- 
Steven.

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


Re: Herds of cats

2005-12-23 Thread Mike Meyer
Steve Holden <[EMAIL PROTECTED]> writes:
> Alex Martelli wrote:
>> Not a bad point at all, although perhaps not entirely congruent to
>> open
>> source: hiring key developers has always been a possibility (net of
>> non-compete agreements, but I'm told California doesn't like those).

California places pretty strict limits on non-compete agreements. I
was at Ingres when their parent company - ASK - got bought by CA. CA
required people choosing to leave the company to sign an agreement
that included *their* standard non-compete clause before getting the
separation cash. Enough people left that found this clause irritating
that it got take to multiple lawyers. Every last one of them declared
it unenforceable in CA.

> The essential difference, it seems to me, is that buying the company
> gets you control over the company's proprietary technologies, whereas
> hiring the developer only gets you access to the development skills of
> the people who've been involved open source developments.

But it's not at all clear which of these is the more desirable
outcome. CA bought ASK to get control of Ingres, which their Unicenter
product used as a database. The *entire* server software development
group left, meaning CA had all the sources and technologies, but none
of the talent that created them. We called this the $300 million
source license.

CA pretty clearly got screwed on this deal. They have since
open-sourced the Ingres product.

 http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


query on csv file reading and replacing

2005-12-23 Thread muttu2244
Hi everybody

Am trying to read a csv file "temp.csv", which has the below info,


compName   macAddripAddr
opSys

Chris-Dev 0003469F44CC  10.160.24.226   Microsoft Windows XP
Professional
Shivayogi-Dev  000D5234F44C 10.160.24.136   Microsoft Windows XP
Professional
John-test 000D123F44CC  10.160.24.216   Microsoft Windows XP
Professional Steve-Dev000D123F55CC  10.160.24.116   Microsoft
Windows XP Professional

am trying to read it in the following way--

>>> import csv
>>> infoFile = open ('c:\\temp.csv','r')
>>> rdr = csv.reader(infoFile)
>>> for row in rdr:
... if row[0] == infnList[0]:
... if not row[1] == infnList[1] or not row[2] == infnList[2]:

now am comparing my comp Name  with the "compName" fields, and if it
matches i ll then compare for the "mac address" and "ip address". if
they are not matching with my system, i have to modify them there
itself, i mean i have to update "mac address" and "ip address" in the
same row itself, i dont want to append the information with another row
to the "temp.csv" file. otherwise it will have two similar computer
names for two rows, which i dont want to happen.

please give me the ways how i can work on this.

thanks in advance
yogi

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


Re: sorting with expensive compares?

2005-12-23 Thread Steven D'Aprano
On Fri, 23 Dec 2005 09:20:55 -0800, bonono wrote:

> 
> Dan Stromberg wrote:

[snip]

>> I've been using the following compare function, which in short checks, in
>> order:
>>
>> 1) device number
>> 2) inode number
>> 3) file length
>> 4) the beginning of the file
>> 5) an md5 hash of the entire file
>> 6) the entire file
>>
>> (If #1 and #2 are identical, then the file must be a hardlink to the other
>> file.  Also, files that do not have the same length can never be
>> identical.  And of course these items are generated on demand, making it
>> frequently possible to avoid doing full-file-length compare on a lot of
>> files)
>>
>> However, my program is still doing more #6 comparisons than seems
>> strictly necessary when I could just toss all the filenames describing
>> identical files into a list, and avoid re-comparing files with identical
>> content over and over - I don't want to compare them to each other again
>> and again), when there are a lot of identical files in the input list.
>
> Why would #5 not enough as an indicator that the files are indentical ?

(1) Because the MD5 algorithm does include collisions. I was going to say
"rare collisions", but there is actually an infinite number of them. The
collisions are just distributed thinly -- because MD5 is a good hash
algorithm, *very* thinly.

(Proof of this comes from the pigeon-hole principle: there is an infinite
number of possible files of arbitrary length, and only a finite number of
possible hashes. Therefore, an infinite number of files must hash to each
possible hash.)

(2) Having said that, unless the original poster is dealing with billions
(plus) of files, it is unlikely that he is finding any of the collisions
unless there is a bug in his sort routine. Since he claims to be doing
more comparisions-by-file-contents than expected (I would suggest *one*
is more than expected), I predict a bug in his code, his algorithm, or
both.


-- 
Steven.

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


pyQt for windows

2005-12-23 Thread relativity
I have downloaded and installed pyQt 3.14 educational but when I run any of 
the examples I get an error saying qt-mtedu333.dll was not found. I have 
also installed the qt4 opensource version for windows but I am not sure 
everything was set up correctly. When I run configure it complains about 
file or folder not found (mingw32-make). I installed mingw with qt. Anyway 
any help would be appreciated. All i want is to be able to use QT on windows 
with python. 


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


Re: Indentation/whitespace

2005-12-23 Thread Terry Hancock
On Fri, 23 Dec 2005 11:51:23 -0700
Dave Benjamin <[EMAIL PROTECTED]> wrote:
> +1 on the preprocessor idea, especially if it would allow
> us to hook in  at the AST level as well. (No comment on
> the curlies. ;)

Only +0 on it myself, but I do know of a use-case -- certain
types of web-templating frameworks can be easier to use if
the inserted code can be put on one line.

Some people have been agitating for some way to do this with
Python for some time (on Zope lists), and a preprocessor
would provide a means for them to get what they want.

OTOH, I have been able to manage with the way things are. It
encourages good separation between templates and code, which
is supposed to be a good thing according to the "Zope Zen".
;-)


-- 
Terry Hancock ([EMAIL PROTECTED])
Anansi Spaceworks http://www.AnansiSpaceworks.com

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


Re: How to call function which is in one program ...

2005-12-23 Thread Shahriar Shamil Uulu
Thank you Fredrik Lundh
for your help ...
it worked ...
the problem was in saving of file first.py
Fredrik Lundh wrote:
> "Shahriar Shamil Uulu" wrote:
>
> > i got another questions. For example i have two programs in python
> > like: first.py, second.py.
> > In first.py i have a function test() like:
> > # first.py
> > ...
> > def test(name):
> >  print name
> >
> >  so other functions
> > =
> >
> > #second.py
> >
> > Question is how i can include first.py into second.py and use function
> > test.py.
>
> # File: second.py
> import first
> first.test()
>
> tips: read a Python tutorial *before* you post your next question.  start 
> here:
> 
> http://www.python.org/doc/Intros.html
> 
> 

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


run line or selection

2005-12-23 Thread linda.s
is there any tool like "run line or selection" in Pythonwin?
Thanks!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Vaults of Parnassus hasn't been updated for months

2005-12-23 Thread Do Re Mi chel La Si Do
Hi!


>>> Just a poll: Who misses the Vaults of Parnassus like me?

Me   (+1)


@-salutations

Michel Claveau



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


Re: Indentation/whitespace

2005-12-23 Thread Thomas Bartkus
"Joe" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Is Python going to support s syntax the does not use it's infamous
> whitespace rules? I recall reading that Python might include such a
> feature. Or, maybe just a brace-to-indentation preprocessor would be
> sufficient.
>
> Many people think Python's syntax makes sense. There are strong
> feelings both ways. It must depend on a person's way of thinking,
> because I find it very confusing, even after using with Python for some
> time, and trying to believe the advice that I would learn to like it.
> The most annoying thing is that multiple dedents are very unreadable. I
> still don't understand how anybody can think significant-but-invisible
> dedentation is a good thing.
>
> Note: No need to follow up with long opinions of why indentation is
> good -- they have been posted hundreds of times. It just seems that
> Python developers think the whitespace thing is only an issue for
> newbies. I think that many experienced users don't learn to like it,
> but instead just learn to live with it.

Okay - I'll take your note and not argue about "why indentation is good"

But - why should Python
   "support s syntax the does not use it's infamous whitespace rules"
It's unique to Python. That's what Python *is*.

If one doesn't like it, one needn't waste one's time with it.  No other
other language abides by those rules except Python.

So just choose a different language to work with.
Thomas Bartkus


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


jython/wlst: How to avoid newlines in output from "cd" command (and others)

2005-12-23 Thread davidmichaelkarr
I'm using WebLogic Scripting Tool, which uses Jython, which uses Python
2.1.  In a script I'm writing, executing a "cd()" always emits a
newline to stdout.  Is there a way to make it not emit that newline on
the "cd()" command (and others like it)?

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


Re: Parsing a date-time string?

2005-12-23 Thread linda.s
Hi,
I got the message of "There was an error in the DDE conversation with
Pythonwin" when I tried to run Pythonwin.
I googled and found the possible solution is:
modify the Pythonwin shortcut to pass a
"/nodde" command-line option.
I got lost how to do that.
Thanks for any help!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Some errors when running code in diveintopython: (

2005-12-23 Thread beryan
El Fri, 23 Dec 2005 05:18:30 -0800, iclinux escribió:

> I can visit those two websites above, but when I run your code, I get
> those errors(BTW,I have closed my firewall
> ):
> 
 import socket
 socket.getaddrinfo("www.xmethods.net", 80)
> 
> Traceback (most recent call last):
>   File "", line 1, in -toplevel-
> socket.getaddrinfo("www.xmethods.net", 80)
> gaierror: (11001, 'getaddrinfo failed')
 socket.getaddrinfo("services.xmethods.net", 80)
> 
> Traceback (most recent call last):
>   File "", line 1, in -toplevel-
> socket.getaddrinfo("services.xmethods.net", 80)
> gaierror: (11001, 'getaddrinfo failed')
 
> 
> what can I do?


Have you got a Firewall ?
Take a look over firewall settings and give Python rights for accesing
port 80
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Indentation/whitespace

2005-12-23 Thread Dave Benjamin
Alex Martelli wrote:
> The main reason I suggest a general-purpose mechanism for the hooking-up
> of the preprocessor is that such a mechanism might stand a chance to be
> accepted (via the usual PEP procedure), as long as other interesting use
> cases can be found; I suspect that if the only use case was "turn braces
> into indents/dedents", the PEP would stand no chance.

+1 on the preprocessor idea, especially if it would allow us to hook in 
at the AST level as well. (No comment on the curlies. ;)

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


Re: Providing 'default' value with raw_input()?

2005-12-23 Thread Scott David Daniels
planetthoughtful wrote:
> ...
> I had thought to build GUIs in wxPython - is Tkinter any easier to
> learn?

I certainly found Tkinter easier.  There are a couple of good tutorials
(and there is always the Grayson book) on the web to get started.  What
is easiest to learn is (in many cases) a property of the student,
however.  Were I a Linux-only GPL kind of a guy, I think Qt might be
an interesting way to go.  One thing that helps tremendously in learning
Tkinter: using Idle in single-process mode:

 C:\Python24\Python C:\Python24\Lib\idlelib\idle.pyw -n

This is obviously a WinXX example, but the "-n" parameter to idle is
the important part.  Since a single-process Idle is running the Tkinter
GUI loop, you can try operations a step at a time (letting you see what
happens).

--Scott David Daniels
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: sorting with expensive compares?

2005-12-23 Thread Steve Holden
[EMAIL PROTECTED] wrote:
> Dan Stromberg wrote:
[...]
>>I've been using the following compare function, which in short checks, in
>>order:
>>
>>1) device number
>>2) inode number
>>3) file length
>>4) the beginning of the file
>>5) an md5 hash of the entire file
>>6) the entire file
[...]
> Why would #5 not enough as an indicator that the files are indentical ?
> 
Because it doesn't guarantee that the files are identical. It indicates, 
to a very high degree of probability (particularly when the file lengths 
are equal), that the two files are the same, but it doesn't guarantee it.

Technically there are in infinite number of inputs that can produce the 
same md5 hash.

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: sorting with expensive compares?

2005-12-23 Thread Peter Otten
Dan Stromberg wrote:

> I'm wanting to sort a large number of files, like a bunch of output files
> from a large series of rsh or ssh outputs on a large series of distinct
> machines, a music collection in .ogg format (strictly redistributable and
> legally purchased music), a collection of .iso cdrom images (strictly
> redistributable and legally purchased software), and so forth.

Are you really trying to establish an order or do want to eliminate the
duplicates?

>>> File("perfectly_legal.ogg") < File("free_of_charge.mp3")
True

doesn't make that much sense to me, regardless of what the comparison may
actually do.

Peter

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


Re: Indentation/whitespace

2005-12-23 Thread Alex Martelli
Joe <[EMAIL PROTECTED]> wrote:

> Is Python going to support s syntax the does not use it's infamous
> whitespace rules?

No, never (even apart from the "its" vs "it's" issue here...;-).

> I recall reading that Python might include such a
> feature.

And I recall reading that Elvis is still alive and was kidnapped by
aliens, but I don't necessarily believe all that I read.

> Or, maybe just a brace-to-indentation preprocessor would be
> sufficient.

Fine, then write one -- it's not too hard (about an average interview
question for hiring a programmer, I'd say).  As for how to integrate
such a preprocessor with CPython, I would suggest you follow precedent
by allowing an arbitrary "source-code-reading hook" to be optionally
specified by setting sys.preprocessor (and/or via commandline flag,
environment variable, etc -- but, the ability to install the hook from
site-configure.py would probably be sufficient).

You could maybe get 99% of the way there by using the existing "import
hooks" mechanism (the same one that lets you import from zipfiles: it's
designed to be easily extensible), but I don't think that would help
with the "main script" (which doesn't get imported), interactive
interpreter sessions, etc; also, I'm not sure it would easily allow
seamless interoperation with other such hooks (e.g., to let you import
from zipfiles sources that need to be preprocessed).

The main reason I suggest a general-purpose mechanism for the hooking-up
of the preprocessor is that such a mechanism might stand a chance to be
accepted (via the usual PEP procedure), as long as other interesting use
cases can be found; I suspect that if the only use case was "turn braces
into indents/dedents", the PEP would stand no chance.

For example, a small but vocal minority has long campaigned for
non-ASCII characters to be allowed in identifiers; a preprocessor might
be able to do this by translating them into ASCII on the fly (though
that wouldn't necessarily work well with getattr and friends... but
then, neither do 'private' identifiers starting with two underscores;-).

> still don't understand how anybody can think significant-but-invisible
> dedentation is a good thing.

We're even, then, since I can't understand the reverse;-).

> Note: No need to follow up with long opinions of why indentation is
> good -- they have been posted hundreds of times. It just seems that

Respecting your wish, I'm not discussing the issue at all (although, by
trying to make some point AGAINST it, you really make it very hard: if
you don't want such a discussion you shouldn't start one yourself and
then try to impede your opponents from rebutting your points, that is
really an extremely unfair attempt on your part).  I'm pointing you to
ways you might get your wish, if you're willing to do some work for the
purpose. Coding the preprocessor is the easy part -- the work is mostly
in doing the PEP, including a variety of strong use cases for a general
purpose preprocessor.  (Of course, forking Python to hardcode your
preprocessor is easier, but forking always has other problems).


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


Re: Indentation/whitespace

2005-12-23 Thread Larry Bates
Joe wrote:
> Is Python going to support s syntax the does not use it's infamous
> whitespace rules? I recall reading that Python might include such a
> feature. Or, maybe just a brace-to-indentation preprocessor would be
> sufficient.
> 
> Many people think Python's syntax makes sense. There are strong
> feelings both ways. It must depend on a person's way of thinking,
> because I find it very confusing, even after using with Python for some
> time, and trying to believe the advice that I would learn to like it.
> The most annoying thing is that multiple dedents are very unreadable. I
> still don't understand how anybody can think significant-but-invisible
> dedentation is a good thing.
> 
> Note: No need to follow up with long opinions of why indentation is
> good -- they have been posted hundreds of times. It just seems that
> Python developers think the whitespace thing is only an issue for
> newbies. I think that many experienced users don't learn to like it,
> but instead just learn to live with it.
> 
Characterizing indentation as "invisible" isn't really fair.
It it WAY more visible than a { character. IMHO the
indentation works very well.  I've tried to wade through PHP,
JavaScript, C code that uses those 
brace ({}) blocks until my head hurt, especially if they
didn't indent as well as using the braces.  If they indent
so I can actually read the code, why also use braces to
clutter things up?  I've solved the multiple dedent problem
by inserting a comment that shows where the indented blocks
end (sort of where the ending brace (}) would have been.
I also find that if I'm indenting more than a couple of
levels, I probably need to refactor my code into smaller
objects or rethink the process so that I process collections
of objects.  I've written in many different languages over
a span of 32+ years and it seems to work for me.

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


Re: Guido at Google

2005-12-23 Thread rbt
Luis M. González wrote:
> rbt wrote:
>> Go right ahead. Perhaps we should do one for Perl too:
>>
>> It's like having King Kong as your very own personal body guard ;)
> 
> Good analogy:
> You know, they call Perl the "eight-hundred-pound gorilla" of scripting
> languages.

Absolutely. It's big, hairy, smelly, a bit dense at times and always
difficult to communicate with, but by god it gets the job done albeit in
a messy sort of way ;)

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


Re: sorting with expensive compares?

2005-12-23 Thread Alex Martelli
Dan Stromberg <[EMAIL PROTECTED]> wrote:
   ...
> I'm wanting to sort a large number of files, like a bunch of output files
> from a large series of rsh or ssh outputs on a large series of distinct
> machines, a music collection in .ogg format (strictly redistributable and
> legally purchased music), a collection of .iso cdrom images (strictly
> redistributable and legally purchased software), and so forth.
> 
> I'm not sorting the content of each file individually.
> 
> I'm treating each file as a potentially very large string, and "sorting
> the strings".

OK, very clear.

> I've been using the following compare function, which in short checks, in
> order:
> 
> 1) device number
> 2) inode number
> 3) file length
> 4) the beginning of the file
> 5) an md5 hash of the entire file
> 6) the entire file

Makes sense, including the possibility of computing some items on
demand.  However, using a key-callable rather than a cmp-callable may
still make sense -- you just need a callable that extracts the
attributes on demand (and caches them thereafter... assuming you have
enough memory to keep all the caches, I guess [6] might be a problem).
I do see that key-callables won't necessarily work easily here, but
since the key-callable's __cmp__ will in turn be called, that might
still work better... but, on reflection, it's probably just a minor
gain.

> However, my program is still doing more #6 comparisons than seems
> strictly necessary when I could just toss all the filenames describing
> identical files into a list, and avoid re-comparing files with identical
> content over and over - I don't want to compare them to each other again
> and again), when there are a lot of identical files in the input list.

The comparison should never get called twice on the same two objects,
anyway.  So, I'm not sure what you think you could gain by optimizing
future comparisons of two objects once you've ascertained they are in
fact equal.  Still, assuming for example that self.name is a unique
identifier (i.e. the so-called name is in fact a complete path), the
optimization (memoization) is quite easy to perform.  Rename what you
currently have as __cmp__ by another name, say _real_cmp, add a
_compared dict to the class, and code the following __cmp__ ...:

_compared = {}
def __cmp__(self, other):
try: return -self._compared[other.name, self.name]
except KeyError: pass
key = self.name, other.name
if key in self._compared: return self._compared[key]
result = self_compared[key] = self._real_cmp(other)
return result

I would not expect this optimization to matter at all, because no key
should ever be already present in the self._compared dictionary (the
same two files should never, ever get compared twice anyway).

However, it might be possible to extend this idea by using the
properties you know an ordering should have -- if A and B have never
been compared, but both have been compared with C, in some cases you
don't need to compare A and B but may exploit already-known results.
For example, if A==C and B==C, you already know that A==B without any
actual comparison; if Ahttp://mail.python.org/mailman/listinfo/python-list


Indentation/whitespace

2005-12-23 Thread Joe
Is Python going to support s syntax the does not use it's infamous
whitespace rules? I recall reading that Python might include such a
feature. Or, maybe just a brace-to-indentation preprocessor would be
sufficient.

Many people think Python's syntax makes sense. There are strong
feelings both ways. It must depend on a person's way of thinking,
because I find it very confusing, even after using with Python for some
time, and trying to believe the advice that I would learn to like it.
The most annoying thing is that multiple dedents are very unreadable. I
still don't understand how anybody can think significant-but-invisible
dedentation is a good thing.

Note: No need to follow up with long opinions of why indentation is
good -- they have been posted hundreds of times. It just seems that
Python developers think the whitespace thing is only an issue for
newbies. I think that many experienced users don't learn to like it,
but instead just learn to live with it.

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


Re: urlretrieve() questions

2005-12-23 Thread Dan M
> Pretty straight forward...but what I'm finding is if the
> url is pointing to a file that is not there, the server
> returns a file that's a web page displaying a 404 error. 
> 
> Anyone have any recommendations for handling this?

You're right, that is NOT documented in a way that's easy to find! 

What I was able to find is how to what you want using urllib2 instead of
urllib. I found an old message thread that touches on the topic:
http://groups.google.com/group/comp.lang.python/browse_thread/thread/3f02bee97a689927/88c7bfec87e18ba9?q=%22http+status%22+%2Burllib&rnum=3#88c7bfec87e18ba9
(also accessable as http://tinyurl.com/952dw). Here's a quick summary:
---

Ivan Karajas
Apr 28 2004, 11:03 pm   show options
Newsgroups: comp.lang.python
From: Ivan Karajas <[EMAIL PROTECTED]> - Find messages by this author
Date: Wed, 28 Apr 2004 23:03:54 -0800
Local: Wed, Apr 28 2004 11:03 pm
Subject: Re: 404 errors
Reply to Author | Forward | Print | Individual Message | Show original | Report 
Abuse

On Tue, 27 Apr 2004 10:46:47 +0200, Tut wrote:
> Tue, 27 Apr 2004 11:00:57 +0800, Derek Fountain wrote:

>> Some servers respond with a nicely formatted bit of HTML explaining the
>> problem, which is fine for a human, but not for a script. Is there some
>> flag or something definitive on the response which says "this is a 404
>> error"?

> Maybe catch the urllib2.HTTPError?

This kind of answers the question. urllib will let you read whatever it
receives, regardless of the HTTP status; you need to use urllib2 if you
want to find out the status code when a request results in an error (any
HTTP status beginning with a 4 or 5). This can be done like so:

import urllib2
try:
asock = urllib2.urlopen("http://www.foo.com/qwerty.html";)
except urllib2.HTTPError, e:
print e.code

The value in urllib2.HTTPError.code comes from the first line of the web
server's HTTP response, just before the headers begin, e.g. "HTTP/1.1 200
OK", or "HTTP/1.1 404 Not Found".

One thing you need to be aware of is that some web sites don't behave as
you would expect them to; e.g. responding with a redirection rather than a
404 error when you when you request a page that doesn't exist. In these
cases you might still have to rely on some clever scripting.
--

I hope that helps.

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


Re: How to get started in GUI Programming?

2005-12-23 Thread Heiko Wundram
Tim Peters wrote:
> My wild-ass guess is that, same as most other Open
> Source communities, we average [at] about one asshole per member.

Tim, you saved my day. QOTW!

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


Re: sorting with expensive compares?

2005-12-23 Thread bonono

Dan Stromberg wrote:
> On Thu, 22 Dec 2005 22:06:42 +, Dan Stromberg wrote:
>
> >
> > Hi folks.
> >
> > Python appears to have a good sort method, but when sorting array elements
> > that are very large, and hence have very expensive compares, is there some
> > sort of already-available sort function that will merge like elements into
> > a chain, so that they won't have to be recompared as many times?
> >
> > Thanks!
>
> I probably should've been more specific.
>
> I'm wanting to sort a large number of files, like a bunch of output files
> from a large series of rsh or ssh outputs on a large series of distinct
> machines, a music collection in .ogg format (strictly redistributable and
> legally purchased music), a collection of .iso cdrom images (strictly
> redistributable and legally purchased software), and so forth.
>
> I'm not sorting the content of each file individually.
>
> I'm treating each file as a potentially very large string, and "sorting
> the strings".
>
> I've been using the following compare function, which in short checks, in
> order:
>
> 1) device number
> 2) inode number
> 3) file length
> 4) the beginning of the file
> 5) an md5 hash of the entire file
> 6) the entire file
>
> (If #1 and #2 are identical, then the file must be a hardlink to the other
> file.  Also, files that do not have the same length can never be
> identical.  And of course these items are generated on demand, making it
> frequently possible to avoid doing full-file-length compare on a lot of
> files)
>
> However, my program is still doing more #6 comparisons than seems
> strictly necessary when I could just toss all the filenames describing
> identical files into a list, and avoid re-comparing files with identical
> content over and over - I don't want to compare them to each other again
> and again), when there are a lot of identical files in the input list.
>
Why would #5 not enough as an indicator that the files are indentical ?

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


Re: Vaults of Parnassus hasn't been updated for months

2005-12-23 Thread Wolfgang Grafen
 > Everybody is using the cheeseshop now:
 >
 > http://cheeseshop.python.org/pypi?%3Aaction=browse
 >

Everybody excluding me. Looks like a huge pile of cheese thrown above
a table. Sorry, I don't find what I am looking for. Can somebody
explain the improvement over Parnassus for me?

It is not only that Parnassus (http://py.vaults.ca/apyllo.py?a=tree) has
2000+ Entries compared to 673 at the cheeseshop
(http://cheeseshop.python.org/pypi?:action=browse&asdf=214) but its
appearence and user interface is also much better. Where is the
search button, where can I find the latest additions?

Instead I have to scroll over a alphabetical sorted list of 673 items
what I definitely don't like. Invisible unless you scroll to the bottom
of the page there is a grouped/cluttered bunch of links to more specific
collections...

Well, at least I am very upset! This site shows the least possible
implementation of a repository. There are a *lot* books about GUI
design around for years pointing out the does and don't does. Why should
this be an improvement? Why does such a inferiour solution substitute a
already useable solution like Parassus?

I know that setup.py gives the opportunity to registrate a module
automatically there. As long this is used to build up a computer
accessible repository it is a good thing. But just now it is no option
as the user's usability constraints are not met! And the completeness
lacks compared to the Vaults of Parnassus.

I am not a very organized person. Nevertheless, I like to click through
responsive and clearly designed sites. I want to search by means of a
search engine and get relevant hits. Often Google hits were better than
dedicated engines but this changes recently. If this is the new Python way
I cry for the past...

Just a poll: Who misses the Vaults of Parnassus like me?


Olivier Grisel wrote:
> Wolfgang Grafen a écrit :
> 
>> What happened to the Vaults of Parnassus? It was always my
>> favourite resource for Python code since ever. The latest
>> entry is now 8/23. It has been up to date for years but now...
>> What a pity!
> 
> 
> Everybody is using the cheeseshop now:
> 
> http://cheeseshop.python.org/pypi?%3Aaction=browse
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: sorting with expensive compares?

2005-12-23 Thread Dan Stromberg
On Thu, 22 Dec 2005 22:06:42 +, Dan Stromberg wrote:

> 
> Hi folks.
> 
> Python appears to have a good sort method, but when sorting array elements
> that are very large, and hence have very expensive compares, is there some
> sort of already-available sort function that will merge like elements into
> a chain, so that they won't have to be recompared as many times?
> 
> Thanks!

I probably should've been more specific.

I'm wanting to sort a large number of files, like a bunch of output files
from a large series of rsh or ssh outputs on a large series of distinct
machines, a music collection in .ogg format (strictly redistributable and
legally purchased music), a collection of .iso cdrom images (strictly
redistributable and legally purchased software), and so forth.

I'm not sorting the content of each file individually.

I'm treating each file as a potentially very large string, and "sorting
the strings".

I've been using the following compare function, which in short checks, in
order:

1) device number
2) inode number
3) file length
4) the beginning of the file
5) an md5 hash of the entire file
6) the entire file

(If #1 and #2 are identical, then the file must be a hardlink to the other
file.  Also, files that do not have the same length can never be
identical.  And of course these items are generated on demand, making it
frequently possible to avoid doing full-file-length compare on a lot of
files)

However, my program is still doing more #6 comparisons than seems
strictly necessary when I could just toss all the filenames describing
identical files into a list, and avoid re-comparing files with identical
content over and over - I don't want to compare them to each other again
and again), when there are a lot of identical files in the input list.

Thanks!

def __cmp__(self,other):
#   sys.stderr.write('Comparing %s and %s\n' % (self.name, 
other.name))
if verbosity >= 1:
sys.stderr.write('Comparing file_class objects %s and 
%s\n' %
(self.name, other.name))
if self.device == -1:
if verbosity:
sys.stderr.write('Getting stat data for file 
%s\n' % self.name)
result = os.stat(self.name)
self.device = result[stat.ST_DEV]
self.inode = result[stat.ST_INO]
self.size = result[stat.ST_SIZE]
if other.device == -1:
if verbosity:
sys.stderr.write('Getting stat data for file 
%s\n' % other.name)
result = os.stat(other.name)
other.device = result[stat.ST_DEV]
other.inode = result[stat.ST_INO]
other.size = result[stat.ST_SIZE]
if self.device == other.device and self.inode == other.inode:
# same device, same inode, must be identical files 
return 0
if self.length < other.length:
return -1
elif self.length > other.length:
return 1
# if we've reached this point, the files are not hardlinks, and 
their
lengths are identical # so slurp in the prefixes if needed, 
then compare
them if self.prefix == -1:
if verbosity:
sys.stderr.write('Getting prefix for file %s\n' 
% self.name)
file = open(self.name, 'r')
self.prefix = file.read(self.max_prefix_length) 
file.close()
if other.prefix == -1:
if verbosity:
sys.stderr.write('Getting prefix for file %s\n' 
% other.name)
file = open(other.name, 'r')
other.prefix = file.read(self.max_prefix_length) 
file.close()
if self.prefix < other.prefix:
return -1
elif self.prefix > other.prefix:
return 1
# if we've reached this point, we know that: # 1) The files are 
not
hardlinks of each other # 2) They have identical sizes # 3) 
Their
prefixes are identical
# 4) We haven't yet tried doing a cryptographic hash, so 
compute them if
needed, and compare them if self.hash == '':
self.gen_hash()
if other.hash == '':
other.gen_hash()
if self.hash < other.hash:
return -1
elif self.hash > other.hash:
return 1
# if we've reached this point, we know that: # 1) The files are 
not
hardlinks of each other # 2) They have identical sizes # 3) 
Their
prefixes are id

Re: Herds of cats

2005-12-23 Thread Steve Holden
Alex Martelli wrote:
> Nicola Musatti <[EMAIL PROTECTED]> wrote:
>...
> 
Ah, the closed source days! Back then you could just buy the company
and be done with it. Now you have to chase developers one by one all
over the world... ;-)
>>>
>>>.
>>>You propellor-heads (I write that in all fondness, Nicola) are
>>>all laughing, but I'm certain that the right elaboration of
>>>that proposition could make it into the *Harvard Business Review*
>>>(or *IBM Systems Journal*, which seems to have tilted irreversibly
>>>in that direction).
>>
>>I was only half joking, actually. Compare Python to Delphi. If a
>>company wanted to acquire control over Delphi, they'd try and buy
>>Borland; to acquire control over Python what are they to do? Well,
>>hiring Guido and Alex is probably a step in the right direction ;-) but
>>would it be enough? Programming languages are not the best example, but
>>if you change it to Mozilla and Opera my argument makes more sense.
> 
> 
> Not a bad point at all, although perhaps not entirely congruent to open
> source: hiring key developers has always been a possibility (net of
> non-compete agreements, but I'm told California doesn't like those).
> E.g., Microsoft chose to hire Anders Hejlsberg away from Borland (to
> develop J++, the WFC, and later C# and other key parts of dotNet) rather
> than buying Borland and adapting Delphi; while acquiring companies is
> often also a possibility (e.g., Novell chose to buy SuSE GmbH, rather
> than trying to hire specific people off it, despite SuSE's roots in open
> source and free software).

The essential difference, it seems to me, is that buying the company 
gets you control over the company's proprietary technologies, whereas 
hiring the developer only gets you access to the development skills of 
the people who've been involved open source developments.

The open source projects remain outwith the control of the company; I 
don't expect Google's employment of Guido to have a significant effect 
on the development directions for Python. I'm happy to say I *do* expect 
  Python's development rate to improve hereafter.

I'm also happy that Google are a significant and public supporter of the 
Python Software Foundation through (among other things) their sponsor 
membership of the Foundation, and their sponsorship of PyCon.

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: Python IMAP4 Memory Error

2005-12-23 Thread Dody Suria Wijaya
like magic it did the trick :D

This should be applied to future Python release. Thanks.

Fredrik Lundh wrote:
> Jean-Paul Calderone wrote:
> if you look at the debug output (which you may already have done),
> it's an obvious case of fragmentation-inducing behaviour.  any malloc-
> based system may choke on the sequence
> 
> for a large number of attempts:
> allocate a 15 megabyte block
> shrink block to a couple of kilobytes
> occasionally allocate a medium-sized block
> 
> from what I can tell, replacing the
> 
> data = self.sslobj.read(size-read)
> 
> line with
> 
> data = self.sslobj.read(min(size-read, 16384))
> 
> should do the trick.

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


Re: How to get started in GUI Programming?

2005-12-23 Thread Tim Peters
[D H]
> ...
> Doesn't the python community already have enough assholes as it is?

The Python Software Foundation may well wish to fund a study on that. 
Write a proposal!  My wild-ass guess is that, same as most other Open
Source communities, we average about one asshole per member.  I'd love
to proven wrong, though.

at-my-age-you-need-all-the-evacuation-routes-you-can-get-ly y'rs  - tim
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to get started in GUI Programming?

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

What kind of helpful advice is that?

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

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


Re: What is unique about Python?

2005-12-23 Thread D H
Kay Schluehr wrote:
> gsteff wrote:
> 
> 
>>So I'm wondering, what is
>>innovative about Python, either in its design or implementation?  Or is
>>its magic really just in combining many useful features of prior
>>languages in an unusually pleasant way?
>>
>>Greg
> 
> 
> The latter.
> 
> http://www.python-in-business.org/ep2005/download.cpy?document=8599
> 
> As Guido described in his presentation Python is a decendent of ABC
> developed at the university where he studied.
> 
> Here is some material about the primary motivations of ABC:
> 
> http://homepages.cwi.nl/~steven/abc/language.html
> 
> Python seems to proof that eclecticism can be done right. 

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


Re: Guido at Google

2005-12-23 Thread Luis M. González

rbt wrote:
> Go right ahead. Perhaps we should do one for Perl too:
>
> It's like having King Kong as your very own personal body guard ;)

Good analogy:
You know, they call Perl the "eight-hundred-pound gorilla" of scripting
languages.
Although most of the time, it would be a a very unsuitable body guard
(can't get into a car, into a plane, go to a party, etc..).

OTHOH James Bond is always perfect. He would sleep with your wife
though...

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


Re: Logging: Formatter: name of the function

2005-12-23 Thread Bengt Richter
On Fri, 23 Dec 2005 16:23:57 +0100, Gregor Horvath <[EMAIL PROTECTED]> wrote:

>Hi,
>
>Is there a possibility to format a log message to give the function name 
>where the log appears?
>
>Example
>
>import logging
>
>def aTestFunction():
>   logger.debug("This is a message")
>
>The log should read:
>
>aTestFunction  This is a message.
>
>There is a possibilty to format the module namewith %(module)s, but I 
>did not find one for the function name.
>
>Is there a possibilty or can I create it myself?
>How can I determine the function name within a function?
>Introspection?
>
There's not a nice way that I know of, but you can do something like

 >>> import sys
 >>> def foo():
 ... print 'logger string containing function name 
"%s"'%sys._getframe().f_code.co_name
 ...
 >>> foo()
 logger string containing function name "foo"

However, you might want to consider using a decorator that could
wrap a function if debugging and leave it alone otherwise. Also you
can log before and after calling the function. E.g.,

 >>> def debugdeco(f):
 ... if not __debug__: return f
 ... def wrap(*args, **kw):
 ... print 'before entering function "%s" ...'%f.func_name
 ... result = f(*args, **kw)
 ... print 'after returning from function "%s" ...'%f.func_name
 ... return result
 ... wrap.func_name = f.func_name # make it look the same if desired
 ... return wrap
 ...
 >>> @debugdeco
 ... def foo(something): print something; return 'whatever'
 ...
 >>> foo('hello')
 before entering function "foo" ...
 hello
 after returning from function "foo" ...
 'whatever'
 >>> __debug__ = False
   File "", line 1
 SyntaxError: can not assign to __debug__

Oops, can't experiment that way ;-)
 >>> ^Z

We'll just start it with -O to set __debug__ False:
 
 [ 8:45] E:\Info\Politics>py24 -O
 Python 2.4b1 (#56, Nov  3 2004, 01:47:27)
 [GCC 3.2.3 (mingw special 20030504-1)] on win32
 Type "help", "copyright", "credits" or "license" for more information.
 >>> def debugdeco(f):
 ... if not __debug__: return f
 ... def wrap(*args, **kw):
 ... print 'before entering function "%s" ...'%f.func_name
 ... result = f(*args, **kw)
 ... print 'after returning from function "%s" ...'%f.func_name
 ... return result
 ... wrap.func_name = f.func_name # make it look the same if desired
 ... return wrap
 ...
 >>> @debugdeco
 ... def foo(something): print something; return 'whatever'
 ...
 >>> foo('hello')
 hello
 'whatever'

You could still do stuff unconditionally of course, and also inside foo.

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


Re: print UTF-8 file with BOM

2005-12-23 Thread Walter Dörwald
John Bauman wrote:

> UTF-8 shouldn't need a BOM, as it is designed for character streams, and 
> there is only one logical ordering of the bytes. Only UTF-16 and greater 
> should output a BOM, AFAIK. 

However there's a pending patch (http://bugs.python.org/1177307) for a 
new encoding named utf-8-sig, that would output a leading BOM on writing 
and skip it on reading.

Bye,
Walter Dörwald
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Providing 'default' value with raw_input()?

2005-12-23 Thread Alex Martelli
planetthoughtful <[EMAIL PROTECTED]> wrote:

> Thank you for the suggestion, I'll have a look at this as an
> alternative.
> 
> I must admit, it seems a little like a 'kludge', though -- but probably
> a necessary one, given the limitations of the OS.

Hmmm, what OS?  The recipe I mentioned is probably the best approach on
Windows, MacOS, Linux, and other Unix variants -- what other OS do you
have in mind, that would let you submit to the user hundreds of
characters for editing without in fact using an editor?

> I'm assuming os.popen() keeps track of when the editor closes? Or would

It has to, because it needs to supply all the subprocess's output as the
contents of the file object it returns, and it couldn't be sure it has
all of the output until the subprocess has finished.  There are, of
course, other ways to control sub-processes (Python 2.4's subprocess
module, in particular).

> I have to manually fire an 'ok, now update the record in the db' event
> after editing the value?

In some situations it may be impractical to rely on the editor closing;
for example, the user's favorite editor might be a multitab one that's
big, heavy, and slow to start, so that the user doesn't close the whole
process but rather just a specific tab.  In such cases, unless you can
build in some hook specific to the user's favorite editor (so you can
know when a specific tab/file is done getting edited), you may end up
requiring the user to press enter at your prompt to indicate he or she's
done editing, or some such semi-kludge.  I cannot think of a
sufficiently general solution, given the variety of editors around, to
just magically divine the crucial "done with editing" condition...


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


Re: Herds of cats

2005-12-23 Thread Alex Martelli
Nicola Musatti <[EMAIL PROTECTED]> wrote:
   ...
> > >Ah, the closed source days! Back then you could just buy the company
> > >and be done with it. Now you have to chase developers one by one all
> > >over the world... ;-)
> > .
> > You propellor-heads (I write that in all fondness, Nicola) are
> > all laughing, but I'm certain that the right elaboration of
> > that proposition could make it into the *Harvard Business Review*
> > (or *IBM Systems Journal*, which seems to have tilted irreversibly
> > in that direction).
> 
> I was only half joking, actually. Compare Python to Delphi. If a
> company wanted to acquire control over Delphi, they'd try and buy
> Borland; to acquire control over Python what are they to do? Well,
> hiring Guido and Alex is probably a step in the right direction ;-) but
> would it be enough? Programming languages are not the best example, but
> if you change it to Mozilla and Opera my argument makes more sense.

Not a bad point at all, although perhaps not entirely congruent to open
source: hiring key developers has always been a possibility (net of
non-compete agreements, but I'm told California doesn't like those).
E.g., Microsoft chose to hire Anders Hejlsberg away from Borland (to
develop J++, the WFC, and later C# and other key parts of dotNet) rather
than buying Borland and adapting Delphi; while acquiring companies is
often also a possibility (e.g., Novell chose to buy SuSE GmbH, rather
than trying to hire specific people off it, despite SuSE's roots in open
source and free software).


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


Re: Detect File System changes

2005-12-23 Thread Lawrence Oluyede
Il 2005-12-23, Lukas Meyer <[EMAIL PROTECTED]> ha scritto:
> Hello,
>
> I'm trying to detect changes in a directory. E.g if someone crates a
> file, i'll execute another function on this file.

pyinotify (wrapper of inotify) is for you (it's not portable however)

http://pyinotify.sourceforge.net/

-- 
Lawrence - http://www.oluyede.org/blog
"Anyone can freely use whatever he wants but the light at the end
of the tunnel for most of his problems is Python"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Guido at Google

2005-12-23 Thread David E. Konerding DSD staff
In article <[EMAIL PROTECTED]>, Greg Stein wrote:
> Guido would acknowledge a query, but never announce it. That's not his
> style.
> 
> This should have a positive impact on Python. His job description has a
> *very* significant portion of his time dedicated specifically to
> working on Python. (much more than his previous "one day a week" jobs
> have given him)

Well, given that he's going to be spending his 80% time working on python,
it makes one wonder how he'll be spending his 20% time :-)

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


Re: Some errors when running code in diveintopython: (

2005-12-23 Thread David Wahler
Istvan Albert wrote:
> I remeber once I had truly puzzling problem that manifested itself the
> same way ... Firefox and cygwin python would work fine but the windows
> python would raise errors when trying to connect via http ...
>
> ... finally I realized that the day before IE was set to use a proxy
> server ( to capture traffic for testing but the proxy was not on that
> moment) ... I know little on how Windows works but it was quite a
> surprise that setting IE to work some way had some unwanted
> reprecussions somewhere else ...

See the documentation for urllib.urlopen:

"""
In a Windows environment, if no proxy environment variables are set,
proxy settings are obtained from the registry's Internet Settings
section.
"""

-- David

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


Re: GUI and graph

2005-12-23 Thread bearophileHUGS
Maybe this graph library can be useful to you:
http://sourceforge.net/projects/pynetwork/

Bye,
bearophile

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


Re: print UTF-8 file with BOM

2005-12-23 Thread John Bauman
UTF-8 shouldn't need a BOM, as it is designed for character streams, and 
there is only one logical ordering of the bytes. Only UTF-16 and greater 
should output a BOM, AFAIK. 


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


Have a very Pythonic Christmasolstihanukwanzaa

2005-12-23 Thread infidel
Happy holidays to my fellow Pythonistas.

Love,

Saint Infidel the Skeptic

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


Re: GUI and graph

2005-12-23 Thread Fabrizio Milo
> pydot is pretty amazing in its abilitity to make nice, readable renderings of 
> graph data.
> http://dkbza.org/pydot.html

Well It's thanks to graphwiz..

http://www.research.att.com/sw/tools/graphviz/

I suggest to read the DOT language specification ( it is really easy )
and to roll up your own python script to build your dot file.

Fabrizio Milo aka Misto
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Providing 'default' value with raw_input()?

2005-12-23 Thread planetthoughtful
Thank you for the suggestion, I'll have a look at this as an
alternative.

I must admit, it seems a little like a 'kludge', though -- but probably
a necessary one, given the limitations of the OS.

I'm assuming os.popen() keeps track of when the editor closes? Or would
I have to manually fire an 'ok, now update the record in the db' event
after editing the value?

Much warmth,

planetthoughtful

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


Re: Providing 'default' value with raw_input()?

2005-12-23 Thread planetthoughtful
My intention is to build a GUI for this app, yes, but given that I'm
about a week old in my learning of Python, I thought a command-line app
was a better place to start. I'm actually quite surprised at how
featured I've managed to make this app all things considered, and now
I'm running into things that aren't easy to do in Python (and probably
also not easy to do in any scripting language on a Win machine), as
opposed to not easy for me to work out.

I had thought to build GUIs in wxPython - is Tkinter any easier to
learn?

Much warmth,

planetthoughtful

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


urlretrieve() questions

2005-12-23 Thread Rene Lopez
I'm building an app that needs to download a file from the
web.  

I'm trying to make sure I catch any issues with the download
but I've run into a problem. 

here's what I have so far:

try:
urllib.urlretrieve(url,filename)
print "File: ", filename, " downloaded"
except IOError:
print "IOError File Not Found: ", url

Pretty straight forward...but what I'm finding is if the
url is pointing to a file that is not there, the server
returns a file that's a web page displaying a 404 error. 

Anyone have any recommendations for handling this? 
-- 

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


Logging: Formatter: name of the function

2005-12-23 Thread Gregor Horvath
Hi,

Is there a possibility to format a log message to give the function name 
where the log appears?

Example

import logging

def aTestFunction():
   logger.debug("This is a message")

The log should read:

aTestFunction  This is a message.

There is a possibilty to format the module namewith %(module)s, but I 
did not find one for the function name.

Is there a possibilty or can I create it myself?
How can I determine the function name within a function?
Introspection?

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


Re: sorting with expensive compares?

2005-12-23 Thread Aahz
In article <[EMAIL PROTECTED]>,
Dan Stromberg  <[EMAIL PROTECTED]> wrote:
>
>Python appears to have a good sort method, but when sorting array
>elements that are very large, and hence have very expensive compares,
>is there some sort of already-available sort function that will merge
>like elements into a chain, so that they won't have to be recompared as
>many times?

I'll just note that Python's sort is specifically designed to reduce the
number of compares precisely because *all* compares in Python are
relatively expensive.  I'll suggest a variant on the previous suggestion
of hash:

[a] -> [hash(a), index(a), a]
-- 
Aahz ([EMAIL PROTECTED])   <*> http://www.pythoncraft.com/

"Don't listen to schmucks on USENET when making legal decisions.  Hire
yourself a competent schmuck."  --USENET schmuck (aka Robert Kern)
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   >