Re: Python / web

2005-09-02 Thread garabik-news-2005-05
Robert <[EMAIL PROTECTED]> wrote:
> Hi,
> I know general Python pretty well and interested in using Python for a 
> web project. It will have the standard display, user input, fields, 
> look-ups, reports, database routines, etc. Been looking though the 
> Python web docs. and seeing stuff like mod_python, CGI, PSP, CherryPy, 
> etc...,  Also a fair amount of googling. I'll say there's a large 
> amount of technology to pick from.  Rather than spend time going down 
>  the wrong road, can I get some feedback as directions from you folks 
> that's "been there, done that."

I am now writing a moderately complex application using karrigell.
It has a very shallow learning curve, if you know python and html, you
can start writing an application right away, but yet it is rather
versatile, and the author is responding.

-- 
 ---
| Radovan Garabík http://kassiopeia.juls.savba.sk/~garabik/ |
| __..--^^^--..__garabik @ kassiopeia.juls.savba.sk |
 ---
Antivirus alert: file .signature infected by signature virus.
Hi! I'm a signature virus! Copy me into your signature file to help me spread!
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: reg email packages work

2005-09-02 Thread Tim Roberts
praba kar <[EMAIL PROTECTED]> wrote:
>
>   I am working in web based email system project.
>Here I try to build email message
>from scratch. I used below code to build email
>message
>
>   msg =  email.MIMEBase('text','html')
>   msg['Return-Path'] = user+'@'+domain
>   msg['Date'] = formatdate(localtime=1)
>   msg['Subject'] =  subject
>   msg['From'] = from_name
>   msg['To'] = to
>   msg['Cc'] = cc
>   msg.set_payload("Body of the email messagge")
>   fh = os.popen('/bin/sendmail  %s'% (eachid),'w')
>   fh.write(msg.as_string())
>   fh.close()
>
>This code will build plain email message properly.

No, it doesn't.  It builds an HTML message (see the very first line).  If
you supply plain text to this as the body of the message, all the lines
will be concatenated together, which sounds a lot like what you are seeing.

If you are not feeding HTML as the body, change the fist line to
('text','plain').
-- 
- Tim Roberts, [EMAIL PROTECTED]
  Providenza & Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The penis is way too delicate for masturbation

2005-09-02 Thread Sybren Stuvel
Steve Holden enlightened us with:
> [about Americans]
> Personally I find that most individuals, no matter how misguided,
> have their hearts in the right place.

Same here. Then again, I might have just met the smart ones who were
visiting Europe.





Just kidding!

Sybren
-- 
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself? 
 Frank Zappa
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Code run from IDLE but not via double-clicking on its *.py

2005-09-02 Thread Richie Hindle

[Richie]
> Now what does the python Command Prompt say?

[n00m]
> It says... NOTHING! It just DISAPPEARS!

That's the strangest thing I've heard all week.  8-)

OK, one more thing to try - redirect the output of Python to some files
and see whether anything useful appears in the files:

C:\> d:
D:\> cd \python23
D:\> python d:\python23\socket6.py > out.txt 2> err.txt

Does anything appear in d:\python23\out.txt or d:\python23\err.txt?

[Dennis]
> I'd be tempted to blame the VBS script then... 

n00m, can you post the vbs?

-- 
Richie Hindle
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bug in string.find

2005-09-02 Thread Fredrik Lundh
Ron Adam wrote:

>> indices point to the "gap" between items, not to the items themselves.
>
> So how do I express a -0?  Which should point to the gap after the last
> item.

that item doesn't exist when you're doing plain indexing, so being able
to express -0 would be pointless.

when you're doing slicing, you express it by leaving the value out, or by
using len(seq) or (in recent versions) None.

>> straight indexing returns the item just to the right of the given gap (this 
>> is
>> what gives you the perceived assymmetry), slices return all items between
>> the given gaps.
>
> If this were symmetrical, then positive index's would return the value
> to the right and negative index's would return the value to the left.

the gap addressing is symmetrical, but indexing always picks the item to
the right.

> Have you looked at negative steps?  They also are not symmetrical.

> print a[3:2:-1]# d   These are symetric?!

the gap addressing works as before, but to understand exactly what characters
you'll get, you have to realize that the slice is really a gap index generator. 
 when
you use step=1, you can view slice as a "cut here and cut there, and return 
what's
in between".  for other step sizes, you have to think in gap indexes (for which 
the
plain indexing rules apply).

and if you know range(), you already know how the indexes are generated for
various step sizes.

from the range documentation:

... returns a list of plain integers [start, start + step, start + 2 * 
step, ...].
If step is positive, the last element is the largest start + i * step less 
than
stop; if step is negative, the last element is the largest start + i * step
greater than stop.

or, in sequence terms (see http://docs.python.org/lib/typesseq.html )

(3) If i or j is negative, the index is relative to the end of the string: 
len(s) + i
or len(s) + j is substituted.

...

(5) The slice of s from i to j with step k is defined as the sequence of 
items
with index x = i + n*k for n in the range(0,(j-i)/k). In other words, the
indices are i, i+k, i+2*k, i+3*k and so on, stopping when j is reached
(but never including j).

so in this case, you get

>>> 3 + 0*-1
3
>>> 3 + 1*-1
2 # which is your stop condition

so a[3:2:-1] is the same as a[3].

> print a[-4:-5:-1]  # d

same as a[-4]

> print a[3:-5:-1]   # d

now you're mixing addressing modes, which is a great way to confuse
yourself.  if you normalize the gap indexes (rule 3 above), you'll get
a[3:2:-1] which is the same as your earlier example.  you can use the
"indices" method to let Python do this for you:

>>> slice(3,-5,-1).indices(len(a))
(3, 2, -1)
>>> range(*slice(3,-5,-1).indices(len(a)))
[3]

> print a[-4:2:-1]   # d

same problem here; indices will tell you what that really means:

>>> slice(-4,2,-1).indices(len(a))
(3, 2, -1)
>>> range(*slice(-4,2,-1).indices(len(a)))
[3]

same example again, in other words.  and same result.

> This is why it confuses so many people.  It's a shame too, because slice
> objects could be so much more useful for indirectly accessing list
> ranges. But I think this needs to be fixed first.

as everything else in Python, if you use the wrong mental model, things
may look "assymmetrical" or "confusing" or "inconsistent".  if you look at
how things really work, it's usually extremely simple and more often than
not internally consistent (since the designers have the "big picture", and
knows what they're tried to be consistent with; when slice steps were
added, existing slicing rules and range() were the obvious references).

it's of course pretty common that people who didn't read the documentation
very carefully and therefore adopted the wrong model will insist that Python
uses a buggy implementation of their model, rather than a perfectly consistent
implementation of the actual model.  slices with non-standard step sizes are
obviously one such thing, immutable/mutable objects and the exact behaviour
of for-else, while-else, and try-else are others.  as usual, being able to reset
your brain is the only thing that helps.

 



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


fileinput.input - newbie question

2005-09-02 Thread martijn
I'm testing some writing/reading with a file and i'm not sure if it is
possible to print/use the line with fileinput.input inplace=1 (see
below)


import fileinput
thefile = fileinput.input('bla.txt',inplace=1,backup='.bak')
for line in thefile:
if line != "1\n":
print line,

#is it possible to 'use' / print the 'line' on the screen here?

thefile.close()

When its not possible then I use 2 file's filein.txt,fileout.txt

Thanks,
GC-Martijn

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


Re: Code run from IDLE but not via double-clicking on its *.py

2005-09-02 Thread n00m
LOL... seems it disappears only in Win98. In Win2k it goes like this:

C:\>d:
D:\>python23\python d:\python23\socket6.py
D:\>


> C:\> d:
> D:\> cd \python23
> D:\> python d:\python23\socket6.py > out.txt 2> err.txt
> Does anything appear in d:\python23\out.txt or d:\python23\err.txt?
NOTHING APPEARED IN THEM.

> n00m, can you post the vbs?

Set cn = CreateObject("ADODB.Connection")
cn.Open _
"Provider=sqloledb;Data Source=192.168.0.3,1434;" & _
"Network Library=DBMSSOCN;Initial Catalog=pubs;" & _
"User ID=qwe;Password=asdasd;"
cn.Execute "select top 1 * from authors;"
cn.Close
Set cn = Nothing

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


Re: Proposal: add sys to __builtins__

2005-09-02 Thread Michael Hoffman
MrJbQ7 wrote:
> Steve Holden wrote:
> 
>>I wonder if it would be worth special-casing the AttributeError [snip]
> 
> What is it that Tim Peters said? "Special cases aren't special
> enough..."

That suggestion is a little too much magic for me.

> Besides, a better way is to use your ~/.pythonrc file for customizing
> according to your needs.
> 
> A simple:
> 
>   echo "import sys, os" >> ~./pythonrc
> 
> will do the job.

Until someone else tries to use your script or module.
-- 
Michael Hoffman
-- 
http://mail.python.org/mailman/listinfo/python-list


plotting with gnuplot.py

2005-09-02 Thread [EMAIL PROTECTED]
Hi,

I've been having some problems trying some basic plotting commands with
gnuplot.py. My setup is the Python 2.3 Enthought edition and my script
looks as:

from scipy import *
from scipy import gplt
import scipy.io.array_import
#import Gnuplot

filename = ('Default.PL1')
data = scipy.io.array_import.read_array(filename)


y = data[:,1]
x = data[:,0]
z = data[:,2]
gplt.plot(x,y,'with points')
gplt('set logscale x')
gplt('set logscale y')


With the following error message:

--->gplt('set logscale x')
TypeError: 'module' object is not callable
warning: Failure executing file: 

Any help would appreciated...

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


Re: Code run from IDLE but not via double-clicking on its *.py

2005-09-02 Thread n00m
Dennis:
> However, threads aren't really needed for this simple connection
> relay... The following has /not/ been run (since I don't have your
> server nor VBS) but should do about the same thing (see comments for one
> lack).

To some degree you are right!
If the vbs issues only some "primitive" sql commands, like

select au_fname from authors where zip=678678678
(the authors is a table in the pubs database in SQL Server)

then it works even without threading it.
But if the vbs issues e.g. this command for sql server:

"waitfor delay '000:00:05'; raiserror ('AAA',10,1) with nowait;"

then things go messed and confused...
and the code refuses to work in only one (main) thread.
In short, see this my topic on an sql server forum:

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=48619

Btw, I have NOT yet seen any WORKING C# code for my subject.

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


How to handle video & alpha channel

2005-09-02 Thread Mic
I'm looking for a way to build a little player  (if possibile with 
python ) that could handle common video file formats  (mpeg or other) 
with above an image with alpha channel (png or other)

Is there a way to make this with python and available libs (PIL etc)?


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


Re: To the python-list moderator

2005-09-02 Thread skip

Fredrik> Terry Hancock wrote:
>> I got one of these too, recently.  Maybe somebody is turning up the
>> screws to get rid of spam that's been appearing on the list?

Fredrik> I've been getting these about once a day lately.  at first, I
Fredrik> suspected some kind of "you're posting to quickly"-filter with
Fredrik> a manual "okay, you're whitelisted for another 24 hours" setup,
Fredrik> but it seems to block messages mostly by random.  and some
Fredrik> messages don't seem to get through at all.  slightly annoying.

I think it's just that the SpamBayes training database used to check the
list's messages is perhaps getting a little tired.

Skip

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


problems with smtplib

2005-09-02 Thread Jon Hewer
hi

having a few problems sending an email with smtplib.  i do have an
smtp server running on port 25 of my local machine

here's the relevant code (taken from python docs):

s = smtplib.SMTP('localhost')
s.connect()
s.sendmail(me, to, msg.as_string())
s.close()

and i'm getting this error:

Traceback (most recent call last):
  File "pysendmail.py", line 31, in ?
s = smtplib.SMTP()
  File "/usr/lib/python2.3/smtplib.py", line 254, in __init__
addr = socket.gethostbyname(socket.gethostname())
socket.gaierror: (-2, 'Name or service not known')

if i don't sepcify 'localhost' i get the same error

if i specify the port and local_hostname too

class SMTP([host[, port[, local_hostname]]])

then my script just freezing at some point trying to connect/send and
the email doesn't get sent

if anyone can help that would be great...

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


Re: descriptors for container items

2005-09-02 Thread bruno modulix
Terry Reedy wrote:
> "Brock Filer" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
> 
>>countries['us']['Colorado']['Denver']['@population']
>>
>>This is going to be used in user-input formulae, so I'm willing to do a
>>lot of work for minor beautifications. I'd like to be able to say (I
>>know, the quotes are still ugly, but at least you save a bracket):
>>
>>countries/'us'/'Colorado'/'Denver'/'@population'
>>
>>That's easy to do with a __div__ method, but it only works for getting,
>>not setting or deleting.
>>
>>I'd appreciate any thoughts on this problem.
> 
> 
> I personally would first try to dump the quotes and use standard 
> attributes --  countries.us.Colorado... -- 



> and the  __get/set/delattr__  methods.
> 
>>I keep thinking descriptors might be involved somehow in the solution,
>>but I may be on a completely wrong track.
> 
> 
> As far as I know, 'descriptor' is a behind-the-scenes concept, not 
> something you directly program with.  Perhaps you meant 'property'. 

Properties are just syntactic sugar for a possible use of descriptors. A
descriptor is just an object that follows a specific protocol (__get__,
__set__, __del__) and is used as an attribute or method (the difference
is very thin) of another object. You'll find all the relevant doc on
python.org.

> However, properties are fixed in number when you create the class.

Dynamically adding attributes to an object (or a class - which is just
another object) is not a problem.


If what you need is to provide an higher level view of your data,
descriptors may be a good choice. I used them that way for a
higher-level ldap API, where the class representing the LDAP object
mainly stores the raw result (as returned by python-ldap) of the ldap
query and uses descriptors to provide controlled (an simpler) access to
the data.

You may also want to read a recent thread here about descriptors:
http://groups.google.fr/group/comp.lang.python/browse_frm/thread/6159fa26439b9ba5/0ad621b88a752b47


-- 
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: fileinput.input - newbie question

2005-09-02 Thread Peter Otten
[EMAIL PROTECTED] wrote:

> I'm testing some writing/reading with a file and i'm not sure if it is
> possible to print/use the line with fileinput.input inplace=1 (see
> below)

fileinput.input(inplace=True) redirects stdout to the file[s] given as its
first parameter. Instead of appearing on the screen the output of print
statements is therefore written to the file currently being read (there are
actually two files, just like in your alternative approach).

You can work around redirection by saving a copy of the original stdout:

> import fileinput
  import sys
  original_stdout = sys.stdout
> thefile = fileinput.input('bla.txt',inplace=1,backup='.bak')
> for line in thefile:
> if line != "1\n":
  # this is written to 'bla.txt'
> print line,
  # this is written to the screen (if you don't 
  # redirect stdout externally)
  print >> original_stdout, line,
> 
> #is it possible to 'use' / print the 'line' on the screen here?
> 
> thefile.close()

> When its not possible then I use 2 file's filein.txt,fileout.txt

I would prefer that for its conceptual simplicity.

Peter

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


Re: plotting with gnuplot.py

2005-09-02 Thread Varun Hiremath
On Fri, Sep 02, 2005 at 02:35:45AM -0700, [EMAIL PROTECTED] wrote:
> Hi,
> 
> I've been having some problems trying some basic plotting commands with
> gnuplot.py. My setup is the Python 2.3 Enthought edition and my script
> looks as:
> 
> from scipy import *
> from scipy import gplt
> import scipy.io.array_import
> #import Gnuplot
> 
> filename = ('Default.PL1')
> data = scipy.io.array_import.read_array(filename)
> 
> 
> y = data[:,1]
> x = data[:,0]
> z = data[:,2]
> gplt.plot(x,y,'with points')
> gplt('set logscale x')
> gplt('set logscale y')
> 
> 
> With the following error message:
> 
> --->gplt('set logscale x')
> TypeError: 'module' object is not callable
> warning: Failure executing file: 
> 
> Any help would appreciated...


Hi,

Try doing this:

import Gnuplot,Numeric
filename = ('Default.PL1')
data = scipy.io.array_import.read_array(filename)
 
y = data[:,1]
x = data[:,0]
z = data[:,2]

//I think u need to take the transpose of this column before
plotting..

x=Numeric.transpose(x)
y=Numeric.transpose(y)

g=Gnuplot.Gnuplot()
d=Gnuplot.Data(x,y)
g('set logscale xy')
g.plot(d)

It should work...

Bye

-- 
---
Varun Hiremath
461, Jamuna Hostel
IIT Madras,
Chennai - 600 036
mob : +919840299732
---
My Webpage : http://www.ae.iitm.ac.in/~ae03b032
---
-- 
http://mail.python.org/mailman/listinfo/python-list


anaconda.real in RH7.1

2005-09-02 Thread Allan Adler

I'm trying to reinstall RedHat 7.1 Linux on a PC that was disabled when
I tried to upgrade from RH7.1 to RH9. This is presenting lots of unexpected
difficulties. Apart from wanting to keep the old model T in shape, I'm treating
this as a learning experience. Right now, I'm trying to gain more control
over the installation CD. By that I mean, I intend to modify the installation
script and other aspects of the CD and burn a new installation CD. The
installation script starts off as a shell script named anaconda which
then calls a python script named anaconda.real. The former is pretty easy
to understand, but I don't know anything about python. At the moment, I'm
using the book, "Programming Python", by Mark Lutz, as a reference. The
file anaconda.real is about 526 lines long. I've copied out about an eighth
of it into a notebook and am trying to use the book to make sense of what
I have copied. I'm not finding it very helpful. I don't know whether that
is because the script relies on aspects of python that aren't well explained
in the book or because it relies on aspects of RedHat Linux. I thought I
should ask here first about what seem like purely python issues.

The file anaconda.real is invoked with the line
exec /usr/bin/anaconda.real -T "$@"
I don't know what effect the -T "$@" has.

The file anaconda.real begins:

#!/usr/bin/python
signal.signal(signal.SIGINT,signal.SIG_DFL)

There is nothing about signal or signal.signal or the other signal.*
in the book. The file continues:

# For anaconda in test mode
if (os.path.exists('isys'))
sys.path.append('edd')
sys.path.append('libfdisk')
[lots of lines like that]
else:
  sys.path.append('/usr/lib/anaconda')
  sys.path.append('/usr/lib/anaconda/textw')
  sys.path.append('/usr/lib/anaconda/iw')
  sys.path.append('/usr/lib/anaconda/installclasses')

Here I'm guessing that the if never happens and the various /usr/lib/anaconda
directories are appended to the PATH environment variable.

Later on, after importing traceback (which is briefly mentioned in the book),
string, isys, iutil, _ from translate, handleException from exception, it
apparently worries about the environment variable ANACONDAARGS and then
executes

try:
 (args, extra) = isys.getopt(theargs, 'GTRxtdr:fm:',
['gui','text','reconfig','xmode','test','debug','nofallback',
 'method=','rootpath=',...

Anyway, in a nutshell, whenever I see anything specific in the file
anaconda.real, it isn't mentioned in the book and I don't know how to
get more information about it and I don't know how python gets its information
about it.

What do I need to read?
-- 
Ignorantly,
Allan Adler <[EMAIL PROTECTED]>
* Disclaimer: I am a guest and *not* a member of the MIT CSAIL. My actions and
* comments do not reflect in any way on MIT. Also, I am nowhere near Boston.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Decrypting GPG/PGP email messages

2005-09-02 Thread Piet van Oostrum
> Alessandro Bottoni <[EMAIL PROTECTED]> (AB) wrote:

>AB> Of course, I want to be sure that only the allowed people is able to send
>AB> such dangerous messages to my server so I will ask my users to encrypt and
>AB> digitally sign their messages using Thunderbird, Enigmail and GPG ...

What benefit is there in encrypting the messages? It would only prevent
people intercepting the message from seeing what's inside, but it won't
give you any additional protection on the server. 

And if somebody can intercept the messages there is a much bigger danger:
They could save the message and replay it later. You can't protect against
this with encryption (well, with encryption they won't know what they
are doing). Neither with a digital signature. Only checking timestamps,
keeping track of the messages received and/or a challenge/response system
will help in this case.

>AB> 1) What would you use to decrypt the messages? The GPG module created by
>AB> Andrew Kuchling is declared "incomplete" and "no more maintained" on his
>AB> web pages (http://www.amk.ca/python/code/gpg) so I think it is out of the
>AB> game. Would you use OpenPGP (http://www.aonalu.net/openpgp/python)? Any
>AB> other module?

If you only sign, it will be sufficient, but there is a more complete one
(including decryption) in
http://trac.t7a.org/isconf/file/trunk/lib/python/isconf/GPG.py 

-- 
Piet van Oostrum <[EMAIL PROTECTED]>
URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4]
Private email: [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


How to use Advanced Debugger Support API calls in Python/C API?

2005-09-02 Thread Danushka Menikkumbura








Hi,

  Can somebody please explain
me how to use the Advanced Debugger Support in Python/C API? I want to use this
to trace and get debug information from a script

which is being interpreted by the
python interpreter.

 

Thanks in advance.

 

Cheers!!!

 

Danushka

 







**
The information contained in this email is confidential and is meant to be read only by the person to whom it is addressed.
Please visit http://www.millenniumit.com/legal/email.htm to read the entire confidentiality clause.
**
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: scroll a frame to display several lines of widgets at a time

2005-09-02 Thread Matt Hammond
I don't quite understand (if I'm interpreting you correctly) why you want  
separate widgets, all displayed at once, for several hundred records -  
surely better to just reuse the one set of widgets and have the scrollbar  
or back-forward buttons change which record is being displayed in the  
widgets.

If you're after replacing widgets, then you need to destroy them first.  
Use the self.destroy method and unset/change any variables referencing the  
widget so it get a chance to be garbage collected.

However, if you want a scrollable view onto a larger area, what you need  
to do is use a Canvas, with a window shape on it. You then put a frame  
into that window.

canvas = Tkinter.Canvas(  )
canvas.grid( ... )
winID = self.canvas.create_window(0,0, anchor=Tkinter.NW)

Then later you can add a frame to that window on the canvas:

canvas.itemconfigure( winID, window =  )
canvas['scrollregion'] = canvas.bbox('all')

Make sure you've created the frame and perhaps called update_idletasks()  
to give it a chance to size itself before shoving it onto the canvas.

And of course, the scrollbar!

yscroll = Tkinter.Scrollbar( , orient=Tkinter.VERTICAL)
yscroll.grid( ... )
yscroll['command'] = canvas.yview
canvas['yscrollcommand'] = yscroll.set


On Thu, 01 Sep 2005 14:33:36 +0100, William Gill <[EMAIL PROTECTED]>  
wrote:

> I need to display a couple of labels and a checkbox from each entry in  
> my database.  Simple enough, but there are several hundred records, and  
> I only want to display 5 or 10 at a time.  Can this be accomplished by  
> putting everything in a Frame(), using width, height, grid_propagate(0)  
> , and a scrollbar?  or do I have to grid 5 rows at a time?  If the  
> latter, can I just grid over the previous 5 or do they have to be  
> explicitly removed first.
>
> Thanks.
>
> Bill



-- 

| Matt Hammond
| R&D Engineer, BBC Research and Development, Tadworth, Surrey, UK.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Decrypting GPG/PGP email messages

2005-09-02 Thread Piet van Oostrum
> Alessandro Bottoni <[EMAIL PROTECTED]> (AB) wrote:

>AB> Of course, I want to be sure that only the allowed people is able to send
>AB> such dangerous messages to my server so I will ask my users to encrypt and
>AB> digitally sign their messages using Thunderbird, Enigmail and GPG ...

What benefit is there in encrypting the messages? It would only prevent
people intercepting the message from seeing what's inside, but it won't
give you any additional protection on the server. 

And if somebody can intercept the messages there is a much bigger danger:
They could save the message and replay it later. You can't protect against
this with encryption (well, with encryption they won't know what they
are doing). Neither with a digital signature. Only checking timestamps,
keeping track of the messages received and/or a challenge/response system
will help in this case.

>AB> 1) What would you use to decrypt the messages? The GPG module created by
>AB> Andrew Kuchling is declared "incomplete" and "no more maintained" on his
>AB> web pages (http://www.amk.ca/python/code/gpg) so I think it is out of the
>AB> game. Would you use OpenPGP (http://www.aonalu.net/openpgp/python)? Any
>AB> other module?

If you only sign, it will be sufficient, but there is a more complete one
(including decryption) in
http://trac.t7a.org/isconf/file/trunk/lib/python/isconf/GPG.py 

-- 
Piet van Oostrum <[EMAIL PROTECTED]>
URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4]
Private email: [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Decrypting GPG/PGP email messages

2005-09-02 Thread Piet van Oostrum
> Alessandro Bottoni <[EMAIL PROTECTED]> (AB) wrote:

>AB> Of course, I want to be sure that only the allowed people is able to send
>AB> such dangerous messages to my server so I will ask my users to encrypt and
>AB> digitally sign their messages using Thunderbird, Enigmail and GPG ...

What benefit is there in encrypting the messages? It would only prevent
people intercepting the message from seeing what's inside, but it won't
give you any additional protection on the server. 

And if somebody can intercept the messages there is a much bigger danger:
They could save the message and replay it later. You can't protect against
this with encryption (well, with encryption they won't know what they
are doing). Neither with a digital signature. Only checking timestamps,
keeping track of the messages received and/or a challenge/response system
will help in this case.

>AB> 1) What would you use to decrypt the messages? The GPG module created by
>AB> Andrew Kuchling is declared "incomplete" and "no more maintained" on his
>AB> web pages (http://www.amk.ca/python/code/gpg) so I think it is out of the
>AB> game. Would you use OpenPGP (http://www.aonalu.net/openpgp/python)? Any
>AB> other module?

If you only sign, it will be sufficient, but there is a more complete one
(including decryption) in
http://trac.t7a.org/isconf/file/trunk/lib/python/isconf/GPG.py 

-- 
Piet van Oostrum <[EMAIL PROTECTED]>
URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4]
Private email: [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: fileinput.input - newbie question

2005-09-02 Thread martijn
That works fine ;)

Thanks for the fast help.

GC-Martijn

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


Re: Decrypting GPG/PGP email messages

2005-09-02 Thread Piet van Oostrum
> Paul Rubin  (PR) wrote:

>PR> PGP/GPG have their own base64 encoding called "ascii armor" in PGP
>PR> lingo.  This stuff predates widespread use of MIME and traditionally,
>PR> PGP messages are sent as ascii armored plain text, not attachments.

Most PGP/GPG message I have received recently where Mime encoded in
PGP/MIME (RFC 3156). Thunderbird/Enigmail can use PGP/MIME it says.
Theoretically you can encrypt parts of the message, e.g. only an
attachment, but I wouldn't know if Enigmail can do that.
-- 
Piet van Oostrum <[EMAIL PROTECTED]>
URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4]
Private email: [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: problems with smtplib

2005-09-02 Thread Harlin Seritt
What are you getting in your smtpd logs? Are you using postfix?
sendmail? or are you running this against a Windows stmp service?

Harlin Seritt
Internet Villa: www.seritt.org

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


Re: The penis is way too delicate for masturbation

2005-09-02 Thread mgraves

"Eve S." <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
>
> <[EMAIL PROTECTED]> schreef in bericht
> news:[EMAIL PROTECTED]
>> .
>>
>
> A decent amount of gentle sucking on the other hand never goes amiss.

Unless you've got a problem with depth perception and discover that what you 
took for a clit is actually a hemorrhoid.



*spitting out bits of corn*


--

I'm too sexy for my sig.


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


Re: OpenSource documentation problems

2005-09-02 Thread Michael Sparks
Paul Rubin wrote:

> Michael Sparks <[EMAIL PROTECTED]> writes:
>> > I've submitted a number of doc bugs to sourceforge and the ones
>> > that are simple errors and omissions do get fixed.
>> 
>> Cool.
> 
> Better than nothing, but it's only one class of problem, and maybe the
> easiest kind to report.

[lots and lots of stuff snipped]

All very interesting, and will take me a while to digest. I must admit I
find the whole set of suggestions/observations taken together to be
very interesting/useful and I'll try and take them on board with my own
projects first.

Many thanks for the detailed response, it's very much appreciated.

Regards,


Michael.
-- 
[EMAIL PROTECTED], http://kamaelia.sourceforge.net/
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: Add lists to class?

2005-09-02 Thread Paolino
Mike Meyer wrote:
> "BBands" <[EMAIL PROTECTED]> writes:
> 
> 
>>I have a list with some strings in in it, 'one', 'two' 'three' and so
>>on. I would like to add lists to a class with those names. I have no
>>way of knowing what will be in the list or how long the list will be in
>>advance.
> 
> 
> Others have told you how to do it. Now I'm going to tell you why you
> shouldn't.
> 
> First, since you don't know the names of the attributes you added, you
> can't possibly write code that references them in the normal way. So
> is there really much point in making them an attribute at all?
> 
> Second, since you don't know the names of the attributes you added,
> you don't know if one of more of them is going to clobber a feafure of
> the class that you want to use for something else. I.e., consider:
> 
> 
class C:
> 
> ...  pass
> ... 
> 
c = C()
print c
> 
> <__main__.C instance at 0x8270b4c>
> 
c.__str__ = 'foo'
print c
> 
> Traceback (most recent call last):
>   File "", line 1, in ?
> TypeError: 'str' object is not callable
> 
> 
> I.e. - if someone adds a __str__ attribute to your class, you won't be
> able to print it any more. Not a good thing.
> 
> In general, you probably want a dictionary instead of attributes:
> 
> 
class C(dict):
> 
> ...  def __init__(self, l):
> ...   for i in l:
> ...self[i] = []
> ... 
> 
c = C(['a', 'b', 'c'])
c['a']
> 
> []
> 
and 2c more to use attributes but prevent overriding of real attributes

def __getattr__(self,name):
  if name in self:
return self[name]
  raise AttributeError

Paolino





___ 
Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB 
http://mail.yahoo.it
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: NYC Opening

2005-09-02 Thread Jeremy Jones
Diez B. Roggisch wrote:

>Kevin McGann wrote:
>  
>
>>-Expert Java or C++
>>
>>
>
>Now why exactly do you post that in c.l.python?
>
>  
>
>>THEY ARE LOCATED IN NEW YORK, THIS IS FULL-TIME ONLY, WILL NOT CONSIDER
>>ANYONE FROM OUTSIDE THE US! THIS TEAM IS AN ELITE TEAM, YOU BETTER BE
>>GOOD
>>
>>
>
>I'm pretty sure you've some spelling wrong here, you certainly want
>ELITE to be written as 733T to get the attention of the proper people.
>  
>
I think you've got a typo here.  I think you meant "1337".  My H4X0R 
interpretation of what you wrote is "teet", which *may*, however, have 
the desired effect.

>
>SCNR,
>
>Diez
>
>  
>
JMJ
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: problems with smtplib

2005-09-02 Thread n00m
I also can't get my SMTP (win2k) working with Python.
But... funnily this works fine:

import smtplib
s = smtplib.SMTP('smtp.mail.ru')
s.sendmail('[EMAIL PROTECTED]', '[EMAIL PROTECTED]', 'hi
there!')
s.quit()

Why do they (mail.ru) allow outsiders to use their service???

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


Re: Python and file locking - NFS or MySQL?

2005-09-02 Thread Jeremy Jones
Christopher DeMarco wrote:

>Hi all...
>
>...I've got a Python script running on a bunch of boxen sharing some
>common NFS-exported space.  I need (not want :) to lock files for
>writing, and I need (not want :) to do it safely (i.e. atomically).
>I'm doing this in Linux; NFS4 is available.  As I understand it, my
>options are:
>
>1.  Python's fcntl() is an interface to the fcntl(2) system call,
>which is claimed to work "mostly" over NFS v >= 3.
>  
>
I would go with this one, but test the crap out of it.  This *should* 
work just fine for you on NFS, but again, test the crap out of it.  
Write a script that spawns slightly beyond the number of processes (by 
spawning either threads or processes) you expect to actually occur and 
mercilessly lock, update, unlock the file while checking for the results 
to be consistent with what you think they ought to be.

>2.  open(2) is atomic on a local FS, I've read discussions that imply
>that link(2) is atomic over NFS (is it?), so I can link from local
>lockfile to remote target atomically.  I don't grok this; open(2) +
>link(2) + stat(2) == 3 calls on my fingers.  HTH is this supposed to
>work?
>
>3.  Atomically update a MySQL database indicating that the file is
>locked - MySQL has atomic transactions now, right?  And how good is
>the Python MySQL API - IIRC Perl didn't have atomic transactions last
>year; will this work in contemporary Python?
>
>I've got a while (several weeks) to chew this problem over (my current
>implementation is ``assert("Poof!  File locked")'').
>
>What are my options for safely locking files via NFS?  I don't want to
>get involved with NLM as my impression is it's being buggy and
>unwieldy.  Thanks in advance!
>
>
>I was present at an undersea, unexplained mass sponge migration.
>  
>
HTH,

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


Re: Automatic language translation

2005-09-02 Thread Magnus Lycka
Jon wrote:
> Does python have a module that will translate between different spoken
> languages?  My python program displays all of its messages in English
> currently and my boss wants it to default to Korean now.
> 
> Any ideas how to go about doing this?

"import gettext" is a start... See
http://docs.python.org/lib/module-gettext.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Proposal: add sys to __builtins__

2005-09-02 Thread tiissa
Michael Hoffman a écrit :

> MrJbQ7 wrote:
>
> > Besides, a better way is to use your ~/.pythonrc file for customizing
> > according to your needs.
> >
> > A simple:
> >
> >   echo "import sys, os" >> ~./pythonrc
> >
> > will do the job.
>
> Until someone else tries to use your script or module.

A developper should not be too lazy to add one small line in a complete
script/module.
Besides your entire justification to this proposal was based on shell
one-liners, not script or modules.

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


Re: Python / web

2005-09-02 Thread Luis M. Gonzalez
Karrigell is a very good option. Easy to learn and easy to use.
In words of his author:

"Karrigell is a simple web programming solution, written in Python. It
has been designed to be really simple to use : integrated web server
and data base ( gadfly), easy access to environement data and form
fields, yet full-featured and powerful : Python script execution in the
same process as the server (no CGI), server pages including html and
Python code (similar to PHP, JSP, ASP), easy handling of
authentication, session management, localization features, etc

Karrigell can also work with external web servers : Apache and Xitami
are currently supported. All current databases (sqlite, MySql,
PostGresQL, etc) can be used with the corresponding Python API's. A
convenient way of using databases with a dictionary-like syntax is
provided for gadfly and sqlite "

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


Re: problems with smtplib

2005-09-02 Thread Steve Holden
n00m wrote:
> I also can't get my SMTP (win2k) working with Python.
> But... funnily this works fine:
> 
> import smtplib
> s = smtplib.SMTP('smtp.mail.ru')
> s.sendmail('[EMAIL PROTECTED]', '[EMAIL PROTECTED]', 'hi
> there!')
> s.quit()
> 
That's pretty strange: the second argument should be a list. Are you 
*sure* it worked?

> Why do they (mail.ru) allow outsiders to use their service???
> 
Ask them!

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/

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


HTML tags optimization

2005-09-02 Thread DENG
hi all,

i want to do some optimizations for HTML tags,

something like this:

TEXT1TEXT2

optimise to

TEXT1TEXT2

at the very beginning, i was thinking of analysing each text-block, to
know their color, size, if is bold or italic, but i found it was too
complicated.

e.g

TEXT1

optimise to

TEXT1

but if there is TEXT2 exist

TEXT1TEXT2

we can not do any optimization.

my problem is I can not find a method to treat all those situation, I
had too much thinking and get fool now

anyone can give me some advices?

thanks

PS:

other examples:

1
TEXT
=>
TEXT

2
TEXT TEXT
=>
TEXT TEXT

3
TEXTTEXT
=>
TEXT

etc...

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


Re: problems with smtplib

2005-09-02 Thread n00m

Steve Holden wrote:
> That's pretty strange: the second argument should be a list. Are you
> *sure* it worked?

Hmm...
I sent a couple of letters to my two different addresses... and got
them!

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


Re: pickling the objects returned by array.array()

2005-09-02 Thread Raymond Hettinger

John Machin wrote:
> Looks like arrays are NOW (2.4.1) pickleable but not unpickleable

Please file a bug report and assign to me.


Raymond Hettinger

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


Re: Decrypting GPG/PGP email messages

2005-09-02 Thread François Pinard
[Piet van Oostrum]
> > Alessandro Bottoni <[EMAIL PROTECTED]> (AB) wrote:

> >AB> Of course, I want to be sure that only the allowed people is
> >AB> able to send such dangerous messages to my server so I will ask
> >AB> my users to encrypt and digitally sign their messages using
> >AB> Thunderbird, Enigmail and GPG ...

> What benefit is there in encrypting the messages?  It would only
> prevent people intercepting the message from seeing what's inside, but
> it won't give you any additional protection on the server.

Whenever a message contains sensitive information, it is a good idea to
crypt it.  Humans, and not only computers, may be harmful! :-) There
are cases where information may not leak, when it vehicles private
information about people.  Companies also have industrial secrets.  The
mere fact that two people are communicating is often a secret in itself.

> And if somebody can intercept the messages there is a much bigger danger:
> They could save the message and replay it later. You can't protect against
> this with encryption (well, with encryption they won't know what they
> are doing). Neither with a digital signature.

Protection against replay is easily guaranteed by sequencing requests,
that is, including a sequence number within the message, each originator
his sequence.  A digital signature prevents someone from tampering with
the sequence number without being detected.

-- 
François Pinard   http://pinard.progiciels-bpi.ca
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: HTML tags optimization

2005-09-02 Thread Steve Holden
DENG wrote:
> hi all,
> 
> i want to do some optimizations for HTML tags,
> 
> something like this:
> 
> TEXT1TEXT2
> 
> optimise to
> 
> TEXT1TEXT2
> 
> at the very beginning, i was thinking of analysing each text-block, to
> know their color, size, if is bold or italic, but i found it was too
> complicated.
> 
[etc ...]

Are you expecting the answers to be different that they were two days ago?

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/

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


Re: Python and file locking - NFS or MySQL?

2005-09-02 Thread Fredrik Lundh
Christopher DeMarco wrote:

> 2.  open(2) is atomic on a local FS, I've read discussions that imply
> that link(2) is atomic over NFS (is it?), so I can link from local
> lockfile to remote target atomically.  I don't grok this; open(2) +
> link(2) + stat(2) == 3 calls on my fingers.  HTH is this supposed to
> work?

1) generate a "globally unique" file name (e.g. use a UUID
library, or create a string containing the machine name, pid,
timestamp, possibly a random number, the FQDN, etc). e.g.

tempname = os.uname()[1] + "." + str(os.getpid())

lockfile = os.path.join(directory, "mylock")
tempfile = os.path.join(directory, tempname)

2) create a file with that name in the shared directory

f = open(tempfile, "w")
f.close()

3) create the lock file as a hard link to the file you just
created.

   os.link(tempfile, lockfile) # atomic!

5) check the number of links to each file

   n = os.stat(tempfile)[3]
   m = os.stat(lockfile)[3]

6) if n == m, you own the lockfile.  you can now remove
the tempfile and do whatever you need to do.  remove the
lockfile when you're done (this is also an atomic operation).

if n != m is something else, remove tempfile, sleep for a few
seconds, and start all over again.

you may want to add some information to the file to be able to
identify stale locks, add proper error handling (if link or stat fails,
retry), and perhaps some kind of "incremental backoff" to con-
troll the sleep length.

 



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


Re: Python / web

2005-09-02 Thread Benji York
Mike Meyer wrote:
> Robert <[EMAIL PROTECTED]> writes:
>> I know general Python pretty well and interested in using Python
>> for a web project.

> Others have already suggested Zope/Plone, which seems to be the most
> popular such system. I only have limit experience with Zope, but I
> found that it tended to own the resulting code, such that reusing it
> in another framework would be a PITA.

This is much less the case for Zope 3, the separation between domain and 
presentation code is much easier to maintain.
--
Benji York

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


Re: OpenSource documentation problems

2005-09-02 Thread A.M. Kuchling
On Fri, 02 Sep 2005 06:19:16 GMT, 
Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:
>   My attempts at simple came in closer to the life insurance than
> Lincoln -- forget about Hemingway; the only way I could approach his
> writing was to stick to: Hello World; Good day; See you later; Bye.

A quote I like:

  I like long and unusual words, and anybody who does not share my tastes is
  not compelled to read me. Policemen and politicians are under some
  obligation to make themselves comprehensible to the intellectually
  stunted, but not I. Let my prose be tenebrous and rebarbative; let my
  pennyworth of thought be muffled in gorgeous habilements; lovers of Basic
  English will look to me in vain. 
-- Robertson Davies, _Marchbanks' Garland_

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


Re: [OT] HTML tags optimization

2005-09-02 Thread bruno modulix
DENG wrote:
(snip same post as two days ago)


In case you don't know, google.groups is just a web interface (and
archive) to usenet groups. No need to repost the same question twice...


BTW, for what you want to do (which is mostly a waste of time IMHO, but
what, that's your time, not mine), the obvious, CS101 answer is to first
build an AST of your document, then transform this AST - collapsing
nodes when possible etc -, then write it back as (if possible valid) html.


-- 
bruno desthuilliers
ruby -e "print '[EMAIL PROTECTED]'.split('@').collect{|p|
p.split('.').collect{|w| w.reverse}.join('.')}.join('@')"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python and file locking - NFS or MySQL?

2005-09-02 Thread Fredrik Lundh
Fredrik Lundh wrote:

> 5) check the number of links to each file
>
>   n = os.stat(tempfile)[3]
>   m = os.stat(lockfile)[3]

aw, forget that.  I shouldn't trust google over my own code.  here's the
correct algorithm:

f = open(tempfile, "w")
f.close()

n = os.stat(tempfile)[3]
os.link(tempfile, lockfile)
m = os.stat(tempfile)[3]
if n == m+1:
success!

where n==1 and m==2.  the os.link call can be placed in a try/except
clause (if it fails, m won't be 2), or you can use a try/except around the
entire thing.

 



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


Re: OpenSource documentation problems

2005-09-02 Thread A.M. Kuchling
On Thu, 1 Sep 2005 23:08:18 -0400, 
Fred L. Drake, Jr. <[EMAIL PROTECTED]> wrote:
> Ideally, emails to docs at python.org would result in issues being created 
> somewhere, simply so they don't get lost.  It probably doesn't make sense for 
> those to land in SourceForge automatically, since then everyone has to read 
> every plea for a printable version of the documents.

As a stop-gap, could we encourage people to record issues on a wiki page?
Then someone could periodically look at the page and act on the suggestions
there.

The problem is that Wikis aren't really newbie-friendly, either; while you
don't need to register for the Python wiki any more, many people don't
realize the pages are editable.  Still, it might be worth a try.

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


Re: problems with smtplib

2005-09-02 Thread Jon Hewer
I'm running Fedora Core 3, and I assume thats useing sendmail...

On 2 Sep 2005 04:25:41 -0700, Harlin Seritt <[EMAIL PROTECTED]> wrote:
> What are you getting in your smtpd logs? Are you using postfix?
> sendmail? or are you running this against a Windows stmp service?
> 
> Harlin Seritt
> Internet Villa: www.seritt.org
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: HTML tags optimization

2005-09-02 Thread Michael . Coll-Barth

Maybe you can get some ideas over at http://validator.w3.org/docs/.  At
least they have the whole parser thing worked out.

-Original Message-
From:
[EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
n.org]On Behalf Of DENG
Sent: Friday, September 02, 2005 8:36 AM
To: python-list@python.org
Subject: HTML tags optimization


hi all,

i want to do some optimizations for HTML tags,
___
The information contained in this message and any attachment may be
proprietary, confidential, and privileged or subject to the work
product doctrine and thus protected from disclosure.  If the reader
of this message is not the intended recipient, or an employee or
agent responsible for delivering this message to the intended
recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited.
If you have received this communication in error, please notify me
immediately by replying to this message and deleting it and all
copies and backups thereof.  Thank you.

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


Re: OpenSource documentation problems

2005-09-02 Thread A.M. Kuchling
On Fri, 2 Sep 2005 01:28:22 -0500, 
Terry Hancock <[EMAIL PROTECTED]> wrote:
> Hmm. Still sounds like "there ought to be a wiki".  I've seen references
> to two different ones on this thread. One was then debunked as a "failed
> experiment".  The other just gave me a DNS lookup failure (maybe the
> URL was wrong).

The Python wiki is at ; I didn't see the
earlier posting and don't know if it gave the right URL or not.

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


Re: HTML tags optimization [ interesting problem]

2005-09-02 Thread DENG
hi, Sybren,

thanks for your reply, if use CSS:

texttexttext

optimise to:

texttexttext

what i need is the METHOD to do optimization, in fact, i have ready
write a program to analyse the syntax of CSS, to make it works with all
situation

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


Re: Epydoc - Documenting class members?

2005-09-02 Thread Michael Ekstrand
On Thu, 1 Sep 2005 22:38:03 -0500
Terry Hancock <[EMAIL PROTECTED]> wrote:
> > I don't like this, I want to document where I declare the variable
> > below. Doxygen (www.doxygen.org), for one example, knows how to do
> > this.
> 
> Then use Doxygen if it's a superior product. I presume
> it knows how to handle Python code, then?

Doxygen does not support Python - it only works for C-like languages
(C, Java, PHP). Hence the need/desire for something (e.g. extension to
epydoc) that does this.

That said, I did not know about epydoc prior to stumbling across this
thread. Just looked at the website, and I am quite impressed... solves
a lot of problems I've been having with writing documentation for a
project at work.

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


Re: How to handle video & alpha channel

2005-09-02 Thread Diez B. Roggisch
Mic wrote:
> I'm looking for a way to build a little player  (if possibile with 
> python ) that could handle common video file formats  (mpeg or other) 
> with above an image with alpha channel (png or other)
> 
> Is there a way to make this with python and available libs (PIL etc)?

Check out pymedia.

Regards,

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


Re: anaconda.real in RH7.1

2005-09-02 Thread pruebauno
Allan Adler wrote:
> I'm using the book, "Programming Python", by Mark Lutz, as a reference.

No offence to Mark Lutz or O'Reilly but I consider "Programming Python"
one of the worst books I have read (in my case an old first edition).
It overwhelms the beginning programmer ("Learning Python" is probably
better for that), it bores the experienced programmer to death with
introductory details and does not work as a reference book. It is a
nice survey of application areas for python, but the book lacks a clear
goal, purpose and a problem it tries to address. It needs more focus.
It needs to be marketed correctly also. I believe too many people new
to python buy that book and get discouraged about Python, O'Reilly and
programming when they should buy something else instead.

That said what you probably want is "Python in a Nutshell" by O'Reilly
which is a good reference book it has a concise introduction of Python
in the beginning and after that, documentation for the most usefull
libraries out there.

Personally I use the online documentation a lot:

If I know the the name of the module
(for example it starts with sys.zz) I use:
http://www.python.org/doc/2.4.1/modindex.html

If I know what I want but not the name I use:
http://www.python.org/doc/2.4.1/lib/lib.html

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


Re: Well, Python is hard to learn...

2005-09-02 Thread Magnus Lycka
wen wrote:
> due to the work reason, i have to learn python since last month. i have
> spent 1 week on learning python tutorial and felt good. but i still don't
> understand most part of sourcecode of PYMOL(http://pymol.sourceforge.net/)
> as before.

Maybe you (or someone else) is making a mistake if you are trying
to understand PyMol in this stage of learning. I haven't used
PyMol, but I really doubt that you need to understand its source
code unless your aiming to maintain that code.

If you approached it as a learning exercise, you aimed way too high.

If you approached it because you need to use PyMol, trying to understand
its source code is probably the wrong approach.

You don't need to learn all the details of how a car works to drive it.
You don't even have to understand how the engine is designed to change
wheels or fix rust holes.

I'm aware that you use Python to perform advanced operations in PyMol,
but you don't need to understand PyMol's internals for that.
-- 
http://mail.python.org/mailman/listinfo/python-list


PyBool_FromLong

2005-09-02 Thread Andrew MacKeith
In the C API Docs, the signature of PyBool from long seems to be incorrect.

int PyBool_FromLong(long v)
 Returns Py_True or Py_False depending on the truth value of v. New in 
version 2.3.

The description would suggest:

PyObject* PyBool_FromLong(long v)

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


Re: Proposal: add sys to __builtins__

2005-09-02 Thread Michael Hoffman
tiissa wrote:

> A developper should not be too lazy to add one small line in a complete
> script/module.

To the contrary, I agree with Larry Wall that laziness is one of the 
cardinal virtues of a programmer. Although my personal desire to be lazy 
is not at issue here--I always start new scripts and modules from a 
template that includes import sys.

Would you argue that the language is superior because half of its 
modules must have "import sys" at the beginning, although sys is already 
imported? The only difference is that the namespace is not exposed by 
default. I suggest that the default be changed.

It would simplify introductions to the language as well. In the current 
tutorial it is necessary to use "import sys" before it has time to 
explain modules and importing.

> Besides your entire justification to this proposal was based on shell
> one-liners, not script or modules.

Sorry, that's incorrect; please go back and read the original post again.
-- 
Michael Hoffman
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: anaconda.real in RH7.1

2005-09-02 Thread Michael Hoffman
[EMAIL PROTECTED] wrote:

> If I know the the name of the module
> (for example it starts with sys.zz) I use:
> http://www.python.org/doc/2.4.1/modindex.html
> 
> If I know what I want but not the name I use:
> http://www.python.org/doc/2.4.1/lib/lib.html

I have a Firefox Quick Search installed with keyword: pymod and location:

http://www.python.org/doc/lib/module-%s.html

or on a Windows box where I have the docs installed locally:

file:///C:/Documentation/Python-Docs-2.4/lib/module-%s.html
-- 
Michael Hoffman
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PyBool_FromLong

2005-09-02 Thread Michael Hoffman
Andrew MacKeith wrote:
> In the C API Docs, the signature of PyBool from long seems to be incorrect.
> 
> int PyBool_FromLong(long v)
> Returns Py_True or Py_False depending on the truth value of v. New 
> in version 2.3.
> 
> The description would suggest:
> 
> PyObject* PyBool_FromLong(long v)

That's in the source too (dist/src/Objects/boolobject.c, 
dist/src/Include/boolobject.h). Want to submit a documentation bug?
-- 
Michael Hoffman
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The penis is way too delicate for masturbation

2005-09-02 Thread Chucky & Janica
Once upon a time - for example, 1 Sep 2005 05:32:54 -0700 - there was
this guy, or something, called [EMAIL PROTECTED], and they made us
all feel better by saying the following stuff:

>.

That penis, more to the point, is too small for masturbation.




C&J

-- 
Beware of Trojans, they're complete smegheads.

 - 13 & 13b of 12, the CMM Collective.
 - www.afrj-monkeyhouse.org
-- 
http://mail.python.org/mailman/listinfo/python-list


__setslice__ and classes derived from list

2005-09-02 Thread Dave Opstad
According to the documentation the __setslice__ method has been 
deprecated since Python 2.0. However, if I'm deriving classes from the 
builtin list class, I've discovered I can't really ignore __setslice__. 
Have a look at this snippet:


>>> class V(list):
...   def __setitem__(self, key, value):
... if isinstance(key, slice):
...   print "Slice:", key.start, key.stop, key.step
... else:
...   print "Regular:", key
... super(V, self).__setitem__(key, value)
...   def __setslice__(self, i, j, value):
... print "Old method:", i, j
... super(V, self).__setslice__(i, j, value)
... 
>>> v = V([1,2,4,8])
>>> v
[1, 2, 4, 8]
>>> v[0] = 100
Regular: 0
>>> v
[100, 2, 4, 8]
>>> v[1:3] = [99, 99]
Old method: 1 3
>>> v   
[100, 99, 99, 8]
>>> v[1:3:1] = [88, 88]
Slice: 1 3 1
>>> v
[100, 88, 88, 8]
>>> v[-1] = 12
Regular: -1
>>> v   
[100, 88, 88, 12]
>>> v[-3:-1] = [77, 66]
Old method: 1 3
>>> v
[100, 77, 66, 12]


If I assign to v[1:3] it dispatches via __setslice__, but if I assign to 
v[1:3:1] it dispatches via __setitem__. The documentation states that if 
a __setslice__ method is present it will be used, but if one isn't 
present then a slice will be synthesized and __setitem__ will be used 
exclusively. Since the builtin list class provides a __setslice__ 
method, what this means is that any class derived from list still has to 
make provisions for this ostensibly deprecated method.

There's a workaround for this, namely to include this method:

def __setslice__(self, i, j, seq):
self.__setitem__(slice(i, j), seq)

That way any custom code I need to include in __setitem__ doesn't have 
to be duplicated in __setslice__. But just out of curiosity I thought 
I'd ask the folks here if there's any other way of doing this? Maybe 
something like a "noslicelist" class which doesn't have __setslice__, 
where the standard list class would then be a subclass of noslicelist 
with the __setslice__ method present for compatibility. That way I could 
subclass noslicelist myself, and not have to worry about it.

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


Re: 'isa' keyword

2005-09-02 Thread Rocco Moretti
Terry Hancock wrote:
> On Thursday 01 September 2005 07:28 am, Fuzzyman wrote:
> 
>>What's the difference between this and ``isinstance`` ?
> 
> I must confess that an "isa" operator sounds like it would
> have been slightly nicer syntax than the isinstance() built-in
> function. But not enough nicer to change, IMHO.

Especially conidering that checking parameters with "isinstance" is 
considered bad form with Python's duck typing.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OpenSource documentation problems

2005-09-02 Thread Tim Peters
[Paul Rubin]
> Until not that long ago, it was possible to submit sf bugs without
> being logged into sf.  Why did that change?

To reduce tracker spam, to reduce tracker vandalism, and to make it
possible to contact submitters when needed.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: __setslice__ and classes derived from list

2005-09-02 Thread Michael Hoffman
Dave Opstad wrote:

> There's a workaround for this, namely to include this method:
> 
> def __setslice__(self, i, j, seq):
> self.__setitem__(slice(i, j), seq)
> 
> That way any custom code I need to include in __setitem__ doesn't have 
> to be duplicated in __setslice__. But just out of curiosity I thought 
> I'd ask the folks here if there's any other way of doing this?

I don't think so; at least it's what I've always done in the past. 
Perhaps you should submit a feature request? It must be time to get rid 
of __setslice__, if not now, then maybe by Python 3.0.
-- 
Michael Hoffman
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: To the python-list moderator

2005-09-02 Thread Neil Schemenauer
Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> Terry Hancock wrote:
>
>> I got one of these too, recently.  Maybe somebody is turning up the
>> screws to get rid of spam that's been appearing on the list?

In the future, sending a message to [EMAIL PROTECTED] is
suggested rather than posting to only to python-list.  What's
happening is that Spambayes is marking the message as UNSURE.  The
message that mailman sends to the sender is unfortunate.  The
"Message has a suspicious header" notice is misleading because the
user did not have any header in their message that caused it to be
held (at least normally not).

I'm not sure why many legitimate messages are being flagged as
UNSURE.  I'll look into it.

> I've been getting these about once a day lately.  at first, I suspected
> some kind of "you're posting to quickly"-filter with a manual "okay,
> you're whitelisted for another 24 hours" setup, but it seems to block
> messages mostly by random.  and some messages don't seem to get
> through at all.  slightly annoying.

Hmm, the message should eventually get through since it ends up
getting moderated by a person.  Maybe they are getting overwhelmed
and are making some mistakes.

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


why no user-def. attributes?

2005-09-02 Thread severa
I appologize in advance for stupid question, which is:
why are user-defined attributes not allowed for builtin types?
[I guess I undestand why *instances* cannot have them (e.g. then every 
dict would have a dict which would have a dict..), but this is a 
different question]

I can imagine several answers, so I put here those that don't seem 
satisfactory to me :)

1. You can subclass, eg. 
class my_int(int): pass
and then do whatnot, like my_int.__getitem__=some_vicious_function

Here the problem is just that it's easier to write 4 than 
my_int(4), or "ha" than my_string("ha") etc.

2. You would probably want to add new methods, so why don't you 
define a function and then write e.g. dowhatIwant([1,2,3]) instead of
[1,2,3].dowhatIwant() 

That's OK, except for the convenience of special methods like __add__ or 
__iter__

3. It would lead to a confusing code

Oops, maybe I shouldn't have written this one..


Anyway, please let me know the true reason (which is perhaps technical)


Best whishes
Paul


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


Re: OpenSource documentation problems

2005-09-02 Thread Peter Hansen
A.M. Kuchling wrote:
> On Fri, 02 Sep 2005 06:19:16 GMT, 
>   Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:
> 
>>  My attempts at simple came in closer to the life insurance than
>>Lincoln -- forget about Hemingway; the only way I could approach his
>>writing was to stick to: Hello World; Good day; See you later; Bye.
> 
> 
> A quote I like:
> 
>   I like long and unusual words, and anybody who does not share my tastes is
>   not compelled to read me. Policemen and politicians are under some
>   obligation to make themselves comprehensible to the intellectually
>   stunted, but not I. Let my prose be tenebrous and rebarbative; let my
>   pennyworth of thought be muffled in gorgeous habilements; lovers of Basic
>   English will look to me in vain. 
> -- Robertson Davies, _Marchbanks' Garland_

Hmmm... So Robertson Davies programmed in Perl? ;-)

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


.pth files question

2005-09-02 Thread Benjamin Rutt
Am I correct in understanding that:

1) foo.pth will be used if it is in the directory
/usr/lib/python-2.4/site-packages

2) foo.pth will not be read from if it is only placed somewhere in the
PYTHONPATH environment, such as foo.pth exists as the file
/tmp/bar/foo.pth, where PYTHONPATH contains "/tmp/bar"?

Thanks,
-- 
Benjamin Rutt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: __setslice__ and classes derived from list

2005-09-02 Thread Dave Opstad
In article <[EMAIL PROTECTED]>,
 Michael Hoffman <[EMAIL PROTECTED]> wrote:

> Perhaps you should submit a feature request? It must be time to get rid 
> of __setslice__, if not now, then maybe by Python 3.0.

I'm happy to submit a feature request, once I figure out how to do it!

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


Re: is there a better way to check an array?

2005-09-02 Thread Peter Hansen
Mike Meyer wrote:
> "Steve M" <[EMAIL PROTECTED]> writes:
>>my_list.find(candidate)
>>-returns the index into my_list of the first occurrence of candidate.
>>Returns -1 if candidate doesn't occur in my_list.
> 
> Lists don't have a find method. strings do. Why is a good question.

Probably because at one point lists didn't even have the index() method, 
and when it was suggested and (I believe) Raymond H. added it, I suspect 
nobody also suggested that implementing find() was a good idea so it 
wasn't done.

And, given both that index() exists and the recent discussion about the 
potential problems caused by find() returning a valid slice index when 
it fails, maybe it's _not_ a good idea...

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


Re: pain

2005-09-02 Thread Peter Hansen
Steve Holden wrote:
> and the day managers stop being ignorant we'll all be able to fly around 
> on pigs. Not wishing to offend the pigs, of course.
> 
> still-working-for-myself-ly y'rs  - steve

What Steve means here, of course, is that he is his own manager.

;-)

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


Re: Jargons of Info Tech industry

2005-09-02 Thread axel
In comp.lang.perl.misc John Bokma <[EMAIL PROTECTED]> wrote:
> "T Beck" <[EMAIL PROTECTED]> wrote:
 
>> I suppose I was (as many people on the internet have a bad habit of
>> doing) being more caustic than was strictly necessary.  I don't really
>> forsee the death of usenet anytime soon, I just don't think the idea of
>> it evolving is necessarily bad.  I don't really have alot of vested
>> interest one way or the other, to be honest, and I'm perfectly happy
>> with the way it is.
 
> me too.
 
>> I just think it's a naive view to presume it never will change, because
>> change is what the internet as a whole was built on.
 
> I can't think of changes that are coming to Usenet (other then ipv6)

The old saying holds true - if it is not broken, do not fix it.

Of course what the original poster did not consider is why
the standard line length was laid down... the VT100 terminals
(and related ones) had a line length which was 80 characters
(ok, with some options to switch to 132 characters if I
remember correctly)... and that is the first machine through
which I access Usenet. And the version of vi which I used
at the time was not very good with dealing with long lines.
But it worked.

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


Re: problems with smtplib

2005-09-02 Thread Peter Hansen
Steve Holden wrote:
> n00m wrote:
> 
>> I also can't get my SMTP (win2k) working with Python.
>> But... funnily this works fine:
>>
>> import smtplib
>> s = smtplib.SMTP('smtp.mail.ru')
>> s.sendmail('[EMAIL PROTECTED]', '[EMAIL PROTECTED]', 'hi
>> there!')
>> s.quit()
>>
> That's pretty strange: the second argument should be a list. Are you 
> *sure* it worked?

No longer required (as of at least Python 2.3 if not earlier).

"to_addrs : A list of addresses to send this mail to.  A bare string 
will be treated as a list with 1 address."  (from smtplib.py sendmail() 
docstring)

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


Re: __setslice__ and classes derived from list

2005-09-02 Thread Michael Hoffman
Dave Opstad wrote:

> I'm happy to submit a feature request, once I figure out how to do it!

http://sourceforge.net/projects/python/

Follow the RFE link.
-- 
Michael Hoffman
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: scroll a frame to display several lines of widgets at a time

2005-09-02 Thread William Gill


Matt Hammond wrote:
> I don't quite understand (if I'm interpreting you correctly) why you 
> want  separate widgets, all displayed at once, for several hundred 
> records -  surely better to just reuse the one set of widgets and have 
> the scrollbar  or back-forward buttons change which record is being 
> displayed in the  widgets.

I need to re-think things a little.  I wanted to be able to quickly 
scroll through several hundred entries in the db, and check off (yes/no) 
which have been reviewed, updated, or whatever.

I will look at having a fixed number of display widgets and scrolling 
through the underlying data to determine which records are currently 
displayed/editable.

My first pass was db -> display/edit widgets -> db.  So I jumped 
(incorrectly) to wanting to 'hold' all record in widgets for 
editing.There's no reason I can't use:

db -> master list -> slice -> display/edit widgets -> master list -> db.

i.e. a list holding all the data, display/edit slices controlled by a 
scrollbar, and storing the final list when done.

> 
> If you're after replacing widgets, then you need to destroy them first.  
> Use the self.destroy method and unset/change any variables referencing 
> the  widget so it get a chance to be garbage collected.
> 
> However, if you want a scrollable view onto a larger area, what you 
> need  to do is use a Canvas, with a window shape on it. You then put a 
> frame  into that window.
> 
>canvas = Tkinter.Canvas(  )
>canvas.grid( ... )
>winID = self.canvas.create_window(0,0, anchor=Tkinter.NW)
> 
> Then later you can add a frame to that window on the canvas:
> 
>canvas.itemconfigure( winID, window =  )
>canvas['scrollregion'] = canvas.bbox('all')
> 
> Make sure you've created the frame and perhaps called 
> update_idletasks()  to give it a chance to size itself before shoving it 
> onto the canvas.
> 
> And of course, the scrollbar!
> 
>yscroll = Tkinter.Scrollbar( , orient=Tkinter.VERTICAL)
>yscroll.grid( ... )
>yscroll['command'] = canvas.yview
>canvas['yscrollcommand'] = yscroll.set
>
Probably, not needed now that I have re-thought the situation, but I do 
have several occasions where i need to view and select/deselect 50 or 60 
  options (checkbuttons).  So this will make them much more manageable.

Thanks,

Bill

> 
> On Thu, 01 Sep 2005 14:33:36 +0100, William Gill <[EMAIL PROTECTED]>  
> wrote:
> 
>> I need to display a couple of labels and a checkbox from each entry 
>> in  my database.  Simple enough, but there are several hundred 
>> records, and  I only want to display 5 or 10 at a time.  Can this be 
>> accomplished by  putting everything in a Frame(), using width, height, 
>> grid_propagate(0)  , and a scrollbar?  or do I have to grid 5 rows at 
>> a time?  If the  latter, can I just grid over the previous 5 or do 
>> they have to be  explicitly removed first.
>>
>> Thanks.
>>
>> Bill
> 
> 
> 
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: .pth files question

2005-09-02 Thread Michael Hoffman
Benjamin Rutt wrote:
> Am I correct in understanding that:
> 
> 1) foo.pth will be used if it is in the directory
> /usr/lib/python-2.4/site-packages
> 
> 2) foo.pth will not be read from if it is only placed somewhere in the
> PYTHONPATH environment, such as foo.pth exists as the file
> /tmp/bar/foo.pth, where PYTHONPATH contains "/tmp/bar"?

Yes. All this is done by the site module.
-- 
Michael Hoffman
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: .pth files question

2005-09-02 Thread Peter Hansen
Benjamin Rutt wrote:
> Am I correct in understanding that:
> 
> 1) foo.pth will be used if it is in the directory
> /usr/lib/python-2.4/site-packages
> 
> 2) foo.pth will not be read from if it is only placed somewhere in the
> PYTHONPATH environment, such as foo.pth exists as the file
> /tmp/bar/foo.pth, where PYTHONPATH contains "/tmp/bar"?

Both by inspection of the source and by experimentation, it appears you 
are correct.  As the docs say, only the "site-specific paths" (i.e. 
sys.prefix and sys.exec_prefix, and lib/python/site-packages 
and lib/site-python) are actually scanned for .pth files, plus any paths 
added as a result of parsing .pth files that are found.

If you want to modify or extend this behaviour, you should take 
advantage of sitecustomize.py by adding your own behaviour, perhaps 
scanning os.environ['PYTHONPATH'] to look for .pth files.

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


Re: is there a better way to check an array?

2005-09-02 Thread Fredrik Lundh
Peter Hansen wrote:

> Probably because at one point lists didn't even have the index() method,
> and when it was suggested and (I believe) Raymond H. added it

the list "index" method has been in Python since, like, forever (early 1991,
according to CVS, which means that it was added about two years before
the first 1.0 alpha was made public...)

 



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


Help for NewBies at WikiBooks

2005-09-02 Thread Alessandro Bottoni
I just discovered that Wikipedia has a very fine WikiBook about Python
Programming:

http://en.wikibooks.org/wiki/Programming:Python

I think that most of the newbies (like me ;-) will find it very interesting.

CU
---
Alessandro Bottoni
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Code run from IDLE but not via double-clicking on its *.py

2005-09-02 Thread Bryan Olson
Dennis Lee Bieber wrote:
 >  I'm going to go back a few messages... Looking for a
 > simplification...
[...]
 >  TWO threads, both just infinite loops of the same nature (you could
 > actually have done ONE def and passed different arguments in to
 > differentiate the two thread invocations.
 >
 >  However, threads aren't really needed for this simple connection
 > relay...

True, though I prefer the tread solution. You can see my exmaple
in message <[EMAIL PROTECTED]>.

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


 > The following has /not/ been run (since I don't have your
 > server nor VBS) but should do about the same thing (see comments for one
 > lack).

There's an easy trick to pseudo-test such a thing: for the
server host and port, edit in 'www.yahoo.com' and 80. Then
direct a browser to http://localhost:1434.


 > ===> Suggested code

I have a few further suggestions.

[...]
 > DBMSSocket.connect((host, DBMSPort))
 >
 > MySocket.bind((host, MyPort))

I'd definitely wait for the client connection to come in, before
making the server connection.


 > MySocket.listen(1)
 >
 > Client, Addr = MySocket.accept()
 >
 > while True:
 > #   wait for either connection to have readable data
 > (inbound, outbound, excption) = select.select([DBMSSocket, 
Client], [], [])

One trick I used was to pass a timeout parameter; I used one
second. Python (at least my version on WinXP) won't honor the
keyboard interrupt while waiting at the select. The select is in
an infinite loop anyway, so it just means polling for a keyboard
interrupt every second.


 > #   handle each readable socket
 > #   NOTE: there is no way (in this quick and dirty code) to
 > #   detect end of connections.
 > #   probably need to do things with the excption list --
 > #   passing in the sockets, and closing them when they
 > #   show up in excption -- actually, if one side closes
 > #   there is no reason to continue processing the other
 > #   side, so on any excption, could close both and exit

Not really. If the remote side shuts down writing, the socket
will select as readable, and read will return the empty string.
That's the documented method to detect when the remote side is
done writing. When it happens, you should send the shutdown
across, much like you copy data across: shutdown writing on the
other socket. To terminate clean, copy all data and both
shutdowns (though the latter shutdown should happen
automatically if you just let the socket be destructed).

 > data = s.recv(4096)
 > if s is Client:
 > print "From VBS: ",
 > MyDBMS.send(data)

Use sendall() in place of send(); same for the other call to
socket.send(). It's an evil trap: under most circumstances,
send() will send all the data, but it's not guaranteed to do so.
With a size of 4096, you're probably O.K., but technically it's
a bug. (The slicker-than-needed thing to do would be to test
whether the outgoing socket is writable within the select, then
send() as much as you can, and keep selecting and sending until
all the data is out.)


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


Re: Sockets: code works locally but fails over LAN

2005-09-02 Thread Bryan Olson
I wrote:
 > Below is a version that respects ^C to terminate
 > more-or-less cleanly.

Oops, one more bug^H^H^H improvement. I forgot to shutdown
writing.


 > import socket, threading, select
 >
 > sqls_host, sqls_port = '192.168.0.3', 1443
 > proxy_host, proxy_port = '', 1434
 >
 >
 > def start_deamon_thread(func, args):
 >  """ Run func(*args) in a deamon thread.
 >  """
 >  thread = threading.Thread(target=func, args=args)
 >  thread.setDaemon(True)
 >  thread.start()
 >
 >
 > def sock_copy(s_from, s_to, annotation):
 > while 1:
 > data = s_from.recv(4096)
 > if not data:

Insert:
| s_to.shutdown(socket.SHUT_WR)

 > break
 > s_to.sendall(data)
 > print annotation + data + '\n\n'
 >
 >
 > s1 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 > s1.bind((proxy_host, proxy_port))
 > s1.listen(5)
 >
 > while 1:
 > s, _, _ = select.select([s1], [], [], 1.0)
 > if s:
 > cn, _ = s1.accept()
 > s2 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 > s2.connect((sqls_host, sqls_port))
 > start_deamon_thread(sock_copy, (cn, s2, 'VB_SCRIPT:'))
 > start_deamon_thread(sock_copy, (s2, cn, 'SQL_SERVER:'))


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


Re: Code run from IDLE but not via double-clicking on its *.py

2005-09-02 Thread bryanjugglercryptographer

I wrote:
> I prefer the tread solution. You can see my exmaple
> in message <[EMAIL PROTECTED]>.
>
>http://groups.google.com/group/comp.lang.python/msg/ffd0159eb52c1b49
[...]

> you should send the shutdown
> across, much like you copy data across: shutdown writing on the
> other socket.

Which, incidentally, I had forgotten to do in my code. See
the follow-up for the fix.


-- 
--Bryan

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


Re: Add lists to class?

2005-09-02 Thread BBands
That's interesting and I take your point. Maybe there is a better way.
Here is what I am doing now. (working)

I start with a text file of ticker symbols. I read each symbol and
stick it in a list, retrieve the data for it from MySQL, do a trivial
smoothing and pass the data to a modeling routine. I read the tickers
into a list, self.symbols. Then for each ticker I create a list,
self._0, self._1, ... and a list for the smoothed values,
self._0_smooth, self._1_smooth, ... I end up with data I can access
with self.__dict__["_" + str(var)] and a matching symbol which I can
access self.symbols[var].

Ideas for a better approach gladly accepted.

jab

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


Re: 'isa' keyword

2005-09-02 Thread talin at acm dot org
Thanks for all the respones :) I realized up front that this suggestion
is unlikely to gain approval, for reasons eloquently stated above.
However, there are still some interesting issues raised that I would
like to discuss.

Let me first respond to a few of the comments:

>What's the difference between this and ``isinstance`` ?

What's the difference between 'in' and 'has_key()"? 1) Its shorter and
more readable, 2) it can be overridden to mean different things for
different container types.

> What's wrong with:
> if image.isa(gif):
> elif image.isa(jpeg):
>elif image.isa(png):

That forces the classification logic to be put into the instance,
rather than in the category. With the "in" keyword, the "__contains__"
function belongs to the container, not the contained item, which is as
it should be, since an item can be in multiple containers.

> Especially conidering that checking parameters with "isinstance" is
> considered bad form with Python's duck typing.

Here's an example where the strict OOP style of programming breaks
down. I'll use SCons as an example. In SCons, there is a "Depends"
function that can take a filename, a list of filenames, or a build
target (which is a python object). So the logic looks like this:

def Depends( target ):
   if isinstance( target, str ):
...
   elif isinstance( target, list ):
   ...
   elif isinstance( target, BuildTarget ):
   ...
   else: error

You can't use method overloading here, because you are dealing with
builtin python objects (except for the BuildTarget).

I can think of several different cases where you would have to resort
to logic like this:
  -- Where you are trying to distinguish between built-n python types
  -- Where you are trying to distinguish between types that are created
by another, independent module and which you can't modify
  -- Where you are trying to do multi-method dispatch logic.

As an example of the latter, imagine a music sequencer application that
edits a stream of Midi events. Lets suppose that there are various
"classes" of events:

   Note On
   Note Off
   Aftertouch
   Pitchbend
   Control Change

In addition, lets suppose that we  have a variety of different ways of
editing these events:

   "Piano Roll" Editor - edits in horizontal "piano roll" form
   "Drum Machine" editor - notes are placed on a grid
   Event List Editor - a text list of events
   Music Notation Editor - uses conventional notes and staves

All of these editors operate on the same underlying data, which is a
stream of events. Each of these editors has a "repaint" function to
render the stream of events. So the rendering of the event depends
*both* on the class of the event, and the class of the editor.

So you could organize it this way:

class PianoRollEditor:
   def repaint( event ):
  if isinstance( event, Note ): # draw note
  elif isinstance( event, Aftertouch ): # draw
  ...etc

You could also invert the logic (which is somewhat clumsier):

class Note:
   def repaint( context ):
  if isinstance( context, PianoRollEditor ): ...
  etc...

Now, I realize that some folks have built multi-method dispatch systems
for Python (I did one myself at one point.) However, these tend to be
somewhat slow and clunky without language support (and no, I am not
asking for Python to become Dylan or CLOS.) But it would be nice to
know if there was a cleaner way to solve the above problems...

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


Re: Add lists to class?

2005-09-02 Thread BBands
That's interesting and I take your point. Maybe there is a better way.
Here is what I am doing now. (working)

I start with a text file of ticker symbols. I read each symbol and
stick it in a list, retrieve the data for it from MySQL, do a trivial
smoothing and pass the data to a modeling routine. I read the tickers
into a list, self.symbols. Then for each ticker I create a list,
self._0, self._1, ... and a list for the smoothed values,
self._0_smooth, self._1_smooth, ... I end up with data I can access
with self.__dict__["_" + str(var)] and a matching symbol which I can
access self.symbols[var].

Ideas for a better approach gladly accepted.

jab

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


Re: Sockets: code works locally but fails over LAN

2005-09-02 Thread n00m
My today's tests (over LAN).
I think *it* will drive me mad very soon.

Firstly I tested both Bryan's codes. And they worked fine!
Just as if they were tested locally!

Then I tested Fredrik suggestion. And it worked out too.
Expect unexpected, - as they say.

At last I decided to test my own version (just for the
experiment's purity). And... pf... it worked OK!

What happened to those machines over the night?
NOTHING! Nobody can access them but me.

Then I decided to test it from other ("the third") machine.
And again both Bryan's codes worked out like champs.
But my own ... failed! (as usually)!

Then I ran the vbs from the 4th machine...
Bryan's and *mine* worked OK...


Bryan wrote:
> The client is trying to make more than one connection.
I don't think so. Look at the very first line of the vbs:

Set cn = CreateObject("ADODB.Connection")

Create .Connection! NOT .Connections.

> Glad it worked, but I'd still disrecommend IDLE...
But it does NOT work without IDLE!

PS:
> Oops, one more bug^H^H^H improvement.
> I forgot to shutdown writing.
LOL Thank you! But while I don't understand what's going on
with the core part of the code this improvement doesn't much
matter.

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


Re: Bug in string.find

2005-09-02 Thread Steve Holden
Dennis Lee Bieber wrote:
> On Fri, 02 Sep 2005 00:23:14 GMT, Ron Adam <[EMAIL PROTECTED]> declaimed
> the following in comp.lang.python:
> 
> 
>>So how do I express a -0?  Which should point to the gap after the last 
>>item.
>>
> 
>   Step one: Obtain a processor that uses ones-complement arithmetic.
> 
Ah, the good old Univac 418 ... [drools into beard and mumbles]

>   Step two: Port Python to said processor...
> 
Unfortunately the 418 would probably come in at about a micro-pystone, 
so perhaps we should emulate it on something more modern?

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/

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


Re: problems with smtplib

2005-09-02 Thread Steve Holden
Peter Hansen wrote:
> Steve Holden wrote:
> 
>>n00m wrote:
>>
>>
>>>I also can't get my SMTP (win2k) working with Python.
>>>But... funnily this works fine:
>>>
>>>import smtplib
>>>s = smtplib.SMTP('smtp.mail.ru')
>>>s.sendmail('[EMAIL PROTECTED]', '[EMAIL PROTECTED]', 'hi
>>>there!')
>>>s.quit()
>>>
>>
>>That's pretty strange: the second argument should be a list. Are you 
>>*sure* it worked?
> 
> 
> No longer required (as of at least Python 2.3 if not earlier).
> 
> "to_addrs : A list of addresses to send this mail to.  A bare string 
> will be treated as a list with 1 address."  (from smtplib.py sendmail() 
> docstring)
> 
Oops. Documentation bug. Fortunately it  looks like it's been fixed in 
response to bug 1217513. Thanks for the tip, Peter.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/

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


Re: Add lists to class?

2005-09-02 Thread Michael Hoffman
BBands wrote:

> I start with a text file of ticker symbols. I read each symbol and
> stick it in a list, retrieve the data for it from MySQL, do a trivial
> smoothing and pass the data to a modeling routine. I read the tickers
> into a list, self.symbols.

OK...

 > Then for each ticker I create a list,
> self._0, self._1, ...

That's not a list. That's a bunch of attributes.

> I end up with data I can access
> with self.__dict__["_" + str(var)] and a matching symbol which I can
> access self.symbols[var].  Ideas for a better approach gladly accepted.

Why don't you use a real list instead? I don't understand what 
self.__dict__["_" + str(var)] gets you.

self.symbols = ["IBM", "MSFT", "SCOX"]
self.values = [99, 100, 0.25]
self.smooth_values = [100, 100, 0]

or you could use a dict:

self.values = dict(IBM=99, MSFT=100, SCOX=0.25)
-- 
Michael Hoffman
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: is there a better way to check an array?

2005-09-02 Thread Peter Hansen
Fredrik Lundh wrote:
> Peter Hansen wrote:
>>Probably because at one point lists didn't even have the index() method,
>>and when it was suggested and (I believe) Raymond H. added it
> 
> the list "index" method has been in Python since, like, forever (early 1991,
> according to CVS, which means that it was added about two years before
> the first 1.0 alpha was made public...)

D'oh!  My apologies:  I was misremembering the addition of the optional 
"start" and "stop" arguments to the existing list() method, which 
happened in June 2003 (SF #754014 at 
http://sourceforge.net/tracker/index.php?func=detail&aid=754014&group_id=5470&atid=355470
 
).

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


Problem building Python on HP-UX

2005-09-02 Thread Dr. Who
I'm trying to build Python 2.4.1 on HP-UX 11.00 with full tcl/tk IDLE
support.  So far, I haven't had any luck.  I always wind up getting
errors of the form:

ld: DP relative code in file
/ptg/devtools/hppa1.1/pre/lib/libtk8.4.a(tkWindow.o) - shared library
must be position independent.  Use +z or +Z to recompile.

I have tried building tcl/tk without any configure options as well as
with --disable-shared and --disable-load but this doesn't help.

Anyone seen anything like this or know how to get around it?

Jeff

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


Re: problems with smtplib

2005-09-02 Thread Jon Hewer
just got home and i've tried my script on windows with my isp's smtp
server, and found that my code wasn't getting past the s.connect()

changed me code to:

s = smtplib.SMTP('smtp.lineone.net')
s.sendmail(me, to, msg.as_string())
s.quit()

and now it works fine

On 9/2/05, Steve Holden <[EMAIL PROTECTED]> wrote:
> Peter Hansen wrote:
> > Steve Holden wrote:
> >
> >>n00m wrote:
> >>
> >>
> >>>I also can't get my SMTP (win2k) working with Python.
> >>>But... funnily this works fine:
> >>>
> >>>import smtplib
> >>>s = smtplib.SMTP('smtp.mail.ru')
> >>>s.sendmail('[EMAIL PROTECTED]', '[EMAIL PROTECTED]', 'hi
> >>>there!')
> >>>s.quit()
> >>>
> >>
> >>That's pretty strange: the second argument should be a list. Are you
> >>*sure* it worked?
> >
> >
> > No longer required (as of at least Python 2.3 if not earlier).
> >
> > "to_addrs : A list of addresses to send this mail to.  A bare string
> > will be treated as a list with 1 address."  (from smtplib.py sendmail()
> > docstring)
> >
> Oops. Documentation bug. Fortunately it  looks like it's been fixed in
> response to bug 1217513. Thanks for the tip, Peter.
> 
> regards
>   Steve
> --
> Steve Holden   +44 150 684 7255  +1 800 494 3119
> Holden Web LLC http://www.holdenweb.com/
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Code run from IDLE but not via double-clicking on its *.py

2005-09-02 Thread n00m
Dennis Lee Bieber wrote:
> Hope you'll forgive my comment -- but for some reason those look...
Your comments are absolutely relevant.

> My version, using select(), shouldn't have this problem.
Now I see what you meant ("You need no threads"). Your code works just
fine (hope over LAN too). I corrected a couple of typos in it.

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


Find day of week from month and year

2005-09-02 Thread Laguna
Hi Gurus,

I want to find the expiration date of stock options (3rd Friday of the
month) for an any give month and year. I have tried a few tricks with
the functions provided by the built-in module time, but the problem was
that the 9 element tuple need to be populated correctly. Can anyone
help me out on this one?

Thanks a bunch,
Laguna

Requirements:

d0 = expiration(9, 2005) # d0 would be 16
d1 = expiration(6, 2003) # d1 would be 20
d2 = expiration(2, 2006) # d2 would be 17

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


Re: Find day of week from month and year

2005-09-02 Thread Paul Rubin
"Laguna" <[EMAIL PROTECTED]> writes:
> I want to find the expiration date of stock options (3rd Friday of the
> month) for an any give month and year. I have tried a few tricks with
> the functions provided by the built-in module time, but the problem was
> that the 9 element tuple need to be populated correctly. Can anyone
> help me out on this one?

It's probably simplest to use the calendar module:

  http://docs.python.org/lib/module-calendar.html

see the weekday function.

> d0 = expiration(9, 2005) # d0 would be 16
> d1 = expiration(6, 2003) # d1 would be 20
> d2 = expiration(2, 2006) # d2 would be 17

# not completely tested
import calendar
def expiration(month, year):
w1 = calendar.weekday(year, month, 1) # weekday of 1st of month
f1d = 1 + (4-w1) % 7  # date of 1st friday
return f1d + 14   # date of 3rd friday
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Find day of week from month and year

2005-09-02 Thread Robert Kern
Laguna wrote:
> Hi Gurus,
> 
> I want to find the expiration date of stock options (3rd Friday of the
> month) for an any give month and year. I have tried a few tricks with
> the functions provided by the built-in module time, but the problem was
> that the 9 element tuple need to be populated correctly. Can anyone
> help me out on this one?

mx.DateTime provides a RelativeDateTime constructor that handles things
like this.

http://www.egenix.com/files/python/mxDateTime.html

-- 
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: OpenSource documentation problems

2005-09-02 Thread skip

Tim> [Paul Rubin]
>> Until not that long ago, it was possible to submit sf bugs without
>> being logged into sf.  Why did that change?

Tim> To reduce tracker spam, to reduce tracker vandalism, and to make it
Tim> possible to contact submitters when needed.

Also, "not that long ago" must mean different things for different people.
I think we've required logins for three years or more.

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


Re: Problem building Python on HP-UX

2005-09-02 Thread Trent Mick
[Dr. Who wrote]
> I'm trying to build Python 2.4.1 on HP-UX 11.00 with full tcl/tk IDLE
> support.  So far, I haven't had any luck.  I always wind up getting
> errors of the form:
> 
> ld: DP relative code in file
> /ptg/devtools/hppa1.1/pre/lib/libtk8.4.a(tkWindow.o) - shared library
> must be position independent.  Use +z or +Z to recompile.
> 
> I have tried building tcl/tk without any configure options as well as
> with --disable-shared and --disable-load but this doesn't help.
> 
> Anyone seen anything like this or know how to get around it?

For Python on HP-UX I build Tcl/Tk with --enable-shared. I don't *think*
I had to do much else special -- other than tweaking Python's setup.py
detect_tkinter() code to find where I had built and "installed" my
Tcl/Tk libs.

Cheers,
Trent

p.s. Note that we now have free ActivePython binary installers for
 HP-UX at ActiveState.
 http://www.activestate.com/Products/ActivePython/

-- 
Trent Mick
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Find day of week from month and year

2005-09-02 Thread Donn Cave
In article <[EMAIL PROTECTED]>,
 "Laguna" <[EMAIL PROTECTED]> wrote:

> I want to find the expiration date of stock options (3rd Friday of the
> month) for an any give month and year. I have tried a few tricks with
> the functions provided by the built-in module time, but the problem was
> that the 9 element tuple need to be populated correctly. Can anyone
> help me out on this one?
...
> Requirements:
> 
> d0 = expiration(9, 2005) # d0 would be 16
> d1 = expiration(6, 2003) # d1 would be 20
> d2 = expiration(2, 2006) # d2 would be 17

What do you mean by, "the 9 element tuple need to be populated
correctly"?  Do you need someone to tell you what values it
needs?  What happens if you use (2005, 9, 1, 0, 0, 0, 0, 0, 0),
for example?  If you make this tuple with localtime or gmtime,
do you know what the 7th (tm[6]) element of the tuple is?
What tricks did you try, exactly?

   Donn Cave, [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OpenSource documentation problems

2005-09-02 Thread Paul Rubin
[EMAIL PROTECTED] writes:
> Also, "not that long ago" must mean different things for different people.
> I think we've required logins for three years or more.

I hope you're not right and that it hasn't really been that long.
Yikes ;-).
-- 
http://mail.python.org/mailman/listinfo/python-list


defining classes

2005-09-02 Thread LeRoy Lee
I have been searching for the answer to this as it will determine how I use 
classes.  Here are two bits of code.

class foo1:
def __init__(self, i):
self.r = i
self.j = 5

>>h = foo1(1)
>>h.r
1
>>h.j
5


Now take this example

class foo2:
def __init__(self):
self.j = 5

>>h = foo2()
>>h.j
Traceback (most recent call last):
  File "", line 1, in ?
AttributeError: foo2 instance has no attribute 'j'

I can't figure out why it is working this way.  I figure I must be thinking 
about this wrong.  I was thinking that I could bind attributes to the class 
from within methods using the self prefix.  According to this example I can 
only when passing other info into the init.  Is there a rule that I am just 
not aware off?  Am I totally off base (I am not real experienced)?  What is 
the self prefix for then if not to bind up the tree?

Thanks,
LeRoy

_
Express yourself instantly with MSN Messenger! Download today - it's FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

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


  1   2   >