Re: Picking a license

2010-05-15 Thread Patrick Maupin
On May 15, 1:34 am, Steven D'Aprano  wrote:
> On Fri, 14 May 2010 19:17:20 -0700, Patrick Maupin wrote:
> > On May 14, 9:04 pm, Lawrence D'Oliveiro  > central.gen.new_zealand> wrote:
> >> In message <548024fc-
> >> dd56-48b9-907d-3aa6a722b...@l31g2000yqm.googlegroups.com>, Patrick
> >> Maupin wrote:
>
> >> > The confusion that some are showing in this thread about whether
> >> > source must be distributed certainly helps to show that as well.
>
> >> What “confusion”? The GPL requires that source must always be offered
> >> in some form. Simple as that.
>
> > Right, but when I explained that that requirement also applies to Joe,
> > who downloaded an ISO from Ubuntu and burned a CD and gave it away, no
> > less than 3 people jumped in to "correct" me.
>
> The confusion is over what form that offer may be, and what counts as
> distribution.
>
> Your claim seems plausible, but whether it is correct or not is not so
> obvious.

Exactly.  And when people say it's obviously incorrect, they're
obviously incorrect, because if it were obvious, it would have been
answered correctly by now :-)

> I would say that, given the lack of any lawsuits against
> individuals and Linux User Groups, the *intention* of the GPL is to allow
> individuals to act as a proxy between the end-user and the actual
> distributor (in this case, Ubuntu) without taking on the obligation to
> provide source code.

Yes, and as I said, lawsuits against individuals would be bad for
business (as business is defined in the GPL world).

> Looking at the FAQs, my comments in square brackets:
>
> http://www.gnu.org/licenses/gpl-faq.html#WhatDoesWrittenOfferValid

Well, for one thing, that section is only *directly* relevant to GPL
v2.  For another thing, it is only directly relevant to Canonical's
obligations, not Joe's.

[Text snipped; part of d'Aprano interpretation left]

>     [I am obliged to tell my friend they can get the Ubuntu written
>     offer from Ubuntu's website, and pass it on directly if asked]

Sure, and that's *exactly* what I said isn't going to happen in a lot
of cases, because it takes a careful reading of the license and FAQ
for someone to realize that.  The download button at Ubuntu tells you
to make more copies (your "rights") without telling you about the
source code (your "obligations").  Which is perfectly legal, but
someone who isn't reading carefully could easily give a CD to a friend
without the offer of source.

>     This means that people who did not get the binaries directly
>     from you can still receive copies of the source code, along
>     with the written offer.

More obligations on the part of Canonical;  note, however, that
Canonical's obligation to distribute source to a CD that you gave to a
friend may not even be long enough to cover 3 years after the time you
gave the CD to your friend.

>     The reason we require the offer to be valid for any third party
>     is so that people who receive the binaries indirectly in that way
>     can order the source code from you. [In other words, if I give
>     Fred a copy of Ubuntu, it is Canonical and not me who is responsible
>     for providing the source code to Fred if he asks for it.]
>
> Okay, it's not the licence itself, but the FAQ pretty much makes the
> intention clear.

Yes, it does.  The FAQ part you quote is for Canonical and for v2.
The one for the user handing over the CD still says (for v3):

"I downloaded just the binary from the net. If I distribute copies, do
I have to get the source and distribute that too? Yes. The general
rule is, if you distribute binaries, you must distribute the complete
corresponding source code too. The exception for the case where you
received a written offer for source code is quite limited."

But, even if you fall under that limited exception, you *still* have
to make the written offer, and I stand by my assertion that even that
token act is not happening in lots of cases as we speak.

> Merely handing over an Ubuntu DVD to a friend is not a
> violation of the GPL.

... as long as you make the written offer.

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


help need to write a python spell checker

2010-05-15 Thread harry k
Write a spell checking tool that will identify all misspelled word in a text 
file using a provided dictionary.


The program will accept either one or two command line parameters.
1.  The first command line parameter is the name of the text file that will 
be checked.
2.  The optional second command line parameter is the name of the 
dictionary file – a file of words with one word per line.  The default 
dictionary file is ref.txt.
The program will write out the misspelled words, one per line, in alphabetical 
order.

Extend the spell checking tool so that as well as identifying all misspelled 
words,  the program will list the line numbers in the file where the incorrect 
spelling occurs.

The program will write out the misspelled words (one per line, in alphabetical 
order), followed by a tab character, followed by the list of line numbers that 
word is misspelled in,in ascending order, on the same line, separated by a 
single space.


Extend the spell-checking tool so that the program will also print out a list 
of possible correct spellings for the words.

The program will write out the misspelled words (one per line, in alphabetic 
order), followed (on the same line) by a single space, followed by the list of 
line numbers in ascending order, each separated by a single space, followed by 
a single space, then the list of possible correct spellings, each separated by 
a single space.

Find the alternate spellings by considering:
a.  Words in the dictionary that are the same length but:
a.  Have a pair of characters interchanged
b.  Differ by one character from the misspelled word
b.  Words that are one character longer or one character shorter, but 
otherwise match the misspelled word.

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


Re: help need to write a python spell checker

2010-05-15 Thread Xavier Ho
1) Welcome to Python-List!

2) Python-list doesn't like to do other people's homework.

3) What have you tried?

Cheers,
Xav

On Fri, May 14, 2010 at 6:19 PM, harry k  wrote:

> Write a spell checking tool that will identify all misspelled word in a
> text file using a provided dictionary.
>
>
> The program will accept either one or two command line parameters.
> 1.  The first command line parameter is the name of the text file that
> will be checked.
> 2.  The optional second command line parameter is the name of the
> dictionary file – a file of words with one word per line.  The default
> dictionary file is ref.txt.
> The program will write out the misspelled words, one per line, in
> alphabetical order.
>
> Extend the spell checking tool so that as well as identifying all
> misspelled words,  the program will list the line numbers in the file where
> the incorrect spelling occurs.
>
> The program will write out the misspelled words (one per line, in
> alphabetical order), followed by a tab character, followed by the list of
> line numbers that word is misspelled in,in ascending order, on the same
> line, separated by a single space.
>
>
> Extend the spell-checking tool so that the program will also print out a
> list of possible correct spellings for the words.
>
> The program will write out the misspelled words (one per line, in
> alphabetic order), followed (on the same line) by a single space, followed
> by the list of line numbers in ascending order, each separated by a single
> space, followed by a single space, then the list of possible correct
> spellings, each separated by a single space.
>
> Find the alternate spellings by considering:
> a.  Words in the dictionary that are the same length but:
> a.  Have a pair of characters interchanged
> b.  Differ by one character from the misspelled word
> b.  Words that are one character longer or one character shorter, but
> otherwise match the misspelled word.
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: help need to write a python spell checker

2010-05-15 Thread James Mills
On Fri, May 14, 2010 at 6:19 PM, harry k  wrote:
> Write a spell checking tool that will identify all misspelled word in a text 
> file using a provided dictionary.

Is this an assignment ? Sure looks like it!

I don't see a question anywhere.

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


Re: Broken pipe

2010-05-15 Thread Lie Ryan
On 05/15/10 11:56, Lawrence D'Oliveiro wrote:
> In message <4bec2a9...@dnews.tpgi.com.au>, Lie Ryan wrote:
> 
>> On 05/13/10 22:41, Lawrence D'Oliveiro wrote:
>>> In message , Chris
>>> Rebert wrote:
>>>
 Also, please don't use semicolons in your code. It's bad style.
>>>
>>> Wonder why they’re allowed, then.
>>
>> they're there for line continuation, e.g.:
>>
>> a = 40; foo(a)
>>
>> but in many cases, putting two statements in a single line reduces
>> readability so use the semicolons extremely conservatively. But the
>> worst is the abuse of semicolons for end-of-line markers.
> 
> So why are they allowed, then?

Convenience. I've sometimes, in the interactive interpreter, written
codes that looks like:

a = 0; ... other code ...

since I need to reset the variable 'a' every time 'other code' is run.
If there hasn't been the ;, then I'd have to press up, up, enter, up,
up, change, enter. Compare that to up, change, enter since I can "up"
two "lines" at once.

In the interactive interpreter these sort of conveniences is often useful.

Unless your "why are they allowed" is about why a blank continuation
(i.e. abusing ; as line ending) is allowed. In that case, I'd presume
it's just because conceptually:

foo();
bar

is just:

foo()

bar()


but probably you're right; maybe they should be strictly disallowed. But
it's too late for this kind of change, not until py4k.
-- 
http://mail.python.org/mailman/listinfo/python-list


yappi 0.51 released

2010-05-15 Thread k3xji
Hi all,

Yappi (Yet Another Python Profiler) 0.51 released. See the version
highlights:

* OPTIMIZATION:Use per-pit cpc for better accuracy in different
timing_sample values. Now timing_sample is not linearly decreasing the
timing accuracy for most of the applications tested. We reduced the
runtime of the profiler from 3.2 secs to 0.7 by giving away ~%2 timing
accuracy. This means yappi can now run 4x-7x times faster than the
standart cProfile by increasing timing_sample values with very little
accuracy defect.
* Python 2.6.5 gives import yappi Dll load failed error. This is
due to VC2008 compile. Unfortunately, we need to use VC Express Mingw
is not working because of MSVCR dll files on 2.6.5 on some machines.
* Use snprintf for stat handling code. There may be some buffer
overflow situations. Use PyOS_snprintf for platform differences.
(Thanks to Dave Peticolas)
* Format stat STRINGs from left, instead of right. (Thanks to Dave
Peticolas)
* OPTIMIZATION:Move ctx calculation code to callback function.
Optimize call_XXX functions as much as possible.
* Move timing calculation code from header to the C file.
* MACRO defining code in setup.py is broken for some compilers,
use DEFINE_MACRO keyword.
* OPTIMIZATION:Disable HASH table linked list swapping code, it is
not adapting to the profiler nature very well. Rollback to simple hash-
table-bucketing.

See below for more and download:
http://code.google.com/p/yappi/

Thanks,
twitter.com/sumercip
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Puzzled by code pages

2010-05-15 Thread Lie Ryan
On 05/15/10 10:27, Adam Tauno Williams wrote:
> I'm trying to process OpenStep plist files in Python.  I have a parser
> which works, but only for strict ASCII.  However plist files may contain
> accented characters - equivalent to ISO-8859-2 (I believe).  For example
> I read in the line:
> 
 handle = open('file.txt', 'rb')
 data = handle.read()
 handle.close()
 data
> '"skyp4_filelist_10201/localit\xc3\xa0 termali_sortfield" =
> NSFileName;\n'

I presume you're using Python 2.x.

> What is the correct way to re-encode this data into UTF-8 so I can use
> unicode strings, and then write the output back to ISO8859-?
> 
> I can read the file using codecs as ISO8859-2, but it still doesn't seem
> correct.
> 
 handle = codecs.open('file.txt', 'rb', encoding='iso8859-2')
 data = handle.read()
 handle.close()
 data
> u'"skyp4_filelist_10201/localit\u0102\xa0 termali_sortfield" =
> NSFileName;\n'

When printing in the interactive interpreter, python uses __repr__
representation by default. If you want to use __str__ representation use
"print data" (note, your terminal must support printing unicode
characters); either way, even though the string looks like '\u0102' when
printed on the terminal, the binary pattern inside the memory should
correctly represents the accented character.

f = codecs.open("in.txt", 'rb', encoding="iso8859-2")
f2 = codecs.open("out.txt", 'wb', encoding="utf-8")
s = f.read()
f2.write(s)
f.close()
f2.close()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: help need to write a python spell checker

2010-05-15 Thread Tim Chase

2) Python-list doesn't like to do other people's homework.



This could be fun... :)  For this problem, all you have to do is 
a big "if/elif/else" statement for every possible mis-spelling. 
If you want to get really fancy, you could put all the 
mis-spellings in a set() and then test the incoming word against 
the set for membership...For bonus points, you could use the 
anydbm module as a mapping from known-bad-spellings to the 
correct spelling so it can auto-correct for you...


Then you know if the word is mis-spelled.  The rest is pretty 
easy. ;-)


-tkc


(or maybe this only sounds amusing if you're sleep-deprived, up 
with your kid in the wee hours of the morning when you'd prefer 
to be snoozing)


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


Human word reader

2010-05-15 Thread timo verbeek
I'm planning to create a human word program
A human inputs a string
"Give me the weather for London please."
Then I will strip the string.
"weather for london"
Then I get the useful information.
what:"weather" where:"london"
After that I use the info.

I need help with getting the useful information how do I get the place
if I don't now how long the string is?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Human word reader

2010-05-15 Thread Xavier Ho
On Sat, May 15, 2010 at 9:02 PM, timo verbeek wrote:

> I'm planning to create a human word program
>



>
> I need help with getting the useful information how do I get the place
> if I don't now how long the string is?
>
> Boy, that is a very hard problem. Are the inputs restricted to anything?
English only? Can the human user type in *anything*?

You need to have a very, very good set of heruistics and deterministic
functions to do that.

What have you got so far?

-

Otherwise,

"How do I get the position of a known word in a string if the length if
unknown?"

>>> input = 'Give me the weather for London please.'
>>> input.find('weather')
12

Cheers,
Xav
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Human word reader

2010-05-15 Thread Xavier Ho
On Sat, May 15, 2010 at 9:12 PM, Xavier Ho  wrote:

> You need to have a very, very good set of heruistics and deterministic
> functions to do that.
>
> "How do I get the position of a known word in a string if the length if
> unknown?"
>

And this is what I get for late night e-mailing.

is*

heuristic*

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


Re: Human word reader

2010-05-15 Thread timo verbeek
On May 15, 1:02 pm, timo verbeek  wrote:
Place starts always with for

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


Re: Picking a license

2010-05-15 Thread Ed Keith
--- On Fri, 5/14/10, Steven D'Aprano  
wrote:

> From: Steven D'Aprano 
> Subject: Re: Picking a license
> To: python-list@python.org
> Date: Friday, May 14, 2010, 10:59 PM
> On Fri, 14 May 2010 06:39:05 -0700,
> Ed Keith wrote:
> 
> > Yes, under the GPL every one has one set of freedoms,
> under the MIT or
> > Boost license every one has more freedoms. Under other
> licenses they
> > have fewer freedoms.
> 
> I think this talk about freedoms is dangerously incomplete,
> and is 
> confusing the issue rather than shedding more light. Both
> licences grant 
> the same positive freedoms (freedom to do something).
> MIT-style licences 
> grant permission to:
> 
> * make copies of the work;
> * make derivative works based on the work; and
> * distribute those derivative works to others.
> 
> The GPL grants precisely the same three rights. There is no
> difference in 
> the rights granted.
> 
> The MIT licence imposes an obligation on the licencee:
> 
> * you must include a copy of the licence and copyright
> notice with the 
> work and/or any derivative works.
> 
> 
> The GPL adds a further obligation:
> 
> * any derivative works must also be licenced under the
> GPL.
> 
> 

That is why I prefer Boost, which adds very few obligations.



> If we want to talk about "freedoms", rather than rights and
> obligations, 
> we need to distinguish between positive freedoms (freedom
> to do 
> something) and negative freedoms (freedoms from something)
> and not just 
> blithely mix them up.
> 

Good point.

   -EdK

Ed Keith
e_...@yahoo.com

Blog: edkeith.blogspot.com




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


Re: Picking a license

2010-05-15 Thread Ethan Furman

Steven D'Aprano wrote:

On Thu, 13 May 2010 06:24:04 -0700, Ed Keith wrote:


--- On Thu, 5/13/10, Lawrence D'Oliveiro
 wrote:

What have you got against LGPL for this purpose? --


Most of my clients would not know how to relink a program if their life
depended on it. And I do not want to put then in DLL hell. So I avoid
the LGPL.



Are you implying that by distributing your libraries under the MIT or 
Apache licence, no linking is required? That's a cool trick, can you 
explain how it works please?


I believe he is implying that with MIT or Apache, he is able to do all 
the compiling/linking/generating himself, thus saving his customers the 
effort.


You're a smart man, Steven, surely you could have figured that out?  ;)

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


Re: Picking a license

2010-05-15 Thread Ethan Furman

Brendan Abel wrote:

While I think most of the disagreement in this long thread results
from different beliefs in what "freedom" means, I wanted to add, that
most of the responses that argue that the MIT license permits the user
more freedom than the GPL, suffer from the broken window fallacy.
This fallacy results from the short-sided-ness of the user base, as it
is only considering the first generation of derivative works.

I agree, that under an MIT license, the first generation of derivative
works have more freedom.  But any extra freedom gained here comes at
the direct expense of all future generations of derivative software.


You are assuming that _all_ future generations become propriety, then? 
How pessimistic.




Under a GPL license, it is true that the first generation will have
less freedom to distribute their software as they would like.  But it
also ensures that all subsequent generations of derivative works have
the freedom to access all previous derivative works.


Just because you have the code for the _current_ version of something, 
doesn't mean you have the code for that something three versions ago... 
after all, it may have been modified.



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


Re: Picking a license

2010-05-15 Thread Ed Keith
--- On Thu, 5/13/10, Steven D'Aprano  
wrote:

> From: Steven D'Aprano 
> Subject: Re: Picking a license
> To: python-list@python.org
> Date: Thursday, May 13, 2010, 7:41 PM
> On Thu, 13 May 2010 06:24:04 -0700,
> Ed Keith wrote:
> 
> > --- On Thu, 5/13/10, Lawrence D'Oliveiro
> > 
> wrote:
> >>
> >> What have you got against LGPL for this purpose?
> --
> >> 
> > Most of my clients would not know how to relink a
> program if their life
> > depended on it. And I do not want to put then in DLL
> hell. So I avoid
> > the LGPL.
> 
> 
> Are you implying that by distributing your libraries under
> the MIT or 
> Apache licence, no linking is required? That's a cool
> trick, can you 
> explain how it works please?
> 
> 
> 
> -- 
> Steven
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 

Normally I link it for them. As I read the LGPL, if I use any LGPLed code I 
need to teach the client how to link the software against any possible future 
version of the LGPLed library. 

-EdK

Ed Keith
e_...@yahoo.com

Blog: edkeith.blogspot.com





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


Re: Picking a license

2010-05-15 Thread Ethan Furman

Steven D'Aprano wrote:

On Thu, 13 May 2010 19:10:09 -0700, Patrick Maupin wrote:

The only time
that comes into play in my programming life is *when I have to recode*
something that is nominally available under the GPL,


You've never had to recode something because it was nominally available 
under a proprietary licence that you (or your client) was unwilling to 
use? Lucky you!


Steven, did you actually read what he wrote?  If you did, why would you 
say something so stupid?


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


Re: Do any debuggers support "edit and continue?"

2010-05-15 Thread Lawrence D'Oliveiro
In message , Joel 
Koltner wrote:

> Just curious... in Microsoft's Visual Studio (and I would presume some
> other tools), for many languages (both interpreted and compiled!) there's
> an "edit and conitnue" option that, when you hit a breakpoint, allows you
> to modify a line of code before it's actually executed.

Microsoft’s Visual Studio also has a reputation as a bloated and resource-
hungry study in software obesity.

Coincidence? Not if you can come up with a better example of the feature 
you’re touting as so wonderful...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Human word reader

2010-05-15 Thread Xavier Ho
On Sat, May 15, 2010 at 9:32 PM, timo verbeek wrote:

> On May 15, 1:02 pm, timo verbeek  wrote:
> Place starts always with for
>

Okay, much better.

Given that constraint, it looks like regular expression can do the job. I'm
not very experienced with regex, though.

\w* matches a whole word composed of letters and numbers by default.

>>> result = re.search('for \w*', 'Give me the weather for London please.')
>>> result.group()
'for London'
>>> result.group().split()[1]
'London'

Cheers,
Xav
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Human word reader

2010-05-15 Thread superpollo

timo verbeek ha scritto:

I'm planning to create a human word program
A human inputs a string
"Give me the weather for London please."
Then I will strip the string.
"weather for london"
Then I get the useful information.
what:"weather" where:"london"
After that I use the info.

I need help with getting the useful information how do I get the place
if I don't now how long the string is?



>>> query = "Give me the weather for London please."
>>> what = query.strip("Give me the ").split()[0]
>>> where = query.strip("Give me the " + what + " for ").split()[0]
>>> print what, where
weather London
>>>
--
http://mail.python.org/mailman/listinfo/python-list


Re: Picking a license

2010-05-15 Thread Duncan Booth
Ed Keith  wrote:

> I can not imagine anyone being stupid enough to pay me for rights to
> use code I had already published under the Boost License, which grants
> then the rights to do anything they want with it without paying me
> anything. 
>   -EdK
> 
Really?

The Boost License says, amongst other things:

> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
> EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
> NON-INFRINGEMENT. 

Are you sure you can't imagine anyone offering to pay you for an 
alternative license that came with some kind of warranty or support?

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


Re: Human word reader

2010-05-15 Thread superpollo

superpollo ha scritto:

timo verbeek ha scritto:

I'm planning to create a human word program
A human inputs a string
"Give me the weather for London please."
Then I will strip the string.
"weather for london"
Then I get the useful information.
what:"weather" where:"london"
After that I use the info.

I need help with getting the useful information how do I get the place
if I don't now how long the string is?



 >>> query = "Give me the weather for London please."
 >>> what = query.strip("Give me the ").split()[0]
 >>> where = query.strip("Give me the " + what + " for ").split()[0]
 >>> print what, where
weather London
 >>>


maybe better not with strip, fot it might not do what i intended (see 
docs); maybe preferable to use "partition" method:


>>> query = "Give me the weather for London please."
>>> what  = query.partition("Give me the ")[2].split()[0]
>>> where = query.partition(" for ")[2].split()[0]
>>> print what, where
weather London
>>>
--
http://mail.python.org/mailman/listinfo/python-list


Re: write a 20GB file

2010-05-15 Thread Nobody
On Fri, 14 May 2010 18:38:55 -0400, J wrote:

>>> someone smarter than me can correct me, but file.write() will write when
>>> it's buffer is filled, or close() or flush() are called.
>>
>> And, in all probability, seek() will either flush it immediately or cause
>> the next write() to flush it before writing anything.
> 
> Ahhh... I didn't know that... I thought seek() just moved the pointer
> through the file a little further

Think about how this affects buffering. write() writes at the current file
position. If you write, then seek, then write, it can't just concatenate
the two sets of data, as that would "lose" the seek.

Either the buffer has to contain multiple, distinct sets of data, each
with an associated position, or (far more likely), the original data must
be written to the correct location before the second set of data can be
stored.

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


Pyinstaller on WINE - cannot install pywin32

2010-05-15 Thread train
Pyinstaller works fine on Windows XP. I am trying to get it working on
WINE. Running
configure.py results in asking for pywin32, however pywin 32 will not
install

C:\pywin32-214>c:\python26\python setup.py
Building pywin32 2.6.214.0
This is a distutils setup-script for the pywin32 extensions

To build the pywin32 extensions, simply execute:
  python setup.py -q build
or
  python setup.py -q install
to build and install into your current Python installation.

These extensions require a number of libraries to build, some of which
may
require you to install special SDKs or toolkits.  This script will
attempt
to build as many as it can, and at the end of the build will report
any
extension modules that could not be built and why.
Currently, the Vista SDK and DirectX SDK are required to successfully
build
all extension modules - note that using the Vista SDK doesn't force
you to
use Vista as your build environment.  Please use google to find the
SDK -
links to microsoft.com seem to only stay current for a short time.
Also note
that the SDK that comes with VS2008 is not good enough to compile
earlier
versions.  If you installed VS2008 after the Vista SDK, try doing a
'repair'
on your SDK install.

Early versions of certain Windows headers/SDK versions will also cause
certain modules to be skipped. If you don't use the extensions that
fail to
build, you can ignore these warnings; if you do use them, you must
install
the correct libraries.

The 'exchange' extensions require headers that are no longer in any
current
SDKs, so these fail to build, but the 'mapi' extension should still
build.

Building:
-

To install the pywin32 extensions, execute:
  python setup.py -q install

This will install the built extensions into your site-packages
directory,
create an appropriate .pth file, and should leave everything ready to
use.
There is no need to modify the registry.

To build or install debug (_d) versions of these extensions, ensure
you have
built or installed a debug version of Python itself, then pass the "--
debug"
flag to the build command - eg:
  python setup.py -q build --debug
or to build and install a debug version:
  python setup.py -q build --debug install

To build 64bit versions of this:

* py2.5 and earlier - sorry, I've given up in disgust.  Using VS2003
with
  the Vista SDK is just too painful to make work, and VS2005 is not
used for
  any released versions of Python. See revision 1.69 of this file for
the
  last version that attempted to support and document this process.

*  2.6 and later: On a 64bit OS, just build as you would on a 32bit
platform.
   On a 32bit platform (ie, to cross-compile), you must use VS2008 to
   cross-compile Python itself. Note that by default, the 64bit tools
are not
   installed with VS2008, so you may need to adjust your VS2008 setup.
Then
   use:

  setup.py build --plat-name=win-amd64

   see the distutils cross-compilation documentation for more details.

Standard usage information follows:
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: setup.py --help [cmd1 cmd2 ...]
   or: setup.py --help-commands
   or: setup.py cmd --help

error: no commands supplied
C:\pywin32-214>c:\python26\python setup.py -q install
Building pywin32 2.6.214.0
error: Unable to find vcvarsall.bat
C:\pywin32-214>

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


Re: Puzzled by code pages

2010-05-15 Thread Adam Tauno Williams
On Sat, 2010-05-15 at 20:30 +1000, Lie Ryan wrote:
> On 05/15/10 10:27, Adam Tauno Williams wrote:
> > I'm trying to process OpenStep plist files in Python.  I have a parser
> > which works, but only for strict ASCII.  However plist files may contain
> > accented characters - equivalent to ISO-8859-2 (I believe).  For example
> > I read in the line:
>  handle = open('file.txt', 'rb')
>  data = handle.read()
>  handle.close()
>  data
> > '"skyp4_filelist_10201/localit\xc3\xa0 termali_sortfield" =
> > NSFileName;\n'
> I presume you're using Python 2.x.

Yes.  But the days of all-unicode-strings will be wonderful when it
comes. :)

> > What is the correct way to re-encode this data into UTF-8 so I can use
> > unicode strings, and then write the output back to ISO8859-?
> > I can read the file using codecs as ISO8859-2, but it still doesn't seem
> > correct.
>  handle = codecs.open('file.txt', 'rb', encoding='iso8859-2')
>  data = handle.read()
>  handle.close()
>  data
> > u'"skyp4_filelist_10201/localit\u0102\xa0 termali_sortfield" =
> > NSFileName;\n'
> When printing in the interactive interpreter, python uses __repr__
> representation by default. If you want to use __str__ representation use
> "print data" (note, your terminal must support printing unicode
> characters); 

Using GNOME Terminal, so Unicode characters should display correctly.
And I do see the characters when I 'cat' the file.

> either way, even though the string looks like '\u0102' when
> printed on the terminal, the binary pattern inside the memory should
> correctly represents the accented character.

Yep.  But in the interpreter both unicode() and repr() produce the same
output.  Nothing displays the accented character.

h = codecs.open('file.txt', 'rb', encoding='iso8859-2')
data = h.read()
h.close()
str(data)

'ascii' codec can't encode characters in position 33-34: ordinal not in
range(128)

unicode(data)
u'"skyp4_filelist_10201/localit\u0102\xa0 termali_sortfield" =
NSFileName;\n'

repr(data)
'u\'"skyp4_filelist_10201/localit\\u0102\\xa0 termali_sortfield" =
NSFileName;\\n\''

I think I'm getting close.  Parsing the file seems to work, and while
writing it out does not error, rereading my own output fails. :(
Possibly I'm 'accidentally' writing the output as UTF-8 and not
ISO8859-2.  I need the internal data to be UTF-8 but read as ISO8859-2
and rewritten back to ISO8859-2 [at least that is what I believe from
the OpenStep files I'm seeing].

What is the 'official' way to encode something from UTF-8 to another
code page.  I *assumed* that if I wrote a unicode stream back through:

h = codecs.open(output_filename, 'wb', encoding='iso8859-2')
data = writer.store(defaults)
h.write(data)
h.close()

that is would be re-encoded [word?].  But maybe not?



> f = codecs.open("in.txt", 'rb', encoding="iso8859-2")
> f2 = codecs.open("out.txt", 'wb', encoding="utf-8")
> s = f.read()
> f2.write(s)
> f.close()
> f2.close()

-- 
Adam Tauno Williams  LPIC-1, Novell CLA

OpenGroupware, Cyrus IMAPd, Postfix, OpenLDAP, Samba
"skyp4_filelist_10201/località termali_sortfield" = NSFileName;
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Re: joining two column

2010-05-15 Thread mannu jha


On Sat, 15 May 2010 00:14:05 +0530  wrote
>On 05/14/2010 12:55 PM, James Mills wrote:

>> file1:

>> a1 a2

>> a3 a4

>> a5 a6

>> a7 a8

>>

>> file2:

>> b1 b2

>> b3 b4

>> b5 b6

>> b7 b8

>>

>> and I want to join them so the output should look like this:

>>

>> a1 a2 b1 b2

>> a3 a4 b3 b4

>> a5 a6 b5 b6

>> a7 a8 b7 b8

>

> This is completely untested, but this "should" (tm) work:

>

> from itertools import chain

>

> input1 = open("input1.txt", "r").readlines()

> input2 = open("input2.txt", "r").readlines()

> open("output.txt", "w").write("".join(chain(input1, input2)))



I think you meant izip() instead of chain() ... the OP wanted to 

be able to join the two lines together, so I suspect it would 

look something like



  # OPTIONAL_DELIMITER = " "

  f1 = file("input1.txt")

  f2 = file("input2.txt")

  out = open("output.txt", 'w')

  for left, right in itertools.izip(f1, f2):

   out.write(left.rstrip('\r\n'))

   # out.write(OPTIONAL_DELIMITER)

   out.write(right)

  out.close()



This only works if the two files are the same length, or (if 

they're of differing lengths) you want the shorter version. The 

itertools lib also includes an izip_longest() function with 

optional fill, as of Python2.6 which you could use instead if you 

need all the lines



-tkc









-- 

with this 
from itertools import chain
# OPTIONAL_DELIMITER = " "
f1 = file("input1.txt")
f2 = file("input2.txt")
out = open("output.txt", 'w')
for left, right in itertools.izip(f1, f2):
  out.write(left.rstrip('\r\n'))
# out.write(OPTIONAL_DELIMITER)
  out.write(right)
out.close()

it is showing error:
ph08...@linux-af0n:~> python join.py
Traceback (most recent call last):
  File "join.py", line 6, in 
for left, right in itertools.izip(f1, f2):
NameError: name 'itertools' is not defined
ph08...@linux-af0n:~>



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


Re: write a 20GB file

2010-05-15 Thread Nathan Rice
This is precisely the situation mmap was made for :)  It has almost the same
methods as a file so it should be an easy replacement.

On Sat, May 15, 2010 at 10:05 AM, Nobody  wrote:

> On Fri, 14 May 2010 18:38:55 -0400, J wrote:
>
> >>> someone smarter than me can correct me, but file.write() will write
> when
> >>> it's buffer is filled, or close() or flush() are called.
> >>
> >> And, in all probability, seek() will either flush it immediately or
> cause
> >> the next write() to flush it before writing anything.
> >
> > Ahhh... I didn't know that... I thought seek() just moved the pointer
> > through the file a little further
>
> Think about how this affects buffering. write() writes at the current file
> position. If you write, then seek, then write, it can't just concatenate
> the two sets of data, as that would "lose" the seek.
>
> Either the buffer has to contain multiple, distinct sets of data, each
> with an associated position, or (far more likely), the original data must
> be written to the correct location before the second set of data can be
> stored.
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: joining two column

2010-05-15 Thread Tim Chase

On 05/15/2010 09:20 AM, mannu jha wrote:

BTW: your mailer makes an absolute mess of plain-text emails, 
putting multiple spaces




between


every


single


line


which


makes


it


very


hard


to


read.

Please fix it, use a real mailer, or risk getting ignored (or 
worse, plonked).  Fortunately, Vim makes it modestly easy to 
unmung the rubbishy format.


>># OPTIONAL_DELIMITER = " "
>>f1 = file("input1.txt")
>>f2 = file("input2.txt")
>>out = open("output.txt", 'w')
>>for left, right in itertools.izip(f1, f2):
>> out.write(left.rstrip('\r\n'))
>> # out.write(OPTIONAL_DELIMITER)
>> out.write(right)
>>out.close()
>> This only works if the two files are the same length, or (if
>> they're of differing lengths) you want the shorter version. The
>> itertools lib also includes an izip_longest() function with
>> optional fill, as of Python2.6 which you could use instead if you
>> need all the lines
>
> with this
>
> from itertools import chain
> # OPTIONAL_DELIMITER = " "
> f1 = file("input1.txt")
> f2 = file("input2.txt")
> out = open("output.txt", 'w')
> for left, right in itertools.izip(f1, f2):
>   out.write(left.rstrip('\r\n'))
> # out.write(OPTIONAL_DELIMITER)
>   out.write(right)
> out.close()
> it is showing error:
> ph08...@linux-af0n:~> python join.py
> Traceback (most recent call last):
>   File "join.py", line 6, in
> for left, right in itertools.izip(f1, f2):
> NameError: name 'itertools' is not defined

That's because you're not importing itertools, but you're just 
importing "chain" from within it.  So of course when you try to 
use "itertools.izip", itertools doesn't exist.  You can either use


  import itertools
  #...
  for left, right in itertools.izip(f1,f2):

or

  from itertools import izip
  #...
  for left, right in izip(f1,f2):

-tkc




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


platform-independent image copy/paste with Tkinter?

2010-05-15 Thread technocake
Hi.

Is there a good way to copy from or paste to the clipboard on all
systems running python using Tkinter?
started a small road too it here:

#!/usr/bin/python
__author__="technocake"
__date__ ="$15.mai.2010 15:53:39$"

from Tkinter import *

if __name__ == "__main__":

def displayClipboard(event):
try:
data = event.widget.clipboard_get(type="STRING")
except :
#Need a method for displaying a image here..
data = "Image" #
finally: #Updates the textlabel
lbl.config(text=data)

root = Tk()
lbl= Label(root, width=20)
lbl.bind("", displayClipboard) #binding to leftclick
lbl.pack()

root.mainloop()

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


Re: Picking a license

2010-05-15 Thread Aahz
In article ,
Stefan Behnel   wrote:
>a...@pythoncraft.com (Aahz) writes:
>>
>> Which license you use depends partly on your political philosophy.
>
>Did they close down debian-legal, or why is this thread growing so long?

Mea culpa, mea culpa, mea maxima culpa  ;-)
-- 
Aahz (a...@pythoncraft.com)   <*> http://www.pythoncraft.com/

f u cn rd ths, u cn gt a gd jb n nx prgrmmng.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Picking a license

2010-05-15 Thread Aahz
In article <7bfa5457-027d-4ee1-a54f-3c0baba45...@e21g2000vbl.googlegroups.com>,
Patrick Maupin   wrote:
>
>So, there are good reasons for both kinds of licenses, which I think
>everybody on the pro-permissive side has been saying all along.  Of
>course, "force" is a more inflammatory word that "obligation" in some
>contexts, and that has been used in what I would admit on my part is a
>knee-jerk reaction to my belief that "free" and "freedom" are more
>inflammatory words than "rights" in the same contexts.

Yes, exactly.
-- 
Aahz (a...@pythoncraft.com)   <*> http://www.pythoncraft.com/

f u cn rd ths, u cn gt a gd jb n nx prgrmmng.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: parsing XML

2010-05-15 Thread superpollo

kak...@gmail.com ha scritto:

Hi to all, let's say we have the following Xml

  
17.1
6.4
  
  
15.5
7.8
  


How can i get the players name, age and height?
DOM or SAX and how

Thanks
Antonis


another minimal xml.etree.ElementTree solution:

>>> print document

  
17.1
6.4
  
  
15.5
7.8
  

>>> import xml.etree.ElementTree as ET
>>> team = ET.XML(document)
>>> for player in team:
... print player.attrib["name"]
... print player.attrib["age"]
... print player.attrib["height"]
... print
...
Mick Fowler
27
1.96m

Ivan Ivanovic
29
2.04m

>>>

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


Re: Puzzled by code pages

2010-05-15 Thread Lie Ryan
On 05/16/10 00:12, Adam Tauno Williams wrote:
> On Sat, 2010-05-15 at 20:30 +1000, Lie Ryan wrote:
>> On 05/15/10 10:27, Adam Tauno Williams wrote:
>>> I'm trying to process OpenStep plist files in Python.  I have a parser
>>> which works, but only for strict ASCII.  However plist files may contain
>>> accented characters - equivalent to ISO-8859-2 (I believe).  For example
>>> I read in the line:
>> handle = open('file.txt', 'rb')
>> data = handle.read()
>> handle.close()
>> data
>>> '"skyp4_filelist_10201/localit\xc3\xa0 termali_sortfield" =
>>> NSFileName;\n'
>> I presume you're using Python 2.x.
> 
> Yes.  But the days of all-unicode-strings will be wonderful when it
> comes. :)
> 
>>> What is the correct way to re-encode this data into UTF-8 so I can use
>>> unicode strings, and then write the output back to ISO8859-?
>>> I can read the file using codecs as ISO8859-2, but it still doesn't seem
>>> correct.
>> handle = codecs.open('file.txt', 'rb', encoding='iso8859-2')
>> data = handle.read()
>> handle.close()
>> data
>>> u'"skyp4_filelist_10201/localit\u0102\xa0 termali_sortfield" =
>>> NSFileName;\n'
>> When printing in the interactive interpreter, python uses __repr__
>> representation by default. If you want to use __str__ representation use
>> "print data" (note, your terminal must support printing unicode
>> characters); 
> 
> Using GNOME Terminal, so Unicode characters should display correctly.
> And I do see the characters when I 'cat' the file.

'cat' works because 'cat' works in bytes and doesn't try to interpret
the stream it is writing. You can tell python to output string instead
of unicode to get the same effect.

> h = codecs.open('file.txt', 'rb', encoding='iso8859-2')
> data = h.read()
> h.close()
> str(data)
> 
> 'ascii' codec can't encode characters in position 33-34: ordinal not in
> range(128)

this means either your terminal can't print unicode or python for some
reason thinks that the terminal is ascii terminal. You can encode the
string manually, e.g.:

print u'\u0102\xa0'.encode('utf-8')

or you should figure out a way to set your terminal properly so python
recognizes it as utf-8 terminal, see
http://drj11.wordpress.com/2007/05/14/python-how-is-sysstdoutencoding-chosen/

when python tries to print unicode object, python first needs to encode
that 'unicode' object into 'str'; by default python uses
sys.stdout.encoding to determine the encoding to use when printing
unicode object.

> unicode(data)
> u'"skyp4_filelist_10201/localit\u0102\xa0 termali_sortfield" =
> NSFileName;\n'

If data is a 'unicode', this is not surprising, as 'unicode(data)'
simply returns 'data'.

> I think I'm getting close.  Parsing the file seems to work, and while
> writing it out does not error, rereading my own output fails. :(
> Possibly I'm 'accidentally' writing the output as UTF-8 and not
> ISO8859-2.  I need the internal data to be UTF-8 but read as ISO8859-2
> and rewritten back to ISO8859-2 [at least that is what I believe from
> the OpenStep files I'm seeing].

unicode string doesn't have encoding (well, python needs some encoding
to store the unicode data in RAM, but that's implementation detail).
unicode string is not a stream of bytes encoded in specific way, it's an
encoding-agnostic block of text.

> What is the 'official' way to encode something from UTF-8 to another
> code page.  I *assumed* that if I wrote a unicode stream back through:
> 
> h = codecs.open(output_filename, 'wb', encoding='iso8859-2')
> data = writer.store(defaults)
> h.write(data)
> h.close()

what's "writer.store(defaults)"? It should return a 'unicode' if you
want h.write() to work properly. Otherwise, if data is 'str', h.write
will try to decode the 'str' to 'unicode' using the default decoder
(usually ascii), then encode that 'unicode' to 'iso8859-2'.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: parsing XML

2010-05-15 Thread superpollo

superpollo ha scritto:

kak...@gmail.com ha scritto:

Hi to all, let's say we have the following Xml

  
17.1
6.4
  
  
15.5
7.8
  


How can i get the players name, age and height?
DOM or SAX and how

Thanks
Antonis


another minimal xml.etree.ElementTree solution:

 >>> print document

  
17.1
6.4
  
  
15.5
7.8
  

 >>> import xml.etree.ElementTree as ET
 >>> team = ET.XML(document)
 >>> for player in team:
... print player.attrib["name"]
... print player.attrib["age"]
... print player.attrib["height"]
... print
...
Mick Fowler
27
1.96m

Ivan Ivanovic
29
2.04m

 >>>

bye


or, an alternative xml.dom.minidom solution:

>>> import xml.dom.minidom as MD
>>> team = MD.parseString(document)
>>> players = team.getElementsByTagName("player")
>>> for player in players:
... print player.getAttribute("name")
... print player.getAttribute("age")
... print player.getAttribute("height")
... print
...
Mick Fowler
27
1.96m

Ivan Ivanovic
29
2.04m

>>>

bye

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


Re: Is Python a functional programming language?

2010-05-15 Thread travis+ml-python
On Mon, May 10, 2010 at 08:45:51PM +0100, Nobody wrote:
> On Tue, 11 May 2010 00:24:22 +1200, Samuel Williams wrote:
> > Is Python a functional programming language?
> Not in any meaningful sense of the term.

LOL

> > I heard that lambdas were limited to a single expression,
> 
> Yes. In a functional language that wouldn't be a problem, as there's no
> limit to the complexity of an expression. Python's expressions are far
> more limited, which restricts what can be done with a lambda.

One very annoying thing in Python is the distinction between
statements and expressions.

Ever since learning LISP (well, Scheme) in S&ICP I find myself
frequently annoyed by this pointless distinction, started by
C (or earlier), and propogated without much thought.

Often I'll want to write a lamda that, say, prints something, or
modifies a global variable, and find that, well, it's either
impossible or beyond my interest in figuring it out.

It appears there is finally a ternary operator (for making if/else
into "expressions"):
http://en.wikipedia.org/wiki/Ternary_operation#Python
Maybe it will grow on me - it makes sense in English, but on
first glance I thought the programmer suffered from dyslexia.

To be fair, it appears that Python's whitespace-sensitive syntax sort
of precludes the "make a complex function on one line" that is typical
of languages which don't have statement/expression distinctions, but
I'm not convinced it couldn't be solved, perhaps by allowing anonymous
functions to span multiple lines, just like named functions.

> > Finally, even if Python supports functional features, is this a model that
> > is used often in client/application code?
> 
> Not really. List comprehensions are probably the most common example of
> functional idioms, but again they're limited by Python's rather limited
> concept of an expression.

Map/reduce, lambda, apply, that kind of stuff... kinda similar to
functional languages.

But "statements lack any side effects"?  No way.

In fact, a common distinction you'll see observed, but not always, is
that "statements may have side effects, expressions do not".

For some definitions of "functional language", there are no
side-effects, so there is no need for a statement which doesn't
evaluate to a value, so there is no need for a statement/expression
distinction, so everything is an expression.

You may have seen Paul Graham's other article about Python and LISP:
http://www.paulgraham.com/icad.html

Upon re-skimming it, I find myself wondering if I got the
expression/statement annoyance from his pages, or from my own
experience.  I can't remember :-) Probably it was an annoyance that I
hadn't put my finger on until he spelled it out for me, like a
splinter in my mind :-)

He obliquely references my other pet peeve, the global/class/local
distinction, completely ignoring arbitrarily-nested lexical scoping.
From what I've read in this thread, there's a recent "nonlocal"
declaration that sounds like it might accomplish something useful in
this regard.

(I still haven't figured out how he managed to use lexical closures in
 his web server to allow one web page to use another to allow the user
 to select and return a value, like a color from a color wheel, unless
 he implemented his own web server in LISP, since HTTP is stateless).

I really like Scheme's clean syntax (never learned Common LISP, sorry,
too much to remember) but frankly, I've never looked at a problem and
said, "you know, Scheme would be perfect for this".  Maybe if I was
writing a program that did optimizing transformations on abstract
syntax trees, or something.  And since Scheme has never come in handy,
I never bothered with Common LISP.  I feel similarly about ML, OCAML
and Haskell... maybe one day when I'm bored, not today, not this
project.

So in the end, I find myself using python more than anything else,
fully acknowledging its warts.  I used to admire its simplicity, but
now with decorators, iterators, generators, metaclasses, and the
proliferation of special method names, I have to wonder if that still
holds true...  certainly I understand 90+% of python programs, but
do I understand that proportion of the constructs?

PS: Why do people call LISP object-oriented?  Are they smoking crack?
No classes, no methods, no member variables... WTF?
-- 
A Weapon of Mass Construction
My emails do not have attachments; it's a digital signature that your mail
program doesn't understand. | http://www.subspacefield.org/~travis/ 
If you are a spammer, please email j...@subspacefield.org to get blacklisted.


pgpYyYI8jLDVr.pgp
Description: PGP signature
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Picking a license

2010-05-15 Thread Robert Kern

On 2010-05-14 21:37 , Steven D'Aprano wrote:

On Fri, 14 May 2010 06:42:31 -0700, Ed Keith wrote:


I am not a lawyer, but as I understand the LGPL, If I give someone
something that used any LGPLed code I must give them the ability to
relink it with any future releases of the LGPLed code. I think that
means that I need to give them a linker and teach them how to use it,
and I do not want to go there.


Surely you're joking?

Does this mean that if they lose their hands in an accident, you have to
come sit at their computer and do their typing?

The LGPL and GPL don't grant people "the ability" to do anything, since
that's not within our power to grant. Some people don't want to, or
can't, program, or don't have time. It's not like the LGPL is the bite of
a radioactive spider that can grant superpowers. It is a licence which
grants *permissions*.


No, the LGPL requires you to do something extra to enable your users to be able 
to relink your program. You need to provide the ability to do this, up to some 
unspecified and untested limit of reasonableness (your example is obviously 
beyond the limit of reasonableness). You can't just give them, say, a statically 
linked program and nothing else. You can't require for-fee, proprietary linkers. 
This is usually not hard to do (just give them unlinked .o or .obj files and a 
Makefile or project file), but it is *not* just a matter of granting permissions.


But you're right, you don't have to teach them how to do it.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

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


Local variables persist across function calls

2010-05-15 Thread Dave
I've been writing Python for a few years now, and tonight I ran into
something that I didn't understand. I'm hoping someone can explain
this to me. I'm writing a recursive function for generating
dictionaries with keys that consist of all permutations of a certain
set. Here's the function:


def make_perm(levels, result = {}, key = ''):
local = key
if levels == 1:
for i in ['a', 'b', 'c', 'd']:
result [local + i] = ''
else:
for i in ['a', 'b', 'c', 'd']:
make_perm(levels - 1, result, local + i)
return result


The first time I ran it, make_perm(2) does what I expected, returning
a dictionary of the form {'aa': '', 'ab':'', 'ac':'', ... }. But, if I
run make_perm(3) after that, I get a dictionary that combines the
contents of make_perm(2) with the values of make_perm(3), a dictionary
like {'aaa':'', 'aab':'', ...}. Running make_perm(2) again will return
the same result as make_perm(3) just did. It's like the local variable
is preserved across different calls to the same function. I don't
understand why this happens: "result" is not a global variable, and
accessing it outside the function generates a NameError, as it should.
After running make_perm once, printing the value of result inside the
function produces the last result returned on the first iteration.

If, however, I explicitly pass an empty dictionary into make_perm as
the second argument, the value of "result" is returned correctly. So I
have a solution to my problem, but I still don't understand why it
works. I've tried this on both Python 2.6 and Python 3.2, both in IDLE
and from the command line, and it behaves the same way. So it seems
like this is an intentional language feature, but I'm not sure exactly
why it works this way, or what's going on. Anyway, I'd appreciate it
if someone could explain this to me.
-- 
http://mail.python.org/mailman/listinfo/python-list


pickle.load() all dict

2010-05-15 Thread Yutao Deng
Hi all:
I'm trying to learn to use Python  wrote a applet to record every day doing.
and i use the pickle
pickle.dump something to file no problem i think.
but pickle.load whith a problem. can not load all dict do my way that what i
pickle.dump().

My code:

import cPickle as pickle
pickle_file = open("data2","rb")
i = pickle.load(pickle_file)
print i
i = pickle.load(pickle_file)
print i
i = pickle.load(pickle_file)
print i
i = pickle.load(pickle_file)
print i
i = pickle.load(pickle_file)
print i

console show :
{'2010-5-23': ['1242', 'first']}
{'2010-5-24': ['1232', 'third']}
{'2010-5-25': ['211', 'second']}
{'2010-3-22': ['3211', 'fou']}
{'2050-3-2': ['3990', '322']}

This is i want but that's silly. if the dict too much, then i have not
ideas.

the other way from
http://mail.python.org/pipermail/tutor/2005-July/039859.html


import cPickle as pickle
pickle_file = open("data2","rb")

number_of_pickles = pickle.load(pickle_file)
for n in range(number_of_pickles):
p = pickle.load(pickle_file)
print p

this way didnt work for me.

console show:
Traceback (most recent call last):
number_of_pickles = pickle.load(pickle_file)
cPickle.UnpicklingError: invalid load key, '
'.
how do i define the range of pickle.load a file. i mean that how can i know
how many dict in the data2.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: d-cm Controll Manager

2010-05-15 Thread Kruptein
http://launchpad.net/d-cm
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Picking a license

2010-05-15 Thread Albert van der Horst
In article <7bdce8a7-bf7d-4f1f-bc9d-1eca26974...@d27g2000yqc.googlegroups.com>,
Patrick Maupin   wrote:

>
>That is correct.  All "privileges" as you put it are merely things
>that a user can do with the code without fear of a lawsuit by the
>author, and when an author uses a permissive license, he indicates
>that the things that he could possibly find egregious enough to sue
>over are very few.  For example, if you give an Ubuntu CD to your
>friend without giving source code or a written offer of source code,
>you have violated the license on quite a few of the programs on the
>CD, but not, for example, on Python or Apache, because these licenses
>do not attempt to forbid you from doing this.

Bit this is stupid! The GPL is to accomplish a political goal,
an operating system with tools available to all, that can be
modified by anybody capable of doing so.

Enforcements not amenable to that goal will not happen.

It might surprise even RMS himself but ...
The political goal has been large and by accomplished at the expense
of great legal effort and great efforts of Linus Torvalds c.s. Without
the GPL Linux would not exist -- except in the form of an academic
exercise -- and neither would gcc, so neither would Python.
By proxy I estimate that none of the software with a permissive
license you mention would not be available.

You seem to imply that RMS is a nasty guy.
Yes, RMS is a nasty guy. All warriors are! Get in his
way and you're blasted. But some warriors fight for a right
cause ... This really has nothing to do with anything.
The meek will inherit the world, yes, but only after
the second coming.

>
>Regards,
>Pat

Groetjes Albert

--
-- 
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
alb...@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst

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


Re: Is Python a functional programming language?

2010-05-15 Thread Aahz
In article ,
  wrote:
>
>One very annoying thing in Python is the distinction between
>statements and expressions.

One extremely valuable thing in Python is the distinction between
statements and expressions.

In fact, given the semantic similarity between Python and Lisp, I would
argue that Python having the distinction is partly responsible for its
popularity.
-- 
Aahz (a...@pythoncraft.com)   <*> http://www.pythoncraft.com/

f u cn rd ths, u cn gt a gd jb n nx prgrmmng.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Local variables persist across function calls

2010-05-15 Thread Alf P. Steinbach

On 15.05.2010 19:18, * Dave:

I've been writing Python for a few years now, and tonight I ran into
something that I didn't understand. I'm hoping someone can explain
this to me. I'm writing a recursive function for generating
dictionaries with keys that consist of all permutations of a certain
set. Here's the function:


def make_perm(levels, result = {}, key = ''):
local = key
if levels == 1:
for i in ['a', 'b', 'c', 'd']:
result [local + i] = ''
else:
for i in ['a', 'b', 'c', 'd']:
make_perm(levels - 1, result, local + i)
return result



I bet this is a FAQ, but I don't know where the FAQ is (probably at 
python.org?).

The defaults for formal parameters are evaluated /once/, namely at function 
definition time, when the execution first passes through the definition.


And what you're doing is to update that original default 'result' dictionary.

To achieve the effect that you apparently want you can do


  def make_perm( levels, result = None, key = '' )
  if result is None: result = {}  # Evaluated for each call.
  # Blah blah, the rest


There are also other ways.


Cheers & hth.,

- Alf

--
blog at http://alfps.wordpress.com>
--
http://mail.python.org/mailman/listinfo/python-list


Re: Local variables persist across function calls

2010-05-15 Thread Chris Rebert
On Sat, May 15, 2010 at 10:18 AM, Dave  wrote:
> I've been writing Python for a few years now, and tonight I ran into
> something that I didn't understand. I'm hoping someone can explain
> this to me. I'm writing a recursive function for generating
> dictionaries with keys that consist of all permutations of a certain
> set. Here's the function:
>
> 
> def make_perm(levels, result = {}, key = ''):
>        local = key
>        if levels == 1:
>                for i in ['a', 'b', 'c', 'd']:
>                        result [local + i] = ''
>        else:
>                for i in ['a', 'b', 'c', 'd']:
>                        make_perm(levels - 1, result, local + i)
>        return result
> 
>
> The first time I ran it, make_perm(2) does what I expected, returning
> a dictionary of the form {'aa': '', 'ab':'', 'ac':'', ... }. But, if I
> run make_perm(3) after that, I get a dictionary that combines the
> contents of make_perm(2) with the values of make_perm(3), a dictionary
> like {'aaa':'', 'aab':'', ...}. Running make_perm(2) again will return
> the same result as make_perm(3) just did. It's like the local variable
> is preserved across different calls to the same function. I don't
> understand why this happens: "result" is not a global variable, and
> accessing it outside the function generates a NameError, as it should.
> After running make_perm once, printing the value of result inside the
> function produces the last result returned on the first iteration.
>
> If, however, I explicitly pass an empty dictionary into make_perm as
> the second argument, the value of "result" is returned correctly. So I
> have a solution to my problem, but I still don't understand why it
> works. I've tried this on both Python 2.6 and Python 3.2, both in IDLE
> and from the command line, and it behaves the same way. So it seems
> like this is an intentional language feature, but I'm not sure exactly
> why it works this way, or what's going on. Anyway, I'd appreciate it
> if someone could explain this to me.

Default argument values are only evaluated *once*, at
function-definition time, *not* every time the function is called. So
whenever you call make_perm() without specifying the `result`
argument, `result` will get *the same dictionary* as its value every
time, and modifications to that dictionary will thus persist across
calls.

When a default argument value is of a mutable type such as a
dictionary, the following idiom is used to get around the
aforementioned behavior:

def make_perm(levels, result = None, key = ''):
if result is None:
result = {}
#rest same as before...

This ensures `result` gets a fresh dictionary every time.

See also the "Important warning" on
http://docs.python.org/tutorial/controlflow.html#default-argument-values

Cheers,
Chris
--
I'm not a fan of this behavior either.
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Picking a license

2010-05-15 Thread Patrick Maupin
On May 14, 8:04 am, Ethan Furman  wrote:
> Steven D'Aprano wrote:

>> You've never had to recode something because it was nominally available
>> under a proprietary licence that you (or your client) was unwilling to
>> use? Lucky you!

> Steven, did you actually read what he wrote?  If you did, why would you
> say something so stupid?

Well, in Steven's defense, my literal words "... labor that could have
been spent elsewhere if someone else had done something differently.
The only time that comes into play in my programming life is when I
have to recode something that is nominally available under the GPL..."
could easily be taken to mean that I have never had to recode
something that was under a proprietary license.

In truth most of what any of us write is probably very similar to
stuff that others have written, so taken in a very literal sense, yes,
obviously, there are several times that I have had to recode
proprietary software.  But I was responding to Brendan's "broken
window" analogy, and, rightly or wrongly, I *assumed* he was only
referring to software that was free *at one time* but then was somehow
taken out of the commons.  To my knowledge, I've never recoded such
software, and to the extent that anybody might be suggesting that
*all* software belongs in an easily-accessible commons and that nobody
should ever have to recode anything -- well, I could probably be
seduced by the Utopian vision, but I strongly reject that the sort of
rights-pooling mandated by the GPL is the single way to get there.

If everybody believes in the Utopian vision, the GPL is rendered
unnecessary, and to the extent that some people *really* don't believe
in the Utopian vision, the wording of the GPL makes a gentle
transition from proprietary to free difficult for programmers with
feet in both camps.  However, the GPL *does* provide a core focal
point for the actual Utopian vision itself, and this does serve a
useful purpose.  Personally, I think we are gradually lurching towards
the Utopian vision, and probably at a faster pace than if we only had
the GPL or if we only had permissive licenses.  I think even RMS
believes this; as a matter of practicality he will suggest the LGPL or
even permissive licensing under some circumstances.

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


Reading XML namespaces

2010-05-15 Thread Adam Tauno Williams
Say I have an XML document that begins with:


http://www.dsml.org/DSML";>
...

How can one access the namespaces define in this node?  I've done a fair
amount of XML in Python, but haven't been able to uncover the call to
enumerate the namespaces.

Primarily I am using etree from lxml.
-- 
Adam Tauno Williams  LPIC-1, Novell CLA

OpenGroupware, Cyrus IMAPd, Postfix, OpenLDAP, Samba

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


Re: Picking a license

2010-05-15 Thread Patrick Maupin
On May 15, 12:49 pm, Albert van der Horst 
wrote:
> In article 
> <7bdce8a7-bf7d-4f1f-bc9d-1eca26974...@d27g2000yqc.googlegroups.com>,
> Patrick Maupin   wrote:
> 
>
> >That is correct.  All "privileges" as you put it are merely things
> >that a user can do with the code without fear of a lawsuit by the
> >author, and when an author uses a permissive license, he indicates
> >that the things that he could possibly find egregious enough to sue
> >over are very few.  For example, if you give an Ubuntu CD to your
> >friend without giving source code or a written offer of source code,
> >you have violated the license on quite a few of the programs on the
> >CD, but not, for example, on Python or Apache, because these licenses
> >do not attempt to forbid you from doing this.
>
> Bit this is stupid! The GPL is to accomplish a political goal,
> an operating system with tools available to all, that can be
> modified by anybody capable of doing so.

Sure.

> Enforcements not amenable to that goal will not happen.

Absolutely agreed.  I have no real problem with that.  I *do* have a
problem with some of the faithful acting like I'm completely wrong and
trying to actively mislead about how the license works, but then I
guess that's par for the course for politics.

> It might surprise even RMS himself but ...
> The political goal has been large and by accomplished at the expense
> of great legal effort and great efforts of Linus Torvalds.

Agreed.

> c.s. Without
> the GPL Linux would not exist -- except in the form of an academic
> exercise

Not sure that's true.  Linus would have picked *some* license.
Possibly something like the BSD.  He started development using Minix,
which certainly wasn't licensed freely, and which was first released 2
years before the GPL, so the GPL was not instrumental in providing his
first development environment.  He might have had to choose a
different compiler if GCC weren't available, but there was a compiler
with Unix.  I can believe that the GPL helped Linux gain some momentum
it wouldn't have had otherwise, but I reject your absolute assertion.

> -- and neither would gcc,

Well, not gcc itself, but there were compilers around...

> so neither would Python.

That I *completely* disagree with.  Python was written for the amoeba
O/S, which was in existence and had compilers a good 3 or 4 years
before the first release of gcc.

> By proxy I estimate that none of the software with a permissive
> license you mention would not be available.

I disagree.  If Linux weren't around, MS would not be the sole
winner.  Free development would have coalesced around one of the BSDs
(which in absolute numbers are still pretty big projects right now, in
any case, just lacking the mindshare of Linux).  As apache and other
projects have shown, the propensity of the few to try to lock things
up can easily be overcome with sheer numbers and willpower -- no
reciprocal license required.

> You seem to imply that RMS is a nasty guy.

I think we both agree that people who make history are often
unreasonable.  I really don't have a problem with that, but I do have
a problem with apologists claiming it isn't so in his case.

> Yes, RMS is a nasty guy. All warriors are! Get in his
> way and you're blasted.

So maybe you're not one of the ones I have a problem with.

> But some warriors fight for a right
> cause ... This really has nothing to do with anything.
> The meek will inherit the world, yes, but only after
> the second coming.

If you read all the posts carefully, you will see that people arguing
that sometimes permissive licenses are the right ones also allow a
place for the GPL.  It is only some of the GPL adherents who accuse
some of the "non-believers" of acting duplicitously, with malice, of
being against "freedom".  I reject that characterization of myself,
and when people accuse me of this, I mentally place them in the
category of "religious nutter".  Once I have placed someone in that
category, it is sometimes hard for me to respond civilly to them,
especially when they write something stupid.  I have not yet placed
you in that category, but I do categorically reject your
interpretation of some of the relevant historical events.

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


Re: Puzzled by code pages

2010-05-15 Thread Mark Tolonen


"Adam Tauno Williams"  wrote in message 
news:1273932760.3929.18.ca...@linux-yu4c.site...

On Sat, 2010-05-15 at 20:30 +1000, Lie Ryan wrote:

On 05/15/10 10:27, Adam Tauno Williams wrote:

[snip]


Yep.  But in the interpreter both unicode() and repr() produce the same
output.  Nothing displays the accented character.

h = codecs.open('file.txt', 'rb', encoding='iso8859-2')
data = h.read()
h.close()
str(data)


Here you are correctly reading an iso8859-2-encoded file and converting it 
to Unicode.


Try "print data".  "str(data)" converts from Unicode strings to byte 
strings, but only uses the default encoding, which is 'ascii'.  print will 
use the stdout encoding of your terminal, if known.   Try these commands on 
your system (mine is Windows XP):



import sys
sys.getdefaultencoding()

'ascii'

sys.stdout.encoding

'cp437'

You should only attempt to "print" Unicode strings or byte strings encoded 
in the stdout encoding.  Printing byte strings in any other encoding will 
often print garbage.


[snip]

I think I'm getting close.  Parsing the file seems to work, and while
writing it out does not error, rereading my own output fails. :(
Possibly I'm 'accidentally' writing the output as UTF-8 and not
ISO8859-2.  I need the internal data to be UTF-8 but read as ISO8859-2
and rewritten back to ISO8859-2 [at least that is what I believe from
the OpenStep files I'm seeing].


"internal data" is Unicode, not UTF-8.  Unicode is the absence of an 
encoding (Python uses UTF-16 or UTF-32 internally, but that is an 
implementation detail).  UTF-8 is a byte-encoding.


If you actually need the internal data as UTF-8 (maybe you are working with 
a library that works with UTF-8 strings, then:



f = codecs.open("in.txt", 'rb', encoding="iso8859-2")
s = f.read()  # s is a Unicode string.
s = s.encode('utf-8') # now s is a UTF-8 byte string
f.close()


(process data as UTF-8 here).


s = s.decode('utf-8') # s is Unicode again.
f2 = codecs.open("out.txt", 'wb', encoding="iso8859-2")
f2.write(s)
f2.close()


Note you *decode* byte strings to Unicode and *encode* Unicode into byte 
strings.


-Mark


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


Re: Picking a license

2010-05-15 Thread Paul Boddie
On 15 Mai, 04:20, Lawrence D'Oliveiro  wrote:
> In message 
> , Paul 
> Boddie wrote:
> > Although people can argue that usage of the GPL prevents people from
> > potentially contributing because they would not be able to sell
> > proprietary versions of the software ...
>
> It doesn’t prevent them from selling proprietary versions of their own
> contributions, any more than any other licence does.

I already mentioned this several days ago, upon which it was regarded
as not addressing some complaint or other. You own your own work, but
if you release that work to someone and it makes use of a GPL-licensed
work, then the user must be able to deal with the work according to
the terms of the GPL.

> The fact that their contribution may not be much use without the rest of
> that GPL’d code is entirely another matter. It was their choice to build on
> the work of others; they could have reinvented it from scratch themselves.

Yes. I mentioned this before: WebKit (or probably more specifically
WebCore) is an example of both originally building on GPL-licensed
code, and also building on permissively licensed code. The code
specifically belonging to WebKit and its predecessor was never GPL-
licensed itself.

My point about a platform vendor choosing to undertake the multiple
man-year task of rewriting an existing, mature GPL-licensed library
purely so that people are then able to sell proprietary software is
grounded in the observation that if people were content to make their
source code available for their products on such a platform, the GPL
would be a satisfactory basis for such activities: they own their own
code, can license it permissively (but compatibly with the GPL), and
the sources remain available; they don't need a "weaker" copyleft
licence or a permissive licence to do any of this.

Now, since it is unlikely that a business is going to spend money on a
project that doesn't change the situation in any practical sense -
that people are content with having their source code available to
their users, but now (after several man-years of effort) can link to a
permissively licensed (or weak-copyleft licensed) library - the actual
motivation emerges for choosing the LGPL or a permissive licence as
the basis for the platform's licensing: to permit the only thing that
the GPL does not, which is to let people release their software and
not commit to offering the source code; to permit, in effect, the
delivery of proprietary software.

Any claim that a licensing change is needed merely to let people
develop open source applications on the platform is dishonest,
especially as the "about" page for PySide spells out the licensing
objective. Take away the proprietary software requirement and you
might as well use the GPL.

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


Re: Picking a license

2010-05-15 Thread John Bokma
Paul Boddie  writes:

> especially as the "about" page for PySide spells out the licensing
> objective. Take away the proprietary software requirement and you
> might as well use the GPL.

Thank you for mentioning PySide, I wasn't aware of this project.

-- 
John Bokma   j3b

Hacking & Hiking in Mexico -  http://johnbokma.com/
http://castleamber.com/ - Perl & Python Development
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Reading XML namespaces

2010-05-15 Thread Stefan Behnel

Adam Tauno Williams, 15.05.2010 20:37:

Say I have an XML document that begins with:


http://www.dsml.org/DSML";>
...

How can one access the namespaces define in this node?  I've done a fair
amount of XML in Python, but haven't been able to uncover the call to
enumerate the namespaces.

Primarily I am using etree from lxml.


What do you need the namespaces for?

Stefan

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


pass xxx site ;0

2010-05-15 Thread Mr.Ss
pass xxx site

http://www.2shared.com/uploadComplete.jsp?sId=ISfomojyvBaVf129
-- 
http://mail.python.org/mailman/listinfo/python-list


pass xxx site 2 ;0

2010-05-15 Thread Mr.Ss
pass xxx site

http://www.2shared.com/file/MqzpLfxz/pass_xxx_site.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Reading XML namespaces

2010-05-15 Thread Adam Tauno Williams
On Sat, 2010-05-15 at 22:29 +0200, Stefan Behnel wrote:
> Adam Tauno Williams, 15.05.2010 20:37:
> > Say I have an XML document that begins with:
> > 
> > http://www.dsml.org/DSML";>
> > How can one access the namespaces define in this node?  I've done a fair
> > amount of XML in Python, but haven't been able to uncover the call to
> > enumerate the namespaces.
> > Primarily I am using etree from lxml.
> What do you need the namespaces for?

One needs to know the defined namespace in order to perform xpath
operations.

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


Re: Reading XML namespaces

2010-05-15 Thread Stefan Behnel

Adam Tauno Williams, 15.05.2010 22:40:

On Sat, 2010-05-15 at 22:29 +0200, Stefan Behnel wrote:

Adam Tauno Williams, 15.05.2010 20:37:

Say I have an XML document that begins with:

http://www.dsml.org/DSML";>
How can one access the namespaces define in this node?  I've done a fair
amount of XML in Python, but haven't been able to uncover the call to
enumerate the namespaces.
Primarily I am using etree from lxml.

What do you need the namespaces for?


One needs to know the defined namespace in order to perform xpath
operations.


Well, yes, but unless you already know the namespace (URI), you can't know 
what the tag you find signifies in the first place.


Unless, obviously, you are confusing namespaces with namespace prefixes. 
But you don't need to know the prefixes for XPath.


Does this help?

http://codespeak.net/lxml/xpathxslt.html#namespaces-and-prefixes

Stefan

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


Re: Picking a license

2010-05-15 Thread Patrick Maupin
On May 15, 2:59 pm, Paul Boddie  wrote:

[Rest of the post, that contains points previously debated and well-
refuted, snipped]

> Any claim that a licensing change is needed merely to let people
> develop open source applications on the platform is dishonest,

See, there you go again, impugning the motives and character of
others.  Is it really that surprising that sometimes others get
annoyed by this and start to assume things about your personality that
you disagree with?

> especially as the "about" page for PySide spells out the licensing
> objective.

Yes, it does: "PySide is licensed under the LGPL version 2.1 license,
allowing both Free/Open source software and proprietary software
development."

> Take away the proprietary software requirement and you
> might as well use the GPL.

You obviously agree that PySide was coded as a direct replacement for
PyQt, for licensing reasons, so certainly there's a perception that
*something* is wrong with PyQt's license.  Let's see what the PyQt
license page has to say about it:

PyQt is available under the following licenses.

* GNU General Public License v2
* GNU General Public License v3
* PyQt Commercial License

Hmm, the only thing that PySide seems to allow that is missing from
this list seems to be the "O" in "FOSS".  But of course, you already
knew that, because I already explained it, and as you've told me that
you read and think about everything very carefully, obviously your
objective in repeating this nonsense is to mislead and confuse.

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


Re: Reading XML namespaces

2010-05-15 Thread Adam Tauno Williams
On Sat, 2010-05-15 at 22:58 +0200, Stefan Behnel wrote:
> Adam Tauno Williams, 15.05.2010 22:40:
> > On Sat, 2010-05-15 at 22:29 +0200, Stefan Behnel wrote:
> >> Adam Tauno Williams, 15.05.2010 20:37:
> >>> Say I have an XML document that begins with:
> >>> 
> >>> http://www.dsml.org/DSML";>
> >>> How can one access the namespaces define in this node?  I've done a fair
> >>> amount of XML in Python, but haven't been able to uncover the call to
> >>> enumerate the namespaces.
> >>> Primarily I am using etree from lxml.
> >> What do you need the namespaces for?
> > One needs to know the defined namespace in order to perform xpath
> > operations.
> Well, yes, but unless you already know the namespace (URI), you can't know 
> what the tag you find signifies in the first place.
> Unless, obviously, you are confusing namespaces with namespace prefixes. 
> But you don't need to know the prefixes for XPath.
> Does this help?
> http://codespeak.net/lxml/xpathxslt.html#namespaces-and-prefixes

I know that.  I'm getting an XML document and an xpath and need to
execute it.  But i have to tell xpath via namespaces= the prefixes &
namespaces; so I need to get that data out of the document.   

"If your XPath expression uses namespace prefixes, you must define them
in a prefix mapping"
-- 
Adam Tauno Williams  LPIC-1, Novell CLA

OpenGroupware, Cyrus IMAPd, Postfix, OpenLDAP, Samba

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


Re: Puzzled by code pages

2010-05-15 Thread John Machin
Adam Tauno Williams  whitemice.org> writes:

> On Fri, 2010-05-14 at 20:27 -0400, Adam Tauno Williams wrote:
> > I'm trying to process OpenStep plist files in Python.  I have a parser
> > which works, but only for strict ASCII.  However plist files may contain
> > accented characters - equivalent to ISO-8859-2 (I believe).  For example
> > I read in the line:

> > '"skyp4_filelist_10201/localit\xc3\xa0 termali_sortfield" =
> > NSFileName;\n'
> > What is the correct way to re-encode this data into UTF-8 so I can use
> > unicode strings, and then write the output back to ISO8859-?

> Buried in the parser is a str(...) call.  Replacing that with
> unicode(...) and now the OpenSTEP plist parser is working with Italian
> plists.

Some observations:

Italian text is much more likely to be encoded in ISO-8859-1 than ISO-8859-2.
The latter covers eastern European languages (e.g. Polish, Czech, Hungarian)
that use the Latin alphabet with many "decorations" not found in western 
alphabets.

Let's look at the 'localit\xc3\xa0' example. Using ISO-8859-2, that decodes to
u'localit\u0102\xa0'. The second-last character is LATIN CAPITAL LETTER A WITH
BREVE (according to unicodedata.name()). The last character is NO-BREAK SPACE.
Doesn't look like an Italian word to me.

However, using UTF-8, that decodes to u'localit\xe0'. The last character is
LATIN SMALL LETTER A WITH GRAVE. Looks like a plausible Italian word to me. Also
to Wikipedia: "A località (literally "locality"; plural località) is the name
given in Italian administrative law to a type of territorial subdivision of a
comune ..."

Conclusions:

It's worth closely scrutinising "accented characters - equivalent to ISO-8859-2
(I believe)". Which variety of "OpenStep plist files" are you looking at:
NeXTSTEP, GNUstep, or MAC OS X? If the latter, it's evidently an XML document,
and you should be letting the XML parser decode it for you and in any case as an
XML document it's most likely UTF-8, not ISO-8859-2.

It's worth examining your definition of "working".


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


Re: Human word reader

2010-05-15 Thread David Zaslavsky
Here's my take on that:

 loc = re.search('for\s+(\w+)', string).group(1)

Not much different, really, but it does allow for multiple spaces (\s+) as 
well as requiring at least one character in the word (\w+), and I use a 
matching group to extract the location directly instead of splitting the 
string "by hand".

:) David

On Saturday 15 May 2010 8:38:01 am Xavier Ho wrote:
> On Sat, May 15, 2010 at 9:32 PM, timo verbeek 
wrote:
> > On May 15, 1:02 pm, timo verbeek  wrote:
> > Place starts always with for
> 
> Okay, much better.
> 
> Given that constraint, it looks like regular expression can do the job. I'm
> not very experienced with regex, though.
> 
> \w* matches a whole word composed of letters and numbers by default.
> 
> >>> result = re.search('for \w*', 'Give me the weather for London please.')
> >>> result.group()
> 
> 'for London'
> 
> >>> result.group().split()[1]
> 
> 'London'
> 
> Cheers,
> Xav


signature.asc
Description: This is a digitally signed message part.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Reading XML namespaces

2010-05-15 Thread Stefan Behnel

Adam Tauno Williams, 15.05.2010 23:04:

On Sat, 2010-05-15 at 22:58 +0200, Stefan Behnel wrote:

Adam Tauno Williams, 15.05.2010 22:40:

On Sat, 2010-05-15 at 22:29 +0200, Stefan Behnel wrote:

Adam Tauno Williams, 15.05.2010 20:37:

Say I have an XML document that begins with:

http://www.dsml.org/DSML";>
How can one access the namespaces define in this node?  I've done a fair
amount of XML in Python, but haven't been able to uncover the call to
enumerate the namespaces.
Primarily I am using etree from lxml.

What do you need the namespaces for?

One needs to know the defined namespace in order to perform xpath
operations.

Well, yes, but unless you already know the namespace (URI), you can't know
what the tag you find signifies in the first place.
Unless, obviously, you are confusing namespaces with namespace prefixes.
But you don't need to know the prefixes for XPath.
Does this help?
http://codespeak.net/lxml/xpathxslt.html#namespaces-and-prefixes


I know that.  I'm getting an XML document and an xpath and need to
execute it.  But i have to tell xpath via namespaces= the prefixes&
namespaces; so I need to get that data out of the document.


Ah, you didn't provide that information in your initial post. So you 
control neither the document nor the XPath expression, right? Can't you get 
the namespace-prefix mapping from your user? After all, he/she is the only 
one who knows the meaning of the XPath expression. I'd just reject any 
expression with an undefined prefix.


BTW, I'm still not sure I understand your problem. Could you provide some 
more details?


Stefan

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


Re: Reading XML namespaces

2010-05-15 Thread Martin v. Loewis
> BTW, I'm still not sure I understand your problem. Could you provide
> some more details?
>

Wouldn't it be easier if you told the OP how to access the prefix
mappings in lxml etree, or, if this was actually not possible, admitted
that it is actually not possible?

FWIW, in the DOM, you look at all attributes of an element node, and
search for those whose namespace is "http://www.w3.org/2000/xmlns/";

In SAX, you watch the startPrefixMapping events.

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


Re: Reading XML namespaces

2010-05-15 Thread Adam Tauno Williams
On Sat, 2010-05-15 at 23:25 +0200, Stefan Behnel wrote:
> Ah, you didn't provide that information in your initial post. So you 
> control neither the document nor the XPath expression, right? 

Correct.

> Can't you get the namespace-prefix mapping from your user? 

Nope. Or they are not going to be expecting to have to [since this works
just fine in Java, which for this feature we are pretty much porting
from].

> After all, he/she is the only one who knows the meaning of the XPath 
> expression. 

???  The namespaces are embedded in the document.  Personally I find it
odd I have to tell xpath about the namespace of the document it is a
$*&@(*& method of.

> I'd just reject any expression with an undefined prefix.

Which I'm okay with;  whether the prefix is undefined can be determined
from the document!

> BTW, I'm still not sure I understand your problem. Could you provide some 
> more details?

This is an action in a workflow action (business process modeling).  It
has an input message of an XML document and a parameter of an xpath;  it
invokes a subordinate action [think: foreach] for each node resulting
from the expression.

-- 
Adam Tauno Williams  LPIC-1, Novell CLA

OpenGroupware, Cyrus IMAPd, Postfix, OpenLDAP, Samba

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


Re: Puzzled by code pages

2010-05-15 Thread Martin v. Loewis

> Conclusions:
> 
> It's worth closely scrutinising "accented characters - equivalent to 
> ISO-8859-2
> (I believe)". Which variety of "OpenStep plist files" are you looking at:
> NeXTSTEP, GNUstep, or MAC OS X? If the latter, it's evidently an XML document,
> and you should be letting the XML parser decode it for you and in any case as 
> an
> XML document it's most likely UTF-8, not ISO-8859-2.
> 
> It's worth examining your definition of "working".

I came to the same conclusions after reading the OP's article.

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


Re: Picking a license

2010-05-15 Thread Paul Boddie
On 15 Mai, 03:46, Patrick Maupin  wrote:
> On May 14, 6:52 pm, Paul Boddie  wrote:
> > And suggesting that people have behavioural disorders ("Or because
> > have OCD?") might be a source of amusement to you, or may be a neat
> > debating trick in certain circles you admire, but rest assured that I
> > am neither amused nor impressed, nor are others likely to be.
>
> That was in an honest response to a question you asked "Really, if at
> this point you think I'm playing games with you." where I explained
> that I don't know what to think, because often, when you claimed to be
> addressing my point, you would bring up other red herrings and spend
> more time on those, and often assign positions to me that I never
> took.

You can spare us the excuses. As I said, I was attempting to be
thorough and to explore all possible means of distribution, not least
because this was not your original point - you were originally upset
about Mr Finney's remark, which you still don't accept, but there's
probably no convincing you now - and were then upset at the FSF
definition of a work "based on" or derived from another, leading you
to talk about various strategies for defending potential GPL
violations in the course of copyright infringement litigation. At this
point, it isn't unreasonable to think that you will think of some
other objection to the GPL which you will then have everyone explore.

I have pointed out at least once the section of the GPLv3 which could
reasonably permit someone to receive a binary distribution and there
not be an immediate licence violation, plus an FAQ entry which more or
less addresses the very situation you describe, and I even provided a
link to a discussion of these very issues on the debian-legal mailing
list. You can repeat as often as you like that you don't believe it,
but I have explained my understanding of precisely the "giving CD to a
friend" situation. To summarise: your friend gets the sources from the
same place as the binaries, which is from you. (The SFLC document
seems to treat section 6(d) of GPLv3 as being about Internet
distribution, but given that the term "network server" is only
mentioned after two sentences, and only then in the conditional form,
I regard the FAQ entry I referred to as offering relevant guidance,
and even others [*] have considered the text to be subject to similar
interpretation.)

[*] http://www.gerv.net/hacking/gplv3/draft3/

For the GPLv2 the requirement of a written offer appears to be more
dominant, and I believe the physical media actually shipped by Ubuntu
is accompanied by such an offer. If Ubuntu encourages others to share
media (produced in whichever fashion) or software without any written
offer then it is, as I remarked before, a matter that should be
discussed with them. Yes, it is unfortunate that the obligations are
not communicated, and that is one reason why there is a successor to
that licence, but it merely indicates that the balance of obligation
and tolerance in the licence, maintained without enabling the
widespread and malicious circumvention of the licence, is difficult to
achieve. It doesn't invalidate the intent of the licence, and if
anything it validates the adoption of GPLv3 in preference to GPLv2.

[...]

> (BTW, IMO this was one of your better posts in terms of tone and being
> on-point, etc., and I appreciate that.)

As I said before, spare me the condescension. Making a remark that
someone has a behavioural disorder - a matter, whether true or not,
that should have no influence on the course of any discussion -
especially when that person has attempted to provide explanations for
every quibble spontaneously raised over the course of several days,
not only indicates a certain level of hypocrisy, but it indicates that
as far as you are concerned any remark about a person's mental health
or well-being is fair game if it serves to belittle that person's
standing and ridicule what that person has written.

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


Re: Is Python a functional programming language?

2010-05-15 Thread Terry Reedy

On 5/15/2010 12:42 PM, travis+ml-pyt...@subspacefield.org wrote:


One very annoying thing in Python is the distinction between
statements and expressions.


GvR regards it as a feature, claiming that research in the 1980s showed 
that the syntactic heterogeneity aided comprehension. I believe this is 
true for me.



Ever since learning LISP (well, Scheme) in S&ICP I find myself
frequently annoyed by this pointless distinction,


You have missed the very important distinction generally reflected in 
the statement/expression divide. Some code is meant to be evaluated 
immediately and some is meant to be quoted for later evaluation. In 
general (yes, there are some exceptions), Python statements are either 
restricted gotos or statements that implicitly quote part of the code in 
the statement. And in general, with a few exceptions, including lambda, 
expressions are completely and immediately evaluated. Changing print and 
exec from statements to functions made Py3 more consistent in this 
respect this distinction.


In List, one either quotes explicitly or must remember that certain 
'functions' are not really functions but are 'special functions' or 
'macros' that implicitly quote the code, just like Python statements do.


Simple statement example:

name = expression

The name is implicitely quoted. Behind the scenes, this is a function 
call. At module level, one can write the call explictly, with explicit 
quotes:


globals().__setitem__('name', expression)

If the statement form annoys you, use the expression equivalent. (Within 
functions, however, you do not have this choice in CPython because, for 
efficiency, function local namespaces are not Python objects and hence 
there is no Python function to directly manipulate them.)


In Lisp, the expression would be something like

(set 'name expression)

Compound statement example:

def f(a, b=3);
'doc for a'


The def keyword, default arg expression(s), and doc string are evaluated 
immediately. The function name, parameter names, and body code must be 
quoted somehow. In Python, this is done implicitly as signalled by def 
being a statement keyword rather than a function name. Behind the 
scenes, the def statement is implemented mainly by two function calls: 
compile the (quoted) code and create a function object. I believe that 
one could define functions with explicit calls rather than a statement, 
but it would be much more work and require explicit quotes. Turning a 
class statement into an exec() and type() call is easier, but still 
extra work.


Terry Jan Reedy

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


Access to comp.lang.python

2010-05-15 Thread cjw
This isn't about Python but I'm seeking suggestions as to the best way 
to access the newsgroup.


It seems that messages are coming from a number of sources, such as 
gmane and google groups.


The problem is that many messages seem to get unlinked from their threads.

I use Thunderbird 3.0.5 and wonder whether the problem lies with the 
merge process, the server or my reader.


Would it be better to go to gmane, google groups or some such provider.

In the past, use of Ctrl K had neatly disposed of thread that are of no 
interest.


I would welcome advice.

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


Re: parsing XML

2010-05-15 Thread Pietro Campesato
On May 14, 7:57 am, "kak...@gmail.com"  wrote:
> Hi to all, let's say we have the following Xml
> 
>   
>     17.1
>     6.4
>   
>   
>     15.5
>     7.8
>   
> 
>
> How can i get the players name, age and height?
> DOM or SAX and how
>
> Thanks
> Antonis

I've found some code which converts an XML string to a dictionary
here:
http://nonplatonic.com/ben.php?title=python_xml_to_dict_bow_to_my_recursive_g&more=1&c=1&tb=1&pb=1

Once your data is in a dictionary extracting info will be much easier.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: write a 20GB file

2010-05-15 Thread Dave Angel

Nathan Rice wrote:

This is precisely the situation mmap was made for :)  It has almost the same
methods as a file so it should be an easy replacement.




Only on a 64bit system, and I'm not sure it's even possible there in 
every case.  On a 32bit system, it would be impossible to mmap a 20gb 
file.  You only have 4gb of address space to play with, total.


DaveA

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


Re: write a 20GB file

2010-05-15 Thread Patrick Maupin
On May 15, 7:09 pm, Dave Angel  wrote:
> Nathan Rice wrote:
> > This is precisely the situation mmap was made for :)  It has almost the same
> > methods as a file so it should be an easy replacement.
>
> > 
>
> Only on a 64bit system, and I'm not sure it's even possible there in
> every case.  On a 32bit system, it would be impossible to mmap a 20gb
> file.  You only have 4gb of address space to play with, total.
>
> DaveA

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


Re: write a 20GB file

2010-05-15 Thread Patrick Maupin
On May 15, 7:09 pm, Dave Angel  wrote:
> Nathan Rice wrote:
> > This is precisely the situation mmap was made for :)  It has almost the same
> > methods as a file so it should be an easy replacement.
>
> > 
>
> Only on a 64bit system, and I'm not sure it's even possible there in
> every case.  On a 32bit system, it would be impossible to mmap a 20gb
> file.  You only have 4gb of address space to play with, total.
>
> DaveA

Well, depending on the OS, I think you could have multiple mappings
per file.  So you could maintain your own mapping cache.  That could
get a bit ugly, but depending on what you are doing, it might not be
too bad.

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


Re: Reading XML namespaces

2010-05-15 Thread Martin v. Loewis
> ???  The namespaces are embedded in the document.  Personally I find it
> odd I have to tell xpath about the namespace of the document it is a
> $*&@(*& method of.

How so? Why do you say it's a "method", and why do you say "of"?

Usually, xpath expressions are *not* part of the document they operate
on, but part of the code that performs the operation. Consequentially,
the namespace prefixes in the xpath expression do *not* occur in the
document (other than by chance), but are defined by whoever writes the
xpath expression. That is typically somebody different from the one
writing the document - if you would always write them together, you
wouldn't need xpath in the first place, but could produce the selection
result right away.

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


Re: Picking a license

2010-05-15 Thread Lawrence D'Oliveiro
In message
, Patrick 
Maupin wrote:

> On May 14, 9:21 pm, Lawrence D'Oliveiro  central.gen.new_zealand> wrote:
>
>> In message , Ed
>> Keith wrote:
>>
>>> I just refuse to use [the GPL] in any code for a client, because I
>>> do not want to require someone who does not know source code from Morse
>>> code code to figure out what they need to do to avoid violating the
>>> license.
>>
>> Why don’t you just put the source code on the same disc you send them,
>> and tell them to pass copies of the entire disc to anyone they want?
> 
> What you would really have to tell them is "don't pass along the
> program *unless* you copy the whole disk."  That's no longer a
> courtesy -- that's a mandate.  By not using the GPL, Ed avoids having
> to mandate to his customer how to treat the software he has delivered
> to them.

But that’s what “copyright” means, it means “right to copy”. It’s his right 
to impose terms on how copies of stuff he created are treated.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Picking a license

2010-05-15 Thread Lawrence D'Oliveiro
In message , Ed Keith 
wrote:

> On Fri, 5/14/10, Lawrence D'Oliveiro
>  wrote:
> 
>> In message ,
>> Ed Keith wrote:
>> 
>>> Yes, under the GPL every one has one set of freedoms,
>>> under the MIT or Boost license every one has more freedoms. Under other
>>> licenses they have fewer freedoms.
>> 
>> But what about the “freedom” to take away other
>> people’s freedom? Is that really “freedom”?
> 
> Yes.

But that’s a “freedom” that non-GPL licences do not give you, that the GPL 
does. So which licence gives you more “freedoms”, again?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Picking a license

2010-05-15 Thread Lawrence D'Oliveiro
In message
<93d67bd9-6721-4759-a3de-412b95b29...@c11g2000vbe.googlegroups.com>, Paul 
Boddie wrote:

> Although Bill Gates once apparently claimed that no-one needs the
> source code for their word processor or office suite ...

Thereby committing the sealed-bonnet fallacy.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Picking a license

2010-05-15 Thread Lawrence D'Oliveiro
In message , Ed Keith 
wrote:

> But if my client give someone else a copy of the binary I gave them, they
> are now in violation.

Why would they be in violation? It seems to me a violation would only occur 
if someone asked them for the source, and they refused.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Reading XML namespaces

2010-05-15 Thread Adam Tauno Williams
On Sat, 2010-05-15 at 23:37 +0200, Martin v. Loewis wrote:
> > BTW, I'm still not sure I understand your problem. Could you provide
> > some more details?
> Wouldn't it be easier if you told the OP how to access the prefix

:)

> mappings in lxml etree, or, if this was actually not possible, admitted
> that it is actually not possible?

I suspect that it is not;  but that seems rather surprising. 

> FWIW, in the DOM, you look at all attributes of an element node, and
> search for those whose namespace is "http://www.w3.org/2000/xmlns/";
> In SAX, you watch the startPrefixMapping events.

Given that XML documents can be very large I'd rather avoid a parsing of
the document [beyond what lxml/etree] has already done] just to retrieve
the namespaces and their prefixes.

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


Re: Reading XML namespaces

2010-05-15 Thread Adam Tauno Williams
On Sun, 2010-05-16 at 02:37 +0200, Martin v. Loewis wrote:
> > ???  The namespaces are embedded in the document.  Personally I find it
> > odd I have to tell xpath about the namespace of the document it is a
> > $*&@(*& method of.
> How so? Why do you say it's a "method", and why do you say "of"?
> Usually, xpath expressions are *not* part of the document they operate
> on, but part of the code that performs the operation.

from lxml import etree

doc = etree.parse(data)
doc.xpath()

>  Consequentially,
> the namespace prefixes in the xpath expression do *not* occur in the
> document (other than by chance), but are defined by whoever writes the
> xpath expression. That is typically somebody different from the one
> writing the document 

Maybe true technically, but false in practice.  If I receive XML data
from source XYZ or service XYZ the use of namespaces and their prefixes
is extremely consistent [in practice] and very customary (for example:
I've never seen the DSML namespace abbreviated as anything other than
"dsml" and I rarely see WebDAV propfind XML use a namespace prefix other
than "D").  The odds that a customer or vendors ERP will generate
different namespaces and abbreviations between requests is ludicrously
remote [I don't recall ever seeing it happen].

And if the xpath fails to produce normal [or any] output the workflow
with either do nothing or abend which will draw the attention of an
administrator.

> - if you would always write them together, you
> wouldn't need xpath in the first place, but could produce the selection
> result right away.


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


Re: Picking a license

2010-05-15 Thread Robert Kern

On 2010-05-15 22:05 , Lawrence D'Oliveiro wrote:

In message
, Patrick
Maupin wrote:


On May 14, 9:21 pm, Lawrence D'Oliveiro  wrote:


In message, Ed
Keith wrote:


I just refuse to use [the GPL] in any code for a client, because I
do not want to require someone who does not know source code from Morse
code code to figure out what they need to do to avoid violating the
license.


Why don’t you just put the source code on the same disc you send them,
and tell them to pass copies of the entire disc to anyone they want?


What you would really have to tell them is "don't pass along the
program *unless* you copy the whole disk."  That's no longer a
courtesy -- that's a mandate.  By not using the GPL, Ed avoids having
to mandate to his customer how to treat the software he has delivered
to them.


But that’s what “copyright” means, it means “right to copy”. It’s his right
to impose terms on how copies of stuff he created are treated.


It's also his right to choose which terms to impose, depending on the client and 
project. If he doesn't think the GPL serves his goals, then he shouldn't use it. 
It shouldn't matter to him how well it serves your goals or how unburdensome you 
personally find the GPL's requirements.


--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

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


Re: Is Python a functional programming language?

2010-05-15 Thread Paul Rubin
travis+ml-pyt...@subspacefield.org writes:
> To be fair, it appears that Python's whitespace-sensitive syntax sort
> of precludes the "make a complex function on one line" that is typical
> of languages which don't have statement/expression distinctions, but
> I'm not convinced it couldn't be solved, perhaps by allowing anonymous
> functions to span multiple lines, just like named functions.

Haskell has whitespace-based syntax like Python (you can alternatively
use curly braces).  Their term for it is "layout".  You can
alternatively use curly braces and semi-colons.  I'd have to say that
Haskell's indentation rules are a bit harder to understand than Python's
at first.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Access to comp.lang.python

2010-05-15 Thread Terry Reedy

On 5/15/2010 6:34 PM, cjw wrote:

This isn't about Python but I'm seeking suggestions as to the best way
to access the newsgroup.

It seems that messages are coming from a number of sources, such as
gmane and google groups.

The problem is that many messages seem to get unlinked from their threads.


Some people have said that that is due to newreaders not tagging 
responses properly.



I use Thunderbird 3.0.5 and wonder whether the problem lies with the
merge process, the server or my reader.

Would it be better to go to gmane, google groups or some such provider.


I believe some spam (like from Google accounts) is filtered out between 
c.l.p and python-list. Gmane mirrors python-list, not c.l.p., so it gets 
the benefit of the filtering. You can see from the headers that that is 
where I post from.


tjr



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


Re: Access to comp.lang.python

2010-05-15 Thread Aahz
In article ,
Terry Reedy   wrote:
>On 5/15/2010 6:34 PM, cjw wrote:
>>
>> The problem is that many messages seem to get unlinked from their threads.
>
>Some people have said that that is due to newreaders not tagging 
>responses properly.

It's also at least partly due to problems with mail<->news gateways and
the differing fields used to maintain threading.
-- 
Aahz (a...@pythoncraft.com)   <*> http://www.pythoncraft.com/

f u cn rd ths, u cn gt a gd jb n nx prgrmmng.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Access to comp.lang.python

2010-05-15 Thread James Mills
On Sun, May 16, 2010 at 3:12 PM, Aahz  wrote:
> It's also at least partly due to problems with mail<->news gateways and
> the differing fields used to maintain threading.

Some blame goes on MUAs too :)
-- 
http://mail.python.org/mailman/listinfo/python-list


[ANN] Benchmarker 1.0.0 - a samll utility for benchmarking

2010-05-15 Thread kwatch
Hi,

I released Benchmarker 1.0.0.
http://pypi.python.org/pypi/Benchmarker/

Benchmarker is a small library for benchmarking.


Example
---

ex.py::

def fib(n):
return n <= 2 and 1 or fib(n-1) + fib(n-2)
from benchmarker import Benchmarker
bm = Benchmarker()  # or Benchmarker(width=30, out=sys.stderr,
header=True)
## Python 2.5 or later
with bm('fib(n) (n==34)'):  fib(34)
with bm('fib(n) (n==35)'):  fib(35)
## Python 2.4
bm('fib(n) (n==34)').run(lambda: fib(34))
bm('fib(n) (n==35)').run(lambda: fib(35))

Output::

$ python ex.py
   utime  stime
total   real
fib(n) (n==34)4.3700 0.0200 4.3900
4.9449
fib(n) (n==35)7.1500 0.0500 7.2000
8.0643


Download


http://pypi.python.org/pypi/Benchmarker/

Installation::

## if you have installed easy_install:
$ sudo easy_install Benchmarker
## or download Benchmarker-1.0.0.tar.gz and install it
$ wget 
http://pypi.python.org/packages/source/B/Benchmarker/Benchmarker-1.0.0.tar.gz
$ tar xzf Benchmarker-1.0.0.tar.gz
$ cd Benchmarker-1.0.0/
$ sudo python setup.py install


License
---

Public Domain


Copyright
-

copyright(c) 2010 kuwata-lab.com all rights reserved
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Reading XML namespaces

2010-05-15 Thread Stefan Behnel

Martin v. Loewis, 15.05.2010 23:37:

BTW, I'm still not sure I understand your problem. Could you provide
some more details?


Wouldn't it be easier if you told the OP how to access the prefix
mappings in lxml etree, or, if this was actually not possible, admitted
that it is actually not possible?


Well, there's an "nsmap" property on each Element that provides the mapping 
of prefixes to namespace URIs that form the scope of the Element. However, 
while this is what the OP asked for, it is not what the OP wants, simply 
because it doesn't solve the problem. Prefixes can get defined and 
redefined arbitrarily often, so there is no such thing as a 
prefix-namespace mapping "of the document". Example:






That's why I asked for more details in order to understand what the actual 
problem is that the OP is trying to solve, because the approach that the OP 
is apparently trying to follow is clearly misguided.


Stefan

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