ANNOUNCE: Kamaelia 0.1.2 Released

2005-04-13 Thread Michael Sparks
Kamaelia 0.1.2 has been released!


What is it?
===
Kamaelia is a collection of Axon components designed for network
protocol experimentation in a single threaded, select based environment.
Axon components are python generators are augmented by inbox and outbox
queues (lists) for communication in a communicating sequential processes
(CSP) like fashion.

The architecture is specifically designed to try and simplify the
process of designing and experimenting with new network protocols in
real environments.

This release contains components allowing the creation of TCP based
clients and servers, and includes a few (very) simple protocol handlers
to show usage.

Other components include vorbis decode and playback, asynchronous file
reading, and equivalents of tee and strings. (Writing systems is
much like building unix pipelines, hence the need for similar tools)

The system is known to work under Linux, Mac OS X, Windows and a subset
works on Series 60 mobiles.

We've also started a weblog which will form an informal discussion forum
for issues generally surrounding kamaelia. (We might put things like
tutorials there for example)
   * http://kamaelia.sourceforge.net/cgi-bin/bl


What's new in version 0.1.2 ?
=

Additionally tested under Windows ME, 2000 and Mac OS X, along with
a subset tested on Series 60 mobiles and compatibility updates made
as a result. Ability to make simple multicast servers, clients and
transceivers added. Test harnesses for network servers tightened up.

Collection of examples added in the Examples directory:
   * Example 1 : Contains a simple FortuneCookie protocol system.
 Includes a server and client as part of a single system.

   * Example 2 : This has much the same structure, but rather than serve
 and display fortune cookies, serves (ogg vorbis) audio over a TCP
 connection to a client which decodes and plays back the audio.

   * Example 3 : Splits the structure in example 2 into a specific
 server application and a client application. This puts the two
 halves at odds, *competing* with each other for CPU time. Thus if
 both are run on the same (single CPU) system you will hear audio
 breakage. If run on separate machines (as client and server(!)) you
 won't hear this. In practice, part of the issue is that there is no
 buffering in the receiver.

   * Example 4 : Simple multicast based streaming system. Since it uses
 raw ogg vorbis with no resends and no codebook facility, you will
 need to *start all the client machines first* and *then* the
 server. Uses the multicast transceiver object exclusively.


Requirements

   * Python 2.3 or higher recommended, though please do report any bugs
 with 2.2.
   * Axon (Any released version, 1.0.3 recommended, 1.0.4 when released)
   * vorbissimple (if you want to use the vorbis decode component)

(Both Axon and vorbissimple are separate parts of the Kamaelia project,
and available at the same download location - see below)


Platforms
=
Kamaelia has been used successfully under both Linux, Windows and Mac OS
X. A subset of Kamaelia has been successfully tested on Series 60 Nokia
mobiles when used with the Axon SERIES 60 branch.

Where can I get it?
===
Web pages are here:
   http://kamaelia.sourceforge.net/Docs/
   http://kamaelia.sourceforge.net/ (includes info on mailing lists)

ViewCVS access is available here:
   http://cvs.sourceforge.net/viewcvs.py/kamaelia/

Weblog
   * http://kamaelia.sourceforge.net/cgi-bin/bl


Licensing
=
Kamaelia is released under the Mozilla tri-license scheme
(MPL/GPL/LGPL). Specifically you may choose to accept either
the Mozilla Public License 1.1, the GNU General Public License
2.0 or the Lesser General Public License 2.1. Proprietary terms
and conditions available upon request.

Best Regards,


Michael.
-- 
[EMAIL PROTECTED]
British Broadcasting Corporation, Research and Development
Kingswood Warren, Surrey KT20 6NP

This message (and any attachments) may contain personal views
which are not the views of the BBC unless specifically stated.


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

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


Re: Global Variables

2005-04-13 Thread George Sakkis
Use 'global':

def change_filename():
   global filename
   filename=raw_input()


def change_path():
   global path
   path=raw_input()


Even better, don't use globals at all; in 99% if the time, there are
better ways to achieve the same effect.

George

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


Re: Python license (2.3)

2005-04-13 Thread Antoon Pardon
Op 2005-04-12, Robert Kern schreef [EMAIL PROTECTED]:
 Antoon Pardon wrote:

 What licence can I use? Somewhere they say you can combine python
 code with GPL code. Does that mean that the resulting code has
 to have both the GPL license as the PSF license, as both seem
 to want that derived work uses the same license.

 No, the PSF does not want that. It does not say so anywhere in the 
 license text. Yes, you can GPL the derived work. The licenses are 
 compatible.


This comes from the license text.

| 2. Subject to the terms and conditions of this License Agreement, PSF
| hereby grants Licensee a nonexclusive, royalty-free, world-wide
| license to reproduce, analyze, test, perform and/or display publicly,
| prepare derivative works, distribute, and otherwise use Python 2.3
| alone or in any derivative version, provided, however, that PSF's
| License Agreement and PSF's notice of copyright, i.e., Copyright (c)
| 2001, 2002, 2003 Python Software Foundation; All Rights Reserved are
| retained in Python 2.3 alone or in any derivative version prepared by
| Licensee.

So what should I understand by: provided, however, that PSF's License
Agreement ... are retained in Python 2.3 alone or in any derivative 
version prepared by Licensee.

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


win32 readline maintenance (was Re: IPython - problem with...

2005-04-13 Thread Ville Vainio
 Fernando == Fernando Perez [EMAIL PROTECTED] writes:

Fernando Bummer.  I wonder, if the changes are minor and easy,
Fernando perhaps you (or someone else) could offer Gary to take
Fernando over maintenance of readline/win32?  It sounds

Someone on the ipython mailing list already had patches for it - I
think it was for Belgian keyboards. She didn't submit the patches,
just asked whether she should submit them.

Fernando like he is perhaps too busy to keep up with the patches
Fernando and improvements, so perhaps it's time for someone else
Fernando to take over?  That kind of library, while

Optimally, something like this should be in the pywin32 package. I
suppose it could be hosted at scipy if someone was to take over the
maintenance? It's open source, so the maintenance doesn't need to be
transferred - just put up version control somewhere and we'll see
what happens :-).

In the meantime I would suggest win32 users to do as I do and use a
different keyboard layout. US layout is better for programming anyway
and you learn it in a day or two. Settings-Control Panel-Regional
Options-Input Locales.

-- 
Ville Vainio   http://tinyurl.com/2prnb
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python license (2.3)

2005-04-13 Thread Robert Kern
Antoon Pardon wrote:
Op 2005-04-12, Robert Kern schreef [EMAIL PROTECTED]:
Antoon Pardon wrote:

What licence can I use? Somewhere they say you can combine python
code with GPL code. Does that mean that the resulting code has
to have both the GPL license as the PSF license, as both seem
to want that derived work uses the same license.
No, the PSF does not want that. It does not say so anywhere in the 
license text. Yes, you can GPL the derived work. The licenses are 
compatible.


This comes from the license text.
| 2. Subject to the terms and conditions of this License Agreement, PSF
| hereby grants Licensee a nonexclusive, royalty-free, world-wide
| license to reproduce, analyze, test, perform and/or display publicly,
| prepare derivative works, distribute, and otherwise use Python 2.3
| alone or in any derivative version, provided, however, that PSF's
| License Agreement and PSF's notice of copyright, i.e., Copyright (c)
| 2001, 2002, 2003 Python Software Foundation; All Rights Reserved are
| retained in Python 2.3 alone or in any derivative version prepared by
| Licensee.
So what should I understand by: provided, however, that PSF's License
Agreement ... are retained in Python 2.3 alone or in any derivative 
version prepared by Licensee.
Yes, the license text and the copyright notice must be attached. It 
doesn't mean that the PSF license is the operative one for the 
derivative work. You can put *your* own terms on top for *your* own code 
as long as you can satisfy the requirements of the PSF license, which 
are very light.

Read Larry Rosen's book:
  http://www.rosenlaw.com/oslbook.htm
--
Robert Kern
[EMAIL PROTECTED]
In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die.
  -- Richard Harter
--
http://mail.python.org/mailman/listinfo/python-list


Re: PyChart into web site error

2005-04-13 Thread Michele Petrazzo
Lee Harr wrote:
On 2005-04-12, Michele Petrazzo [EMAIL PROTECTED] wrote:
I'm using PyChart like a module for create charts into a little web
site, but when I try to create one, I have this error:
/var/www/html/lgt/draw.py:19, in draw:
can = canvas.init(self.file_name)
/usr/lib/python2.3/site-packages/pychart/canvas.py:60, in init:
can = pngcanvas.T(fname)
/usr/lib/python2.3/site-packages/pychart/pscanvas.py:25, in __init__:
basecanvas.T.__init__(self)
/usr/lib/python2.3/site-packages/pychart/basecanvas.py:70, in __init__:
self.title = re.sub((.*)\\.py$, \\1, sys.argv[0])
AttributeError: 'module' object has no attribute 'argv'
Why my script doesn't have sys.argv?
Is there another way to use PyChart into my script?

You are probably going to have to give more details.
Is there a file in your html/lgt folder called sys?
No.
 os.listdir('/var/www/html/lgt/')
['engine.py', 'db.py', 'index.spy', 'linetest.py', 'index.html', 
'db_mysql.py', 'mysession.spy', 'cds.html', 'templates', 'tmp', 'draw.py']


How are you serving the pages?
Apache 2.0.48, mod_python 3.1.3 and Python 2.3.3
on my mdk 10.0
Thanks,
Michele
--
http://mail.python.org/mailman/listinfo/python-list


Re: Doubt regarding sorting of a list specific field

2005-04-13 Thread Steven Bethard
praba kar wrote:
I have doubt regarding sorting. I have a list
that list have another list (eg)
list = [[1234,'name1'],[2234,'name2'],[0432,'name3']]
I want to sort only numeric value having array field.
How I need to do for that. 
In Python 2.4:
py import operator
py seq = [(1234,'name1'),(2234,'name2'),(1432,'name3')]
py seq.sort(key=operator.itemgetter(0))
py seq
[(1234, 'name1'), (1432, 'name3'), (2234, 'name2')]
Note that I've changed your name 'list' to 'seq' since 'list' is 
shadowing the builtin list function in your code, and I've changed your 
nested lists to tuples because they look like groups of differently 
typed objects, not sequences of similarly typed objects.  See:

http://www.python.org/doc/faq/general.html#why-are-there-separate-tuple-and-list-data-types
That said, the code I've given will still work if you shadow the builtin 
list or if you use lists instead of tuples.

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


Re: Web Application Client Module

2005-04-13 Thread Berislav Lopac
Raffi wrote:
 Hi All,

 I hope I'm posting this question to the correct newsgroups. We have a
 web based database application that's accessed using IE. The
 application opens a popup window to run in. With all the popup
 blockers and compromised browsers out there, I'm looking into
 developing a web based custom client side application to access the
 application with. The application will be developed to only reach the
 web application site using the https protocol. It also needs to
 javascript enabled. It will be downloaded from the main web site and
 used to access the database application.

 Any suggestions/ideas on how to go about developing the client
 application? What tools tools are out there for such a project.

http://msdn.microsoft.com/library/default.asp?url=/workshop/author/hta/hta_node_entry.asp
 


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


Re: Doubt regarding sorting of a list specific field

2005-04-13 Thread F. Petitjean
Le Wed, 13 Apr 2005 01:13:40 -0600, Steven Bethard a écrit :
 praba kar wrote:
 list = [[1234,'name1'],[2234,'name2'],[0432,'name3']]
 
 I want to sort only numeric value having array field.
 How I need to do for that. 
 
 In Python 2.4:
 
 py import operator
 py seq = [(1234,'name1'),(2234,'name2'),(1432,'name3')]
 py seq.sort(key=operator.itemgetter(0))
 py seq
 [(1234, 'name1'), (1432, 'name3'), (2234, 'name2')]
 
 Note that I've changed your name 'list' to 'seq' since 'list' is 
 shadowing the builtin list function in your code, and I've changed your 
 nested lists to tuples because they look like groups of differently 
 typed objects, not sequences of similarly typed objects.  See:
 
 STeVe
nice explaination. But, if the items of the list are tuples the default
rule for comparing tuples is such that
seq.sort()
would be sufficient here.

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


Re: Doubt regarding sorting of a list specific field

2005-04-13 Thread Steven Bethard
vincent wehren wrote:
praba kar [EMAIL PROTECTED] schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
| Dear All,
|
|I have doubt regarding sorting. I have a list
| that list have another list (eg)
|
| list = [[1234,'name1'],[2234,'name2'],[0432,'name3']]

- Be careful, 0432 is octal notation for 282.
|
| I want to sort only numeric value having array field.
| How I need to do for that.
You may want use the decorate-sort-undecorate idiom.
I othere words, you isolate the index you want to sort by,
sort on the indices, than get rid of the indices again.
Something like:
def sortSeqOfSeqs(seq, idx):
tmp = sorted([(elem[idx], elem) for elem in seq])
return [elem[1] for elem in tmp]
Note that this is not stable:
py seq = [(1,'c'),(1,'b')]
py [tup[1] for tup in sorted((x[0], x) for x in seq)]
[(1, 'b'), (1, 'c')]
Which should not have reordered the list since 1 == 1.  If you want a 
stable version, you could use:

py [tup[2] for tup in sorted((x[0], i, x) for i, x in enumerate(seq))]
[(1, 'c'), (1, 'b')]
But that seems pretty silly.  You're already using Python 2.4 features 
(e.g. sorted), so you might as well use the key argument to sorted:

py sorted(seq, key=operator.itemgetter(0))
[(1, 'c'), (1, 'b')]
Note if you're not using 2.4, you may want to use the 
decorate-sort-undecorate pattern like:

py decorated_seq = [(x[0], i, x) for i, x in enumerate(seq)]
py decorated_seq.sort()
py [tup[2] for tup in decorated_seq]
[(1, 'c'), (1, 'b')]
But personally, I'd just upgrade. ;)
STeVe
--
http://mail.python.org/mailman/listinfo/python-list


Re: Doubt regarding sorting of a list specific field

2005-04-13 Thread Steven Bethard
F. Petitjean wrote:
Le Wed, 13 Apr 2005 01:13:40 -0600, Steven Bethard a écrit :
praba kar wrote:
list = [[1234,'name1'],[2234,'name2'],[0432,'name3']]
I want to sort only numeric value having array field.
How I need to do for that. 
In Python 2.4:
py import operator
py seq = [(1234,'name1'),(2234,'name2'),(1432,'name3')]
py seq.sort(key=operator.itemgetter(0))
py seq
[(1234, 'name1'), (1432, 'name3'), (2234, 'name2')]
Note that I've changed your name 'list' to 'seq' since 'list' is 
shadowing the builtin list function in your code, and I've changed your 
nested lists to tuples because they look like groups of differently 
typed objects, not sequences of similarly typed objects.  See:

STeVe
nice explaination. But, if the items of the list are tuples the default
rule for comparing tuples is such that
seq.sort()
would be sufficient here.
See my other post in this thread.  seq.sort() is not stable; if the OP's 
list looked like:
   [(1234,'name3'), (1234,'name1')]
then calling seq.sort() would give
   [(1234,'name1'), (1234,'name3')]
instead of
   [(1234,'name3'), (1234,'name1')]
which is what I assumed the OP wanted when he said I want to sort only 
numeric value.

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


Re: win32 readline maintenance (was Re: IPython - problem with...

2005-04-13 Thread Michele Simionato
Switching to the US keyboard did not help for me.

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


Re: Doubt regarding sorting of a list specific field

2005-04-13 Thread Steven Bethard
Steven Bethard wrote:
See my other post in this thread.  seq.sort() is not stable;
Hmmm...  That didn't come out right.  list.sort *is* stable.  It's just 
that if you want to sort only by the first element of each tuple in a 
list, then list.sort won't produce results that are stable under this 
criterion.

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


Re: Python license (2.3)

2005-04-13 Thread Antoon Pardon
Op 2005-04-13, Robert Kern schreef [EMAIL PROTECTED]:
 Antoon Pardon wrote:
 Op 2005-04-12, Robert Kern schreef [EMAIL PROTECTED]:
 
Antoon Pardon wrote:


What licence can I use? Somewhere they say you can combine python
code with GPL code. Does that mean that the resulting code has
to have both the GPL license as the PSF license, as both seem
to want that derived work uses the same license.

No, the PSF does not want that. It does not say so anywhere in the 
license text. Yes, you can GPL the derived work. The licenses are 
compatible.

 
 
 This comes from the license text.
 
 | 2. Subject to the terms and conditions of this License Agreement, PSF
 | hereby grants Licensee a nonexclusive, royalty-free, world-wide
 | license to reproduce, analyze, test, perform and/or display publicly,
 | prepare derivative works, distribute, and otherwise use Python 2.3
 | alone or in any derivative version, provided, however, that PSF's
 | License Agreement and PSF's notice of copyright, i.e., Copyright (c)
 | 2001, 2002, 2003 Python Software Foundation; All Rights Reserved are
 | retained in Python 2.3 alone or in any derivative version prepared by
 | Licensee.
 
 So what should I understand by: provided, however, that PSF's License
 Agreement ... are retained in Python 2.3 alone or in any derivative 
 version prepared by Licensee.

 Yes, the license text and the copyright notice must be attached. It 
 doesn't mean that the PSF license is the operative one for the 
 derivative work.

Why attach a license that is not operative. That doesn't make sense
to me and will IMO just create confusion.

 You can put *your* own terms on top for *your* own code 
 as long as you can satisfy the requirements of the PSF license, which 
 are very light.

 Read Larry Rosen's book:

http://www.rosenlaw.com/oslbook.htm

I skimmed it and it doesn't seem to contain anything that helps me
with the PSF. If it does could you at least point me to the right
chapter.

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


Re: [perl-python] Python documentation moronicities (continued)

2005-04-13 Thread bruno modulix
Ivan Van Laningham wrote:
Hi All--
Richie Hindle wrote:
[Xah]
motherfucking ... fucking ... fucking ... fucking ... fuck ... fucking
fucking ... fucking ... mother fucking ... fucking ... piece of shit ...
motherfucking ... fucking ... fucking ... big asshole ... masturbation ...
Fucking morons ... fucking stupid ... fuckhead coders ... fuckheads ...
you fucking asses.

paypal me a hundred dollars and i'll rewrite the whole re doc in a few
hours.
Can we paypal you a hundred dollars to leave us alone?  I'll pledge $10.
Are there another nine people here who'll do the same?

Why don't we pay him $100 to re-write the PERL docs?
+1 !
--
bruno desthuilliers
python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for 
p in '[EMAIL PROTECTED]'.split('@')])
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python documentation moronicities (continued)

2005-04-13 Thread Fredrik Lundh
runes [EMAIL PROTECTED] wrote:

 I found the Howto through Google. Somehow I didn't see that link in the
 documentation.

 And please do not make any assumptions about my  reading of manuals.

if you were unable to find a link in the documentation you were reading, can you
perhaps suggest a better place to put that link?

/F 



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


email: Content-Disposition and linebreaks with long filenames

2005-04-13 Thread Martin Krner
Hi NG,
I am using email module for creating mails with attachment (and then 
sending via smtplib).

If the name of the attachment file is longer than about 60 characters 
the filename is wrapped in the Content-Disposition header:

Content-Disposition: attachment;
filename=This is a sample file with a very long filename
0123456789.zip
This leads to a wrong attachment filename in email clients - the space 
after filename is not shown or the client displays a special character 
(the linbreak or tab before 0123456789.zip).

If I use a standard email client and generate a mail with the same 
attachment, it creates the following header:

Content-Disposition: attachment;
 filename=This is a sample file with a very long filename 0123456789.zip
(no line break)
Here is my code:
msg = MIMEMultipart()
msg['Subject']  = 'Test'
msg['From'] = '[EMAIL PROTECTED]'
msg['To']   = '[EMAIL PROTECTED]'
msg.epilogue = ''
# Add body
part_body = MIMEText('blabla')
msg.attach(part_body)
# Add attachment
file = 'This is a sample file with a very long filename 0123456789.zip'
fp = open(file, 'rb')
part_att = MIMEBase('application','zip')
part_att.set_payload(fp.read())
fp.close()
part_att.add_header('Content-Disposition', 'attachment', filename=file)
# Encode the payload using Base64
email.Encoders.encode_base64(part_att)
msg.attach(part_att)
Is it possible to prevent the linebreak?
Thank you
Martin
--
http://mail.python.org/mailman/listinfo/python-list


A command in a String ?

2005-04-13 Thread Peter Moscatt
I have a rather odd question:

Is there a way Python can execute a command within a string ?

For example if I had something like:
_str = fm=OptionMenu(root,xx,'string1','string2','string3')

And the execute _str.

The reason why I am trying to do this that as I am aware the OptionMenu
hasn't the ability insert options therefore the options would be inserted
by manipulating strings.

Pete

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


Re: A command in a String ?

2005-04-13 Thread Fredrik Lundh
Peter Moscatt wrote:

I have a rather odd question:

 Is there a way Python can execute a command within a string ?

 For example if I had something like:
 _str = fm=OptionMenu(root,xx,'string1','string2','string3')

 And the execute _str.

exec _str

 The reason why I am trying to do this that as I am aware the OptionMenu
 hasn't the ability insert options therefore the options would be inserted
 by manipulating strings.

does this do what you want?

strings = string1, string2, string3
fm = OptionMenu(root, xx, *strings)

/F 



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


Re: Looking for a very specific type of embedded GUI kit

2005-04-13 Thread Frithiof Andreas Jensen

Sizer [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

 So the question is: what non-X gui toolkit can we use that has Python
 bindings and will let us use a custom display driver at the lowest level?

There is a discussion of Embedded X's here:

http://www.linuxdevices.com/files/elec-oct00/anderson/img0.html (metrolink
seem's to be dead).

http://www.microwindows.org/

maybe sourceforge knows more?



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


Re: A command in a String ?

2005-04-13 Thread Tim Daneliuk
Peter Moscatt wrote:
I have a rather odd question:
Is there a way Python can execute a command within a string ?
For example if I had something like:
_str = fm=OptionMenu(root,xx,'string1','string2','string3')
And the execute _str.
The reason why I am trying to do this that as I am aware the OptionMenu
hasn't the ability insert options therefore the options would be inserted
by manipulating strings.
Pete
Look into the eval operation ...
--

Tim Daneliuk [EMAIL PROTECTED]
PGP Key: http://www.tundraware.com/PGP/
--
http://mail.python.org/mailman/listinfo/python-list


Re: A command in a String ?

2005-04-13 Thread Peter Moscatt
/F,

Thanks for the help on this.  Yea the 'exec' did the trick.
The second example just placed all the strings in one option button.

Pete



On Wed, 13 Apr 2005 10:34:20 +0200, Fredrik Lundh wrote:

 Peter Moscatt wrote:
 
I have a rather odd question:

 Is there a way Python can execute a command within a string ?

 For example if I had something like:
 _str = fm=OptionMenu(root,xx,'string1','string2','string3')

 And the execute _str.
 
 exec _str
 
 The reason why I am trying to do this that as I am aware the OptionMenu
 hasn't the ability insert options therefore the options would be inserted
 by manipulating strings.
 
 does this do what you want?
 
 strings = string1, string2, string3
 fm = OptionMenu(root, xx, *strings)
 
 /F

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


Compute pi to base 12 using Python?

2005-04-13 Thread Dick Moores
I need to figure out how to compute pi to base 12, to as many digits as 
possible. I found this reference, 
http://mathworld.wolfram.com/Base.html, but I really don't understand 
it well enough. Could someone show me how to do what I need?

Thanks,
Dick Moores
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list


Re: A command in a String ?

2005-04-13 Thread Fredrik Lundh
Peter Moscatt wrote:

 strings = string1, string2, string3
 fm = OptionMenu(root, xx, *strings)

 Thanks for the help on this.  Yea the 'exec' did the trick.
 The second example just placed all the strings in one option button.

did you include the asterisk?  if you remove that, you get one option.  if you
include it, you get three options.

/F 



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


Re: Python license (2.3)

2005-04-13 Thread Robert Kern
Antoon Pardon wrote:
Op 2005-04-13, Robert Kern schreef [EMAIL PROTECTED]:

Yes, the license text and the copyright notice must be attached. It 
doesn't mean that the PSF license is the operative one for the 
derivative work.

Why attach a license that is not operative. That doesn't make sense
to me and will IMO just create confusion.
Because it's not your code. The tiny obligation that you have to satisfy 
is to say that some of the code comes from someone else and is available 
under such-and-such a license. That's it. You can keep the code hidden, 
you can charge whatever you like for it, but you have to attribute it 
properly. Open source licenses don't get much less restrictive than this.

You can put *your* own terms on top for *your* own code 
as long as you can satisfy the requirements of the PSF license, which 
are very light.

Read Larry Rosen's book:
  http://www.rosenlaw.com/oslbook.htm

I skimmed it and it doesn't seem to contain anything that helps me
with the PSF. If it does could you at least point me to the right
chapter.
Well besides reading to understand the mechanics of copyright and 
licensing, you should read Chapter 5: Academic Licenses, a class of open 
source licenses to which the PSF License belongs. The only thing 
particularly different between the PSF License and most other academic 
licenses (like BSD and MIT) is that the PSF License is more explicit.

Of course, IANAL and TINLA, so if you want real legal advice instead of 
advice from random newsgroup bums like myself, you should talk to a lawyer.

--
Robert Kern
[EMAIL PROTECTED]
In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die.
  -- Richard Harter
--
http://mail.python.org/mailman/listinfo/python-list


Re: A command in a String ?

2005-04-13 Thread Peter Otten
Peter Moscatt wrote:

 Thanks for the help on this.  Yea the 'exec' did the trick.
 The second example just placed all the strings in one option button.

Peter, you most certainly do *not* need an exec statement. If you take the
time to explain what you want to do (as opposed to how you want to do it) a
bit more exhaustively, perhaps with some context code, the profit will be
all on your side.

Peter

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


Re: Python license (2.3)

2005-04-13 Thread Antoon Pardon
Op 2005-04-13, Robert Kern schreef [EMAIL PROTECTED]:
 Antoon Pardon wrote:
 Op 2005-04-13, Robert Kern schreef [EMAIL PROTECTED]:

Yes, the license text and the copyright notice must be attached. It 
doesn't mean that the PSF license is the operative one for the 
derivative work.
 
 
 Why attach a license that is not operative. That doesn't make sense
 to me and will IMO just create confusion.

 Because it's not your code. The tiny obligation that you have to satisfy 
 is to say that some of the code comes from someone else and is available 
 under such-and-such a license. That's it. You can keep the code hidden, 
 you can charge whatever you like for it, but you have to attribute it 
 properly. Open source licenses don't get much less restrictive than this.

Well maybe this is a semantic problem. I wouldn't use the word attach
here. So what I seem obligated to do, is 1) Mentioning this came
from the python distribution and 2) explain where this distribution can
be attained and under what license.

You can put *your* own terms on top for *your* own code 
as long as you can satisfy the requirements of the PSF license, which 
are very light.

Read Larry Rosen's book:

   http://www.rosenlaw.com/oslbook.htm
 
 
 I skimmed it and it doesn't seem to contain anything that helps me
 with the PSF. If it does could you at least point me to the right
 chapter.

 Well besides reading to understand the mechanics of copyright and 
 licensing, you should read Chapter 5: Academic Licenses, a class of open 
 source licenses to which the PSF License belongs. The only thing 
 particularly different between the PSF License and most other academic 
 licenses (like BSD and MIT) is that the PSF License is more explicit.

 Of course, IANAL and TINLA, so if you want real legal advice instead of 
 advice from random newsgroup bums like myself, you should talk to a lawyer.

Well if it comes so far I have to consult a lawyer I'd rather not publish
it in the first place.

The only reason I'm concerned is that this is to be part of a tutorial
and I prefer not to burden those who read the tutoral with any kind of
license. As far as I'm concerned people reading the tutorial can use
any code provided with it in any way they see fit.

I see this as my contribution to the communities who has provided me
with all kinds of things that are usefull to me. I'm willing to put
time into this, but if I have to spend money because it is impossible
otherwise to find out how to contribute legally, that is a hurdle
I'm reluctant to take.

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


Re: A command in a String ?

2005-04-13 Thread Peter Moscatt
/F,

No, I hadn't included the '*'   Ya learn something every day.

Pete


On Wed, 13 Apr 2005 11:07:13 +0200, Fredrik Lundh wrote:

 Peter Moscatt wrote:
 
 strings = string1, string2, string3
 fm = OptionMenu(root, xx, *strings)

 Thanks for the help on this.  Yea the 'exec' did the trick.
 The second example just placed all the strings in one option button.
 
 did you include the asterisk?  if you remove that, you get one option.  if you
 include it, you get three options.
 
 /F

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


Re: email: Content-Disposition and linebreaks with long filenames

2005-04-13 Thread André Malo
* Martin Körner [EMAIL PROTECTED] wrote:

 I am using email module for creating mails with attachment (and then 
 sending via smtplib).
 
 If the name of the attachment file is longer than about 60 characters 
 the filename is wrapped in the Content-Disposition header:
 
 Content-Disposition: attachment;
   filename=This is a sample file with a very long filename
   0123456789.zip
 
 
 This leads to a wrong attachment filename in email clients - the space 
 after filename is not shown or the client displays a special character 
 (the linbreak or tab before 0123456789.zip).

Yeah, this is badly applied header folding. You can circumvent it by
encoding the filename parameter according to
http://ftp.rfc-editor.org/in-notes/rfc2184.txt

Note that parameter continuation ala filename*1=...; filename*2= is not
really supported by MUAs, but support for filename*=... seems to be a /bit/ 
better.

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


how to explain such codes, python's bug or mine?

2005-04-13 Thread MaHahaXixi
 j = range(20)
 print j
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
 for k in j:
 if k = 10:
  j.remove(k)


 print j
[1, 3, 5, 7, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19]



Python 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)] on
win32
Type copyright, credits or license() for more information.

i think python do convert there codes to such style:
for (i = 0; i  len(j); i++)
   k = j[i]
   ..



what do u think?


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


Re: numarray.array can be VERY slow

2005-04-13 Thread Jim
Edward C. Jones wrote:
Steven Bethard wrote:
  As mentioned, this has nothing to do with numarray, and everything to
  do with your inexplicable use of lists.  Why don't you just write this
  as:
 
  arr = numarray.ones((8, 8, 256, 256), Float64)
The code I posted was simplified from a larger program which I have now 
revised. But I still ask: why did it take 4.3 seconds to run?
Is the simple answer not that repeated use of array.append is 
inefficient as python has to repeatedly re-allocate memory for the array?

I had a similar problem as I ran a simulation and appended the results 
to a results set. Now I create a list of objects of the size required 
and the overwrite them. Much faster :)

Jim
Getting in there late cos I've been skiving
--
http://mail.python.org/mailman/listinfo/python-list


Re: how to explain such codes, python's bug or mine?

2005-04-13 Thread [EMAIL PROTECTED]
Hi,

it is not python bug.
You refer the list j and remove the element in the same time, that is
the problem. Python dinamicaly goes to the next element with the same
index but apply it in the new list.

use this code instead:
  j = range(20)
  print j
  L = [x for x in j if x  10]
  print L

Sincerely Yours,
Pujo

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


Re: Compute pi to base 12 using Python?

2005-04-13 Thread Bengt Richter
On Wed, 13 Apr 2005 02:06:11 -0700, Dick Moores [EMAIL PROTECTED] wrote:

I need to figure out how to compute pi to base 12, to as many digits as 
possible. I found this reference, 
http://mathworld.wolfram.com/Base.html, but I really don't understand 
it well enough. Could someone show me how to do what I need?

Thanks,

Dick Moores
[EMAIL PROTECTED]

See if this is enough digits for homework? ;-) 

(Digits A and B are 10 and 11 in decimal respectively)

3184809493B918664573A6211BB151551A05729290A7809A492742140A60A55256A0661A03753A3AA54805646880181A
3683083272BBBA0A370B12265529A828903B4B256B8403759A71626B8A54687621849B849A8225616B442796A31737B2
29B2391489853943B8763725616447236B027A421AA17A38B52A18A838B01514A51144A23315A3009A8906B61B8B48A6
2253A88A50A43BA0944572315933664476B3AABB77583975120683526B75B462060BB03B432551913772729A21475535
31793848A0402B999B5058535374465A68806716644039539A8431935198527B9399B112990ABB0383B107645424577A
51601B3624A88B7A676A3992912121A213887B92873946A61332242217AA7354115357744939112602BA4B18A326
9222B528487747839994AB223B65B8762695422822669BA00A586097842A51750362073B5A768363B21BB1A97A4A1944
47749399804922175A068A46739461990A2065BB0A30BBAB7024A585B1A84428195489784A07A331A7B0A1574565B373
B05B03A5A80A13AB87857734679985558A5373178A7B28271992A3894A5776085083B9B238B2220542462888641A2BAB
8B3083AB49659172A312B78518654494A068662586A181835A64440B2970A12281397589881536720890580103288144
9223841428763329617531239B9A657405584014534390B587625606BB80923795944B43757A431B039556282978A6A4
9590553490BA1844947175637A908247B50127722464441380A852B0847B5813019BB70A67663B426565434069884476
132193344BA55A2128A03838974606B851B2979321A408067225A5AA4B3464A1A17473595333909AB9127079655B3164
B68B9B28A9B818A220A025AB0934203995B7A62A7AA739355340539BA3182905B193905603A43B660B9426A922946971
44A896A5B2339358BB2B7294BB89635B071A6351211360B820B1882AB8433B54757B87A373284B1BA182A10326476B36
9A4A6365B58B8018994BB152556765475A704BB94B6B2A39458971A8B90512786B5029404818644323552916170B3ABB
7363496427B088B68725A68570040617949289077B278069A09B559324B8A66828B40549B0296065B2300330592569A7
B76B92BA1293585B6A9B604567A0901362856373B4B56897946256B4172B1B50474351364749A33996A81BA8847347A8
411B850B79A03018291672AA0945656A159AA6AA0A845531A592005B8A34366B882257107B190969A846474836A98007
50778920BA797297A2791101B0685A86BB704B9BAA17B055293679843B35215B0A8B1182B611953B080AA5431B219907
A8448A81B1A9493245676B88013B470335240859594158621014216619553246570601967448B470174B924489244481
7453865A4003B5AA7176451AAB90681A949786154AA040477382BA69371041710B8728458A23979252B254236753A44A
1900AA283536A227648812525743868B410A567794663359A6726A5286783328135114789B7645505B047848020A730A
9557B206776AA56A19682744107901306B29008808619866B4911A05264B872A46B5376383932699531B449195640B62
A63622830886247A47B3957169861239358041AA281333622AA15912B0A636047A489BB0726282A78B96671B27305A96
52496B9B999011A7BA36898891665B1A6009058978850A21B01A158A1473B84A192B8672542A2A7056581995207A436A
5B3BA2824637A3112ABB57176468206A071200A327B3216425148100786502AA21236ABB35499277670A126973058340
3B1922A483856007301983989159BB688A58B602339806B63002A339A50B0BA533B84827793913081070A32595A10180
3A9A20234691B1A0B623274B69B0B44688195169461059543A252BB05208720BA13118266A872B26B9B584959B451795
19534B221A335A2BB6971B3276B3A63A5B791723109B176529BB90651584279B7825712521B8269800738B07A62B1454
7884414451224092937165625696557A78799A82126613535A36B410309B759976119777B895801074B9779B9B513753
8B2799951012273399BB818B721967957713B90947B2A11A6A665848B22B531726616515939323229080B8AB574AA749
4773AB411A57150203067A112944833235A86153803A98689A0762B79835413A46B347888A4AAB259665694B93129B62
1391751430A98B002620718437A7B85B891179479651AA3410663715415B55BA47AA59465AB81567B7655780A8038135
85230122578485B071A529692B19A6537B28616A63556816945380634A90470354AAB303884B7B09B2037B95405BA145
704B19B14AA8028810881AB6072441194A875477836B37704B5199062319A336375437403562A663B835B891957883AB

Hint: Lambert Meertens. Tweak the algorithm you find ;-)

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


Re: HTTPSConnection script fails, but only on some servers (long)

2005-04-13 Thread andreas
Well HTTPSConnection does not support proxies. (HTTP/CONNECT + switch to HTTPS)

And it hasn't ever. Although the code seems to make sense there is
no support for handling that switch. Probably a good thing to complain
about (file a new bug report).

In the meantime you should take a look a cURL and pycurl, which do support
all kind of more extreme HTTP (FTP, etc.) handling, like using https over
an proxy.

Andreas

On Tue, Apr 12, 2005 at 03:37:33AM -0400, Steve Holden wrote:
 Paul Winkler wrote:
 This is driving me up the wall... any help would be MUCH appreciated.
 I have a module that I've whittled down into a 65-line script in
 an attempt to isolate the cause of the problem.
 
 (Real domain names have been removed in everything below.)
 
 SYNOPSIS:
 
 I have 2 target servers, at https://A.com and https://B.com.
 I have 2 clients, wget and my python script.
 Both clients are sending GET requests with exactly the
 same urls, parameters, and auth info.
 
 wget works fine with both servers.
 The python script works with server A, but NOT with server B.
 On Server B, it provoked a Bad Gateway error from Apache.
 In other words, the problem seems to depend on both the client
 and the server. Joy.
 
 Logs on server B show malformed URLs ONLY when the client
 is my python script, which suggests the script is broken...
 but logs on server A show no such problem, which suggests
 the problem is elsewhere.
 
 DETAILS
 
 Note, the module was originally written for the express
 purpose of working with B.com;  A.com was added as a point of reference
 to convince myself that the script was not totally insane.
 Likewise, wget was tried when I wanted to see if it might be
 a client problem.
 
 Note the servers are running different software and return different
 headers. wget -S shows this when it (successfully) hits url A:
 
  1 HTTP/1.1 200 OK
  2 Date: Tue, 12 Apr 2005 05:23:54 GMT
  3 Server: Zope/(unreleased version, python 2.3.3, linux2) ZServer/1.1
  4 Content-Length: 37471
  5 Etag:
  6 Content-Type: text/html;charset=iso-8859-1
  7 X-Cache: MISS from XXX.com
  8 Keep-Alive: timeout=15, max=100
  9 Connection: Keep-Alive
 
 ... and this when it (successfully) hits url B:
 
  1 HTTP/1.1 200 OK
  2 Date: Tue, 12 Apr 2005 04:51:30 GMT
  3 Server: Jetty/4.2.9 (Linux/2.4.26-g2-r5-cti i386 java/1.4.2_03)
  4 Via: 1.0 XXX.com
  5 Content-Length: 0
  6 Connection: close
  7 Content-Type: text/plain
 
 Only things notable to me, apart from the servers are the Via: and
 Connection: headers. Also the Content-Length: 0 from B is odd, but
 that doesn't seem to be a problem when the client is wget.
 
 Sadly I don't grok HTTP well enough to spot anything really
 suspicious.
 
 The apache ssl request log on server B is very interesting.
 When my script hits it, the request logged is like:
 
 A.com - - [01/Apr/2005:17:04:46 -0500] GET
 https://A.com/SkinServlet/zopeskin?action=updateSkinIdfacilityId=1466skinId=406
 HTTP/1.1 502 351
 
 ... which apart from the 502, I thought reasonable until I realized
 there's
 not supposed to be a protocol or domain in there at all.  So this is
 clearly
 wrong. When the client is wget, the log shows something more sensible
 like:
 
 A.com - - [01/Apr/2005:17:11:04 -0500] GET
 /SkinServlet/zopeskin?action=updateSkinIdfacilityId=1466skinId=406
 HTTP/1.0 200 -
 
 ... which looks identical except for not including the spurious
 protocol and domain, and the response looks as expected (200 with size
 0).
 
 So, that log appears to be strong evidence that the problem is in my
 client
 script, right?  The failing request is coming in with some bad crap in
 the path, which Jboss can't handle so it barfs and Apache responds with
 
 Bad Gateway.  Right?
 
 So why does the same exact client code work when hitting server B??
 No extra gunk in the logs there. AFAICT there is nothing in the script
 that could lead to such an odd request only on server A.
 
 
 THE SCRIPT
 
 #!/usr/bin/python2.3
 
 from httplib import HTTPSConnection
 from urllib import urlencode
 import re
 import base64
 
 url_re = re.compile(r'^([a-z]+)://([A-Za-z0-9._-]+)(:[0-9]+)?')
 
 target_urls = {
 'B': 'https://B/SkinServlet/zopeskin',
 'A': 'https://A/zope/manage_main',
 }
 
 auth_info= {'B':('userXXX', 'passXXX'),
 'A':('userXXX', 'passXXX'),
 }
 
 def doRequest(target, **kw):
 Provide a trivial interface for doing remote calls.
 Keyword args are passed as query parameters.
 
 url = target_urls[target]
 user, passwd = auth_info[target]
 proto,host,port=url_re.match(url).groups()
 if port:
 port = int(port[1:])   # remove the ':' ...
 else:
 port = 443
 creds = base64.encodestring(%s:%s % (user, passwd))
 headers = {Authorization: Basic %s % creds }
 params = urlencode(kw).strip()
 if params:
 url = '%s?%s' % (url, params)
 body = None # only needed for POST
 args =('GET', url, body, headers)
 print ARGS: %s % 

Re: Programming Language for Systems Administrator

2005-04-13 Thread Ville Vainio
 beliavsky == beliavsky  [EMAIL PROTECTED] writes:

beliavsky The key difference between the Unix approach and the
beliavsky MSH one is that rather than creating a pipeline based
beliavsky on textual input and output, MSH passes data between
beliavsky the various commandlets as arbitrary objects.

They clearly read my rant from last summer 

http://groups.google.com/groups?threadm=du7brj2mpg9.fsf%40mozart.cc.tut.fi

;-)

-- 
Ville Vainio   http://tinyurl.com/2prnb
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to explain such codes, python's bug or mine?

2005-04-13 Thread Jim
MaHahaXixi wrote:
j = range(20)
print j
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
for k in j:
 if k = 10:
  j.remove(k)

print j
[1, 3, 5, 7, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19]

Python 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)] on
win32
Type copyright, credits or license() for more information.
i think python do convert there codes to such style:
for (i = 0; i  len(j); i++)
   k = j[i]
   ..

what do u think?

I'm not quite sure of your question but with the second style you're not 
attempting to change the original list but make a copy. That's perfectly 
easy to do in Python as it is. The exampmle is a cautionary one about 
changing the list on which you are iterating.

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


Re: Compute pi to base 12 using Python?

2005-04-13 Thread Dick Moores
Bengt Richter wrote at 03:19 4/13/2005:
On Wed, 13 Apr 2005 02:06:11 -0700, Dick Moores [EMAIL PROTECTED] wrote:
I need to figure out how to compute pi to base 12, to as many digits as
possible. I found this reference,
http://mathworld.wolfram.com/Base.html, but I really don't understand
it well enough. Could someone show me how to do what I need?

Thanks,

Dick Moores
[EMAIL PROTECTED]

See if this is enough digits for homework? ;-)
This is not homework, nor am I a student, though I am trying to learn 
Python. I'm just trying to help an artist acquaintance who needs (I just 
learned) the first 3003 digits of pi to the base 12.

Hint: Lambert Meertens. Tweak the algorithm you find ;-)
Sorry. Your hint is beyond me.
Dick Moores
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list


for line in file weirdness

2005-04-13 Thread Cordula's Web
Hello,

here's a strange bug (?) I've came across (using Python 2.2):

# loop_1
for line in file:
if some_condition(line): break
do_something()

# loop_2
for line in file:
do_something_else()

The problem is, that loop_2 doesn't resume where loop_1 left off, but
skips many lines (a block's worth or so) before continuing.

Why is this? Is reading from a file non-reentrant?

It is always possible to slurp the whole file content into a list, and
then iterate through the list, but I want to handle HUGE files too.

Thanks,
-cpghost.

-- 
Cordula's Web. http://www.cordula.ws/

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


Re: Compute pi to base 12 using Python?

2005-04-13 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2005-04-13 03:27:06 -0700:
 Bengt Richter wrote at 03:19 4/13/2005:
 This is not homework, nor am I a student, though I am trying to learn 
 Python. I'm just trying to help an artist acquaintance who needs (I just 
 learned) the first 3003 digits of pi to the base 12.
 
 Hint: Lambert Meertens. Tweak the algorithm you find ;-)
 
 Sorry. Your hint is beyond me.

it says use google.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python documentation moronicities (continued)

2005-04-13 Thread runes
Seems like criticising the manual is som kind of heresy.  So be it.

You know, the Re documentation contains many pages. Ufortunately I
didn't dwell with the first introductory paragraph, I was trying to
solve a particular problem. I'm not that used to looking for links to
external sources in the manual either. Unable? I wasn't looking for a
Howto in the manual. And frankly, 'python regex howto in Google is
quicker way.

Of course I cannot suggest a better place for the link.

Writing technical documents always trigger the question: Who is the
audience. I accept that I may not be the primary audience.  If I should
suggest anything, it would be that the examples section is expanded.

Generally: I have got my experiences with the Python Manual over the
the last 30 months Python beeing my preferred language. One of them is
that I have to look elsewhere.

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


Re: how to explain such codes, python's bug or mine?

2005-04-13 Thread [EMAIL PROTECTED]
Hi

The second style can be used:
   j = range(20)
  print j
  L = [x for x in j if x  10]
  j = L

There are another method such poping the item based on last index to 0:
 for i in range(len(j)-1,0-1,-1):
if j[i]=10:
  j.pop(i)
 
 print j

Pujo

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


Re: args attribute of Exception objects

2005-04-13 Thread Sebastien de Menten
 Did I misunderstand the problem again?

Hmmm, yes ! But I think I am not expressing clearly my concern :-)

So my problem is that default exception are badly designed in their
use of their args attribute.

I know it is possible to subclass Exception as every object and add
the attributes I want with the name I want, etc...

BUT, some (if not most) default exceptions in __builtins__ use the
args attribute and put a string in it without delivering interesting
information about the exception.

So 1) I think it is nice to keep args as name for the attribute as it
avoids looking at the documentation for looking at each specific
exception/attribute name.
   2) but args should be more cleverly designed (again, I am speaking
about exceptions in __builtins__ not user defined exceptions) and not
be a simple string.

Now, forcing user to avoid using default exceptions (i.e. force them
to use user defined exceptions) for anything but interactive use or
debugging is short minded (nobody says that, but the current situation
implies that).

Anyway, I log this as request on SF.

Best regards,

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


Re: Compute pi to base 12 using Python?

2005-04-13 Thread Dan Bishop
Dick Moores wrote:
 I need to figure out how to compute pi to base 12, to as many digits
as
 possible. I found this reference,
http://mathworld.wolfram.com/Base.html,
 but I really don't understand it well enough.

How many stars are in *?

You probably answered 25.  This means that, for convenience, you've
broken down the row of stars into ** + ** + *, that
is, 2 tens with 5 left over, which the base-10 numeral system denotes
as 25.

But there's no reason other than tradition why you should arrange them
into groups of 10.  For example, you could write it as  +
 +  + *, or 3 eights plus 1.  In octal (base-8)
notation, this is written as 31; the tens place in octal represents
eights.

In general, in the base-r numeral system, the nth digit to the left of
the ones digit represents r^n.  For example, in the binary number
11001, the place values for each digit are, right to left, 1, 2, 4, 8,
and 16, so the number as a whole represents
1×16+1×8+0×4+0×2+1×1=16+8+1=25.  This analogous to 25=2×10+5 in
base-10.

It's also possible to write it as 3×8+0×4+0×2+1×1 = 3001 base 2,
but by convention, base-r only uses the digits in range(r).  This
ensures a unique represenation for each number.  This makes 11001 the
unique binary representation for decimal 25.

Note that for bases larger than 10, the digits will be numbers that are
not single digits in base 10.  By convention, letters are used for
larger digits: A=10, B=11, C=12, ... Z=35.  For example, the number
(dec) 2005 = 1×12³+1×12²+11×12+1×1 is represented in base-12 by
11B1.

Fractions are handled in a similar manner.  The nth place to the right
of the radix point (i.e., the decimal point, but that term is
inaccurate for bases other than ten) represents the value radix**(-n).

For example, in binary,
0.1 = 1/2 = dec. 0.5
0.01 = 1/4 = dec. 0.25
0.11 = 1/2 + 1/4 = 3/4 = dec. 0.75
0.001 = 1/8 = dec. 0.125
0.01010101... = 1/4 + 1/16 + 1/64 + ... = 1/3
0.0001100110011... = 1/10 = dec. 0.1

The last row explains why Python gives:

 0.1
0.10001

Most computers store floating-point numbers in binary, which doesn't
have a finite representation for one-tenth.  The above result is
rounded to 53 signficant bits
(1.100110011001100110011001100110011001100110011010×2^-4), which is
exactly equivalent to decimal
0.155511151231257827021181583404541015625, but gets
rounded to 17 significant digits for display.

Similarly, in base-12:

0.1 = 1/12
0.14 = 1/12 + 4/144 = 1/9
0.16 = 1/12 + 6/144 = 1/8
0.2 = 2/12 = 1/6
0.3 = 3/12 = 1/4
0.4 = 4/12 = 1/3
0.6 = 6/12 = 1/2
0.8 = 8/12 = 2/3
0.9 = 9/12 = 3/4
0.A = 10/12 = 5/6

Notice that several common fractions have simpler representations in
base-12 than in base-10.  For this reason, there are people who believe
that base-12 is superior to base-10.
(http://www.dozenalsociety.org.uk)

 Could someone show me how to do what I need?

You'll need 3 things:

(1) An algorithm for computing approximations of pi.

The simplest one is 4*(1-1/3+1/5-1/7+1/9-1/11+...), which is based on
the Taylor series expansion of 4*arctan(1).

There are other, faster ways.  Search Google for them.

(2) An unlimited-precision numeric representation.  The standard
float isn't good enough: It has only 53 bits of precision, which is
only enough for 14 base-12 digits.

The decimal module will probably work, although of course its base-10
internal representation will introduce slight inaccuracies.

(3) A function for converting numbers to their base-12 representation.

For integers, this can be done with:

DIGITS = 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ
def itoa(num, radix=10):
   is_negative = False
   if num  0:
  is_negative = True
  num = -num
   digits = []
   while num = radix:
  num, last_digit = divmod(num, radix)
  digits.append(DIGITS[last_digit])
   digits.append(DIGITS[num])
   if is_negative:
  digits.append(-)
   digits.reverse()
   return ''.join(digits)

For a floating-point number x, the representation with d decimal
places count be found by taking the representation of int(round(x *
radix ** d)) and inserting a . d places from the right.

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


Re: Python documentation moronicities (continued)

2005-04-13 Thread Steve Holden
runes wrote:
Seems like criticising the manual is som kind of heresy.  So be it.
Don't think so, but this being open source I suspect that Fredrik was 
trying to get them improved.

You know, the Re documentation contains many pages. Ufortunately I
didn't dwell with the first introductory paragraph, I was trying to
solve a particular problem. I'm not that used to looking for links to
external sources in the manual either. Unable? I wasn't looking for a
Howto in the manual. And frankly, 'python regex howto in Google is
quicker way.
Right, so you found what you needed, you just think it should be 
referenced from the main docs. I think this is a good idea.

Of course I cannot suggest a better place for the link.
Come on, of course you can. All you need to say is whereabouts in the re 
 documentation it should mention the How-To.

Writing technical documents always trigger the question: Who is the
audience. I accept that I may not be the primary audience.  If I should
suggest anything, it would be that the examples section is expanded.
Again, you would be a good candidate to suggest changes, since you've 
just been learning that part of Python.

Generally: I have got my experiences with the Python Manual over the
the last 30 months Python beeing my preferred language. One of them is
that I have to look elsewhere.
But anyone is allowed to suggest improvements. Please don't be deterred 
because you think people were trying to put you off. The documentation 
contains links for suggesting improvements. That is a working channel 
for criticism and suggestion (and it's how many others first got their 
names in the python documentation, including myself). See

  http://docs.python.org/doc/doc.html
  http://docs.python.org/doc/about.html
regards
 Steve
--
Steve Holden+1 703 861 4237  +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Programming Language for Systems Administrator

2005-04-13 Thread Uwe Grauer
Kanthi Kiran Narisetti wrote:
 Hi All,
 
 Thank You for your suggestionsI request you all to eloborate the
 Uses(In Practical) for systems administrator.Some of my questions
 regarding the same follows.
 
 1)Can i build web applications in Python ? If so how. I am planning to
 build a web application for intranet use which deals with workflow of
 Internal office communication.
 
Look here:
http://www.python.org/moin/WebProgramming

 2)Which is best opensource database to be used with Python ?
 
I personally think that Firebird is a very good Database:
http://www.firebirdsql.org/
http://kinterbasdb.sourceforge.net/

 3)When i write a remote execution script in python is it required that
 python should be installed in remote system.
 
 4)I heard about Perl/CGI and that CGI application done by python
 too.Is CGI still valid when PHP has taken over the WebApplication
 Development, Dominating.
 
 Sorry if these questions are out of this group , but answers to these ?
 will help me a lot.
 
 Thanks in Advance
 
 Kanthi.
 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: os.path.walk

2005-04-13 Thread Steve Holden
Tony Meyer wrote:
If I have os.path.walk(name, processDirectory, None) and 
processDirectory needs three arguments how can I ass them 
because walk only takes 3?

Assuming that processDirectory is a function of yours that returns a bool,
then you'd do something like:
  os.path.walk(name, processDirectory(a,b,c))
Where a, b, and c are the arguments that processDirectory requires.  (You
can add the None parameter to the os.path.walk call, but it won't change
anything, since it's the default).
Tony:
I think if you try this you will find that it doesn't work because 
os.path.walk will try to call the *result* of processDirectory(a,b,c) 
for each directory in the path.

You could, however, write a doDirectory() function that called 
processDirectory() when os.path.walk called *it*.

regards
 Steve
--
Steve Holden+1 703 861 4237  +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Northampton, UK

2005-04-13 Thread Fuzzyman

Martin Franklin wrote:
 Fuzzyman wrote:
  Just on the off chance I thought I'd ask if there were any
  Pythoneers out there local to Northampton UK ?
 
  Best Regards,
 
  Fuzzy
  http://www.voidspace.org.uk/python
 

 I'm just over the border (Bedfordshire) but like a lot of
 people commute :-(

Compared to most people on this list, you're practically next door :-)

I've just discovered the Python-UK mailing list. Hurrah.

Best Regards,

Fuzzy
http://www.voidspace.org.uk/python

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


Re: how to explain such codes, python's bug or mine?

2005-04-13 Thread MaHahaXixi
yes. i think it does so.
it take me the whole afternoon to find out the bug (mine)
i change:
for i  in range(len(j) -1, -1, -1):
   d = j[i]
   if d = 10:
j.remove(d)

the real code is not so simple,so j[11:] will not work for me.
but, i think phthon could found that i remove the current element,  why it
does not move the pointer automatically?
for python, i am a newbie, but i did not found the warning of such usage
from the python tutorial

[EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hi,

 it is not python bug.
 You refer the list j and remove the element in the same time, that is
 the problem. Python dinamicaly goes to the next element with the same
 index but apply it in the new list.

 use this code instead:
   j = range(20)
   print j
   L = [x for x in j if x  10]
   print L

 Sincerely Yours,
 Pujo



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


Has Python 2.4.1 changed implementation for __init__.py???

2005-04-13 Thread Werner Merkl
Hallo,
I just downloaded http://www.python.org/pypi/xexpr/0.02, installed
if (python setup.py install) and tried the example in the README file.
Than I got following error: AttributeError: 'module' object has no 
attribute 'Read'

This is same behavior for all module using empty __init__.pr files,
like venster, Pyrex or libxmlmods...
Is there a change in the implementation, so that every module needs an
explicit list for exchanged modules? Or is there a switch or an
environment variable to change?
Thanks a lot
Werner
EXAMPLE

Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on 
win32
Type help, copyright, credits or license for more information.
 import xexpr
 example = 'foo a=b c=dbarbaz a=d /Blah/bar/foo'
 xexpr.Read.to_xexpr(example)
Traceback (most recent call last):
  File stdin, line 1, in ?
AttributeError: 'module' object has no attribute 'Read'

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


Re: Compute pi to base 12 using Python?

2005-04-13 Thread Dick Moores
Dan Bishop wrote at 04:07 4/13/2005:
(3) A function for converting numbers to their base-12 representation.
For integers, this can be done with:
DIGITS = 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ
def itoa(num, radix=10):
   is_negative = False
   if num  0:
  is_negative = True
  num = -num
   digits = []
   while num = radix:
  num, last_digit = divmod(num, radix)
  digits.append(DIGITS[last_digit])
   digits.append(DIGITS[num])
   if is_negative:
  digits.append(-)
   digits.reverse()
   return ''.join(digits)
I see this works perfectly for integers. Thanks!
For a floating-point number x, the representation with d decimal
places count be found by taking the representation of int(round(x *
radix ** d)) and inserting a . d places from the right.
But I'm sorry, but I can't follow you. I do have the first 1 or so 
places of pi base 10 (http://mathwithmrherte.com/pi_digits.htm), but 
could you show me what to do with, say, just 3.14159?

I apologize for being so dense.
Dick Moores
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list


Re: for line in file weirdness

2005-04-13 Thread Fredrik Lundh
Cordula's Web [EMAIL PROTECTED] wrote:

 here's a strange bug (?) I've came across (using Python 2.2):

 # loop_1
 for line in file:
if some_condition(line): break
do_something()

 # loop_2
 for line in file:
do_something_else()

 The problem is, that loop_2 doesn't resume where loop_1 left off, but
 skips many lines (a block's worth or so) before continuing.

 Why is this? Is reading from a file non-reentrant?

as mentioned in the documentation, the iterator interface (which is used by the
for-in machiner) uses a read-ahead buffer.  in 2.2, whenever you enter a new
loop, a new read-ahead buffer is created, and it starts where the last one 
ended,
rather than right after the last line you read.

to get more reliable results in 2.2, you can create the iterator outside the 
loop,
and loop over the iterator object instead of the file itself.

file = iter(open(...))
for line in file:
if some_condition(line): break
do_something()
for line in file:
do_something_else()

(iirc, this quirk was fixed in 2.3)

/F 



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


Re: Has Python 2.4.1 changed implementation for __init__.py???

2005-04-13 Thread Fredrik Lundh
Werner Merkl wrote:

 I just downloaded http://www.python.org/pypi/xexpr/0.02, installed
 if (python setup.py install) and tried the example in the README file.

 Than I got following error: AttributeError: 'module' object has no attribute 
 'Read'

 This is same behavior for all module using empty __init__.pr files,
 like venster, Pyrex or libxmlmods...

if xexpr is a package with an empty __init__.py file, the behaviour you're
seeing is the expected behaviour.  importing a toplevel module doesn't auto-
matically import any submodules.

 Is there a change in the implementation, so that every module needs an
 explicit list for exchanged modules?

what's an exchanged module?

 EXAMPLE
 

 Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32
 Type help, copyright, credits or license for more information.
  import xexpr
  example = 'foo a=b c=dbarbaz a=d /Blah/bar/foo'
  xexpr.Read.to_xexpr(example)
 Traceback (most recent call last):
   File stdin, line 1, in ?
 AttributeError: 'module' object has no attribute 'Read'
 

does it work better if you type

import xexpr.Read

before you call the to_xexpr function?

/F 



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


Re: for line in file weirdness

2005-04-13 Thread SamIam
I think what you need to do is to have a nested if_else statment:
for line in filelines:
if some_condition : break
else: do_something_else

If the if statment is excuted then break return to for_loop
else do something different then return to for_loop.
When I read from a file I read the whole file into a variable then
work form the variable

file = open('InputString','r')  # open file
for reading only
filelines = map(string.strip,file.readlines())  #remove newlines
for string

Then you can just use the variable filelines and loop through as much
as you like. If I can help you can email me at [EMAIL PROTECTED]
I also use SKYPE username servando_garcia
Hope this helped.

Cordula's Web wrote:
 Hello,

 here's a strange bug (?) I've came across (using Python 2.2):

 # loop_1
 for line in file:
 if some_condition(line): break
 do_something()

 # loop_2
 for line in file:
 do_something_else()

 The problem is, that loop_2 doesn't resume where loop_1 left off, but
 skips many lines (a block's worth or so) before continuing.

 Why is this? Is reading from a file non-reentrant?

 It is always possible to slurp the whole file content into a list,
and
 then iterate through the list, but I want to handle HUGE files too.

 Thanks,
 -cpghost.
 
 -- 
 Cordula's Web. http://www.cordula.ws/

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


terminate exectutioin in PythonWin

2005-04-13 Thread Jim
Hi all
1.Could someone tell me how to terminate execution in PythonWin?
2.Can anyone recommend a free development environment in which you can 
save your workspace (e.g. open files, debugging breakpoints etc.)

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


Re: [perl-python] Python documentation moronicities (continued)

2005-04-13 Thread Sibylle Koczian
Pokerface schrieb:
Gotta say, is we let this man write the docs for us, they'll sure as
sugar be more colorful than the ones we presently have, even if he
doesn't manage to make them better.
The [insert relation]ing Python interpreter is usually installed
as /usr/local/bin/python on those g*dd*mn machines where it is
available; putting /usr/local/bin in your ing Unix shell's search
path makes it possible to start it by typing the command python to the
shell.  F***er.

Please think of people with other native languages who can possibly read 
the existing documentation without a dictionary but would certainly need 
one for this.

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


Re: Has Python 2.4.1 changed implementation for __init__.py???

2005-04-13 Thread Werner Merkl
Fredrik Lundh wrote:
Werner Merkl wrote:

I just downloaded http://www.python.org/pypi/xexpr/0.02, installed
if (python setup.py install) and tried the example in the README file.
Than I got following error: AttributeError: 'module' object has no attribute 
'Read'
This is same behavior for all module using empty __init__.pr files,
like venster, Pyrex or libxmlmods...

if xexpr is a package with an empty __init__.py file, the behaviour you're
seeing is the expected behaviour.  importing a toplevel module doesn't auto-
matically import any submodules.
Oh, I see. I have to write:
import xexpr.Read
Now it works...

Is there a change in the implementation, so that every module needs an
explicit list for exchanged modules?

what's an exchanged module?
Oops! This should say every module...
Thanx a lot
Werner

EXAMPLE

Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32
Type help, copyright, credits or license for more information.
import xexpr
example = 'foo a=b c=dbarbaz a=d /Blah/bar/foo'
xexpr.Read.to_xexpr(example)
Traceback (most recent call last):
 File stdin, line 1, in ?
AttributeError: 'module' object has no attribute 'Read'
does it work better if you type
import xexpr.Read
before you call the to_xexpr function?
/F 


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


Re: how to explain such codes, python's bug or mine?

2005-04-13 Thread Fredrik Lundh
MaHahaXixi [EMAIL PROTECTED] wrote:

 for python, i am a newbie, but i did not found the warning of such usage
 from the python tutorial

4.2 for Statements

It is not safe to modify the sequence being iterated over in the loop (this
can only happen for mutable sequence types, such as lists). If you need
to modify the list you are iterating over (for example, to duplicate 
selected
items) you must iterate over a copy. (followed by an example)

/F 



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


Re: terminate exectutioin in PythonWin

2005-04-13 Thread Larry Bates
1) To exit any application:

import sys
sys.exit(0)

2) I'm not familiar with any of these development systems.  I use
what comes with ActiveState's PythonWin.  It does have debugging
breakpoints, etc.

Larry Bates

Jim wrote:
 Hi all
 
 1.Could someone tell me how to terminate execution in PythonWin?
 
 2.Can anyone recommend a free development environment in which you can
 save your workspace (e.g. open files, debugging breakpoints etc.)
 
 Jim
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python documentation moronicities (continued)

2005-04-13 Thread rbt
runes wrote:
Generally: I have got my experiences with the Python Manual over the
the last 30 months Python beeing my preferred language. One of them is
that I have to look elsewhere.
I've gotten great help from this newsgroup. By following these steps:
1. Read the docs at http://docs.python.org/modindex.html
2. Trail  Error testing.
3. If 2 doesn't work or if I don't fully understand how it's working, I 
post a message here asking for help and clarification.

I've never been disappointed with the help I've received here. There 
will always be a few wise guys who like to make snide remarks and give 
arrogant answers, but it has been my experience that 95% of the people 
who answer do so with a very helpful, encouraging attitude.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Compute pi to base 12 using Python?

2005-04-13 Thread Roy Smith
In article [EMAIL PROTECTED],
 Dan Bishop [EMAIL PROTECTED] wrote:

 But there's no reason other than tradition why you should arrange them
 into groups of 10.

Well, it is traditional for people to have 10 fingers :-)

Other fun things to think about are negative bases.  For example, 3(10) = 
111(-2).  That's 1*(-2)^2  + 1*(-2)^1 + 1*(-2)^0 = 4 - 2 + 1.  I can't 
think of any use for negative bases, but they are a fun game to play with 
(if you're into that sort of stuff).

Non-integer bases are fun too.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: terminate exectutioin in PythonWin

2005-04-13 Thread Jim
Larry Bates wrote:
1) To exit any application:
import sys
sys.exit(0)
...

Thanks Larry.
Actually I meant how do I stop a program running that I have started in 
the interpreter. If I get into an infinite loop I can't stop it without 
qutting PythonWin.

Then I have to open all the files and re-insert breakpoints etc.  :(
Jim
--
http://mail.python.org/mailman/listinfo/python-list


preallocate list

2005-04-13 Thread Jim
Hi all
Is this the best way to preallocate a list of integers?
listName = range(0,length)
What about non integers?
I've just claimed in the newsgroup above that pre-allocating helps but I 
might be getting confused with matlab ;)

If I have a file with a floating point number on each line, what is the 
best way of reading them into a list (or other ordered structure)?

I was iterating with readline and appending to a list but it is taking ages.
Jim
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.4 killing commercial Windows Python development ?

2005-04-13 Thread Robin Becker
Raymond Hettinger wrote:
[Robin Becker]
People have mentioned the older v6 build scripts/tools still work. Last time I
tried they seemed a bit out of date.

I routinely use the current CVS to build Py2.4 and Py2.5 with MSC6.
It is effortless and I've had no problems.
Raymond Hettinger
 I wonder if it is maintained though.
Last time I tried I think I had to move it one level up to be correct for some 
of the python/my extension locations, but perhaps I misremember.
--
Robin Becker

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


Re: Python 2.4 killing commercial Windows Python development ?

2005-04-13 Thread Peter Hansen
Peter Hansen wrote:
The last I recall reading in this forum was that the regular
distribution is compiled with a copy of the compiler
*provided by* Microsoft.
On re-reading, I see this might not be clear enough.
By 'provided by' I meant *donated by*, as in given
free (apparently) to the PSF or at least to one of
the core developers for the purpose of compiling
Python itself.  Given the nature of Python, one
might see this as an implicit comment about the
status of the two key DLL files in question and
how concerned Microsoft is (or is not) about their
possible widespread distribution in software whose
authors didn't directly pay MS for the compiler.
A Google search might reveal the message in which
I read that, posted a few months ago I believe.
-Peter
--
http://mail.python.org/mailman/listinfo/python-list


Re: os.path.walk

2005-04-13 Thread Peter Hansen
Micheal wrote:
If I have os.path.walk(name, processDirectory, None) and processDirectory
needs three arguments how can I ass them because walk only takes 3?
The best answer to this is: if you aren't stuck
using a version of Python prior to 2.4, don't
use os.path.walk but use os.walk() instead...
-Peter
--
http://mail.python.org/mailman/listinfo/python-list


isbntools. (python script to download book informaiton)

2005-04-13 Thread paul
Hello,

I am trying to make up a catalogue of my books.

I found tools on isbntools.com in python.  YAY i thought.

Something happens! But I cant seem to get the part to download the books
information from amazon.com working correctly. It connects, but I think the
regular expressions used in the code aren't upto date(amazon has changed the
form or html code). I was wondering has anyone hacked around with it to get
it working.

Thanks.


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


Is socket.shutdown(1) useless

2005-04-13 Thread pyguy2
Issues of socket programming can be wierd, so I'm looking for some
comments.

In my python books I find exclusive use of socket.close(). From my
other readings, I know about a partial close operation. So, I figured
it would be useful to post some code about how socket.close() has an
implicit send in it and you can actually gain some clarity by being
more explicit with the partial close which means  splitting
socket.close() up into socket.shutdown(1) and socket.close().

And got a response in essence saying, why bother, socket.shutdown,
isn't useful.

Here is my thinking:

With a standard socket.close(), the client closes the socket
immediately after the implicit send. This means the client assumes it
was ok to actually close the socket, independant of how the server
reacts to that last bit of data. To me that is an assumption you may
not always want to make.

If, instead, the client does a socket.shutdown(1) to say it is done
sending, it can still recv and wait for the server to respond with
either:
1)yep, I agree you finished sending
or
2)I know you are done,and I got your data, but I do not think you are
done

To me these seem like a very useful distinction, since now if the
client cares, it can find out if it's final communication did matter.
It helps avoid what I call the princess bride phenomenon of #2:

You keep using that word. I do not think it means what you think it
means.

So, is this whole business with socket.shutdown mostly useless? So
useless that I cannot find any mention of it in 2nd edition,
Programming Python. 

john

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


Re: preallocate list

2005-04-13 Thread rbt
Jim wrote:
If I have a file with a floating point number on each line, what is the 
best way of reading them into a list (or other ordered structure)?

I was iterating with readline and appending to a list but it is taking 
ages.
Perhaps you should use readlines (notice the s) instead of readline.
--
http://mail.python.org/mailman/listinfo/python-list


Re: preallocate list

2005-04-13 Thread Bill Mill
On 4/13/05, Jim [EMAIL PROTECTED] wrote:
 Hi all
 
 Is this the best way to preallocate a list of integers?
 listName = range(0,length)
 

the 0 is unnecessary; range(length) does the same thing.

 What about non integers?
 

arr = [myobject() for i in range(length)]

 I've just claimed in the newsgroup above that pre-allocating helps but I
 might be getting confused with matlab ;)
 
 If I have a file with a floating point number on each line, what is the
 best way of reading them into a list (or other ordered structure)?
 
 I was iterating with readline and appending to a list but it is taking ages.
 

I would profile your app to see that it's your append which is taking
ages, but to preallocate a list of strings would look like:

[This is an average length string for i in range(approx_length)]

My guess is that it won't help to preallocate, but time it and let us
know. A test to back my guess:

import timeit, math

def test1():
lst = [0 for i in range(10)]
for i in xrange(10):
lst[i] = math.sin(i) * i

def test2():
lst = []
for i in xrange(10):
lst.append(math.sin(i) * i)

t1 = timeit.Timer('test1()', 'from __main__ import test1')
t2 = timeit.Timer('test2()', 'from __main__ import test2')
print time1: %f % t1.timeit(100)
print time2: %f % t2.timeit(100)

09:09 AM ~$ python test.py
time1: 12.435000
time2: 12.385000

Peace
Bill Mill
bill.mill at gmail.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: printing with wxPython

2005-04-13 Thread Fabio Pliger
Yeah,
There are two about printing... there is also an example in the wxDemo...
but they all talk about printing text... In my case i need to print (or at
least to make a print preview) a bitmap (or a panel...)


Peter Hansen [EMAIL PROTECTED] ha scritto nel messaggio
news:[EMAIL PROTECTED]
 Fabio Pliger wrote:
  Hi!
  I'm using wxPython to handle my application gui.. So,  I have a notebook
  widget and i have to print the object inside it's tab ... Maybe doing a
  preview before printing... I know that wx has many objects to handle
  printing.. i've tryied to use them, but i wasn't able to... Any hint? By
  now, i solved the problem saving a screenshot if the screen in an
image(bmp)
  and then sending it to printer... (a print preview would be cool...)
  tnx

 Maybe the recipes on the wxPython wiki page would
 help:
 http://wiki.wxpython.org/index.cgi/RecipesOther

 There are at least two dealing with Printing.


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


Re: preallocate list

2005-04-13 Thread Jim
rbt wrote:
Jim wrote:
If I have a file with a floating point number on each line, what is 
the best way of reading them into a list (or other ordered structure)?

I was iterating with readline and appending to a list but it is taking 
ages.

Perhaps you should use readlines (notice the s) instead of readline.
I don't know if I thought of that, but I'm tokenizing each line before 
adding to a list of lists.

for line in f:
factor = []
tokens = line.split()
for i in tokens:
factor.append(float(i))
factors.append(factor)
Is this nasty?
Jim
--
http://mail.python.org/mailman/listinfo/python-list


Re: preallocate list

2005-04-13 Thread Bill Mill
Just a correction:

snip
 I would profile your app to see that it's your append which is taking
 ages, but to preallocate a list of strings would look like:
 
 [This is an average length string for i in range(approx_length)]
 
 My guess is that it won't help to preallocate, but time it and let us
 know. A test to back my guess:
 
 import timeit, math
 
 def test1():
 lst = [0 for i in range(10)]
 for i in xrange(10):
 lst[i] = math.sin(i) * i
 
 def test2():
 lst = []
 for i in xrange(10):
 lst.append(math.sin(i) * i)
 
 t1 = timeit.Timer('test1()', 'from __main__ import test1')
 t2 = timeit.Timer('test2()', 'from __main__ import test2')
 print time1: %f % t1.timeit(100)
 print time2: %f % t2.timeit(100)
 

The results change slightly when I actually insert an integer, instead
of a float, with lst[i] = i and lst.append(i):

09:14 AM ~$ python test.py
time1: 3.352000
time2: 3.672000

The preallocated list is slightly faster in most of my tests, but I
still don't think it'll bring a large performance benefit with it
unless you're making a truly huge list.

I need to wake up before pressing send.

Peace
Bill Mill
--
http://mail.python.org/mailman/listinfo/python-list


Re: preallocate list

2005-04-13 Thread Jim
Thanks for the suggestions. I guess I must ensure that this is my bottle 
neck.
code
def readFactorsIntoList(self,filename,numberLoads):
	factors = []
f = open(self.basedir + filename,'r')
line = f.readline()
tokens = line.split()
columns = len(tokens)
if int(columns) == number:
for line in f:
factor = []
tokens = line.split()
for i in tokens:
factor.append(float(i))
factors.append(loadFactor)
else:
for line  in f:
tokens = line.split()
factors.append([float(tokens[0])] * number)
	return factors
/code

OK. I've just tried with 4 lines and the code works. With 11000 lines it 
uses all CPU for at least 30 secs. There must be a better way.

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


Re: database in python ?

2005-04-13 Thread Terry Hancock
On Tuesday 12 April 2005 04:54 pm, Pierre-Frédéric Caillaud wrote:
   Speaking of the manual, the mysql manual is quite... well... i don't  
 quite find the word, but it has many sentences which sound like PR stuff.  
 Like, we don't do this like you or anyone would expect, but there is a  
 reason ! Embrace our school of thought, stop worrying about integrity  !  
 Peace, my friend, etc. And the non-working examples posted in the user  
 comments are nice to look at, too. The organization of the manual is a  
 mess, too, it's often quite difficult to find what I seek. The postgres  
 manual is just wonderful.

Whereas the Postgresql manual starts with an explanation of how the
universe was formed and goes on to a diatribe against anyone who
ever works on a competing RDBMS because it wastes effort.
Arrogance like that is stunning, and it destroys my confidence in the
project itself if the people responsible for it think like that.

I put it down at that point, myself. ;-)

It would be nice to think that that has been since removed, but I
haven't bothered to check. 

Actually, I'm exaggerating, but I certainly found the MySQL online
manual vastly easier to read than the Postgresql documentation.  That
may not be a totally fair comparison, since I'm comparing the MySQL
manual *now* to the Postgresql manual *then*.   But then you all
keep describing MySQL's 1990s feature set, including the licensing.

   I know I'm feeding the flamewar, but I can't resist, 

Yeah, well, as long as we don't take ourselves too seriously. ;-)

 once I came up on a  
 post on the mysql website from a guy basically saying wow, the fulltext  
 is so powerful, I can search this document set in only half a second !  
 and then the same day, on the postgres mailinglist, there was a message  
  from a guy who was really upset because his full text search on something  
 like 1000 times bigger would take more than one tenth a second, and that  
 wan't really acceptable for him, and then several competent people  
 responded and helped him make it work.

That's interesting.  Most sources I've read seemed to suggest that postgresql
is slower than MySQL, at least for modest size tables.  There must, I suppose,
be some turnover point on the size of the database?  Or are you arguing that
postgresql is now faster than MySQL in the general case?  Can you suggest
sources for investigating that formally?

It's just possible that I should reconsider Postgresql compatibility. I
would assume that using the Python DB API would make portability
between the two easier in any case, wouldn't it?

Cheers,
Terry

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com

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


Re: preallocate list

2005-04-13 Thread Mike C. Fletcher
Jim wrote:

 Thanks for the suggestions. I guess I must ensure that this is my
 bottle neck.

...

 for line in f:
 factor = []
 tokens = line.split()
 for i in tokens:
 factor.append(float(i))
 factors.append(loadFactor)

...

You might try:

factors = [ [float(item) for item in line.split()] for line in f ]

avoiding the extra statements for appending to the lists.  Also might try:

factors = [ map(float, line.split()) for line in f ]

though it uses the out-of-favour functional form for the mapping.

Good luck,
Mike


  Mike C. Fletcher
  Designer, VR Plumber, Coder
  http://www.vrplumber.com
  http://blog.vrplumber.com

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


Re: terminate exectutioin in PythonWin

2005-04-13 Thread Neil Hodgson
Jim,

 1.Could someone tell me how to terminate execution in PythonWin?

   Use the Break into running code command on the context menu of the 
PythonWin icon in the bottom right of the taskbar.

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


Re: terminate exectutioin in PythonWin

2005-04-13 Thread Jim
Neil Hodgson wrote:
Jim,

1.Could someone tell me how to terminate execution in PythonWin?

   Use the Break into running code command on the context menu of the 
PythonWin icon in the bottom right of the taskbar.

   Neil
Great thanks! PythonWin isn't hot on keyboard shortcuts but ironically 
calls this a KeyboardInterrupt :|

Know any keyboard shortcuts for debug view? e.g. open it, run(debug), 
step etc.

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


Re: Scanner Access in Python

2005-04-13 Thread Fredrik Lundh
GMane Python wrote:

  I was hoping for a bit of advise.  I wanted to know if anyone has any
 experience with scanning.  I'm mostly using Windows.  I tried quickly the
 pyTwain, but haven't gotten too far with that.  I'm not sure if scanner
 access is built-in to other packages, such as maybe PIL or any others?

the PIL source kit includes a contributed Sane interface.  (I think binary RPM:s
are available for some platforms, but I'm not sure).

/F 



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


Re: sort of a beginner question about globals

2005-04-13 Thread fred.dixon
I want to use OPTIONS as a global var.
In this particular case I am trying to set a global debug constant so I
can have some debug logging happen when my program is run with a
-debug option.
what will actuall end up in OPTIONS is OPTIONS.debug = True as i am
using optparse module.

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


Re: preallocate list

2005-04-13 Thread peufeu
what about :
factors = [map(float, line.split()) for line in file]
should be a hell of a lot faster and nicer.
 for line in f:
 factor = []
 tokens = line.split()
 for i in tokens:
 factor.append(float(i))
 factors.append(factor)
Is this nasty?
Jim
--
http://mail.python.org/mailman/listinfo/python-list


Re: Compute pi to base 12 using Python?

2005-04-13 Thread Dan Bishop
Dick Moores wrote:
 Dan Bishop wrote at 04:07 4/13/2005:
...
 For a floating-point number x, the representation with d decimal
 places count be found by taking the representation of int(round(x *
 radix ** d)) and inserting a . d places from the right.

 But I'm sorry, but I can't follow you. I do have the first 1 or
so
 places of pi base 10 (http://mathwithmrherte.com/pi_digits.htm),
but
 could you show me what to do with, say, just 3.14159?

First, decide how many decimal places to use for the conversion.
Five decimal digits is equivalent to 5*log(10)/log(12) = 4.63 base-12
digits, so use 4 digits.

Next, multiply by 12**4, obtaining the value 65144.01024, and round to
the nearest integer, 65144.  Convert this to base 12, obtaining 31848.
But this is 12**4 times the number we really want, so divide this by
12**4 (i.e., shift the radix point left 4 places), for a final result
of 3.1848.

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


Re: sort of a beginner question about globals

2005-04-13 Thread Steven Bethard
fred.dixon wrote:
I want to use OPTIONS as a global var.
In this particular case I am trying to set a global debug constant so I
can have some debug logging happen when my program is run with a
-debug option.
what will actuall end up in OPTIONS is OPTIONS.debug = True as i am
using optparse module.
Why not just make options a module?
Then you can do something like:
- options.py -
debug = False
--
- file1.py -
import file2
import options
options.debug = True
a = file2.class1()
a.func1()

- file2.py -
import options
class class1(object):
def func1(self):
if options.debug:
print 'Debugging'
pass

Note that if you're trying to output debugging messges, you should 
really look into the logging module instead.

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


Re: os.path.walk

2005-04-13 Thread Steven Bethard
Peter Hansen wrote:
Micheal wrote:
If I have os.path.walk(name, processDirectory, None) and processDirectory
needs three arguments how can I ass them because walk only takes 3?
The best answer to this is: if you aren't stuck
using a version of Python prior to 2.4, don't
use os.path.walk but use os.walk() instead...
I believe os.walk was introduced in 2.3 (according to the docs[1]), so 
unless you're using a really old Python, you should be able to use it.

I also agree that os.walk is *much* simpler.
STeVe
[1] http://docs.python.org/lib/os-file-dir.html#l2h-1628
--
http://mail.python.org/mailman/listinfo/python-list


Re: database in python ?

2005-04-13 Thread Steve Holden
Terry Hancock wrote:
[...]
That's interesting.  Most sources I've read seemed to suggest that postgresql
is slower than MySQL, at least for modest size tables.  There must, I suppose,
be some turnover point on the size of the database?  Or are you arguing that
postgresql is now faster than MySQL in the general case?  Can you suggest
sources for investigating that formally?
It's just possible that I should reconsider Postgresql compatibility. I
would assume that using the Python DB API would make portability
between the two easier in any case, wouldn't it?
Cheers,
Terry
--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com
I don't know about the whole picture, but I know form evidence on this 
group that there are PostgreSQL driver modules (the name psycopg comes 
to mind, but this may be false memory) that appear to take diabolical 
liberties with DBAPI-2.0, whereas my experience with MySQLdb has been 
that I can interchange the driver with mxODBC (for example) as a drop-in 
replacement (modulo the differing paramstyles :-().

regards
 Steve
--
Steve Holden+1 703 861 4237  +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
--
http://mail.python.org/mailman/listinfo/python-list


Codig style: or

2005-04-13 Thread Sara Khalatbari
Hi!

Suppose you're writing a module  writing the
definition of each function in that module in  or
.
for example:
a) This function does this  that
or:
b)  This function does blah blah blah

What are the differences between  and  ? 
I'm using gedit  I wanna know a bit about coding
style.

To be very honest: I have a very strict boss who looks
for bugs in my codes  he insists to know exactly
which 'CODING STYLE AUTHORITATIVE SOURCE' I've based
my coding style on when using  or .

Can anybody out there give me some hint?
Can anybody tell me where to find a document on python
coding style.

tnx,
Sara



__ 
Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/
-- 
http://mail.python.org/mailman/listinfo/python-list


A Question About Handling SIGINT With Threads

2005-04-13 Thread Keith
I got this to work, but was hoping there was a better way.  I was
hoping that I wouldn't have to use globals.  I wouldn't doubt that I
could be totally off in what I am doing.

Here is some psuedo-code of what I did:

def main_thread():
  # Don't know how to get rid of these guys
  global lock
  global my_thread

  # Set up a signal handler for Ctrl-C
  signal.signal(signal.SIGINT, sighdlr)

  # Create  start thread
  lock = thread.allocate_lock()
  lock.acquire()
  my_thread = threading.Thread(
  target=child_thread,
  name='thread_test',
  args=(lock,)
  my_thread.start()

  do_some_work_here()

  # Tell thread to stop working
  lock.release()

  # Wait for child thread to finish
  my_thread.join()

def child_thread(lock):

  while lock.locked():
  do_some_stuff()

  do_some_cleanup()

def sighdlr(signum, frame):

  # Allow child to finish
  lock.release()
  my_thread.join()
  sys.exit(1)

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


Re: preallocate list

2005-04-13 Thread Steven Bethard
Jim wrote:
Thanks for the suggestions. I guess I must ensure that this is my bottle 
neck.
code
def readFactorsIntoList(self,filename,numberLoads):
factors = []
f = open(self.basedir + filename,'r')
line = f.readline()
tokens = line.split()
columns = len(tokens)
if int(columns) == number:
for line in f:
factor = []
tokens = line.split()
for i in tokens:
factor.append(float(i))
factors.append(loadFactor)
else:
for line  in f:
tokens = line.split()
factors.append([float(tokens[0])] * number)
return factors
/code

OK. I've just tried with 4 lines and the code works. With 11000 lines it 
uses all CPU for at least 30 secs. There must be a better way.
Was your test on *just* this function?  Or were you doing something with 
the list produced by this function as well?

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


Re: sort of a beginner question about globals

2005-04-13 Thread fred.dixon
how would i use the following if OPTIONS was in a module ?
---
from optparse import OptionParser

usage = usage: %prog [options] arg
parser = OptionParser(usage)

parser.add_option(-d, --debug, ction=store_true, dest=verbose)
(OPTIONS = parser.parse_args()

ps
Im not anywhere near my program right now just doing some kunch time
surfing.

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


Re: terminate exectutioin in PythonWin

2005-04-13 Thread Steve Holden
Jim wrote:
[...]
Actually I meant how do I stop a program running that I have started in 
the interpreter. If I get into an infinite loop I can't stop it without 
qutting PythonWin.

Then I have to open all the files and re-insert breakpoints etc.  :(
Jim
Look in the system tray! Right-mouse on the Python and select break 
into running program.

regards
 Steve
--
Steve Holden+1 703 861 4237  +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Codig style: or

2005-04-13 Thread Roy Smith
Sara Khalatbari  [EMAIL PROTECTED] wrote:
What are the differences between  and  ? 

The triple-quote form lets you write multi-line quoted strings:

This function does a lot of neat stuff.  It takes
many lines of text to describe what it does.

Multiple paragraphs, even.


To be very honest: I have a very strict boss who looks
for bugs in my codes  he insists to know exactly
which 'CODING STYLE AUTHORITATIVE SOURCE' I've based
my coding style on when using  or .

Show him PEP-8 (http://www.python.org/peps/pep-0008.html).  PEP-8, in
turn, references a few other style PEPs.  If adopting them wholesale
as authoritative is all you need to keep your PHB happy, go for it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is socket.shutdown(1) useless

2005-04-13 Thread Steven Bethard
[EMAIL PROTECTED] wrote:
In my python books I find exclusive use of socket.close(). From my
other readings, I know about a partial close operation. So, I figured
it would be useful to post some code about how socket.close() has an
implicit send in it and you can actually gain some clarity by being
more explicit with the partial close which means  splitting
socket.close() up into socket.shutdown(1) and socket.close().
And got a response in essence saying, why bother, socket.shutdown,
isn't useful.
I had to use socket.shutdown once because the socket architecture we had 
relied on sending a piece of data, waiting for it to be processed, and 
then receiving a result back.  The server on the other end of the socket 
wouldn't process anything until it was sure that all data had been sent. 
 So our code basically looked like:

s = socket.socket(...)
s.connect(...)
s.send(...)
s.shutdown(1)
data = s.makefile().read()
s.close()
STeVe
--
http://mail.python.org/mailman/listinfo/python-list


Re: Codig style: or

2005-04-13 Thread Will McGugan
Sara Khalatbari wrote:
Hi!
Suppose you're writing a module  writing the
definition of each function in that module in  or
.
for example:
a) This function does this  that
or:
b)  This function does blah blah blah
What are the differences between  and  ? 
I'm using gedit  I wanna know a bit about coding
style.

To be very honest: I have a very strict boss who looks
for bugs in my codes  he insists to know exactly
which 'CODING STYLE AUTHORITATIVE SOURCE' I've based
my coding style on when using  or .
Can anybody out there give me some hint?
Can anybody tell me where to find a document on python
coding style.
Triple quotes allow you to have quotes inside the string. I tend to use 
triple quotes if I'm writing text of any length, that way I dont need to 
change anything if I do need to insert a quote. I dont think its a 
matter of coding style, its purely a practical issue. If your PHB 
insists on consistency, I would just use 

Will McGugan
--
http://www.willmcgugan.com
.join( [ {'*':'@','^':'.'}.get(c,None) or chr(97+(ord(c)-84)%26) for c 
in jvyy*jvyyzpthtna^pbz ] )
--
http://mail.python.org/mailman/listinfo/python-list


Re: Codig style: or

2005-04-13 Thread Bill Mill
On 4/13/05, Sara Khalatbari [EMAIL PROTECTED] wrote:
 Hi!
 
 Suppose you're writing a module  writing the
 definition of each function in that module in  or
 .
 for example:
 a) This function does this  that
 or:
 b)  This function does blah blah blah
 
 What are the differences between  and  ?
 I'm using gedit  I wanna know a bit about coding
 style.
 
 To be very honest: I have a very strict boss who looks
 for bugs in my codes  he insists to know exactly
 which 'CODING STYLE AUTHORITATIVE SOURCE' I've based
 my coding style on when using  or .
 
 Can anybody out there give me some hint?
 Can anybody tell me where to find a document on python
 coding style.
 

the authoritative coding style guide is pep 8:

http://www.python.org/peps/pep-0008.html

Of course, there are style points that are debatable, but for
comments, you should definitely be using triple-quotes. Pep 8 points
you to pep 257, which is all about docstrings:

http://www.python.org/peps/pep-0257.html

Peace
Bill Mill
bill.mill at gmail.com
--
http://mail.python.org/mailman/listinfo/python-list


Kamaelia 0.1.2 Released

2005-04-13 Thread Michael Sparks
Kamaelia 0.1.2 has been released!


What is it?
===
Kamaelia is a collection of Axon components designed for network
protocol experimentation in a single threaded, select based environment.
Axon components are python generators are augmented by inbox and outbox
queues (lists) for communication in a communicating sequential processes
(CSP) like fashion.

The architecture is specifically designed to try and simplify the
process of designing and experimenting with new network protocols in
real environments.

This release contains components allowing the creation of TCP based
clients and servers, and includes a few (very) simple protocol handlers
to show usage.

Other components include vorbis decode and playback, asynchronous file
reading, and equivalents of tee and strings. (Writing systems is
much like building unix pipelines, hence the need for similar tools)

The system is known to work under Linux, Mac OS X, Windows and a subset
works on Series 60 mobiles.

We've also started a weblog which will form an informal discussion forum
for issues generally surrounding kamaelia. (We might put things like
tutorials there for example)
   * http://kamaelia.sourceforge.net/cgi-bin/bl


What's new in version 0.1.2 ?
=

Additionally tested under Windows ME, 2000 and Mac OS X, along with
a subset tested on Series 60 mobiles and compatibility updates made
as a result. Ability to make simple multicast servers, clients and
transceivers added. Test harnesses for network servers tightened up.

Collection of examples added in the Examples directory:
   * Example 1 : Contains a simple FortuneCookie protocol system.
 Includes a server and client as part of a single system.

   * Example 2 : This has much the same structure, but rather than serve
 and display fortune cookies, serves (ogg vorbis) audio over a TCP
 connection to a client which decodes and plays back the audio.

   * Example 3 : Splits the structure in example 2 into a specific
 server application and a client application. This puts the two
 halves at odds, *competing* with each other for CPU time. Thus if
 both are run on the same (single CPU) system you will hear audio
 breakage. If run on separate machines (as client and server(!)) you
 won't hear this. In practice, part of the issue is that there is no
 buffering in the receiver.

   * Example 4 : Simple multicast based streaming system. Since it uses
 raw ogg vorbis with no resends and no codebook facility, you will
 need to *start all the client machines first* and *then* the
 server. Uses the multicast transceiver object exclusively.


Requirements

   * Python 2.3 or higher recommended, though please do report any bugs
 with 2.2.
   * Axon (Any released version, 1.0.3 recommended, 1.0.4 when released)
   * vorbissimple (if you want to use the vorbis decode component)

(Both Axon and vorbissimple are separate parts of the Kamaelia project,
and available at the same download location - see below)


Platforms
=
Kamaelia has been used successfully under both Linux, Windows and Mac OS
X. A subset of Kamaelia has been successfully tested on Series 60 Nokia
mobiles when used with the Axon SERIES 60 branch.

Where can I get it?
===
Web pages are here:
   http://kamaelia.sourceforge.net/Docs/
   http://kamaelia.sourceforge.net/ (includes info on mailing lists)

ViewCVS access is available here:
   http://cvs.sourceforge.net/viewcvs.py/kamaelia/

Weblog
   * http://kamaelia.sourceforge.net/cgi-bin/bl


Licensing
=
Kamaelia is released under the Mozilla tri-license scheme
(MPL/GPL/LGPL). Specifically you may choose to accept either
the Mozilla Public License 1.1, the GNU General Public License
2.0 or the Lesser General Public License 2.1. Proprietary terms
and conditions available upon request.

Best Regards,


Michael.
-- 
[EMAIL PROTECTED]
British Broadcasting Corporation, Research and Development
Kingswood Warren, Surrey KT20 6NP

This message (and any attachments) may contain personal views
which are not the views of the BBC unless specifically stated.


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


RE: Codig style: or

2005-04-13 Thread Harper, Gina
Try PEP 8, Guido's Style Guide:
http://www.python.org/peps/pep-0008.html
Good luck with your boss!

*gina*

-Original Message-
From: Sara Khalatbari [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, April 13, 2005 11:13 AM
To: Python List
Subject: Codig style:  or 


Hi!

Suppose you're writing a module  writing the
definition of each function in that module in  or
.
for example:
a) This function does this  that
or:
b)  This function does blah blah blah

What are the differences between  and  ? 
I'm using gedit  I wanna know a bit about coding
style.

To be very honest: I have a very strict boss who looks
for bugs in my codes  he insists to know exactly
which 'CODING STYLE AUTHORITATIVE SOURCE' I've based
my coding style on when using  or .

Can anybody out there give me some hint?
Can anybody tell me where to find a document on python
coding style.

tnx,
Sara



__ 
Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/

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


Re: database in python ?

2005-04-13 Thread peufeu
postgresql
is slower than MySQL, at least for modest size tables.  There must, I
	When not using transactions, MySQL will blow away postgres in  
INSERT/UPDATE speed until the concurrency gets up a bit and the readers  
block writers strategy used by MyISAM starts to show its weaknesses.
	This is in agreement with mass hosting for instance, a lot of small  
databases on a mysql will not have concurrency problems.
	Of course when not using transactions you have to remind that your data  
is not secure, and any power crash might corrupt your database.
	Postgres on a RAID with battery backed up cache will no longer have to  
sync the disk on each transaction so it gets a lot faster, and you still  
have data security. You can also run it with fsync=off for a massive  
speedup in transactions per second but you lose data security.
	When using transactions (innodb) I've read that postgres is a bit faster.
	Regarding query optimization, for simple dumb queries like grabbing a row  
from a table, mysql will be a little faster (say 0.2 vs 0.3 ms), and for  
medium complex queries like joins on = 4 medium sized tables (10 K rows)  
postgres can be faster by anything from 1x to 1000x. I've seen it happen,  
the same query taking 0.5 seconds in my and 0.5 ms in postgres, simply  
because mysql can't plan it correctly.

suppose,
be some turnover point on the size of the database?  Or are you arguing  
that
postgresql is now faster than MySQL in the general case?  Can you
I'd suggest that on anything medium postgres will be a lot faster.
I don't know about the whole picture, but I know form evidence on this  
group that there are PostgreSQL driver modules (the name psycopg comes  
to mind, but this may be false memory) that appear to take diabolical  
liberties with DBAPI-2.0, whereas my experience with MySQLdb has been  
that I can interchange the driver with mxODBC (for example) as a drop-in  
replacement (modulo the differing paramstyles :-().
	psycopg is extremely fast and powerful, so it makes a lot more things  
that the dbapi says.
	I'd say that database independence is an utopia, once you start to use  
triggers and stored procedures and specific column types, you'll be more  
or less tied to one database, and doing this is necessary to get good  
performance and generally do things right.
--
http://mail.python.org/mailman/listinfo/python-list


Re: for line in file weirdness

2005-04-13 Thread Cordula's Web
A read-ahead buffer? Yes, that would explain it. Sorry, I missed this
piece of information in the documentation.

Thanks to all who replied.

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


Re: preallocate list

2005-04-13 Thread Jim
Steven Bethard wrote:
Jim wrote:
Thanks for the suggestions. I guess I must ensure that this is my 
bottle neck.
code
def readFactorsIntoList(self,filename,numberLoads):
factors = []
f = open(self.basedir + filename,'r')
line = f.readline()
tokens = line.split()
columns = len(tokens)
if int(columns) == number:
for line in f:
factor = []
tokens = line.split()
for i in tokens:
factor.append(float(i))
factors.append(loadFactor)
else:
for line  in f:
tokens = line.split()
factors.append([float(tokens[0])] * number)
return factors
/code

OK. I've just tried with 4 lines and the code works. With 11000 lines 
it uses all CPU for at least 30 secs. There must be a better way.

Was your test on *just* this function?  Or were you doing something with 
the list produced by this function as well?

Just this. I had a breakpoint on the return.
I'm going to try peufeu's line of code and I'll report back.
Jim
--
http://mail.python.org/mailman/listinfo/python-list


Re: sort of a beginner question about globals

2005-04-13 Thread Steven Bethard
fred.dixon wrote:
how would i use the following if OPTIONS was in a module ?
---
from optparse import OptionParser
usage = usage: %prog [options] arg
parser = OptionParser(usage)
parser.add_option(-d, --debug, ction=store_true, dest=verbose)
(OPTIONS = parser.parse_args()
Just have this code update the options module:
import options
...
opts, args = parser.parse_args()
options.__dict__.update(opts.__dict__)
STeVe
--
http://mail.python.org/mailman/listinfo/python-list


Re: Codig style: or

2005-04-13 Thread Steven Bethard
Sara Khalatbari wrote:
Hi!
Suppose you're writing a module  writing the
definition of each function in that module in  or
.
for example:
a) This function does this  that
or:
b)  This function does blah blah blah
What are the differences between  and  ? 
I'm using gedit  I wanna know a bit about coding
style.

To be very honest: I have a very strict boss who looks
for bugs in my codes  he insists to know exactly
which 'CODING STYLE AUTHORITATIVE SOURCE' I've based
my coding style on when using  or .
Can anybody out there give me some hint?
Can anybody tell me where to find a document on python
coding style.
PEP 8:
http://www.python.org/peps/pep-0008.html
and for docstrings, PEP 257:
http://www.python.org/peps/pep-0257.html
which says:
For consistency, always use triple double quotes around docstrings.
STeVe
--
http://mail.python.org/mailman/listinfo/python-list


  1   2   3   >