Re: Picking a license

2010-05-14 Thread Carl Banks
On May 13, 10:59 pm, Steven D'Aprano  wrote:
> On Thu, 13 May 2010 17:18:47 -0700, Carl Banks wrote:
> > The thing you GPL fanbois refuse to understand or accept is that, in the
> > real world, a person or company who doesn't want to open source their
> > "derivative work" will only rarely be forced to by the GPL. They'll work
> > around it instead, vast majority of the time.  They could:
>
> > 1. Derive their work from a project with a license that grants the user
> > more freedom
> > 2. Reimplment the functionality seperately (*cough* PySide)
>
> Yes. So what? In what possible way is this an argument against the GPL?

[snip a bunch of crap I don't care about]


It's not.  It's an argument that the GPL doesn't do much good.

Arguments against the GPL are found elsewhere in this thread, I don't
need to repeat them here.


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


Re: client to upload big files via https and get progress info

2010-05-14 Thread News123
Hi Sean,




Sean DiZazzo wrote:
> On May 13, 9:54 pm, Sean DiZazzo  wrote:
>> On May 13, 9:39 am, News123  wrote:
>>
>>
>>
>>> Hi Aaaz,
>>> Aahz wrote:
 In article <[email protected]>,
 News123   wrote:
> I'd like to perform huge file uploads via https.
> I'd like to make sure,

> 
> oops...that doesn't help with the other requirements.  My suggestion
> is to not use https.  I don't think it was created to move around
> large pieces of data.  Lots of small pieces rather.  SFTP?


I had to check, but I guess sftp is not exactly suitable for my usecase.

My problem
- the whole communication is to be intended to work like a drop box.
  - one can upload files
  - one can not see, what one has uploaded before
  - no way to accidentally overwrite a previous upload, etc.
- I don't know enough about sftp servers to know how I could configure
it to act as a drop box.


That's much easier to hide behind an https server than behind an out of
the box sftp server.



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


Re: client to upload big files via https and get progress info

2010-05-14 Thread News123
Hi James,

James Mills wrote:
> On Wed, May 12, 2010 at 6:48 PM, News123  wrote:
>> Hi,
>>
>> I'd like to perform huge file uploads via https.
>> I'd like to make sure,
>> - that I can obtain upload progress info (sometimes the nw is very slow)
>> - that (if the file exceeds a certain size) I don't have to
>>  read the entire file into RAM.
>>
> 
> My suggestion is to find some tools that can
> send multiple chucks of data. A non-blocking
> i/o library/tool might be useful here (eg: twisted or similar).
> 

I never used twisted so far.
Perhaps the time to look at it.


bye


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


Re: client to upload big files via https and get progress info

2010-05-14 Thread News123
Hi J,


J.O. Aho wrote:
> News123   wrote:
> 
>> What do others do for huge file uploads
>> The uploader might be connected via ethernet, WLAN, UMTS, EDGE, GPRS. )
> 
> Those cases where I have had to move big files it's been scp on those cases
> where you just have to push a new file, in cases where it's a question of
> keeping two directories synced, then it's rsync over ssh.
> The later one I have never done in python.


I agree. From home this is also what I do.
scp / rsync.


However I'd like to use https, as http/https are the two ports, that are
almost everywhere accessible (eve with proxies / firewalls, etc.)



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


Re: stopping execution window on error - newbie

2010-05-14 Thread a
On 14 May, 00:14, Mensanator  wrote:
> On May 13, 4:00 pm, a  wrote:
>
> > I'm coding on an old windows laptop
>
> > i write the code and double click the icon.  
>
> Don't do that.
>
> > it runs the program and
> > writes results to a window.
>
> > when the code finishes, the window closes, i do a time.sleep(10) to
> > see what has happened.
>
> > unfortunately when there is an error it just closes the window.
> > anyway of seeing the error messages?
>
> Go to the windows [Start] button. Select [Run...] and in the popup
> box,
> type "cmd" as the program to run. This will open a DOS shell window (a
> text window.)
>
> Then you can run your Python script from the window prompt and it
> won't
> close until you manually close it, even if the program crashes.
>
> For example, once I open the DOS shell...
>
> 
> Microsoft Windows XP [Version 5.1.2600]
> (C) Copyright 1985-2001 Microsoft Corp.
>
> H:\>C:
>
> C:\>cd python31\user\lotto
>
> C:\Python31\user\lotto>dir
>  Volume in drive C has no label.
>  Volume Serial Number is 06DE-55B4
>
>  Directory of C:\Python31\user\lotto
>
> 05/13/2010  05:53 PM              .
> 05/13/2010  05:53 PM              ..
> 08/19/2009  07:08 PM             3,334 lotto.py
> 05/13/2010  05:56 PM             6,068 lotto_2010.py
>                2 File(s)          9,402 bytes
>                2 Dir(s)  102,247,440,384 bytes free
>
> C:\Python31\user\lotto>..\..\python lotto_2010.py
>
> {1: 2, 2: 3, 3: 2, 4: 1, 5: 2, 6: 1, 7: 2, 8: 1, 9: 1, 10: 2, 11: 2,
> 13: 1, 14: 2, 17: 1, 18: 2, 19: 1, 20: 1, 21: 1, 22: 1, 24: 1, 25: 1,
> 26: 3, 27: 1, 28: 2, 29: 2, 30: 1, 31: 1, 32: 1, 34: 1, 35: 1, 37: 2,
> 38: 2, 39: 2, 40: 1, 42: 2, 43: 1, 44: 2, 46: 2, 47: 1, 48: 1, 50: 1,
> 51: 2, 52: 3}
>
>  1  2 **
>  2  3 ***
>  3  2 **
>  4  1 *
>  5  2 **
>  6  1 *
>  7  2 **
>  8  1 *
>  9  1 *
> 10  2 **
> 11  2 **
> 12
> 13  1 *
> 14  2 **
> 15
> 16
> 17  1 *
> 18  2 **
> 19  1 *
> 20  1 *
> 21  1 *
> 22  1 *
> 23
> 24  1 *
> 25  1 *
> 26  3 ***
> 27  1 *
> 28  2 **
> 29  2 **
> 30  1 *
> 31  1 *
> 32  1 *
> 33
> 34  1 *
> 35  1 *
> 36
> 37  2 **
> 38  2 **
> 39  2 **
> 40  1 *
> 41
> 42  2 **
> 43  1 *
> 44  2 **
> 45
> 46  2 **
> 47  1 *
> 48  1 *
> 49
> 50  1 *
> 51  2 **
> 52  3 ***
>
> (7, 21, 50, 36, 26, 3)
> (7, 21, 50, 36, 26, 17)
> (7, 21, 50, 36, 26, 52)
> (7, 21, 50, 36, 3, 17)
> (7, 21, 50, 36, 3, 52)
> (7, 21, 50, 36, 17, 52)
> (7, 21, 50, 26, 3, 17)
> (7, 21, 50, 26, 3, 52)
> (7, 21, 50, 26, 17, 52)
> (7, 21, 50, 3, 17, 52)
> (7, 21, 36, 26, 3, 17)
> (7, 21, 36, 26, 3, 52)
> (7, 21, 36, 26, 17, 52)
> (7, 21, 36, 3, 17, 52)
> (7, 21, 26, 3, 17, 52)
> (7, 50, 36, 26, 3, 17)
> (7, 50, 36, 26, 3, 52)
> (7, 50, 36, 26, 17, 52)
> (7, 50, 36, 3, 17, 52)
> (7, 50, 26, 3, 17, 52)
> (7, 36, 26, 3, 17, 52)
> (21, 50, 36, 26, 3, 17)
> (21, 50, 36, 26, 3, 52)
> (21, 50, 36, 26, 17, 52)
> (21, 50, 36, 3, 17, 52)
> (21, 50, 26, 3, 17, 52)
> (21, 36, 26, 3, 17, 52)
> (50, 36, 26, 3, 17, 52)
>
>  8  9 32 38 40 48
> 13 22 28 39 42 43
>  1  2  5 11 18 52 +
>  2  3 26 44 51 52 +++
>  4  7 14 26 35 52 +++
>  2  7 10 19 42 47 +
>  5 20 31 34 50 51 +
>  1 28 29 37 39 46
> 10 11 27 37 38 46
>  6 21 24 29 30 44 +
>  3 14 17 18 25 26 +++
>  7 10 39 42 45 46 +
> 15 17 23 36 38 44 ++
> 16 19 23 27 41 49
> 15 25 32 36 44 47 +
> 16 19 24 29 38 41
>  3  4  8 13 43 49 +
>  2 11 17 19 22 50 ++
> 14 21 22 28 30 45 +
>  4 15 21 34 47 49 +
> 19 34 38 39 40 48
>  4 16 24 33 37 48
>  8 16 17 18 39 40 +
>  1 24 27 30 31 47
>  1  7 11 21 30 43 ++
>  1  8 13 18 32 36 +
>  5 10 12 16 20 21 +
>  7 11 23 24 26 35 ++
>  7  8 11 13 42 49 +
>  1  8 17 34 40 50 ++
>  1 24 29 35 41 45
> 15 17 24 32 44 52 ++
>  4 12 21 26 33 38 ++
>  2 13 15 41 48 50 +
>  2  7  9 27 45 52 ++
> 24 25 35 36 39 42 +
>  8 22 39 40 42 48
> 16 18 29 30 34 43
>  7 21 28 36 45 50 
>  4  8 30 35 39 42
>  2 11 15 23 40 51
>  2  7 14 18 23 34 +
>  1 11 22 37 41 50 +
>  4 34 40 44 50 52 ++
> 12 28 33 39 40 52 +
> 14 18 25 36 38 39 +
>  4 11 16 17 27 37 +
>  1 11 16 28 31 36 +
>  8 16 31 34 36 52 ++
>  7 10 15 21 35 36 +++
>  2  9 21 23 29 30 +
> 15 29 33 41 46 47
>  2  5 18 34 36 39 +
>  7 15 21 31 45 50 +++
> 12 17 20 28 39 51 +
>  3  7 22 26 50 52 +
>  1  5 21 27 31 39 +
>  2  8 10 23 34 50 +
>  1 11 24 26 32 52 ++
>  1 18 20 38 41 42
> 12 33 36 42 45 48 +
>  1  6 21 28 37 39 +
> 16 18 19 22 33 35
>  2  7 17 27 29 47 ++
> 15 19 20 25 42 45
>  2  6 17 19 20 41 +
>  1 13 34 42 43 46
> 16 29 30 31 34 47
>  5  7 26 29 36 46 +++
>  1 27 28 30 31 49
>  8 17 19 47 49 52 ++
>  5 23 32 41 42 45
> 11 13 22 29 40 46
> 16 17 18 20 41 43 +
>  3 17 26 38 45 52 
> 13 18 21 38 39 41 +
> 14 19 28 40 44 51
>  4  8  9 36 43 47 +
>  1  9 15 24 36 39 +
>  4 31 37 41 42 43
>  7 12 18 27 36 42 ++
>  3  4 26 27 35 51 ++
>  7 12 19 23 26 45 ++
> 19 28 36 39 42 52 ++
>  8 17 21 44 46 51 ++
>  2  4 18 19 36 49 +
>  1  4 11 16 22 35
> 13 14 17 18 41 46 +
>  8 16 23 29 43 48
>  1  8 25 36 37 44 +
>  7 20 21 23 36 50 
>  3  7 23 27 39 43 ++
>  4 10 21 37 38 48 +
>  6 18 30 3

d-cm Controll Manager

2010-05-14 Thread darragh
Hey,
I'm developing d-cm, it's a program for web-developers that often need
a text-editor,file-manager,sql-manager,ftp-manager.  d-cm combines all
of them in one easy to use program.

i'm looking for people that would like to help developing or to test
the program.
http://code.google.com/p/d-cm
-- 
http://mail.python.org/mailman/listinfo/python-list


write a 20GB file

2010-05-14 Thread Jackie Lee
Hello there,

I have a 22 GB binary file, a want to change values of specific
positions. Because of the volume of the file, I doubt my code a
efficient one:

#! /usr/bin/env python
#coding=utf-8
import sys
import struct

try:
f=open(sys.argv[1],'rb+')
except (IOError,Exception):
print '''usage:
scriptname segyfilename
'''
sys.exit(1)

#skip EBCDIC header
try:
f.seek(3200)
except Exception:
print 'Oops! your file is broken..'

#read binary header
binhead = f.read(400)
ns = struct.unpack('>h',binhead[20:22])[0]
if ns < 0:
print 'file read error'
sys.exit(1)

#read trace header
while True:
f.seek(28,1)
f.write(struct.pack('>h',1))
f.seek(212,1)
f.seek(ns*4,1)

f.close()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to add callbacks that is the same function with different argument in Tkinter python26?

2010-05-14 Thread Bruno Desthuilliers

Jean-Michel Pichavant a écrit :

chen zeguang wrote:

code is in the end.
I want to print different number when pressing different button.
Yet the program outputs 8 no matter which button is pressed.
I guess it's because the callback function is not established untill 
the button is pressed, and i has already reached to 8.


[answering to the op]
The key here is that the current value of 'i' is not captured when the 
lambda function is created. To make it work, you'd have to capture the 
current value of 'i', which is usually done using a default argument ie:


for i in range(9):
func_en.append(lambda i=i:func(i))

Now there are other solutions...



def func(x):
   def _printme():
   print x
   return _printme

for i in range(9):
   Button(root, text='%d'%i, command=func(i)).pack()

Surely someone will explain why your code was not working,


done !-)

I can't 
'cause I don't use lambda, it brings more problems than it solves (maybe 
I'm not talented enough).
Above is how I would have written the code, I tested it, looks like it's 
working.


FWIW, there's now (since 2.5 IIRC) a stdlib way to solve this kind of 
problems:


from functools import partial

def printme(x):
print x

for i in range(9):
   Button(root, text='%d'%i, command=partial(printme,i)).pack()

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


cmd app and xml

2010-05-14 Thread [email protected]
Hi there,
i'm writing a console app using the cmd library. I also use
xml.dom.minidom to parse an xml file that i get as a response to an
HTTP Post request.
with
data = response.read()
i get the xml response from the server.
i then feed the parser with that data.
myDoc = parse(data)
but it doesn't work.
To make it work i open an xml file and the save the data to that file.
myDoc = parse('test.xml')
that worked.
But i don't want to use the local xml file?
What am i doing wrong?

Thanks in advance
A.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: cmd app and xml

2010-05-14 Thread Stefan Behnel

[email protected], 14.05.2010 12:46:

Hi there,
i'm writing a console app using the cmd library. I also use
xml.dom.minidom to parse an xml file that i get as a response to an
HTTP Post request.
with
data = response.read()
i get the xml response from the server.
i then feed the parser with that data.
myDoc = parse(data)
but it doesn't work.


Note that "it doesn't work" is not a very complete description of the 
actual problem.




To make it work i open an xml file and the save the data to that file.
myDoc = parse('test.xml')
that worked.
But i don't want to use the local xml file?
What am i doing wrong?


Not reading the docs?

http://docs.python.org/library/xml.dom.minidom.html

There is a parseString() function that does what you want.

Stefan

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


Re: Picking a license

2010-05-14 Thread Lawrence D'Oliveiro
In message <2ff3643b-6ef1-4471-8438-
[email protected]>, Patrick Maupin wrote:

> On May 13, 10:04 pm, Lawrence D'Oliveiro
>  wrote:
>
>> In message , Ed
>> Keith wrote:
>>
>>> The claim is being made that [the GPL] restricts freedom.
>>
>> What about the “freedom” to restrict other people’s freedom? Should that
>> be restricted or not?
> 
> It's interesting that some people don't like the comparison of the
> Free Software movement to a religion, yet the main argument of the
> movement, and the deliberate co-opting of words like "Free" and "Free
> Software" ...

Haven’t you “co-opted” those words yourself?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Picking a license

2010-05-14 Thread Lawrence D'Oliveiro
In message 
<2b17ee77-0e49-4a97-994c-7582f86c0...@r34g2000yqj.googlegroups.com>, Patrick 
Maupin wrote:

> On May 13, 10:06 pm, Lawrence D'Oliveiro
>  wrote:
>
>> Under the GPL, everybody has exactly the same freedoms.
> 
> That's absolutely not true.  For a start, the original author can dual-
> license.

That’s nothing to do with the GPL.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: write a 20GB file

2010-05-14 Thread Dave Angel

Jackie Lee wrote:

Hello there,

I have a 22 GB binary file, a want to change values of specific
positions. Because of the volume of the file, I doubt my code a
efficient one:

#! /usr/bin/env python
#coding=utf-8
import sys
import struct

try:
f=open(sys.argv[1],'rb+')
except (IOError,Exception):
print '''usage:
scriptname segyfilename
'''
sys.exit(1)

#skip EBCDIC header
try:
f.seek(3200)
except Exception:
print 'Oops! your file is broken..'

#read binary header
binhead = f.read(400)
ns = struct.unpack('>h',binhead[20:22])[0]
if ns < 0:
print 'file read error'
sys.exit(1)

#read trace header
while True:
f.seek(28,1)
f.write(struct.pack('>h',1))
f.seek(212,1)
f.seek(ns*4,1)

f.close()

  
I don't see a question anywhere.  So perhaps you just want comments on 
your code.


1) How do you plan to test this?
2) Consider doing a lot more checking to see that you have in fact a 
file of the right type.

3) Fix indentation - perhaps you've accidentally used a tab in the source.
4) Provide a termination condition for the while True loop, which 
currently will (I think) go forever, or perhaps until the disk fills up.
5) Depending on the purpose of this file, you should consider making the 
changes on a copy, then deleting and renaming.  As it stands, if the 
program gets aborted part way through, there's no way to know how far it 
got.  Since it's just clobbering bytes, it would be safe to rerun the 
same program again, but many times that's not the case.  And this 
program clearly isn't finished yet, so perhaps it's not true here either.
6) I don't see anything inefficient about it.  The nature of the problem 
is going to be very slow (for small values of ns), but I don't know what 
your code could do to speed it up.  Perhaps make sure the file is on a 
fast drive, and not RAID 5.


DaveA

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


Re: write a 20GB file

2010-05-14 Thread Jackie Lee
Thx, Dave,

The code works fine. I just don't know how f.write works. It says that
file.write won't write the file until file.close or file.flush. So I
don't know if the following one is more efficient (sorry I forget to
add condition to break the loop):

#! /usr/bin/env python
#coding=utf-8
import sys
import struct

try:
f=open(sys.argv[1],'rb+')
except (IOError,Exception):
print '''usage:
scriptname segyfilename
'''
sys.exit(1)

#skip EBCDIC header
try:
f.seek(3200)
except Exception:
print 'Oops! your file is broken..'

#read binary header
binhead = f.read(400)
ns = struct.unpack('>h',binhead[20:22])[0]
if ns < 0:
print 'file read error'
sys.exit(1)

#read trace header
while True:
f.seek(28,1)
if f.read(2) == '':
break
f.seek(-2,1)
f.write(struct.pack('>h',1))
f.seek(210,1)
f.seek(ns*4,1)

f.close()


On Fri, May 14, 2010 at 6:04 PM, Dave Angel  wrote:
> Jackie Lee wrote:
>>
>> Hello there,
>>
>> I have a 22 GB binary file, a want to change values of specific
>> positions. Because of the volume of the file, I doubt my code a
>> efficient one:
>>
>> #! /usr/bin/env python
>> #coding=utf-8
>> import sys
>> import struct
>>
>> try:
>>        f=open(sys.argv[1],'rb+')
>> except (IOError,Exception):
>>    print '''usage:
>>        scriptname segyfilename
>> '''
>>    sys.exit(1)
>>
>> #skip EBCDIC header
>> try:
>>    f.seek(3200)
>> except Exception:
>>    print 'Oops! your file is broken..'
>>
>> #read binary header
>> binhead = f.read(400)
>> ns = struct.unpack('>h',binhead[20:22])[0]
>> if ns < 0:
>>    print 'file read error'
>>    sys.exit(1)
>>
>> #read trace header
>> while True:
>>    f.seek(28,1)
>>    f.write(struct.pack('>h',1))
>>    f.seek(212,1)
>>    f.seek(ns*4,1)
>>
>> f.close()
>>
>>
>
> I don't see a question anywhere.  So perhaps you just want comments on your
> code.
>
> 1) How do you plan to test this?
> 2) Consider doing a lot more checking to see that you have in fact a file of
> the right type.
> 3) Fix indentation - perhaps you've accidentally used a tab in the source.
> 4) Provide a termination condition for the while True loop, which currently
> will (I think) go forever, or perhaps until the disk fills up.
> 5) Depending on the purpose of this file, you should consider making the
> changes on a copy, then deleting and renaming.  As it stands, if the program
> gets aborted part way through, there's no way to know how far it got.  Since
> it's just clobbering bytes, it would be safe to rerun the same program
> again, but many times that's not the case.  And this program clearly isn't
> finished yet, so perhaps it's not true here either.
> 6) I don't see anything inefficient about it.  The nature of the problem is
> going to be very slow (for small values of ns), but I don't know what your
> code could do to speed it up.  Perhaps make sure the file is on a fast
> drive, and not RAID 5.
>
> DaveA
>
>



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


Re: cmd app and xml

2010-05-14 Thread [email protected]
On May 14, 7:10 am, Stefan Behnel  wrote:
> [email protected], 14.05.2010 12:46:
>
> > Hi there,
> > i'm writing a console app using the cmd library. I also use
> > xml.dom.minidom to parse an xml file that i get as a response to an
> > HTTP Post request.
> > with
> > data = response.read()
> > i get the xml response from the server.
> > i then feed the parser with that data.
> > myDoc = parse(data)
> > but it doesn't work.
>
> Note that "it doesn't work" is not a very complete description of the
> actual problem.
>
> > To make it work i open an xml file and the save the data to that file.
> > myDoc = parse('test.xml')
> > that worked.
> > But i don't want to use the local xml file?
> > What am i doing wrong?
>
> Not reading the docs?
>
> http://docs.python.org/library/xml.dom.minidom.html
>
> There is a parseString() function that does what you want.
>
> Stefan

ok, i missed that function.
Thank you so much!!
Antonis
-- 
http://mail.python.org/mailman/listinfo/python-list


Data store solution need help

2010-05-14 Thread Haulyn Jason

Hi, all:

I am a Java programmer, now I am working on a Python program. At the 
moment, I need to store some data from user's input, no database, no 
xml, no txt(we can not make users open the data file by vim or other 
text editor).


Any suggestions or reference url? Is there a lib should do this or I 
need to implement it myself?


PS: if I want to implement it myself, which part of python document I 
need to learn? I know how to write txt files now, but not further for me.


--
Thanks!

VVThumb Microproduction

Location:Room 807,QiLuRuanJianDaSha Qilu Software Park
 No. 1 Shunhua Rd High-Tech Development Zone
 Jinan, China 250101
Website: http://www.haulynjason.net/haulyn
Mobile: +86 15854103759

Haulyn Jason

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


Re: Picking a license

2010-05-14 Thread Paul Boddie
On 13 Mai, 22:10, Patrick Maupin  wrote:
>

[...]

Just to deal with your Ubuntu "high horse" situation first, you should
take a look at the following for what people regard to be the best
practices around GPL-licensed software distribution:

http://www.softwarefreedom.org/resources/2008/compliance-guide.html

If you still think Ubuntu are violating the GPL or encouraging others
to do so, feel free to contact their lawyers who I'm sure will be very
interested to hear from you.

> When the leader of your religion bandies terms like "freedom" and
> "evil" about, what do you expect?  Seriously?

I thought you were "done". I guess you are: again, we have the usual
courting of public outrage by labelling stuff you don't like as
"religion" - presumably not the "right one", either - when it is no
such thing.

[...]

> My primary agenda is to explain that RMS does, in fact, have an
> agenda, and the GPL was designed as a tool in furtherance of that
> agenda, and that while the agenda does have some arguably noble goals,
> before using the GPL people should understand its consequences both
> for good and bad, and make their own determination about whether it's
> the right license for their project.

Reading through your "translations" of what are effectively honest
summaries, one gets the impression that you have quite a chip on your
shoulder about the FSF and RMS. Referring to the GPL as a "commercial"
licence and stating that it (as opposed to any other licence or even
the word "copyright" followed by a name) is a threat to sue people,
presumably appealing to the libertarian crowd with a judicious mention
of "government" just to fan the flames of supposed injustice, really
does triangulate where you are coming from. So, yes, we're now rather
more aware of what your agenda is, I think.

And I don't think it improves any argument you may have by projecting
notions of "morality" or "immorality" onto what I have written,
especially when I have deliberately chosen to use other terms which
avoid involving such notions, or by equating the copyleft licences
with criminal enterprises ("pyramid scheme"), or by suggesting that I
endorse criminal endeavours. But if that's what you have left to say
at this point, then I think you probably are "done".

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


Re: Picking a license

2010-05-14 Thread Ed Keith
--- On Thu, 5/13/10, Lawrence D'Oliveiro  
wrote:

> From: Lawrence D'Oliveiro 
> Subject: Re: Picking a license
> To: [email protected]
> Date: Thursday, May 13, 2010, 11:06 PM
> In message ,
> Ed Keith 
> wrote:
> 
> > Assertion I:
> >    If person A is free to do more than
> person B, then person A has
> >    more freedom then person B.
> > 
> > Assertion II:
> >    If person A is free do perform an action
> person B is not free to
> >    perform then person A is free to do more
> than person B.
> > 
> > Assertion III:
> >   If person B is restricted in some way
> that person A is not them Person A
> >   is free to do something Person B is
> not free to do.
> > 
> > Conclusion:
> >   If person B is more resticted than
> Peston A, Person A has mor freedom
> >   than person B.
> > 
> > Which step in this reasoning do you disagree with?
> 
> Under the GPL, everybody has exactly the same freedoms. So
> which of your 
> assertions is supposedly a criticism of the GPL?
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 

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. 

None of my point criticize the GPL, they merely defend my claim that a more 
permissive license grants more freedom. You claimed the contrary. 

Are you withdrawing your previous claim, or will you directly refute my 
arguments?

   -EdK

Ed Keith
[email protected]

Blog: edkeith.blogspot.com




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


Re: Picking a license

2010-05-14 Thread Paul Boddie
On 14 Mai, 03:56, [email protected] (Aahz) wrote:
>
> IMO this only makes sense if one agrees that people should not be allowed
> to sell software for money.  Absent that agreement, your argument about
> freedom seems rather limited.

You'll have to explain this to me because I don't quite follow your
assertion. You can sell copyleft-licensed software, although I accept
that you can't set an arbitrarily high price on the sources for
someone who has already acquired a binary distribution.

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


Re: Picking a license

2010-05-14 Thread Ed Keith
--- On Thu, 5/13/10, Lawrence D'Oliveiro  
wrote:

> From: Lawrence D'Oliveiro 
> Subject: Re: Picking a license
> To: [email protected]
> Date: Thursday, May 13, 2010, 11:07 PM
> In message ,
> Ed Keith 
> wrote:
> 
> > On Thu, 5/13/10, Lawrence D'Oliveiro
> > 
> wrote:
> > 
> >> In message ,
> >> Ed Keith wrote:
> >> 
> >>> So if you want me to even consider using your
> library
> >>> do not use GPL, or LGPL.
> >> 
> >> 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.
> 
> How exactly does the LGPL lead to a requirement to
> “relink”?
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 

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.

   -EdK

Ed Keith
[email protected]

Blog: edkeith.blogspot.com




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


Re: Data store solution need help

2010-05-14 Thread Bruno Desthuilliers

Haulyn Jason a écrit :

Hi, all:

I am a Java programmer, now I am working on a Python program. At the 
moment, I need to store some data from user's input, no database, no 
xml, no txt(we can not make users open the data file by vim or other 
text editor).


Any suggestions or reference url? Is there a lib should do this or I 
need to implement it myself?


PS: if I want to implement it myself, which part of python document I 
need to learn? I know how to write txt files now, but not further for me.




Not sure I really understand whether you want to store your data in just 
any format or if it need to be a "binary" format or else... And you 
don't tell much about how your data structure and how it will be used.


Anyway: two possible solutions are csv or serialization.

For the first option, see the csv module
http://docs.python.org/library/csv.html#module-csv

For the second, look at pickle and shelve modules:
http://docs.python.org/library/pickle.html#module-pickle
http://docs.python.org/library/shelve.html#module-shelve


If none of this fits your needs, please provide more details !-)
HTH
--
http://mail.python.org/mailman/listinfo/python-list


Re: Picking a license

2010-05-14 Thread Ed Keith
--- On Thu, 5/13/10, Patrick Maupin  wrote:

> From: Patrick Maupin 
> Subject: Re: Picking a license
> To: [email protected]
> Date: Thursday, May 13, 2010, 11:45 PM
> On May 13, 10:06 pm, Lawrence
> D'Oliveiro  central.gen.new_zealand> wrote:
> > In message ,
> Ed Keith
> > wrote:
> >
> >
> >
> > > Assertion I:
> > >    If person A is free to do more than person
> B, then person A has
> > >    more freedom then person B.
> >
> > > Assertion II:
> > >    If person A is free do perform an action
> person B is not free to
> > >    perform then person A is free to do more
> than person B.
> >
> > > Assertion III:
> > >   If person B is restricted in some way that
> person A is not them Person A
> > >   is free to do something Person B is not free
> to do.
> >
> > > Conclusion:
> > >   If person B is more resticted than Peston A,
> Person A has mor freedom
> > >   than person B.
> >
> > > Which step in this reasoning do you disagree
> with?
> >
> > Under the GPL, everybody has exactly the same
> freedoms. So which of your
> > assertions is supposedly a criticism of the GPL?
> 
> That's absolutely not true.  For a start, the original
> author can dual-
> license.  This is not a theoretical issue -- it is a
> multi-million
> dollar issue.
> 
> Regards,
> Pat
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 

Everyone I personally know who has released code under the GPL either 
dual-licenses, or hopes to.

   -EdK

Ed Keith
[email protected]

Blog: edkeith.blogspot.com





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


Re: Data store solution need help

2010-05-14 Thread Tim Chase

On 05/14/2010 08:18 AM, Haulyn Jason wrote:

I am a Java programmer, now I am working on a Python program. At the
moment, I need to store some data from user's input, no database, no
xml, no txt(we can not make users open the data file by vim or other
text editor).


You don't mention what type of data you want to store?  Is it a 
single string?  Multiple strings?  Complex nested data?


And how do you want to access it?

Python provides you any number of options:

- you can use standard Python file objects to read/write content 
in a file format of your own definition


- you can use the ConfigParser module to read/write an old-school 
.INI style file (which can also be edited in a text editor, but 
doesn't have to be)


- you can use the "anydbm" module to store key/value pairs of 
strings with an internal user-interface much like a dictionary


- you can use the "pickle" module to persist Python objects into 
files


- you can use the "shelve" module to combine the "pickle" 
persistence with the DBM layer


- you can use the built-in (as of Python2.5) "sqlite3" module for 
a single-file database with full SQL capabilities without the 
need to install a SQL server (MySQL, PostgreSQL, MS SQL Server, etc)


- you can persist to cloud storage or to your own web-server 
using the urllib/urllib2 modules



But without knowing what you want to store or how you want to 
access it, it's hard to offer more concrete advice.


-tkc






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


Re: Picking a license

2010-05-14 Thread Paul Boddie
On 14 Mai, 05:35, Patrick Maupin  wrote:
>
> I mean, it's in English and very technically precise, but if you
> follow all the references, you quickly come to realize that the
> license is a "patch" to the GPL.

It is a set of exceptions applied to version 3 of the GPL, done this
way so that the exceptions machinery of the GPL can be used to remove
them if desired, as opposed to getting into the business of allowing
people to relicense works from the LGPL to the GPL, as was the case
with previous versions of these licences. You don't even have to read
as far as the first clause of the LGPL terms to be told this, but I
guess there's more "sport" in taking cheap shots at the authors than
reading three lines down from the top of the text.

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


Re: Picking a license

2010-05-14 Thread Ed Keith
--- On Fri, 5/14/10, Steven D'Aprano  
wrote:
> 
> The GPL ensures that once software has entered the commons
> (and therefore 
> available for all), it can never be removed from the
> commons. The MIT 
> licence does not. Now, you might argue that in practice
> once software is 
> released under an MIT licence, it is unlikely to ever
> disappear from the 
> commons. Well, perhaps, but if so, that's despite and not
> because of the 
> licence.

Why is MIT licensed code any more likely to dispersal from the common that 
GPLed code? Does using the GPL somehow grantee that my server will never crash?


> 
> In practice, I believe most MIT-licenced code never even
> makes it into 
> the commons in the first place. I'm willing to predict that
> the majority 
> of code you've written for paying customers (as opposed to
> specifically 
> for open source projects) has disappeared into their code
> base, never to 
> be seen by anyone outside of the company. Am I right?

Yes, but it was licensed to the client, and never enter into the commons, That 
which never enters into the commons can never be removed.

Any MIT licensed code that I may have used is still in the common. My using it 
did not reomove it from the common. 

Has the fact that Python has been used for many commercial/propitiatory 
projects reduced your ability to make use of it? If so how?

   -EdK

Ed Keith
[email protected]

Blog: edkeith.blogspot.com




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


Re: Data store solution need help

2010-05-14 Thread Alex Hall
An important question is: will you need this input stored across
multiple runs of the program? What I mean is, do you want the user to
set the data, then have those same settings even after closing and
re-opening the program?

On 5/14/10, Bruno Desthuilliers
 wrote:
> Haulyn Jason a écrit :
>> Hi, all:
>>
>> I am a Java programmer, now I am working on a Python program. At the
>> moment, I need to store some data from user's input, no database, no
>> xml, no txt(we can not make users open the data file by vim or other
>> text editor).
>>
>> Any suggestions or reference url? Is there a lib should do this or I
>> need to implement it myself?
>>
>> PS: if I want to implement it myself, which part of python document I
>> need to learn? I know how to write txt files now, but not further for me.
>>
>
> Not sure I really understand whether you want to store your data in just
> any format or if it need to be a "binary" format or else... And you
> don't tell much about how your data structure and how it will be used.
>
> Anyway: two possible solutions are csv or serialization.
>
> For the first option, see the csv module
> http://docs.python.org/library/csv.html#module-csv
>
> For the second, look at pickle and shelve modules:
> http://docs.python.org/library/pickle.html#module-pickle
> http://docs.python.org/library/shelve.html#module-shelve
>
>
> If none of this fits your needs, please provide more details !-)
> HTH
> --
> http://mail.python.org/mailman/listinfo/python-list
>


-- 
Have a great day,
Alex (msg sent from GMail website)
[email protected]; http://www.facebook.com/mehgcap
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Data store solution need help

2010-05-14 Thread superpollo

Haulyn Jason ha scritto:

Hi, all:

I am a Java programmer, now I am working on a Python program. At the 
moment, I need to store some data from user's input, no database, no 
xml, no txt(we can not make users open the data file by vim or other 
text editor).


security thru obscurity? mmmhhh...
--
http://mail.python.org/mailman/listinfo/python-list


Re: Picking a license

2010-05-14 Thread Ed Keith
--- On Thu, 5/13/10, Patrick Maupin  wrote:

> From: Patrick Maupin 
> Subject: Re: Picking a license
> To: [email protected]
> Date: Thursday, May 13, 2010, 11:35 PM
> On May 13, 10:07 pm, Lawrence
> D'Oliveiro  central.gen.new_zealand> wrote:
> 
> > How exactly does the LGPL lead to a requirement to
> “relink”?
> 
> I think this might be a misconception, but I'm not 100%
> sure.  Since
> Ed gives his customers full source code, there may not be
> the
> requirement to directly provide the ability to relink,
> because "The
> “Corresponding Application Code” for a Combined Work
> means the object
> code and/or source code for the Application." and section
> 4d0 requires
> you to "permit the user to recombine or relink" where
> "recombine"
> isn't defined directly (perhaps in the underlying GPL?)

But if my client give someone else a copy of the binary I gave them, they are 
now in violation. I do not want to put my client in this position. 

When using the GPL or LGPL you can do anything you want as long as you do not 
let anyone else use your work, but if you let someone else have a copy of you 
work you are putting them in a position where that can easily/inadvertently 
violate the law. I do not want to put clients in legal jeopardy, so I do not 
use GPL, or LGPLed code.

I do not claim that using the GLP is immoral, nor deny others right to use it. 
I just feel the risks out way the benefits for me.

-EdK

Ed Keith
[email protected]

Blog: edkeith.blogspot.com





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


Re: Picking a license

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

> The GPL ensures that once software has entered the commons
> (and therefore 
> available for all), it can never be removed from the
> commons. The MIT 
> licence does not. Now, you might argue that in practice
> once software is 
> released under an MIT licence, it is unlikely to ever
> disappear from the 
> commons. Well, perhaps, but if so, that's despite and not
> because of the 
> licence.


Several years ago I released a C++ library under the Boost license. I put it up 
on a small free server. Later my hard drive crashed, both my backup copies were 
corrupted, and when I went to retrieve it from the site I found it no longer 
existed.

I am recreating the code, and it will be MUCH better this time, and it is on 
three web sites, but are you telling me that of I have used the GPL instead of 
Boost I would not have had this problem?

I use the Boost Libraries (http://www.boost.org/) in most of my code. Do you 
believe they are likely to disappear because they are not covered by the GPL?

   -EdK

Ed Keith
[email protected]

Blog: edkeith.blogspot.com




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


Setup global variables settings for the entire applications

2010-05-14 Thread AON LAZIO
Hi,
   Say I have an application which requires a global settings for the user.
When the user finishes setting those global variables for the app. Any class
can use that variables (which are the same for all), something like that.
What is the suitable mechanism for this solution?
   Thanks in advance

Aonlazio

-- 
Passion is my style
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: write a 20GB file

2010-05-14 Thread J
On Fri, May 14, 2010 at 07:32, Jackie Lee  wrote:
> Thx, Dave,
>
> The code works fine. I just don't know how f.write works. It says that
> file.write won't write the file until file.close or file.flush. So I
> don't know if the following one is more efficient (sorry I forget to
> add condition to break the loop):

someone smarter than me can correct me, but file.write() will write
when it's buffer is filled, or close() or flush() are called.
I don't know what the default buffer size for file.write() is though.
close() flushes the buffer before closing the file, and flush()
flushes the buffer and leaves the file open for further writing.

> try:
>        f=open(sys.argv[1],'rb+')
> except (IOError,Exception):
>    print '''usage:
>        scriptname segyfilename
> '''

You can just add a f.flush() every time you write to the file, but, I
tend to open files with 0 buffer size like this:

f = open(filename,"rb+",0)

Then again, I don't deal with files of that size, so there could be a
problem with my way once you start scaling up to the 20GB or larger
that you're working with.

Again, I could be wrong about all of that, so if so, I hope someone
will correct me and fix my understanding...

Cheers,

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


recursively remove all the directories and files which begin with '.'

2010-05-14 Thread albert kao
How do I recursively remove all the directories and files which begin
with '.'?
My test program rmdir.py does not do the job yet.
Please help.
[code]
#!c:/Python31/python.exe -u
import os
from shutil import *

root = "C:\\test\\com.comp.hw.prod.proj.war\\bin"

for curdir, dirs, files in os.walk(root):
  print (curdir)
  print (dirs)
  for d in dirs:
print ("d " + d)
if d.startswith('.'):
  print ("dotd " + os.path.join(curdir, d))
  rmtree(os.path.join(curdir, d))
[/code]

C:\python>rmdir.py
C:\test\com.comp.hw.prod.proj.war\bin
['.svn', 'com']
d .svn
dotd C:\test\com.comp.hw.prod.proj.war\bin\.svn
Traceback (most recent call last):
  File "C:\python\rmdir.py", line 14, in 
rmtree(os.path.join(curdir, d))
  File "C:\Python31\lib\shutil.py", line 235, in rmtree
onerror(os.remove, fullname, sys.exc_info())
  File "C:\Python31\lib\shutil.py", line 233, in rmtree
os.remove(fullname)
WindowsError: [Error 5] Access is denied: 'C:\\test\
\com.comp.hw.prod.proj.war\\bin\\.svn\\entries'

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


Re: Picking a license

2010-05-14 Thread Patrick Maupin
On May 14, 8:47 am, Paul Boddie  wrote:
> On 14 Mai, 05:35, Patrick Maupin  wrote:
>
>
>
> > I mean, it's in English and very technically precise, but if you
> > follow all the references, you quickly come to realize that the
> > license is a "patch" to the GPL.
>
> It is a set of exceptions applied to version 3 of the GPL, done this
> way so that the exceptions machinery of the GPL can be used to remove
> them if desired, as opposed to getting into the business of allowing
> people to relicense works from the LGPL to the GPL, as was the case
> with previous versions of these licences. You don't even have to read
> as far as the first clause of the LGPL terms to be told this, but I
> guess there's more "sport" in taking cheap shots at the authors than
> reading three lines down from the top of the text.
>
> Paul

That's not a cheap shot.  It's a (programmer) technical description of
how the licenses interact, along with an opinion that it would be
easier to read otherwise, along with a quoted snippet that shows (at
least to me) that these are really quite complicated licenses.  The
confusion that some are showing in this thread about whether source
must be distributed certainly helps to show that as well.  Now, it may
well be, and probably is, that the licenses are as simple as they can
be for the desired effect, but that doesn't make them simple.

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


Re: Picking a license

2010-05-14 Thread Patrick Maupin
On May 14, 9:10 am, Ed Keith  wrote:
> --- On Thu, 5/13/10, Patrick Maupin  wrote:
>
>
>
> > From: Patrick Maupin 
> > Subject: Re: Picking a license
> > To: [email protected]
> > Date: Thursday, May 13, 2010, 11:35 PM
> > On May 13, 10:07 pm, Lawrence
> > D'Oliveiro  > central.gen.new_zealand> wrote:
>
> > > How exactly does the LGPL lead to a requirement to
> > “relink”?
>
> > I think this might be a misconception, but I'm not 100%
> > sure.  Since
> > Ed gives his customers full source code, there may not be
> > the
> > requirement to directly provide the ability to relink,
> > because "The
> > “Corresponding Application Code” for a Combined Work
> > means the object
> > code and/or source code for the Application." and section
> > 4d0 requires
> > you to "permit the user to recombine or relink" where
> > "recombine"
> > isn't defined directly (perhaps in the underlying GPL?)
>
> But if my client give someone else a copy of the binary I gave them, they are 
> now in violation. I do not want to put my client in this position.
>
> When using the GPL or LGPL you can do anything you want as long as you do not 
> let anyone else use your work, but if you let someone else have a copy of you 
> work you are putting them in a position where that can easily/inadvertently 
> violate the law. I do not want to put clients in legal jeopardy, so I do not 
> use GPL, or LGPLed code.

Good point.  I guess I haven't distributed something linked in a while
(really just Python), so I tend to forget that aspect of it.

Regards,
Pat

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


parsing XML

2010-05-14 Thread [email protected]
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
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: recursively remove all the directories and files which begin with '.'

2010-05-14 Thread J
On Fri, May 14, 2010 at 10:53, albert kao  wrote:
>
> C:\python>rmdir.py
> C:\test\com.comp.hw.prod.proj.war\bin
> ['.svn', 'com']
> d .svn
> dotd C:\test\com.comp.hw.prod.proj.war\bin\.svn
> Traceback (most recent call last):
>  File "C:\python\rmdir.py", line 14, in 
>    rmtree(os.path.join(curdir, d))
>  File "C:\Python31\lib\shutil.py", line 235, in rmtree
>    onerror(os.remove, fullname, sys.exc_info())
>  File "C:\Python31\lib\shutil.py", line 233, in rmtree
>    os.remove(fullname)
> WindowsError: [Error 5] Access is denied: 'C:\\test\
> \com.comp.hw.prod.proj.war\\bin\\.svn\\entries'
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>

You don't have permissions to remove the subdir or file entries in the
.svn directory...

Maybe that file is still open, or still has a lock attached to it?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Picking a license

2010-05-14 Thread Patrick Maupin
On May 14, 1:08 am, Steven D'Aprano  wrote:
> On Thu, 13 May 2010 19:10:09 -0700, Patrick Maupin wrote:
> > The broken window fallacy is about 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, so I'm not sure
> > this is really making the point you think it is.
>
> 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!

Don't be silly.  That's why I started writing open source software in
the first place.  But if I start writing stuff to put in the commons
with strings removed, why would I bother with a license that just adds
some strings back?

> The GPL ensures that once software has entered the commons (and therefore
> available for all), it can never be removed from the commons.

No it doesn't.  It just insures that if people actually *distribute*
the software to others, they have to distribute the source.  In any
case, for software to remain in the commons, it has to be available
where people can get to it.  Somebody has to care enough to maintain a
repository, or it has to be good enough for people to distribute.

> The MIT licence does not.

The only difference is that somebody has to care enough to maintain a
repository, or it has to be good enough for people to distribute
*along with source*.

> Now, you might argue that in practice once software is
> released under an MIT licence, it is unlikely to ever disappear from the
> commons.

Depends on the software.  See above.

> Well, perhaps, but if so, that's despite and not because of the
> licence.

Same thing for GPLed software.  See above.

> In practice, I believe most MIT-licenced code never even makes it into
> the commons in the first place.

Interesting assertion.

> I'm willing to predict that the majority
> of code you've written for paying customers (as opposed to specifically
> for open source projects) has disappeared into their code base, never to
> be seen by anyone outside of the company. Am I right?

That's true, but what on earth does that have to do with the MIT
license?

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


Re: write a 20GB file

2010-05-14 Thread Martin v. Loewis
> The code works fine. I just don't know how f.write works. It says that
> file.write won't write the file until file.close or file.flush.

You are misinterpreting the documentation. It certainly won't keep the
entire file in memory. Instead, it has a fixed-size buffer (something
like 8kiB or 32kiB) in which it writes and which it flushes when that
buffer is full.

The comment about flush and close merely refers to the problem that some
data may still be in the buffer at any point in time, unless you just
called close or flush.

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


Re: parsing XML

2010-05-14 Thread Martin v. Loewis
[email protected] 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

Homework?

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


Re: parsing XML

2010-05-14 Thread Stefan Behnel

[email protected], 14.05.2010 16:57:

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?


Here's an overly complicated solution, but I thought that an object 
oriented design would help here.



  import xml.etree.ElementTree as ET

  class Player(object):
 def __init__(self, name, age, height):
 self.name, self.age, self.height = name, age, height

  attributes = ['name', 'age', 'height']

  players = []
  for _, element in ET.iterparse("teamfile.xml"):
  if element.tag == 'player':
  players.append(
  Player(*[ element.get(attr) for attr in attributes ]))

  for player in players:
  print player.name, player.age, player.height


Stefan

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


an element from a set

2010-05-14 Thread gerardob

Hello, let S be a python set which is not empty
(http://docs.python.org/library/sets.html)

i would like to obtain one element (anyone, it doesn't matter which one) and
assign it to a variable.

How can i do this? 

Thanks.

-- 
View this message in context: 
http://old.nabble.com/an-element-from-a-set-tp28560792p28560792.html
Sent from the Python - python-list mailing list archive at Nabble.com.

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


Re: Picking a license

2010-05-14 Thread Paul Boddie
On 14 Mai, 09:08, Carl Banks  wrote:
> On May 13, 10:59 pm, Steven D'Aprano  
> wrote:
> > On Thu, 13 May 2010 17:18:47 -0700, Carl Banks wrote:
> > > 2. Reimplment the functionality seperately (*cough* PySide)
>
> > Yes. So what? In what possible way is this an argument against the GPL?

[...]

> It's not.  It's an argument that the GPL doesn't do much good.

Right. So nobody got the benefit from Qt under the GPL or PyQt under
the GPL? Even the PySide developers seem hell-bent on picking over the
work of the PyQt developers for ideas, although they obviously won't
touch the code. Nokia seem to have accrued tremendous benefit from the
existence of PyQt because I rather doubt that anyone would have
bothered rolling a set of mature, usable Python bindings for Qt now
had some not existed already and proved that dynamic languages are
worth supporting.

> Arguments against the GPL are found elsewhere in this thread, I don't
> need to repeat them here.

Yes, don't bother. They fit in rather well with the comment you made
above.

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


Re: recursively remove all the directories and files which begin with '.'

2010-05-14 Thread albert kao
On May 14, 11:01 am, J  wrote:
> On Fri, May 14, 2010 at 10:53, albert kao  wrote:
>
> > C:\python>rmdir.py
> > C:\test\com.comp.hw.prod.proj.war\bin
> > ['.svn', 'com']
> > d .svn
> > dotd C:\test\com.comp.hw.prod.proj.war\bin\.svn
> > Traceback (most recent call last):
> >  File "C:\python\rmdir.py", line 14, in 
> >    rmtree(os.path.join(curdir, d))
> >  File "C:\Python31\lib\shutil.py", line 235, in rmtree
> >    onerror(os.remove, fullname, sys.exc_info())
> >  File "C:\Python31\lib\shutil.py", line 233, in rmtree
> >    os.remove(fullname)
> > WindowsError: [Error 5] Access is denied: 'C:\\test\
> > \com.comp.hw.prod.proj.war\\bin\\.svn\\entries'
>
> > --
> >http://mail.python.org/mailman/listinfo/python-list
>
> You don't have permissions to remove the subdir or file entries in the
> .svn directory...
>
> Maybe that file is still open, or still has a lock attached to it?

I reboot my windows computer and run this script as administrator.
Do my script has a bug?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Picking a license

2010-05-14 Thread Patrick Maupin
On May 14, 8:26 am, Paul Boddie  wrote:
> On 13 Mai, 22:10, Patrick Maupin  wrote:
> Just to deal with your Ubuntu "high horse" situation first, you should
> take a look at the following for what people regard to be the best
> practices around GPL-licensed software distribution:
>
> http://www.softwarefreedom.org/resources/2008/compliance-guide.html

Before, you were busy pointing me at the GPL FAQ as authoritative.
When I show where the FAQ says that you should distribute source if
you give somebody a CD, you point me at a document which is obviously
designed for the Ciscos of the world.

> If you still think Ubuntu are violating the GPL or encouraging others
> to do so, feel free to contact their lawyers who I'm sure will be very
> interested to hear from you.

Did I *ever* say that Ubuntu was violating the GPL.  No.  Do I believe
that the practices of any binary Linux distribution that fits on a
single CD make it easy for the downloader/burner to violate the GPL.
Yes.
>
> > When the leader of your religion bandies terms like "freedom" and
> > "evil" about, what do you expect?  Seriously?
>
> I thought you were "done". I guess you are: again, we have the usual
> courting of public outrage by labelling stuff you don't like as
> "religion" - presumably not the "right one", either - when it is no
> such thing.

Well, you conveniently ignore sections of your bible (for example, the
part of the FAQ where it says you should distribute source with
binary) and reach for more obscure scrolls whenever the real world
gets in the way of your fantasy.  Even here, you don't bother to quote
what you wrote, which would show I am just responding to your outrage.

> > My primary agenda is to explain that RMS does, in fact, have an
> > agenda, and the GPL was designed as a tool in furtherance of that
> > agenda, and that while the agenda does have some arguably noble goals,
> > before using the GPL people should understand its consequences both
> > for good and bad, and make their own determination about whether it's
> > the right license for their project.
>
> Reading through your "translations" of what are effectively honest
> summaries.

There are multiple sides to every discussion, and everybody comes to
the table with biases.  If you honestly think that you are not biased,
then you are deluding yourself.  If you realize that you are biased,
then you will also come to realize that my translations are equally
honest.

> one gets the impression that you have quite a chip on your
> shoulder about the FSF and RMS.

I can take them or leave them until they and their followers start
spouting damaging nonsense.  Many businesses were scared to death of
FOSS for many years, and I lay the blame squarely on RMS's shoulders.
You see only the good he has done; it is tempered by quite a bit of
bad.

> Referring to the GPL as a "commercial"
> licence and stating that it (as opposed to any other licence or even
> the word "copyright" followed by a name) is a threat to sue people,
> presumably appealing to the libertarian crowd with a judicious mention
> of "government" just to fan the flames of supposed injustice, really
> does triangulate where you are coming from. So, yes, we're now rather
> more aware of what your agenda is, I think.

I'm not the one who keeps spouting that it "gives" freedoms (or even
privileges) that copyright would have taken away.  That's complete
bullshit.  As I said, copyright *allows* the author to control various
aspects of his work ("take away freedoms" in GPL-speak), and all
licenses (including the GPL) explicitly state which aspects the author
plans to control.  The only way the author can really exert control is
to sue or credibly threaten to sue.  I can actually point to multiple
instances of GPL authors suing, and people like you crowing about how
great it is that the GPL stands up in court, but I don't actually
recall any suits about violations of the MIT or Apache licenses.  So,
yes, I firmly believe that when somebody slaps a GPL license on their
software (and especially if they sign the copyrights over to the FSF)
they are trying to signal that they are willing to go to court to
protect their rights.  This is no different than when Microsoft sues
an infringer, and is not an evil thing, but it is definitely something
to be aware of.  The easiest way to not get tangled in that kind of
lawsuit is to just make sure that you never distribute any software
with a commercial-type license on it (including the GPL).

> And I don't think it improves any argument you may have by projecting
> notions of "morality" or "immorality" onto what I have written,

But you're arguing from a moral standpoint.

> especially when I have deliberately chosen to use other terms which
> avoid involving such notions

Yes, but you're making exactly the same arguments as others, just
changing the name.

> or by equating the copyleft licences
> with criminal enterprises ("pyramid scheme"),

Well, that may be a bit OTT.  What I re

Re: Picking a license

2010-05-14 Thread Patrick Maupin
On May 14, 6:12 am, Lawrence D'Oliveiro  wrote:
> In message <2ff3643b-6ef1-4471-8438-
>
>
>
> [email protected]>, Patrick Maupin wrote:
> > On May 13, 10:04 pm, Lawrence D'Oliveiro
> >  wrote:
>
> >> In message , Ed
> >> Keith wrote:
>
> >>> The claim is being made that [the GPL] restricts freedom.
>
> >> What about the “freedom” to restrict other people’s freedom? Should that
> >> be restricted or not?
>
> > It's interesting that some people don't like the comparison of the
> > Free Software movement to a religion, yet the main argument of the
> > movement, and the deliberate co-opting of words like "Free" and "Free
> > Software" ...
>
> Haven’t you “co-opted” those words yourself?

Only in response.  But hey, it's not just me; even Stallman says that
MIT-licensed software is "free software", just not "Free Software".

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


Re: Picking a license

2010-05-14 Thread Patrick Maupin
On May 14, 6:13 am, Lawrence D'Oliveiro  wrote:
> In message
> <2b17ee77-0e49-4a97-994c-7582f86c0...@r34g2000yqj.googlegroups.com>, Patrick
>
> Maupin wrote:
> > On May 13, 10:06 pm, Lawrence D'Oliveiro
> >  wrote:
>
> >> Under the GPL, everybody has exactly the same freedoms.
>
> > That's absolutely not true.  For a start, the original author can dual-
> > license.
>
> That’s nothing to do with the GPL.

If you mean "that's out of the control of the GPL" I agree.  But the
whole point of the discussion has been about how people can't take GPL
licensed code proprietary, making enhancements, etc. and I'm just
pointing out that this doesn't apply to the original author.  Someone
can decide they aren't making enough money under the GPL and stop
distributing that way, and make all their enhancements proprietary, if
they are the original author.

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


Re: Picking a license

2010-05-14 Thread mk

Steven D'Aprano wrote:
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?


Err.. Linking statically with library in question? Which excludes LGPL 
for legal reasons and doesn't exclude MIT/Apache license for legal reasons?


(this is obviously orthogonal to a technical question why static linking 
should be used sparringly if at all)



Regards,
mk

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


Re: Picking a license

2010-05-14 Thread Tobiah

> Assertion II:
>If person A is free do perform an action person B is not free to
>perform then person A is free to do more than person B.

This does not hold water.  Let's say there are only 10 activities
available.  Person A can do number 1 and person B can not.  Person
B can do activities 2 through 10, while person A can not.  Therefore,
Person A is indeed free to perform an action that person B is not
free to perform, but person a is *not* free to do more than person B.

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


Re: Picking a license

2010-05-14 Thread Ed Keith
--- On Fri, 5/14/10, Patrick Maupin  wrote:

> From: Patrick Maupin 
> Subject: Re: Picking a license
> To: [email protected]
> Date: Friday, May 14, 2010, 11:47 AM
> On May 14, 6:13 am, Lawrence
> D'Oliveiro  central.gen.new_zealand> wrote:
> > In message
> > <2b17ee77-0e49-4a97-994c-7582f86c0...@r34g2000yqj.googlegroups.com>,
> Patrick
> >
> > Maupin wrote:
> > > On May 13, 10:06 pm, Lawrence D'Oliveiro
> > > 
> wrote:
> >
> > >> Under the GPL, everybody has exactly the same
> freedoms.
> >
> > > That's absolutely not true.  For a start, the
> original author can dual-
> > > license.
> >
> > That’s nothing to do with the GPL.
> 
> If you mean "that's out of the control of the GPL" I
> agree.  But the
> whole point of the discussion has been about how people
> can't take GPL
> licensed code proprietary, making enhancements, etc. and
> I'm just
> pointing out that this doesn't apply to the original
> author.  Someone
> can decide they aren't making enough money under the GPL
> and stop
> distributing that way, and make all their enhancements
> proprietary, if
> they are the original author.
> 

That is one good reason for choosing to use the GPL, instead of a less 
restrictive license. You can license it, for a fee, to someone who wants to use 
it in some way that is not allowed under the GPL. If you use a less 
restrictive license that is not an option. Of course you still could put 
restrictions on future enhancements, but the the original code cannot have 
new restrictions put on it, only taken off. If I release code under the GPL 
today, I can change my mind and release the same code under the Boost 
license tomorrow. But if I release it with the Boost license, while 
technically I can release it with the GPL tomorrow, in practice everyone 
will use the previously released Boost licensed version.

   -EdK

Ed Keith
[email protected]

Blog: edkeith.blogspot.com





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


Re: Picking a license

2010-05-14 Thread Ed Keith
--- On Fri, 5/14/10, Tobiah  wrote:

> From: Tobiah 
> Subject: Re: Picking a license
> To: [email protected]
> Date: Friday, May 14, 2010, 11:59 AM
> 
> > Assertion II:
> >    If person A is free do perform an action
> person B is not free to
> >    perform then person A is free to do more
> than person B.
> 
> This does not hold water.  Let's say there are only 10
> activities
> available.  Person A can do number 1 and person B can
> not.  Person
> B can do activities 2 through 10, while person A can
> not.  Therefore,
> Person A is indeed free to perform an action that person B
> is not
> free to perform, but person a is *not* free to do more than
> person B.

THat argument is valid if and only if the rights of B are not a strict subset 
of the rights of A. As far as I can tell, the rights granted by the GPL are a 
strict subset of the right granted by the Boost license. So your argument does 
not work.

   -EdK

Ed Keith
[email protected]

Blog: edkeith.blogspot.com





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


Re: Iterating over dict and removing some elements

2010-05-14 Thread Bryan
Adi Eyal  wrote:
> > Bryan:
> > Terry Reedy wrote:
> > [...]
> >> for k in [k for k in d if d[k] == 'two']:
> >>          d.pop(k)
>
> > We have a winner.
>
> also
>
> foo = lambda k, d : d[k] == "two"
> d = dict([(k, d[k]) for k in d.keys() if not foo(k, d)])
>
> incidentally, this is marginally slower than pops and dels but has the
> benefit of not modifying the original dict if that's what you need.

Well, I guess, sure. The original problem in this tread was about
modifying the dict over which we are iterating. If you create a new
dict instead, that problem just goes away.

In Python 3.X, and in Python 2.X starting with 2.4, you can drop the
square brackets and avoid creating an extra temporary list:

d = dict((k, d[k]) for k in d.keys() if not foo(k, d))

You can also drop .keys() in Python 3.X or current Python 2.X:

d = dict((k, d[k]) for k in d if not foo(k, d))

Passing the dict to foo() seems inelegant. You could use:

foo = lambda val: val == "two"
d = dict((k, d[k]) for k in d if not foo(d[k]))

I'm sticking with my call of Terry Reedy's last solution as winner. It
solves the originally-stated problem, works correctly and efficiently
in both Python 3.X and current Python 2.X, and there is not a bracket
in it that does not need to be there.

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


Re: an element from a set

2010-05-14 Thread Terry Reedy

On 5/14/2010 11:24 AM, gerardob wrote:


Hello, let S be a python set which is not empty
(http://docs.python.org/library/sets.html)

i would like to obtain one element (anyone, it doesn't matter which one) and
assign it to a variable.

How can i do this?


Depends on whether or not you want the element removed from the set

#3.1
>>> s=set(range(10))
>>> s
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
>>> x=next(iter(s))
>>> x
0
>>> s
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9} # x not removed
>>> x = s.pop()
>>> x
0
>>> s
{1, 2, 3, 4, 5, 6, 7, 8, 9} # x has been removed

The choice of 0 is an implementation artifact. It could have been any 
member.


Terry Jan Reedy



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


Re: Picking a license

2010-05-14 Thread Paul Boddie
On 14 Mai, 17:37, Patrick Maupin  wrote:
>
> Before, you were busy pointing me at the GPL FAQ as authoritative.

No, the licence is the authority, although the FAQ would probably be
useful to clarify the licence author's intent in a litigation
environment.

[Fast-forward through the usual tirade, this time featuring words like
"bible", "moral", "evil"...]

> Well, I thought I was before, but then the discussion about
> downloading an ISO and burning it and giving it to a friend came up.
> This may be technically allowable under the license, but nothing you
> or anybody else has written has yet proved that to me.

Section 3 of GPLv2 (and section 6(d) of GPLv3 reads similarly): "If
distribution of executable or object code is made by offering access
to copy from a designated place, then offering equivalent access to
copy the source code from the same place counts as distribution of the
source code, even though third parties are not compelled to copy the
source along with the object code."

And here's that FAQ entry which clarifies the intent:

http://www.gnu.org/licenses/gpl-faq.html#DistributeWithSourceOnInternet

Like I said, if you really have a problem with Ubuntu shipping CDs and
exposing others to copyright infringement litigation - or even
themselves, since they (and all major distributions) are actively
distributing binaries but not necessarily sources in the very same
download or on the very same disc - then maybe you should take it up
with them.

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


Re: Picking a license

2010-05-14 Thread Patrick Maupin
On May 14, 10:20 am, Paul Boddie  wrote:
> On 14 Mai, 09:08, Carl Banks  wrote:
>
> > On May 13, 10:59 pm, Steven D'Aprano  
> > wrote:
> > > On Thu, 13 May 2010 17:18:47 -0700, Carl Banks wrote:
> > > > 2. Reimplment the functionality seperately (*cough* PySide)
>
> > > Yes. So what? In what possible way is this an argument against the GPL?
>
> [...]
>
> > It's not.  It's an argument that the GPL doesn't do much good.
>
> Right. So nobody got the benefit from Qt under the GPL or PyQt under
> the GPL? Even the PySide developers seem hell-bent on picking over the
> work of the PyQt developers for ideas, although they obviously won't
> touch the code. Nokia seem to have accrued tremendous benefit from the
> existence of PyQt because I rather doubt that anyone would have
> bothered rolling a set of mature, usable Python bindings for Qt now
> had some not existed already and proved that dynamic languages are
> worth supporting.

Perhaps he should have said "the GPL doesn't do any more good than any
other commercial license."

After all, lots of software ideas proved their worth in proprietary
systems, and then were later cloned by FOSS developers.  In many
cases, these clones are, functionally, almost exact copies.  That's
why all the really proprietary people are hell-bent on trying to get
or maintain patent protection -- copyright doesn't protect
"inventions".

Would you have agreed had he had said that "MatLab's license doesn't
do much good" and assigned the same sort of meaning to that statement,
namely that the MatLab license prevented enough motivated people from
freely using MatLab in ways that were important to them?  Obviously,
it was important enough to enough people that they went and built the
GPLed Octave software, which now emulates MatLab very closely.  As I
think both Ed and I have said before, the GPL can be a great license
for a full-blown *program* (like Octave) that people can just download
and use, but is not always so great for program *pieces* that are
designed to be used in the programmatic equivalent of a "mash-up",
like PyQt/PySide, so the cloning of PyQt into PySide is as inevitable
as the cloning of MatLab into Octave, or Unix/Minix into Linux.  As
far as your comments about PyQt proving out the concept, well duh!
Just as there are a lot of proprietary programs that are relatively
useless and *won't* have any GPLed versions written, nobody's going to
waste time rewriting a marginally useful GPLed library just to put a
permissive license on it, either.  They are either going to write
something completely different in the hopes that their vision is
correct, or are going to copy at least some parts of the design and/or
vision of something that is popular and useful.  And that's a great
thing.  It would have been horribly unproductive if the Linux API
weren't at least reasonably close to the Unix API, for example.

It's an interesting tension between the licenses.  Nobody rewrites
permissively licensed software as GPL simply because the license is
unacceptable, but just as people will rewrite proprietary programs and
libraries as GPL because the license is unacceptable, so will some
rewrite GPLed libraries as permissive because the license is
unacceptable.

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


Re: Picking a license

2010-05-14 Thread Patrick Maupin
On May 14, 11:48 am, Paul Boddie  wrote:
> On 14 Mai, 17:37, Patrick Maupin  wrote:
>
>
>
> > Before, you were busy pointing me at the GPL FAQ as authoritative.
>
> No, the licence is the authority, although the FAQ would probably be
> useful to clarify the licence author's intent in a litigation
> environment.

Agreed.

> Section 3 of GPLv2 (and section 6(d) of GPLv3 reads similarly): "If
> distribution of executable or object code is made by offering access
> to copy from a designated place, then offering equivalent access to
> copy the source code from the same place counts as distribution of the
> source code, even though third parties are not compelled to copy the
> source along with the object code."
>
> And here's that FAQ entry which clarifies the intent:
>
> http://www.gnu.org/licenses/gpl-faq.html#DistributeWithSourceOnInternet

That entry, along with the written offer, certainly covers Ubuntu when
they distribute a CD.

But if I *download* an ISO, burn it on a CD, and give it away, *I* am
the one distributing the physical copy, not Ubuntu, and I am not going
to put up an FTP server just so my friend can get source from it.  And
as section 6 of GPL v3 makes clear, I am not allowed to piggyback on
Ubuntu's source offer.  My situation *really is* covered by the FAQ
entry I referred you to:

http://www.gnu.org/licenses/gpl-faq.html#UnchangedJustBinary

> Like I said, if you really have a problem with Ubuntu shipping CDs and
> exposing others to copyright infringement litigation.

So, deliberately or not, you're trying to change the discussion
again.  I *never* discussed Ubuntu shipping a physical CD, and never
intimated that that was a problem.  My discussion was *always* about
an individual *downloading* an ISO and *burning* a CD himself, then
*distributing* the CD to someone else.

> - or even
> themselves, since they (and all major distributions) are actively
> distributing binaries but not necessarily sources in the very same
> download or on the very same disc - then maybe you should take it up
> with them.

Again, I never intimated this.  Please read more carefully in the
future before you reply, and then perhaps you will actually make
cogent replies that address my points, and then I won't be so
frustrated that I make snide comments you take offense at, OK?  This
has happened on at least 4 separate occasions in this thread, and
sometimes a single misunderstanding goes on for quite a few posts, so
I'm starting to wonder if it's deliberate.

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


Re: Picking a license

2010-05-14 Thread Albert van der Horst
In article <[email protected]>,
Lie Ryan   wrote:



>
>Come on, 99%  of the projects released under GPL did so because they
>don't want to learn much about the law; they just need to release it
>under a certain license so their users have some legal certainty. Most
>programmers are not lawyers and don't care about the law and don't care
>about the GPL; if a commercial programmer want to use the GPL-code in an
>incompatible licensed program, and he comes up asking, many would just
>be happy to say yes.

This is a big reason for me to release everything (see my website,
it is a *lot*) under GPL. If someone wants to use it they can,
if someone wants to use it commercially, they can too, as long
as they pay me a little bit too. Really, I'm reasonable.

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


joining two column

2010-05-14 Thread mannu jha
Hi,

I have two different file 

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

how to do that?




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


Re: joining two column

2010-05-14 Thread James Mills
On Sat, May 15, 2010 at 3:22 AM, mannu jha  wrote:
> Hi,
>
> I have two different file
>
> 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
>
> how to do that?

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)))

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


Re: Picking a license

2010-05-14 Thread Paul Boddie
On 14 Mai, 19:00, Patrick Maupin  wrote:
>
> Would you have agreed had he had said that "MatLab's license doesn't
> do much good" and assigned the same sort of meaning to that statement,
> namely that the MatLab license prevented enough motivated people from
> freely using MatLab in ways that were important to them?  Obviously,
> it was important enough to enough people that they went and built the
> GPLed Octave software, which now emulates MatLab very closely.

I don't need to answer your question. It's obvious that the licence
doesn't do much good when people seek to create a platform which is
genuinely and irrevocably open as a response. That they have done so
using the GPL pretty much sinks the previous ridiculous statement
about the GPL, too, unless Octave is somehow a bad thing (which is
what a certain vendor of proprietary statistics software would have
you believe about a certain widely-used statistical analysis tool).
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 has been in no way
demonstrated to be universally true that such contributors would
contribute more than those who do so because of the copyleft
licensing. The creators of Octave are obviously not willing to create
(or help create) another system with all the proprietary limitations
of MatLab, and why should they be willing? The production of a
different "proprietary flavour" of MatLab wouldn't be beneficial to
them at all - it might even be detrimental to their project - and
might only be marginally beneficial, at best, to existing MatLab
customers.

[PySide]

> Just as there are a lot of proprietary programs that are relatively
> useless and *won't* have any GPLed versions written, nobody's going to
> waste time rewriting a marginally useful GPLed library just to put a
> permissive license on it, either.

Unless they really want to release (or encourage the creation of)
proprietary software, which is precisely what PySide is all about.
(And PyQt is not "marginally useful" - it is a widely-used and widely
well-regarded library.) And this apparent overriding need to support
proprietary solutions results in different strategies, such as with
the Chandler project: because the OSAF wanted to be able to sell
proprietary solutions but didn't own all the code, they decided to
pick only permissively licensed software for the components of the
solution, resulting in a lot of extra effort expended in getting their
user interface toolkit up to scratch. You can make your own mind up
about whether that was a sensible strategy.

Usually, however, most people wanting to write proprietary software
cannot be bothered to do the work to replicate an existing GPL-
licensed solution (or even to significantly improve permissively
licensed solutions). They instead appeal to people to release already-
mature permissively licensed software, typically waiting for someone
with enough money or manpower to do most of the work for them. Again,
this is precisely why PySide appeals to a certain audience.

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


Re: Picking a license

2010-05-14 Thread Ed Keith
--- On Fri, 5/14/10, Albert van der Horst  wrote:
 
> This is a big reason for me to release everything (see my
> website,
> it is a *lot*) under GPL. If someone wants to use it they
> can,
> if someone wants to use it commercially, they can too, as
> long
> as they pay me a little bit too. Really, I'm reasonable.

I have no problem with that. 

I have played with your forth assembler a bit. It is good work, and the 
best part is that I can read the source and learn from it. Putting it out 
under GPL allows me to learn from it, and you to profit from it, a real 
win/win. Thank you very much for making it available.

I'm working on an assembler myself. I may steal your ideas, but I will not 
steal your code. I'm writing it in ocaml, your forth code would not be 
easy to translate. When/if I finish I'll publish it under a less restrictive 
open source license, because I do not think I would be able to 
persuade anyone else to pay for a commercial license. But I do not fault 
you if you think you can. 

If I did use your code I would either publish under the GPL or not publish 
at all depending on the exact circumstances. I have been know, on rare 
occasions, to use GPLed code in my own work (mostly plug-ins for GPLed 
applications). I just refuse to use it 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. When I 
deliver my code to the client they are always free to do whatever they want 
with it. 

-EdK

Ed Keith
[email protected]

Blog: edkeith.blogspot.com



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


Re: parsing XML

2010-05-14 Thread [email protected]
On May 14, 6:22 pm, Stefan Behnel  wrote:
> [email protected], 14.05.2010 16:57:
>
> > 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?
>
> Here's an overly complicated solution, but I thought that an object
> oriented design would help here.
>
>    import xml.etree.ElementTree as ET
>
>    class Player(object):
>       def __init__(self, name, age, height):
>           self.name, self.age, self.height = name, age, height
>
>    attributes = ['name', 'age', 'height']
>
>    players = []
>    for _, element in ET.iterparse("teamfile.xml"):
>        if element.tag == 'player':
>            players.append(
>                Player(*[ element.get(attr) for attr in attributes ]))
>
>    for player in players:
>        print player.name, player.age, player.height
>
> Stefan

Thanks stefan!

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


Re: Picking a license

2010-05-14 Thread Patrick Maupin
On May 14, 1:07 pm, Paul Boddie  wrote:
> On 14 Mai, 19:00, Patrick Maupin  wrote:

> > Would you have agreed had he had said that "MatLab's license doesn't
> > do much good" and assigned the same sort of meaning to that statement,
> > namely that the MatLab license prevented enough motivated people from
> > freely using MatLab in ways that were important to them?  Obviously,
> > it was important enough to enough people that they went and built the
> > GPLed Octave software, which now emulates MatLab very closely.
>
> I don't need to answer your question. It's obvious that the licence
> doesn't do much good when people seek to create a platform which is
> genuinely and irrevocably open as a response. That they have done so
> using the GPL pretty much sinks the previous ridiculous statement
> about the GPL, too.

That statement was made in the context of why Carl doesn't use GPL-
licensed *libraries*.  He and I have both explained the difference
between libraries and programs multiple times, not that you care.

> unless Octave is somehow a bad thing (which is
> what a certain vendor of proprietary statistics software would have
> you believe about a certain widely-used statistical analysis tool).
> 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 has been in no way
> demonstrated to be universally true that such contributors would
> contribute more than those who do so because of the copyleft
> licensing.

As I have said before, the availability of multiple (but not too
many!) licenses is a great thing, because each contributor can decide
how he wants to license his creation.  Finding the right license to
contribute under can only enhance the commons.

> The creators of Octave are obviously not willing to create
> (or help create) another system with all the proprietary limitations
> of MatLab, and why should they be willing?

I don't presume to know their motivations, or how the license got
chosen.  However, once it was under the GPL and there were multiple
contributors, it would certainly be difficult to relicense any other
way.

> The production of a
> different "proprietary flavour" of MatLab wouldn't be beneficial to
> them at all - it might even be detrimental to their project - and
> might only be marginally beneficial, at best, to existing MatLab
> customers.

I personally can't see any realistic chance of detriment.  How could a
proprietary clone hope to compete against free software on one side
and real matlab on the other side?  That's a no-win position, so I
wouldn't expect to see any proprietary clones.

> [PySide]
>
> > Just as there are a lot of proprietary programs that are relatively
> > useless and *won't* have any GPLed versions written, nobody's going to
> > waste time rewriting a marginally useful GPLed library just to put a
> > permissive license on it, either.
>
> Unless they really want to release (or encourage the creation of)
> proprietary software.

How does recreating something marginally useful encourage proprietary
software?  That's very confusing.

> which is precisely what PySide is all about.

No, PySide is about non-GPL software, and is released under a license
that even RMS recognizes as "free", and it is certainly not of
marginal utility.

> (And PyQt is not "marginally useful" - it is a widely-used and widely
> well-regarded library.)

Well, we agree on that.  But I don't know why you're trying to claim I
said PyQt was only marginally useful.

> And this apparent overriding need to support
> proprietary solutions results in different strategies, such as with
> the Chandler project: because the OSAF wanted to be able to sell
> proprietary solutions but didn't own all the code, they decided to
> pick only permissively licensed software for the components of the
> solution, resulting in a lot of extra effort expended in getting their
> user interface toolkit up to scratch. You can make your own mind up
> about whether that was a sensible strategy.

Large, high-risk projects are often going to fail and there will
always be some decisions that are easy to second-guess, correctly or
not.  In any case, if the goal was a particular method to get a ROI,
it may have been that they wouldn't have been able to do that at all
with the GPL, either.

> Usually, however, most people wanting to write proprietary software
> cannot be bothered to do the work to replicate an existing GPL-
> licensed solution (or even to significantly improve permissively
> licensed solutions).

Usually, most people wanting to write software can't be bothered to do
the work.  That's nothing new.  Yet occasionally people do some work,
and some projects make progress.

> They instead appeal to people to release already-
> mature permissively licensed software, typically waiting for someone
> with enough money or manpower to do most of the work for them.

Well, personally, I'm still wa

Re: Picking a license

2010-05-14 Thread Paul Boddie
On 14 Mai, 19:15, Patrick Maupin  wrote:
> On May 14, 11:48 am, Paul Boddie  wrote:
> > Section 3 of GPLv2 (and section 6(d) of GPLv3 reads similarly): "If
> > distribution of executable or object code is made by offering access
> > to copy from a designated place, then offering equivalent access to
> > copy the source code from the same place counts as distribution of the
> > source code, even though third parties are not compelled to copy the
> > source along with the object code."
>
> > And here's that FAQ entry which clarifies the intent:
>
> >http://www.gnu.org/licenses/gpl-faq.html#DistributeWithSourceOnInternet

[...]

> http://www.gnu.org/licenses/gpl-faq.html#UnchangedJustBinary

We're all aware of the obligation to provide source code. You've spent
the last few days complaining about it.

> > Like I said, if you really have a problem with Ubuntu shipping CDs and
> > exposing others to copyright infringement litigation.
>
> So, deliberately or not, you're trying to change the discussion
> again.  I *never* discussed Ubuntu shipping a physical CD, and never
> intimated that that was a problem.  My discussion was *always* about
> an individual *downloading* an ISO and *burning* a CD himself, then
> *distributing* the CD to someone else.

I am not changing the discussion at all. You are describing a
situation where someone gets the binaries but not the sources, but
according to the licence they should get both of those things
(ignoring written offers and the like), and this does apply to Ubuntu
since precisely this act of distribution (to use the older term) is
performed by them. That you then pass on the binaries without the
sources is an equivalent situation, ignoring for the moment that you
do not yourself have the sources either.

So, what are you supposed to do when the recipient "calls" you on the
lack of sources? (And, yes, clearly the FSF anticipates that not
everyone will request the sources because it is written in that very
excerpt I provide above.) If the recipient is strict about exact
compliance, you will have to provide the sources on CD to them. And
this makes sense: if they can only make use of the binaries if
provided on CD (and not, say, on an FTP site because they don't have
an Internet connection, for example), then they will need to receive
the sources in the same manner. Of course, the recipient may only
demand certain sources, not wishing to avail themself of the sources
for all copyleft-licensed packages in the binary distribution.

Now we return to the matter of getting the Ubuntu sources. If you
ordered a CD from Ubuntu via their ShipIt service, it is at this point
that you can demand a CD of corresponding sources. If they cannot
provide one, then obviously it poses a problem for your compliance
(and theirs, and you should see once again why Ubuntu's activities do
matter), but naturally Ubuntu provide parallel binary and source
repositories for all their packages. So, even if they were found not
to be in compliance according to the strictest interpretation of the
licence, it is technically possible for you to acquire the
corresponding sources and make them available to the person who was
given the CD. If you downloaded an ISO file, Ubuntu could (and do)
obviously provide source packages from the same location: their Web
site and various mirrors.

Really, if at this point you think I'm playing games with you, then
you really need to stop taking score and formulate the exact problem
you have with the distribution of Ubuntu-style media, because I'm
starting to think that the only real problem here is the one you have
with people using copyleft-style licences for their works. Since we've
had to hear about that over several days, I don't think that
articulating that particular problem once again really brings anything
more to the discussion.

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


Re: joining two column

2010-05-14 Thread Tim Chase

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




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


Re: Is Python a functional programming language?

2010-05-14 Thread Nobody
On Tue, 11 May 2010 18:31:03 -0700, Paul Rubin wrote:

>>> is called an "equation" rather than an "assignment".  It declares "x is
>>> equal to 3", rather than directing x to be set to 3.  If someplace else
>>> in the program you say "x = 4", that is an error, normally caught by
>>> the compiler, since x cannot be equal to both 3 and 4.
>>
>> In both ML and Haskell, bindings are explicitly scoped, i.e.
>>  let x = 3 in ...(Haskell)
> 
> I'm not talking about nested bindings.  I'm talking about two different
> bindings of the same symbol in the same scope:
> 
> $ cat meow.hs
> x = 3
> x = 4
> $ ghc meow.hs
> 
> meow.hs:2:0:
> Multiple declarations of `Main.x'
> Declared at: meow.hs:1:0
>  meow.hs:2:0

It may be worth noting the interactive behaviour:

$ ghci
GHCi, version 6.8.2: http://www.haskell.org/ghc/  :? for help
Loading package base ... linking ... done.
Prelude> let x = 7
Prelude> let f y = x + y
Prelude> f 3
10
Prelude> let x = 5
Prelude> f 3
10

The main point is that variables aren't mutable state.

An important secondary point is that, unlike Python, free (global)
variables in a function body are substituted when the function is defined,
not when it's called.

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


Re: Picking a license

2010-05-14 Thread Patrick Maupin
On May 14, 1:38 pm, Paul Boddie  wrote:
> On 14 Mai, 19:15, Patrick Maupin  wrote:
>
> > On May 14, 11:48 am, Paul Boddie  wrote:
> > > Section 3 of GPLv2 (and section 6(d) of GPLv3 reads similarly): "If
> > > distribution of executable or object code is made by offering access
> > > to copy from a designated place, then offering equivalent access to
> > > copy the source code from the same place counts as distribution of the
> > > source code, even though third parties are not compelled to copy the
> > > source along with the object code."
>
> > > And here's that FAQ entry which clarifies the intent:
>
> > >http://www.gnu.org/licenses/gpl-faq.html#DistributeWithSourceOnInternet
>
> [...]
>
> >http://www.gnu.org/licenses/gpl-faq.html#UnchangedJustBinary
>
> We're all aware of the obligation to provide source code. You've spent
> the last few days complaining about it.
>
> > > Like I said, if you really have a problem with Ubuntu shipping CDs and
> > > exposing others to copyright infringement litigation.
>
> > So, deliberately or not, you're trying to change the discussion
> > again.  I *never* discussed Ubuntu shipping a physical CD, and never
> > intimated that that was a problem.  My discussion was *always* about
> > an individual *downloading* an ISO and *burning* a CD himself, then
> > *distributing* the CD to someone else.
>
> I am not changing the discussion at all. You are describing a
> situation where someone gets the binaries but not the sources, but
> according to the licence they should get both of those things
> (ignoring written offers and the like), and this does apply to Ubuntu
> since precisely this act of distribution (to use the older term) is
> performed by them. That you then pass on the binaries without the
> sources is an equivalent situation, ignoring for the moment that you
> do not yourself have the sources either.

If Joe downloads and burns a CD for his friend, he may not have the
sources and may not have any intention of getting them, and probably
didn't provide a "written offer."  What you're "ignoring for the
moment" is my whole point, that unlike Ubuntu, Joe is now in violation
of the GPL license, because he provided neither a written offer nor
source on CD, nor his own download site.

> So, what are you supposed to do when the recipient "calls" you on the
> lack of sources?

There is possibly no "calling".  Since no source and no written offer
was delivered, Joe's friend may not know about the issue.  Even Joe
himself just saw it was "free software" and didn't read the fine
print, so he may not have a clue how to get the source.


>(And, yes, clearly the FSF anticipates that not
> everyone will request the sources because it is written in that very
> excerpt I provide above.)

Which Joe doesn't know about and didn't adhere to in any case.

> If the recipient is strict about exact
> compliance, you will have to provide the sources on CD to them.

That could be a year later, and Joe, who doesn't really even know
anything about source, is really going to have a hard time figuring
out exactly which sources went into the CD he downloaded that long
ago.

> And
> this makes sense: if they can only make use of the binaries if
> provided on CD (and not, say, on an FTP site because they don't have
> an Internet connection, for example), then they will need to receive
> the sources in the same manner.

To an extent it makes sense.  That's why I explained that I thought it
would be nice of Ubuntu to put a warning to Joe on their site
explaining the consequences of helping his friend out.  Of course,
since the warning would only serve to decrease object downloads, and
since Joe's friend doesn't really want the source anyway, there is no
real point.  That doesn't alter the fact that Joe is immediately in
violation of the GPL once he delivers the CD to his friend without the
written offer.

> Of course, the recipient may only
> demand certain sources, not wishing to avail themself of the sources
> for all copyleft-licensed packages in the binary distribution.

[ Stuff about ShipIt snipped because I was never discussing that.]

> Really, if at this point you think I'm playing games with you.

I don't know what to think about that.  Even after I've explicitly
said multiple times I'm not discussing when Ubuntu ships a CD, you
still felt compelled to include a big paragraph about ShipIt.  Is it
to confuse?  Or because have OCD?  I don't really know.

> then
> you really need to stop taking score and formulate the exact problem
> you have with the distribution of Ubuntu-style media,

I explained it fully multiple times.

> because I'm
> starting to think that the only real problem here is the one you have
> with people using copyleft-style licences for their works.

Well, as I have tried to explain, there are tradeoffs with any
license, including the GPL.  With the GPL, you can easily adhere to
the letter of the license by shipping source with object.  But
sometimes the source is so huge, peo

Re: Is Python a functional programming language?

2010-05-14 Thread Chris Rebert
On Fri, May 14, 2010 at 12:08 PM, Nobody  wrote:
> On Tue, 11 May 2010 18:31:03 -0700, Paul Rubin wrote:
 is called an "equation" rather than an "assignment".  It declares "x is
 equal to 3", rather than directing x to be set to 3.  If someplace else
 in the program you say "x = 4", that is an error, normally caught by
 the compiler, since x cannot be equal to both 3 and 4.
>>>
>>> In both ML and Haskell, bindings are explicitly scoped, i.e.
>>>      let x = 3 in ...        (Haskell)
>>
>> I'm not talking about nested bindings.  I'm talking about two different
>> bindings of the same symbol in the same scope:
>>
>>     $ cat meow.hs
>>     x = 3
>>     x = 4
>>     $ ghc meow.hs
>>
>>     meow.hs:2:0:
>>         Multiple declarations of `Main.x'
>>         Declared at: meow.hs:1:0
>>                      meow.hs:2:0
>
> It may be worth noting the interactive behaviour:
>
>        $ ghci
>        GHCi, version 6.8.2: http://www.haskell.org/ghc/  :? for help
>        Loading package base ... linking ... done.
>        Prelude> let x = 7
>        Prelude> let f y = x + y
>        Prelude> f 3
>        10
>        Prelude> let x = 5
>        Prelude> f 3
>        10

Ahem (emphasis mine):
"""
==This syntax is *ghci-specific*==
The syntax for 'let' that ghci accepts is not the same as we would use
at the “top level” of a normal Haskell program.
"""
-- http://book.realworldhaskell.org/read/getting-started.html

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Picking a license

2010-05-14 Thread Ed Keith
--- On Fri, 5/14/10, Paul Boddie  wrote:


<<< lots of stuff snipped >>>

> > > Like I said, if you really have a problem with
> Ubuntu shipping CDs and
> > > exposing others to copyright infringement
> litigation.


<<< A lot more stuff snipped >>>

Everyone is assuming a certain degree of computer savvy.

I have not installed Ubuntu, but I understand that they strive for ease of 
use, so I assume that if ant now, at some time in the near future, my 
farther, who knows very little about computers, could install it if I gave 
him a CD with it on it (He would never be able to burn it himself).

Supposes download the ISO image and burn a CD and give it to my father. 
(As I understand it I am now in violation of the GPL, but I may not be). 
My father installs it. He likes it, he gives it to a friend. 

Now suppose, just for the sake of argument, that Ubuntu forgets to renew 
their domain name and it gets taken over by a porn site (It happens to Web 
mechanic, it could happen to anyone). If my father's friend's teenage son 
wants the source code, he can not get it from his father, who does not 
even know what source code is. He does not know that I exist, because his 
father forgot where he got the disk. He can not get the source from the 
porn site. 

Clearly someone has violated the GPL, but I'm not sure who, I think it was me, 
but I may be wrong. If not me who? My father for giving the disk I gave him to 
a friend? My father's friend for not keeping track of who gave him the disk? 
Ubuntu, for not including the source in the ISO image I downloaded? or for 
allowing a porn site to take over their domain name?

It is questions like this that make me steer clear of the GPL. If I give 
my father a CD of Microsoft software, I know I'm breaking the law. If I 
give my father a CD of BSD software licensed software I'm on firm legal 
ground. If I give my father a CD of GPLed software, I'm on shaky ground 
unless I include all the source, which he has no use for, on a second 
disk. And if he give his friend the binary disk, but not the source disk 
(which is of no value to him or his friend), then he is in violation of 
the law, and he cannot even understand why.

The GPL is fine when all parties concern understand what source code is 
and what to do with it. But when you add people like my father to the loop 
if gets very ugly very fast.

-EdK

Ed Keith
[email protected]

Blog: edkeith.blogspot.com



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


Re: Is Python a functional programming language?

2010-05-14 Thread Nobody
On Thu, 13 May 2010 12:29:08 +1200, Lawrence D'Oliveiro wrote:

>> Some people would prefer to have a manageable set of rules rather than
>> having to remember the results of all of the possible combinations of
>> interactions between language features.
> 
> What are you accusing Python of, exactly?

I'm not accusing it of anything, exactly. I'm just pointing out that there
are entirely pragmatic reasons for disliking "multi-paradigm" languages.

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


Re: write a 20GB file

2010-05-14 Thread Nobody
On Fri, 14 May 2010 10:50:49 -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.


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


Re: joining two column

2010-05-14 Thread James Mills
On Sat, May 15, 2010 at 4:46 AM, Tim Chase
 wrote:
> 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

You're quite right! My mistake :)

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


Re: Picking a license

2010-05-14 Thread Paul Boddie
On 14 Mai, 20:36, Patrick Maupin  wrote:
>
> That statement was made in the context of why Carl doesn't use GPL-
> licensed *libraries*.  He and I have both explained the difference
> between libraries and programs multiple times, not that you care.

Saying that GPL-licensed applications are acceptable is a minor
concession to the use of copyleft licensing if one advocates
permissive licensing for all things which are not perceived to be
finished products: things that one isn't looking to re-use somehow.
Saying that one likes Octave and that it uses the GPL, too, is really
damning it with faint praise if one were then to say that its parts
should be permissively licensed so that one can incorporate its
functionality into something else. No, I don't care if you have a
problem with GPL-licensed libraries because it is, as we have
established repeatedly, your problem not mine.

[...]

> > The production of a
> > different "proprietary flavour" of MatLab wouldn't be beneficial to
> > them at all - it might even be detrimental to their project - and
> > might only be marginally beneficial, at best, to existing MatLab
> > customers.
>
> I personally can't see any realistic chance of detriment.  How could a
> proprietary clone hope to compete against free software on one side
> and real matlab on the other side?  That's a no-win position, so I
> wouldn't expect to see any proprietary clones.

Well, only permissively licensed software would encourage such clones.
At that point, there are incentives for people to develop
functionality for proprietary deployment instead of for the upstream
project.

[PySide and proprietary software]

> No, PySide is about non-GPL software, and is released under a license
> that even RMS recognizes as "free", and it is certainly not of
> marginal utility.

No, PySide is about permitting the development of proprietary
applications by providing a solution to the all-important "ISVs" which
lets them develop and deploy proprietary software. Do you really think
a platform vendor whose "ISVs" routinely ship proprietary software on
their platform and on other platforms, and who will demand the ability
to continue to do so, now expects all these "ISVs" to provide their
applications under the modified BSD licence? Sure, other developers
can use the software - even people releasing GPL-licensed software -
but that is highly unlikely to be the primary business motivation. If
you think the mobile telephony vendors are a bunch of fluffy bunny
rabbits playing with each other in sugary meadows of niceness, I don't
want to be present when someone directly and finally disabuses you of
this belief. It's all about people selling stuff to "consumers" over
and over again, preferably with the "consumers" rarely if ever being
able to opt-out and do things their own way.

> > (And PyQt is not "marginally useful" - it is a widely-used and widely
> > well-regarded library.)
>
> Well, we agree on that.  But I don't know why you're trying to claim I
> said PyQt was only marginally useful.

Because you followed on from writing about PyQt by introducing the
topic of "marginally useful" libraries, thus giving the impression
that you regarded PyQt as "marginally useful".

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


Including a remote file -- permission denied?

2010-05-14 Thread Aaron Scott
I have a Python script running on the default OSX webserver, stored
in /Library/WebServer/CGI-Executables. That script spits out a list of
files on a network drive, a la "os.listdir('/Volumes/code/
directory/')". If I just execute this from the terminal, it works as
expected, but when I try to access it through a browser
(computer.local/cgi-bin/test.py), I get a permissions error (: [Errno 13] Permission denied: '/Volumes/code/
directory').

Is there any way to give the script permission to access the network
when accessed via CGI?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Picking a license

2010-05-14 Thread Ed Keith
--- On Fri, 5/14/10, Paul Boddie  wrote:


<<<>>
> 
> No, PySide is about permitting the development of
> proprietary
> applications by providing a solution to the all-important
> "ISVs" which
> lets them develop and deploy proprietary software. Do you
> really think
> a platform vendor whose "ISVs" routinely ship proprietary
> software on
> their platform and on other platforms, and who will demand
> the ability
> to continue to do so, now expects all these "ISVs" to
> provide their
> applications under the modified BSD licence? Sure, other
> developers
> can use the software - even people releasing GPL-licensed
> software -
> but that is highly unlikely to be the primary business
> motivation. If
> you think the mobile telephony vendors are a bunch of
> fluffy bunny
> rabbits playing with each other in sugary meadows of
> niceness, I don't
> want to be present when someone directly and finally
> disabuses you of
> this belief. It's all about people selling stuff to
> "consumers" over
> and over again, preferably with the "consumers" rarely if
> ever being
> able to opt-out and do things their own way.

Do you feel the same way about Python? It is released under a 
nonrestrictive license, since you are on this list I assume you use it.

If you want, I think you could use the existing Python code base to create 
a GPLed version of Python, I think the license is permissive enough to 
allow that. If you did, do you think more people would use the GPLed 
version? 

Personally, I would use the version with the more permissive license, unless 
the GPLed version offered a significant advantage of some kind.

 -EdK

Ed Keith
[email protected]

Blog: edkeith.blogspot.com





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


Re: Picking a license

2010-05-14 Thread Patrick Maupin
On May 14, 2:26 pm, Paul Boddie  wrote:
> On 14 Mai, 20:36, Patrick Maupin  wrote:
>
>
>
> > That statement was made in the context of why Carl doesn't use GPL-
> > licensed *libraries*.  He and I have both explained the difference
> > between libraries and programs multiple times, not that you care.
>
> Saying that GPL-licensed applications are acceptable is a minor
> concession to the use of copyleft licensing if one advocates
> permissive licensing for all things which are not perceived to be
> finished products: things that one isn't looking to re-use somehow.

I am only "advocating" to the extent of explaining why I license stuff
permissively, and why, whenever I incorporate other stuff, it has to
be licensed permissively as well.  How you license your stuff is your
business.

> Saying that one likes Octave and that it uses the GPL

I don't recall saying I liked Octave.  I have no opinion.  I have
never used it.  Just threw it out there as an example of how people
rewrite proprietary software to counter your indignation that somebody
would rewrite PyQt.

> damning it with faint praise if one were then to say that its parts
> should be permissively licensed so that one can incorporate its
> functionality into something else.

I'm not operating a chop shop.  Never even had cause to look at the
source.  I really don't care about it.

> No, I don't care if you have a
> problem with GPL-licensed libraries because it is, as we have
> established repeatedly, your problem not mine.

Sure, the problems that I see with the GPL lead me to choose non-GPL
solutions for libraries.  And I never asked you to care.  I had a
brief moment of hope that you could see that my concerns were valid,
if personal, but apparently you can only concede that if you attribute
some sort of selfish ill-will to me.

> > I personally can't see any realistic chance of detriment.  How could a
> > proprietary clone hope to compete against free software on one side
> > and real matlab on the other side?  That's a no-win position, so I
> > wouldn't expect to see any proprietary clones.
>
> Well, only permissively licensed software would encourage such clones.

See, there you go with choice of language again.  Remember, we're both
biased with different viewpoints.  You say "encourage"; I say
"allow."  I further argued that it's immaterial that it's allowed,
nobody sane would do it.

> At that point, there are incentives for people to develop
> functionality for proprietary deployment instead of for the upstream
> project.

What incentives?  The incentives that the original matlab team will
keep outcompeting you from the top, or the incentives that the open
source octave team will keep outcompeting you from the bottom?

> [PySide and proprietary software]
>
> > No, PySide is about non-GPL software, and is released under a license
> > that even RMS recognizes as "free", and it is certainly not of
> > marginal utility.
>
> No, PySide is about permitting the development of proprietary
> applications by providing a solution to the all-important "ISVs" which
> lets them develop and deploy proprietary software.

That's an interesting viewpoint.  Originally, both Qt and PyQt were
available dual-licensed under the GPL or proprietary licenses.  For
anybody serious about proprietary development, the proprietary
licensed versions were actually quite reasonably priced.  Really the
major advantage I see in PySide licensing is for somebody like Ed or
Carl or me, who simply wants to be able to deliver programs with no
strings attached.  That was not possible under the GPL-licensed
version (because of the strings attaching to the customer that Ed has
talked about) or the commercial version (because then Ed couldn't even
give his customer the source to PyQt).  PySide is LGPL, which Ed still
might not touch, but at least any "linking" required between that and
code that uses it is really just an import statement, so then again,
he might be OK with that.

Of course, the fact that Qt and PySide are now both free of cost for
non-GPL customers certainly helps Nokia in their push to get people to
take them.

> Do you really think
> a platform vendor whose "ISVs" routinely ship proprietary software on
> their platform and on other platforms, and who will demand the ability
> to continue to do so, now expects all these "ISVs" to provide their
> applications under the modified BSD licence?

Not at all.  But they have now *enabled* ISVs to do that.  Before,
with QT and PyQt, it was GPL or proprietary.

> Sure, other developers
> can use the software - even people releasing GPL-licensed software -
> but that is highly unlikely to be the primary business motivation.

I think the motivation was to remove all impediments to using it on
the platform, and I see nothing wrong with that motivation.  They
already spent a lot on Qt, and they really want to leverage that.

> If
> you think the mobile telephony vendors are a bunch of fluffy bunny
> rabbits playing with each other i

Re: parsing XML

2010-05-14 Thread Stefan Behnel

Martin v. Loewis, 14.05.2010 17:15:

[email protected] 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


Homework?


I would hope that every school teacher who teaches Python is able to skip 
through c.l.py and the python-tutor list before accepting a homework result.


Stefan

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


Re: Iterating over dict and removing some elements

2010-05-14 Thread Paul Rubin
Bryan  writes:
> In Python 3.X, and in Python 2.X starting with 2.4, you can drop the
> square brackets and avoid creating an extra temporary list:
>
> d = dict((k, d[k]) for k in d.keys() if not foo(k, d))

In 2.x, I think you want d.iterkeys() rather than d.keys() to avoid
making a list with all the keys.  Or you can just say

  d = dict((k, d[k]) for k in d if not foo(k, d))
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: parsing XML

2010-05-14 Thread Adam Tauno Williams
On Fri, 2010-05-14 at 22:17 +0200, Stefan Behnel wrote:
> >> 
> >>
> >>  17.1
> >>  6.4
> >>
> >>
> >>  15.5
> >>  7.8
> >>
> >>  

from lxml import etree
handle = open('file', 'rb')
doc = etree.parse(handle)
handle.close()
players = [ ]
for player in doc.xpath('/team/player'):
  players.append({ 'name': player.xpath('./@name')[0],
   'age': player.xpath('./@age')[0],
   'height': player.xpath('./@height')[0] } )
print players
-- 
Adam Tauno Williams  LPIC-1, Novell CLA

OpenGroupware, Cyrus IMAPd, Postfix, OpenLDAP, Samba

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


Re: Loading C extension from memory

2010-05-14 Thread Martin v. Loewis

> I wonder if there is a way to load C extension from in-memory object,
> not from the file on the disk?
> 
> I'm asking bc I would like to download C extensions over network and
> load them into Python interpreter (without storing the C extension in
> file on the disk).
> 
> I googled for this but there appear only methods of loading compiled
> Python (bytecode) modules.

First, it depends on your operating system. None of the standard
operating systems supports loading shared libraries from memory; they
all need a file name.

Of course, your operating system may provide support for RAM disks. So
if you store the extension onto a RAM disk, you can load it from there -
from memory.

It may be possible to extend the Python interpreter to not rely on
shared libraries anymore for extension modules. Such an interpreter
likely wouldn't use standard shared libraries anymore, so you might
then have to recompile the extensions to make them loadable from memory.
However, it also might be possible to reimplement the shared library
loader of the operating system, in which case you could then run
regular extension modules directly from memory.

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


Re: parsing XML

2010-05-14 Thread Martin v. Loewis
>>> 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
>>
>> Homework?
> 
> I would hope that every school teacher who teaches Python is able to
> skip through c.l.py and the python-tutor list before accepting a
> homework result.

If he uses your proposed solution, it probably wouldn't pass, anyway,
because it's neither DOM nor SAX. If he's really interested in a
solution to the original problem, then ElementTree is fine, of course.

As for teachers scanning relevant forums: that's often impractical.
For example, for an XML lecture, choice of programming language may be
to the student. You then have to search web forums, mailing lists, and
newsgroups for Java, Python, C#, Ruby, Scala, plus StackOverflow.

Solutions copied from the net often show a level of cuteness beyond
what you'd expect from a student (like your solution: who'd be using
reflection to access three attributes?). So you rather take these clues
as the starting point for an investigation (and then hope that Google
comes up with the specific source code).

Of course, it may also be that getting help is explicitly allowed.

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


Alternate string object type for PyStringObject(available Python 2.x) in python 3.x?

2010-05-14 Thread MathanK
What is the replacement in python 3.x for PyStringObject which is available in 
python 2.x?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: write a 20GB file

2010-05-14 Thread J
On Fri, May 14, 2010 at 15:23, Nobody  wrote:
> On Fri, 14 May 2010 10:50:49 -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

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


Re: Alternate string object type for PyStringObject(available Python 2.x) in python 3.x?

2010-05-14 Thread Chris Rebert
On Fri, May 14, 2010 at 10:15 AM, MathanK  wrote:
> What is the replacement in python 3.x for PyStringObject which is available
> in python 2.x?

PyUnicodeObject or PyBytesObject depending on your use case.

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Picking a license

2010-05-14 Thread Paul Boddie
On 14 Mai, 22:12, Patrick Maupin  wrote:
>
> I *obviously*
> was explaining that projects which *aren't* marginal, such as PyQt and
> MatLab, are the *only* kinds of projects that would be rewritten for a
> simple license change.

"As far as your comments about PyQt proving out the concept, well duh!
Just as there are a lot of proprietary programs that are relatively
useless and *won't* have any GPLed versions written, nobody's going to
waste time rewriting a marginally useful GPLed library just to put a
permissive license on it, either."

This being the sudden introduction of this notion of a "marginally
useful" library. And for a long time no-one did rewrite PyQt for the
purpose of having a permissively licensed library, so it's quite
natural to assume that you're saying that until PySide came along, the
reasons for which I have already noted, PyQt was a "marginally useful"
library, not worth rewriting.

> You really should slow down and read a bit more carefully.

You might want to tone down the condescension.

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


Re: Picking a license

2010-05-14 Thread Paul Boddie
On 14 Mai, 21:14, Patrick Maupin  wrote:
>
> If Joe downloads and burns a CD for his friend, he may not have the
> sources and may not have any intention of getting them, and probably
> didn't provide a "written offer."  What you're "ignoring for the
> moment" is my whole point, that unlike Ubuntu, Joe is now in violation
> of the GPL license, because he provided neither a written offer nor
> source on CD, nor his own download site.

Now, wait a moment! Your point is that just by giving the binary CD to
someone, you are now in violation of the licence. What I tried to
explain is that this situation is anticipated - that the FSF
acknowledges that the recipient won't have received the sources at the
same time in all situations - and that the same distributor is
responsible for providing the sources. As long as they don't deny the
recipient access to the sources, by the same means, they are not
violating the licence.

You have a point about recipients not being immediately and obviously
informed of the things they are entitled to, but that is a matter for
the distributing parties to remedy: that is arguably what happens
when, upon loud squealing about matters of "ideology", distributors
decide to de-emphasise the Free Software aspect of their
distributions. Nevertheless, it is my understanding that anyone
attempting to use or install such distributions do get to see a
summary of the licences; only people who pass on the software without
inspecting it (which would involve actually inserting the CD and
booting from it) will be unaware of its contents, and they could only
be held responsible as reasonably as one's Internet service provider
if that party were asked to provide source packages for "that Linux
distro I downloaded last year".

You also have a point about whether people are able to provide sources
at a later date, which might be troublesome if someone gave someone
else a CD with an old version of Ubuntu on it and then were asked to
provide the source packages. Naturally, the FSF have attempted to
address these points in version 3 of the GPL. I would be interested to
hear the opinion of the FSF and distributors on this matter, but I
think it's absurd to accuse the FSF as operating as you allege
Microsoft do, especially as the distributors are the ones who
encourage the sharing of the installation media.

Really, if you think distributions should do a better job at educating
their users and helping them uphold any obligations that may apply to
them, you should talk to them about it. But when I attempt to work
though the issues in a thorough manner in order to thrash out what it
is you really object to - and in practice, the only objections you can
seriously have lie in those two points I mention above (not this
"instant violation" situation, discussed in more detail elsewhere [*])
- and all you can do is suggest that other people are trying to
mislead you, I struggle to feel inclined to indulge you further.

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.

Paul

[*] http://www.mail-archive.com/[email protected]/msg31466.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Picking a license

2010-05-14 Thread Paul Boddie
On 14 Mai, 21:18, Ed Keith  wrote:
>
> The GPL is fine when all parties concern understand what source code is
> and what to do with it. But when you add people like my father to the loop
> if gets very ugly very fast.

Sure, and when I'm not otherwise being accused of pushing one
apparently rather unpopular man's agenda, I am interested in knowing
what the best practices should be and how they can be followed more
widely.

Although Bill Gates once apparently claimed that no-one needs the
source code for their word processor or office suite, there are still
benefits in people like your father having access to the sources, even
if this obviously means that he isn't going to recompile it himself:
he can get others to fix things, particularly if his favourite version
is no longer widely supported; if you were from a part of the planet
where you were comfortable with a widely-spoken "global" language but
your father could only converse in a less widely-spoken "minority"
language not generally supported by such software, someone (perhaps
you) could undertake the task of translating that software.

Whether or not one is comfortable with copyleft-style licences, there
clearly is a benefit in providing access to software governed by those
licences. Being able to do so responsibly is obviously a prerequisite
to feeling comfortable about it.

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


huh??? weird problem

2010-05-14 Thread cerr
Hi There,

I got following code:
start=time.time()
print 'warnTimeout '+str(WarnTimeout)
print 'critTimeout '+str(CritTimeout)
print 'start',str(start)
while wait:
passed =  time.time()-start
print 'passed ',str(passed)
if passed >= WarnTimeout:
  print ' Warning!'
 ...
...
...
which basically means that the loops should go until the warning time
has been reached and then i want it to print 'warning!' and execute
some warning code. But weirdly enough i get following screen output:
warnTimeout 3
critTimeout 5
start 1273882010.43
passed  7.60555267334e-05
passed  0.998471975327
passed  1.99847102165
passed  2.9984691143
passed  3.99847006798
passed  4.998472929
...
...
any one a clue why after 3 seconds it doesn't go into the the if an
print 'Warning!'? That's odd... :o Crazy, what am i not seeing? :(
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Picking a license

2010-05-14 Thread Terry Reedy

The following lines from

http://www.softwarefreedom.org/resources/2008/compliance-guide.html

seem to cover the case of someone who casually redistributes, for free, 
Ubuntu or whatever. Such can refer people back to the Ubuntu site. They 
should, perhaps, be familiar with the url, but I would expect that the 
binary Ubuntu distribution CDs have the appropriate offer and details on 
that disk. Someone who casually distributes, for free, a subset should 
also be covered. Under 4.1.2  Option (b): The Offer,


"The option to provide an offer for source rather than direct source 
distribution is a special benefit to companies equipped to handle a 
fulfillment process. GPLv2 § 3(c) and GPLv3 § 6(c) avoid burdening 
noncommercial, occasional redistributors with fulfillment request 
obligations by allowing them to pass along the offer for source as they 
received it.


Note that commercial redistributors cannot avail themselves of the 
option (c) exception, and so while your offer for source must be good to 
anyone who receives the offer (under v2) or the object code (under v3), 
it cannot extinguish the obligations of anyone who commercially 
redistributes your product. The license terms apply to anyone who 
distributes GPL’d software, "


Terry Jan Reedy


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


Puzzled by code pages

2010-05-14 Thread Adam Tauno Williams
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'

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'


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


Re: huh??? weird problem

2010-05-14 Thread Chris Rebert
On Fri, May 14, 2010 at 5:14 PM, cerr  wrote:
> Hi There,
>
> I got following code:
> start=time.time()
> print 'warnTimeout '+str(WarnTimeout)
> print 'critTimeout '+str(CritTimeout)
> print 'start',str(start)
> while wait:
>    passed =  time.time()-start
>    print 'passed ',str(passed)
>    if passed >= WarnTimeout:
>      print ' Warning!'
>  ...
> ...
> ...
> which basically means that the loops should go until the warning time
> has been reached and then i want it to print 'warning!' and execute
> some warning code. But weirdly enough i get following screen output:
> warnTimeout 3
> critTimeout 5
> start 1273882010.43
> passed  7.60555267334e-05
> passed  0.998471975327
> passed  1.99847102165
> passed  2.9984691143
> passed  3.99847006798
> passed  4.998472929
> ...
> ...
> any one a clue why after 3 seconds it doesn't go into the the if an
> print 'Warning!'? That's odd... :o Crazy, what am i not seeing? :(

print type(WarnTimeout)

I suspect it won't be numerical. Where is WarnTimeout assigned its value?
Note that in Python 2.x, comparisons between e.g. numbers and strings
were allowed, but the ordering was arbitrary.
Python 3.x fixes this and instead raises TypeError for such
nonsensical comparisons.

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Picking a license

2010-05-14 Thread Carl Banks
On May 14, 8:20 am, Paul Boddie  wrote:
> On 14 Mai, 09:08, Carl Banks  wrote:
>
> > On May 13, 10:59 pm, Steven D'Aprano  
> > wrote:
> > > On Thu, 13 May 2010 17:18:47 -0700, Carl Banks wrote:
> > > > 2. Reimplment the functionality seperately (*cough* PySide)
>
> > > Yes. So what? In what possible way is this an argument against the GPL?
>
> [...]
>
> > It's not.  It's an argument that the GPL doesn't do much good.
>
> Right. So nobody got the benefit from Qt under the GPL or PyQt under
> the GPL?

[Snip a bunch of crap I don't care about]

The community as a whole benefited from PyQt because it was free, not
because it was GPL.  The community as whole suffered because it was
GPL instead of a more permissive license.

Now that we have PySide the community as a whole will benefit much,
much more than it could with only a GPLed PyQt.


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


Re: Picking a license

2010-05-14 Thread Patrick Maupin
On May 14, 6:42 pm, Paul Boddie  wrote:

> > You really should slow down and read a bit more carefully.
>
> You might want to tone down the condescension.

I didn't start out condescending, and I agree I could have worded this
particular statement a bit more clearly, so I apologize for that, but
I can point to at least 5 or 6 occurrences of you misreading me when I
stated things very clearly.  It's really starting to get old.

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


Re: Puzzled by code pages

2010-05-14 Thread Adam Tauno Williams
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:
> 
> >>> handle = open('file.txt', 'rb')
> >>> data = handle.read()
> >>> handle.close()
> >>> data
> '"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-?

Typical, 30 seconds after giving up and posting a message... I find the
problem.

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

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


Re: huh??? weird problem

2010-05-14 Thread Mensanator
On May 14, 7:14 pm, cerr  wrote:
> Hi There,
>
> I got following code:
> start=time.time()
> print 'warnTimeout '+str(WarnTimeout)
> print 'critTimeout '+str(CritTimeout)
> print 'start',str(start)
> while wait:
>     passed =  time.time()-start
>     print 'passed ',str(passed)
>     if passed >= WarnTimeout:
>       print ' Warning!'
>  ...
> ...
> ...
> which basically means that the loops should go until the warning time
> has been reached and then i want it to print 'warning!' and execute
> some warning code. But weirdly enough i get following screen output:
> warnTimeout 3
> critTimeout 5
> start 1273882010.43
> passed  7.60555267334e-05
> passed  0.998471975327
> passed  1.99847102165
> passed  2.9984691143
> passed  3.99847006798
> passed  4.998472929
> ...
> ...
> any one a clue why after 3 seconds it doesn't go into the the if an
> print 'Warning!'?

Works for me:

warnTimeout 3
critTimeout 5
start 1273883378.39
passed  1.0
passed  2.0
passed  3.0
 Warning!
passed  4.0
 Warning!
passed  5.0
 Warning!
passed  6.0
 Warning!
passed  7.0
 Warning!


> That's odd... :o Crazy, what am i not seeing? :(

Did you copy it right?

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


Re: Picking a license

2010-05-14 Thread Patrick Maupin
On May 14, 7:24 pm, Terry Reedy  wrote:
>
> "The option to provide an offer for source rather than direct source
> distribution is a special benefit to companies equipped to handle a
> fulfillment process. GPLv2 § 3(c) and GPLv3 § 6(c) avoid burdening
> noncommercial, occasional redistributors with fulfillment request
> obligations by allowing them to pass along the offer for source as they
> received it.

Paul Boddie already pointed out that document.  As I explained, that
document was written for the Ciscos of the world.  The FAQ, which was
written for you and me states very clearly "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." in answer
to the question "I downloaded just the binary from the net. If I
distribute copies, do I have to get the source and distribute that
too?"

As I have pointed out on at least 3 posts by now, this FAQ
interpretation derives directly from the actual license terms and
appears to reflect the terms correctly. If you actually *read* GPLv3 §
6(c), it *only* applies if you received the object code in accordance
with GPLv3 § 6(b).  But if you download an ISO from Ubuntu, that
happens under GPLv3 § 6(d), *not* GPLv3 § 6(b).

However, the distribution to your friend when you give him the CD that
you burned for him is under 6(b), so not only do you not have an
upstream to rely on, you are actually in violation of the license once
you give him the CD without your own written offer!  (At one level,
this makes sense -- if the 3 year window for source is to have any
teeth, then you can't give the poor guy a CD 2 years after you
downloaded it and expect Ubuntu to make good on the source 5 years
after you downloaded it.)

Now maybe there is some *other* way (besides the obvious ways I've
mentioned such as fair use and the fact that nobody's going to sue
because of the PR fallout from bothering some grandma for sharing a CD
that was advertised as "free") that this is not an issue, but nobody
on this thread has yet shown any credible evidence that the act of
just handing somebody a freshly burned Ubuntu CD with no written offer
is not a violation of the license.

As I have made clear, I do not view this as a direct practical
problem.  But I do view it as a huge problem that the license is so
complex that in a couple of days of conversing about it, several
people have asserted that there is no way my reading of the license is
correct, yet nobody has shown solid evidence that would back up an
alternate reading, and I also view it as the tip of the iceberg as far
as the issue of license compliance goes.

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


Re: huh??? weird problem

2010-05-14 Thread Dave Angel

cerr wrote:

Hi There,

I got following code:
start=time.time()
print 'warnTimeout '+str(WarnTimeout)
print 'critTimeout '+str(CritTimeout)
print 'start',str(start)
while wait:
passed =  time.time()-start
print 'passed ',str(passed)
if passed >= WarnTimeout:
  print ' Warning!'
 ...
...
...
which basically means that the loops should go until the warning time
has been reached and then i want it to print 'warning!' and execute
some warning code. But weirdly enough i get following screen output:
warnTimeout 3
critTimeout 5
start 1273882010.43
passed  7.60555267334e-05
passed  0.998471975327
passed  1.99847102165
passed  2.9984691143
passed  3.99847006798
passed  4.998472929
...
...
any one a clue why after 3 seconds it doesn't go into the the if an
print 'Warning!'? That's odd... :o Crazy, what am i not seeing? :(

  
we're not seeing all the relevant code.  While I can ignore the missing 
import, I don't see any creation of the variables WarnTimeout and 
CritTimeout.  Simplest explanation that fits your sample run is that 
they are not of type float.


DaveA

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


Re: Picking a license

2010-05-14 Thread Patrick Maupin
On May 14, 6:52 pm, Paul Boddie  wrote:
> On 14 Mai, 21:14, Patrick Maupin  wrote:
>
> > If Joe downloads and burns a CD for his friend, he may not have the
> > sources and may not have any intention of getting them, and probably
> > didn't provide a "written offer."  What you're "ignoring for the
> > moment" is my whole point, that unlike Ubuntu, Joe is now in violation
> > of the GPL license, because he provided neither a written offer nor
> > source on CD, nor his own download site.
>
> Now, wait a moment! Your point is that just by giving the binary CD to
> someone, you are now in violation of the licence.

Correct -- download an ISO, burn onto CD, hand CD to friend w/o
written offer = license violation.

> What I tried to
> explain is that this situation is anticipated - that the FSF
> acknowledges that the recipient won't have received the sources at the
> same time in all situations - and that the same distributor is
> responsible for providing the sources.

Right.  That distributor would be Joe.

> As long as they don't deny the
> recipient access to the sources, by the same means, they are not
> violating the licence.

But Joe didn't give a written offer, and he doesn't even know how to
download the source, and you still haven't showed why that's not a
problem for him.

> You have a point about recipients not being immediately and obviously
> informed of the things they are entitled to, but that is a matter for
> the distributing parties to remedy:

Well, Joe's the distributor to his friend.  He got the stuff from
Ubuntu, who will give him source and even have a legal page about it,
but Joe didn't bother reading all that stuff.

> that is arguably what happens
> when, upon loud squealing about matters of "ideology", distributors
> decide to de-emphasise the Free Software aspect of their
> distributions.

Yesterday, you were telling me I should inform Ubuntu that they didn't
have enough license information prominently available in the right
places.  Are you now claiming that that's simply because people like
me told Ubuntu that they were emphasizing the license information too
much?

In any case, Ubuntu prominently describes "The Ubuntu Promise" with a
link to more information from their front page.  Of course, the
download button is prominent as well.

> Nevertheless, it is my understanding that anyone
> attempting to use or install such distributions do get to see a
> summary of the licences;

Yes, and we all know that everybody has been trained to fully read and
understand every single license the click on when installing software.

> only people who pass on the software without
> inspecting it (which would involve actually inserting the CD and
> booting from it) will be unaware of its contents,

Well, to make what I said in my previous comment more clear, I believe
that Joe would have actually installed the software himself without
bothering to read the license.  This may be foolish of Joe, but he is
in excellent company -- in one recent unscientific yet (IMO) well-
constructed study, only 12% of users bothered to read the license at
all:

http://www.huffingtonpost.com/2010/04/17/gamestation-grabs-souls-o_n_541549.html

> and they could only
> be held responsible as reasonably as one's Internet service provider
> if that party were asked to provide source packages for "that Linux
> distro I downloaded last year".

You still haven't yet provided any credible evidence for this version
of the chain of responsibility.  But in any case, I suspect Joe would
have actually installed the software without bothering to read any
license information.

> You also have a point about whether people are able to provide sources
> at a later date, which might be troublesome if someone gave someone
> else a CD with an old version of Ubuntu on it and then were asked to
> provide the source packages.

Bingo!  My hypothetical Joe would be in serious hot water at this
point.

> Naturally, the FSF have attempted to
> address these points in version 3 of the GPL.

And I submit that they addressed the problem by making it really clear
that yes, it is Joe's responsibility, in section 6.

> I would be interested to
> hear the opinion of the FSF and distributors on this matter, but I
> think it's absurd to accuse the FSF as operating as you allege
> Microsoft do, especially as the distributors are the ones who
> encourage the sharing of the installation media.

Well, it's really the entire ecosystem. I have to believe that
everybody at the FSF knows how this works, and even though RMS is a
shrinking violet, I suspect that if he seriously cared about this, he
would work up the courage to address it publicly, much as it pains him
to share his opinions.

> Really, if you think distributions should do a better job at educating
> their users and helping them uphold any obligations that may apply to
> them, you should talk to them about it.

I seriously don't think they, or the FSF, are interested in this, and
I don't think they 

Re: parsing XML

2010-05-14 Thread Lawrence D'Oliveiro
In message , Stefan 
Behnel wrote:

> Here's an overly complicated solution, but I thought that an object
> oriented design would help here.

How many times are you going to write the “"name", "age", "height"” 
sequence? The next assignment question I would ask is: how easy would it be 
to add a fourth attribute?

>attributes = ['name', 'age', 'height']

I would put this at the top.

Then this

>class Player(object):
>   def __init__(self, name, age, height):
>   self.name, self.age, self.height = name, age, height

can become

class Player(object):
   def __init__(self, **rest):
   for attr in attributes :
   setattr(self, attr, rest[attr])
   #end for
   #end __init__
#end Player

and

>for player in players:
>print player.name, player.age, player.height

can become

for player in players:
print " ".join(getattr(player, attr) for attr in attributes)
#end for

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


Re: Broken pipe

2010-05-14 Thread Lawrence D'Oliveiro
In message <[email protected]>, 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?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Picking a license

2010-05-14 Thread Lawrence D'Oliveiro
In message <84a26d03-03b3-47d9-
[email protected]>, Patrick Maupin wrote:

> I also firmly believe, as I have stated before, that the GPL is a much
> more commercial license.  If you want to make money off something,
> then, no doubt, GPL keeps your competitors from being able to take
> what you wrote and redistribute it as closed source.  But, frankly I
> view that as more of a business issue than a moral issue.

Nevertheless, it’s probably a big factor in why the GPL has become the 
single most popular open-source licence.
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   >