Re: Possible problem in compiler/transformer.py of Python2.4...

2006-08-31 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote:

> What is surprising is I checkd the entire py2.4 distribution and I
> can't see a symbol.py (or a module with symbol defined) where
> transformer.py could import the symbol module form. All I can see
> is:
>  ./lib/python2.4/compiler/symbols.py
> in the same directory as that of transformer.py (in compiler).
> 
> Has anyone seen this error, or have any pointers to solve the problem.

looks like your installation is botched.

 > dir \python24\lib\compiler\symbols.py

2005-10-28  20:1515 059 symbols.py

$ cd /usr/local/lib/python2.4/compiler
$ ls -l symbols.py
-rw-r--r--1 root root14591 Aug 11  2005 symbols.py

(the former is 2.4.3 on windows, the latter 2.4.1 on unix)



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


Re: all ip addresses of machines in the local network

2006-08-31 Thread Amit Khemka
> in my program so far, multiple threads (255 threads in total) spawned
> at once with each one of them trying to call socket.gethostbyaddr(ip)
> function. i.e. if exception thrown, no machine found. i used .join() to
> wait for the threads to terminate. it's fully working however the
> problem is that it's too slow. it takes approx. 14 seconds to process
> (i tried using 'ping' but it's even slower.).
>
> my question is.. is there a way to improve performance of the program
> if i know what the port number would be? in my case, the port number
> will always be constant although i have no clue on what ip addresses
> would be (that's the reason all of 255 different addresses must be
> tested).
>
> i tried the same function with the port number specified,
> gethostbyaddr(ip:portno), but it is even 10-second slower than using
> the same function without a port number specified (i.e. approx. 25
> seconds to complete).

You can save some (DNS) overheads by escaping the call
"gethostbyaddr", assuming you are not interested in knowing the
'Names' of the machines in your Network. And directly attempt to find
the machines which are listenting on the specified port. A simple way
of
doing this would be to use socket.connect((ip, port)), if the
connections succeds you have
your machine !

( There are various other ways of scanning ports, have a look at:
http://insecure.org/nmap/nmap_doc.html#connect )

Though I am not sure how 'fast' it would be. Also remember that the
time in scanning is affected by network-type,
response-time-of-remote-machine, number-of-machines scanned etc.

I would still be interested, in seeing how nmap(with some smart
options) compares with the python code. ( In my network "nmap
-osscan_limit -p 22 -T5 Class_D_Network" completes in 1.5 seconds !)

cheers,
amit.
-- 

Amit Khemka -- onyomo.com
Home Page: www.cse.iitd.ernet.in/~csd00377
Endless the world's turn, endless the sun's Spinning, Endless the quest;
I turn again, back to my own beginning, And here, find rest.
-- 
http://mail.python.org/mailman/listinfo/python-list


How to avoid a warning message box when sending email via Outlook

2006-08-31 Thread Dermot Doran
Hello All,
 
I'm very new to using win32com!  I just want to send an email message via Outlook.  However, I keep getting an annoying message box (generated by Outlook) indicating that my program could be a virus.  Does anybody know how to get around this?  Here is the sample code I'm using:

from win32com.client import Dispatchs=Dispatch("Outlook.Application")ns=s.GetNamespace("MAPI")ns.Logon() # Note: I've taken the login credentials out of the example :-)mi = ns.Application.CreateItem
(0)mi.Recipients.Add("an,other")mi.Subject="Hello from Python!"mi.Body="I just need to figure out how to avoid the message box now!"mi.Send()ns.Logoff() 
I'm probably missing something silly or have hit a brick wall with what I want to do with CDO.
 
Cheers!!
 
Dermot.
 
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Possible problem in compiler/transformer.py of Python2.4...

2006-08-31 Thread Duncan Booth
Fredrik Lundh wrote:

> [EMAIL PROTECTED] wrote:
> 
>> What is surprising is I checkd the entire py2.4 distribution and I
>> can't see a symbol.py (or a module with symbol defined) where
>> transformer.py could import the symbol module form. All I can see
>> is:
>>  ./lib/python2.4/compiler/symbols.py
>> in the same directory as that of transformer.py (in compiler).
>> 
>> Has anyone seen this error, or have any pointers to solve the problem.
> 
> looks like your installation is botched.
> 
> > dir \python24\lib\compiler\symbols.py
> 
> 2005-10-28  20:1515 059 symbols.py
> 
> $ cd /usr/local/lib/python2.4/compiler
> $ ls -l symbols.py
> -rw-r--r--1 root root14591 Aug 11  2005 symbols.py
> 
> (the former is 2.4.3 on windows, the latter 2.4.1 on unix)
> 

What has listing symbols.py got to do with this? He said he has symbols.py. 
What is missing is symbol.py which should be in the main lib folder, not 
the compiler package. e.g.

 Directory of C:\Python24\Lib

02/09/2004  11:54 2,043 symbol.py
   1 File(s)  2,043 bytes

But yes, the conclusion is that his installation is botched.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how can i change the text delimiter

2006-08-31 Thread sonald
Hi,
I am using
Python version python-2.4.1 and along with this there are other
installables
like:
1. fastcsv-1.0.1.win32-py2.4.exe
2. psyco-1.4.win32-py2.4.exe
3. scite-1.63-setup.exe

We are freshers here, joined new... and are now into handling this
module which validates the data files, which are provided in some
predefined format from the third party.
The data files are provided in the comma separated format.

The fastcsv package is imported in the code...
 import fastcsv
and
 csv = fastcsv.parser(strict = 1,field_sep = ',')

can u plz tell me where to find the parser function definition, (used
above)
so that if possible i can provide a parameter for
text qualifier or text separator or text delimiter..
just as {field_sep = ','} (as given above)

I want to handle string containing double quotes (")
but the problem is that the default text qualifier is double quote

Now if I can change the default text qualifier... to say pipe (|)
the double quote inside the string may be ignored...
plz refer to the example given in my previous query...

Thanks..






Fredrik Lundh wrote:
> "sonald" wrote:
>
> > fast csv is the the csv module for Python...
>
> no, it's not.  the csv module for Python is called "csv".
>
> > and actually the string cannot be modified because
> > it is received from a third party and we are not supposed to modify the
> > data in any way..
>
> that doesn't prevent you from using Python to modify it before you pass it to
> the csv parser, though.
>
> > for details on the fast CSV module please visit
> >
> > www.object-craft.com.au/projects/csv/ or
>
> that module is called "csv", not "fastcsv".  and as it says on that page, a 
> much
> improved version of that module was added to Python in version 2.3.
> 
> what Python version are you using?
> 
> 

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


Re: Allowing ref counting to close file items bad style?

2006-08-31 Thread [EMAIL PROTECTED]
Paul Rubin wrote:
> "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes:
> > I disagree strongly with this assertion.  It's not as efficient overall
> > as other GC implementations, but it's not a case of "less efficient to
> > do the same task".  Reference counting buys you deterministic GC in the
> > pretty common case where you do not have circular references--and
> > determinism is very valuable to programmers.  Other GCs be faster, but
> > they don't actually accomplish the same task.
>
> GC is supposed to create the illusion that all objects stay around
> forever.  It releases unreachable objects since the application can't
> tell whether those objects are gone or not.

No, that's not true of all GC implementations.  Refcounting
implementations give much nicer deterministic guarantees.

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


Re: GC and security

2006-08-31 Thread Fredrik Lundh
Les Schaffer wrote:

> i am working on a python application that uses encryption as part of its
> security features. so then at some point someone has to enter a
> passphrase into the system and passed into a decryption functions (we
> are using gpg via subprocess).
> 
> so i am curious. so long as i drop all reference to the passphrase
> string(s), eventually it gets garbage collected and the memory recycled.
> so "before long" the phrase is gone from memory.

Since Python uses reference counting, if you drop all references, the 
object is garbaged collected immediately, and the associated memory is 
freed.  However, freeing memory doesn't mean that the memory is cleared, 
so the passphrase will still be visible in memory, until some other part 
of your program allocates the same memory area and overwrites it.

you could obscure things a bit by storing the passphrase as a list of 
characters, or a list of integers, and write it to gpg one character at 
a time (if that's possible; if not, you may need to write a custom 
extension that builds a command string in a C-level buffer, runs the 
command, and then overwrites the buffer before returning).



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


Re: GC and security

2006-08-31 Thread Fredrik Lundh
Fredrik Lundh wrote:

> a time (if that's possible; if not, you may need to write a custom 
> extension that builds a command string in a C-level buffer, runs the 
> command, and then overwrites the buffer before returning).

on the other hand, subprocess seems to support the buffer interface, so 
the following slightly convoluted approach could be used instead of such 
an extension:

 >>> cmd = [101, 99, 104, 111, 32, 39, 104, 101, 108, 108, 111, 39]
 >>> cmd = array.array("b", cmd) # build mutable buffer
 >>> subprocess.call([buffer(cmd)], shell=True)
'hello'
 >>> for i in range(len(cmd)): cmd[i] = 0 # nuke it

the secret text will be visible in memory during the subprocess call, 
but it won't linger around once the for-loop has finished.

(don't forget to put a try/finally clause around the critical part)



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


RE: How to avoid a warning message box when sending email via Outlook

2006-08-31 Thread Tim Golden
[Dermot Doran]

| I'm very new to using win32com!  I just want to send an email 
| message via Outlook.  However, I keep getting an annoying 
| message box (generated by Outlook) indicating that my program 
| could be a virus.  Does anybody know how to get around this?  

As far as I've ever been able to tell, you're stuck with it.
Obviously, in a sense, since otherwise any would-be virus /
zombie program would simply turn the option off before using
Outlook to send out its emails!

TJG


This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk

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


Re: GC and security

2006-08-31 Thread Tim N. van der Leeuw

Fredrik Lundh wrote:
> Les Schaffer wrote:
>
> > i am working on a python application that uses encryption as part of its
> > security features. so then at some point someone has to enter a
> > passphrase into the system and passed into a decryption functions (we
> > are using gpg via subprocess).
> >
> > so i am curious. so long as i drop all reference to the passphrase
> > string(s), eventually it gets garbage collected and the memory recycled.
> > so "before long" the phrase is gone from memory.
>
> Since Python uses reference counting, if you drop all references, the
> object is garbaged collected immediately, and the associated memory is
> freed.  However, freeing memory doesn't mean that the memory is cleared,
> so the passphrase will still be visible in memory, until some other part
> of your program allocates the same memory area and overwrites it.
>
> you could obscure things a bit by storing the passphrase as a list of
> characters, or a list of integers, and write it to gpg one character at
> a time (if that's possible; if not, you may need to write a custom
> extension that builds a command string in a C-level buffer, runs the
> command, and then overwrites the buffer before returning).

Storing the passphrase as a list of something has the advantage that
you could set all list-entries to zero, None or random values before
the list goes out of scope. The individual characters from the
passphrase can of course still be snooped from memory, somehow, in
theory -- but without any coherence. (At most the coherence of the
order of allocation).

However, such obfuscation does not make any real sense unless the
passphrase is always stored in a list and in a list only; if it enters
your program in the form of a string somehow then basically such
obfuscations seem very meaningless to me.


Perhaps the Python interpreter should be extended with a new C Type,
'secure_string', which clears all it's bytes before being freed. (Just
phantasizing out loud here, not being in any way serious!)

> 
> 


Cheers,

--Tim

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


urllib2 ftp mirror

2006-08-31 Thread Tonino
Hi,

I need to be able to mirror a remote ftp site recursivly, but my access
to the internet is through a http proxy server.

>From my search I can see that ftpmirror.py uses ftplib and ftplib does
not support proxy servers, you need to use urllib2.

Does anyone know of a simple way to get this done?  recursive ft mirror
using urllib?

Thanks
Tonino

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


Re: How to avoid a warning message box when sending email via Outlook

2006-08-31 Thread Dermot Doran
Hi Tim,
 
looks like I might be back to the drawing board :-(  Thanks for letting me know what your experiences have been.
 
I'm kind of surprised that it works this way since the ns.logon() allows me to access the Outlook address book without any problems.  Without the logon I get another warning box requesting that I allow access to an external program.

 
Ah well.
 
Cheers!!
 
Dermot. 
On 31/08/06, Tim Golden <[EMAIL PROTECTED]> wrote:
[Dermot Doran]| I'm very new to using win32com!  I just want to send an email| message via Outlook.  However, I keep getting an annoying
| message box (generated by Outlook) indicating that my program| could be a virus.  Does anybody know how to get around this?As far as I've ever been able to tell, you're stuck with it.Obviously, in a sense, since otherwise any would-be virus /
zombie program would simply turn the option off before usingOutlook to send out its emails!TJGThis e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactiveanti-virus service working around the clock, around the globe, visit:http://www.star.net.uk
--http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Allowing ref counting to close file items bad style?

2006-08-31 Thread BJörn Lindqvist
On 8/30/06, Dan <[EMAIL PROTECTED]> wrote:
> Is this discouraged?:
>
>  for line in open(filename):
>  

In theory, it is. In practice, that is the way Python code is written
because it more natural and to the point. Not just for hacked together
scripts, lots of third party modules includes code like "data =
open(filename).read()" and similar idioms.

> Is my data safer if I explicitly close, like this?:
>  fileptr = open("the.file", "w")
>  foo_obj.write(fileptr)
>  fileptr.close()

Have you ever experienced a problem caused by not explicitly closing
your file handles?

-- 
mvh Björn
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: How to avoid a warning message box when sending email via Outlook

2006-08-31 Thread Tim Golden
[Dermot Doran]

| looks like I might be back to the drawing board :-(  Thanks 
| for letting me know what your experiences have been.

Just to elaborate slightly on that experience, if all I want
to do is to send an email (ie not look up addresses on Contacts
or do any fancy Outlook-related thing) then I just use an SMTP 
server. Here at work the admins have Exchange set up as an
SMTP server, which may or may not be the case for you. At home
or from websites etc. I simply use whichever SMTP server I'd
normally send mail through.

Obviously this won't do anything like keeping a copy in your
Sent Mail box etc. but it will at least work, and with a bit
more effort you may be able to do things like that manually.

TJG

BTW, people in this group will tend to frown on top-posting,
even though we Outlook users have to work around Outlook's
tendency to offer it a [Reply] ;)


This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk

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


Any relational database design tool written in Python

2006-08-31 Thread metaperl
Hello,

I am wondering if I overlooked such a tool at freshmeat, sf.net, and
cheeseshop and google.  I prefer Python, so that I can patch and
upgrade it. Which also means I prefer opensource over commercial.

I am hoping for something that can create database deltas.  I am sort
of divided over the logical versus physical modeling issue.

While I am looking for something fairly graphical like dbSketch or
dbWrench, I am pretty impressed with Django's built-in ORM's ability to
create and update databases.

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


Re: how can i change the text delimiter

2006-08-31 Thread Fredrik Lundh
sonald wrote:

> Python version python-2.4.1 and along with this there are other
> installables like:
> 1. fastcsv-1.0.1.win32-py2.4.exe

I get zero hits for that file on google.  are you sure that's not an 
in-house tool ?  asking comp.lang.python for help on internal tools 
isn't exactly optimal.

any reason you cannot switch to the built-in "csv" module instead, so 
you can use the solutions you've already gotten ?



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


Re: how can i change the text delimiter

2006-08-31 Thread Amit Khemka
On 31 Aug 2006 00:25:38 -0700, sonald <[EMAIL PROTECTED]> wrote:
> Hi,
> I am using
> Python version python-2.4.1 and along with this there are other
> installables
> like:
> 1. fastcsv-1.0.1.win32-py2.4.exe
> 2. psyco-1.4.win32-py2.4.exe
> 3. scite-1.63-setup.exe
>
> We are freshers here, joined new... and are now into handling this
> module which validates the data files, which are provided in some
> predefined format from the third party.
> The data files are provided in the comma separated format.
>
> The fastcsv package is imported in the code...
>  import fastcsv
> and
>  csv = fastcsv.parser(strict = 1,field_sep = ',')
>
> can u plz tell me where to find the parser function definition, (used
> above)
> so that if possible i can provide a parameter for
> text qualifier or text separator or text delimiter..
> just as {field_sep = ','} (as given above)
>
> I want to handle string containing double quotes (")
> but the problem is that the default text qualifier is double quote
>
> Now if I can change the default text qualifier... to say pipe (|)
> the double quote inside the string may be ignored...
> plz refer to the example given in my previous query...
>
> Thanks..

As Fredrik and Skip mentioned earlier, The csv(from
www.object-craft.com.au/projects/csv/) module you are using is
obsolete. And an improved version is a part of standard python
distribution. You should the standard module, in the way as suggested.

You may like to do the following.
1. Convert all your data-file with say '|' as the quotechar (text delimiter)
2. Use (Import) the *standard* python cvs module ()

A sample code would look like:

import csv # standard csv module distributed with python

inputFile = "csv_file_with_pipe_as_quotchar.txt"
reader = csv.reader(open(inputFile), quotechar='|')

for row in reader:
 # do what ever you would like to do

cheers,
amit.


Amit Khemka -- onyomo.com
Home Page: www.cse.iitd.ernet.in/~csd00377
Endless the world's turn, endless the sun's Spinning, Endless the quest;
I turn again, back to my own beginning, And here, find rest.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: csv module strangeness.

2006-08-31 Thread Fredrik Lundh
tobiah wrote:

>> you may be misreading the docs; the Dialect has no values at all, and 
>> must be subclassed (and the subclass must provide settings). 
> 
> The docs clearly state what the defaults are, but they are not
> in the code.  It seems so clumsy to have to specify every one 
> of these, just to change the delimiter from comma to tab.
> 
> http://docs.python.org/lib/csv-fmt-params.html : 

The "it defaults to" clauses should probably be seen in the context of 
the two "the programmer can" sentences in the first paragraph on that 
page; the default is what's used if you don't do that.

I agree that the first paragraph could need some work.  Any volunteers?



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


Broadcast server

2006-08-31 Thread swell
I would like to write a server with the low level API of python (
socket+select and/or socket+thread ) that allow me to register client
and update them every X seconds ( could be the time, the temperature, a
stock quote, a message , ... ).

How to write the server that keep hot connections with clients and
update them when events are trigerred. I don't know how to begin this ,
i look at the python doc but the doc is more related to client updating
the server and i am not sure of the right design that could be use
here.

Thx
Manu

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


Need Python for Linux (Suse 10.1)

2006-08-31 Thread Dick Moores


I've got a friend interested in trying out Python. I sent him to

http://www.python.org/download/linux/ but he's uncertain as to what
to download. He's rather get a new download than use what was on his Suse
disk. His box is an x86.
Any chance
Python
2.4.3 compressed source tarball would be suitable for him?
Advice for him, please.
Thanks,
Dick Moores




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

Re: Coding style and else statements

2006-08-31 Thread Pete Forman
Ben Finney <[EMAIL PROTECTED]> writes:

 > Why not ensure that there is one return point from the function, so
 > the reader doesn't have to remind themselves to look for hidden
 > return points?

There will always be more potential return points in languages that
support exceptions.
-- 
Pete Forman-./\.-  Disclaimer: This post is originated
WesternGeco  -./\.-   by myself and does not represent
[EMAIL PROTECTED]-./\.-   the opinion of Schlumberger or
http://petef.port5.com   -./\.-   WesternGeco.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python for Windows

2006-08-31 Thread mistral

Larry Bates писал(а):

> mistral wrote:
> > hg писал(а):

> >> Grant Edwards wrote:

>  Will the msi installer modify registry or other system files?
>  Does it possible install Python not touching registry and
>  system files?
> >> You can make your own installer to install Python, and make sure the
> >> registry is not touched - I think the current installer modifies at
> >> least the .py .pyw file association.

> >> hg
> >
> > 
> > not sure how to make custom installer to install Python on windows. Is
> > there some ready one?
> > If msi installer modify just pair of keys, and not touch system files,
> > then OK. Have it uninstaller also?

> > mistral
 --
> If you really want to install Python on Windows, I would recommend that
> you get ActiveState Python, it comes as .MSI installer and has
> uninstaller.

> http://www.activestate.com/Products/ActivePython/

> It does minimal registry changes and I know of no system file changes
> (but I could be wrong).  If you want to put a program written in python
> on a workstation you don't have to put python on it.  Use py2exe to
> package it and create an installer with Inno Setup.

> -Larry


ok, I just want run Python file, which will generate html file.

mistral

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

Re: Python for Windows

2006-08-31 Thread mistral

Larry Bates писал(а):

> mistral wrote:
> > hg писал(а):

> >> Grant Edwards wrote:

>  Will the msi installer modify registry or other system files?
>  Does it possible install Python not touching registry and
>  system files?
> >> You can make your own installer to install Python, and make sure the
> >> registry is not touched - I think the current installer modifies at
> >> least the .py .pyw file association.

> >> hg
> >
> > 
> > not sure how to make custom installer to install Python on windows. Is
> > there some ready one?
> > If msi installer modify just pair of keys, and not touch system files,
> > then OK. Have it uninstaller also?

> > mistral
 --
> If you really want to install Python on Windows, I would recommend that
> you get ActiveState Python, it comes as .MSI installer and has
> uninstaller.

> http://www.activestate.com/Products/ActivePython/

> It does minimal registry changes and I know of no system file changes
> (but I could be wrong).  If you want to put a program written in python
> on a workstation you don't have to put python on it.  Use py2exe to
> package it and create an installer with Inno Setup.

> -Larry


ok, I just want run Python file, which will generate html file.

mistral

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

Re: how can i change the text delimiter

2006-08-31 Thread John Machin
sonald wrote:
> Hi,
> I am using
> Python version python-2.4.1 and along with this there are other
> installables
> like:
> 1. fastcsv-1.0.1.win32-py2.4.exe

Well, you certainly didn't get that from the object-craft website --
just go and look at their download page
http://www.object-craft.com.au/projects/csv/download.html -- stops dead
in 2002 and the latest windows kit is a .pyd for Python 2.2. As you
have already been told and as the object-craft csv home-page says,
their csv was the precursor of the Python csv module.


> 2. psyco-1.4.win32-py2.4.exe
> 3. scite-1.63-setup.exe
>
> We are freshers here, joined new... and are now into handling this
> module which validates the data files, which are provided in some
> predefined format from the third party.
> The data files are provided in the comma separated format.
>
> The fastcsv package is imported in the code...
>  import fastcsv
> and
>  csv = fastcsv.parser(strict = 1,field_sep = ',')

Aha!! Looks like some misguided person has got a copy of the
object-craft code, renamed it fastcsv, and compiled it to run with
Python 2.4 ... so you want some docs. The simplest thing to do is to
ask it, e.g. like this, but with Python 2.4 (not 2.2) and call it
fastcsv (not csv):

... command-prompt...>\python22\python
Python 2.2.3 (#42, May 30 2003, 18:12:08) [MSC 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import csv
>>> help(csv.parser)
Help on built-in function parser:

parser(...)
parser(ms_double_quote = 1, field_sep = ',',
   auto_clear = 1, strict = 0,
   quote_char = '"', escape_char = None) -> Parser

Constructs a CSV parser object.

ms_double_quote
When True, quotes in a fields must be doubled up.

field_sep
Defines the character that will be used to separate
fields in the CSV record.

auto_clear
When True, calling parse() will automatically call
the clear() method if the previous call to parse() raised
an
exception during parsing.

strict
When True, the parser will raise an exception on
malformed fields rather than attempting to guess the right
behavior.

quote_char
Defines the character used to quote fields that
contain the field separator or newlines.  If set to None
special characters will be escaped using the escape_char.
# That's what you are looking for #
escape_char
Defines the character used to escape special
characters.  Only used if quote_char is None.

>>> help(csv)
Help on module csv:

NAME
csv - This module provides class for performing CSV parsing and
writing.

FILE
SOMEWHERE\csv.pyd

DESCRIPTION
The CSV parser object (returned by the parser() function) supports
the
following methods:
clear()
Discards all fields parsed so far.  If auto_clear is set to
zero. You should call this after a parser exception.

parse(string) -> list of strings
Extracts fields from the (partial) CSV record in string.
Trailing end of line characters are ignored, so you do not
need to strip the string before passing it to the parser.
If
you pass more than a single line of text, a csv.Error
exception will be raised.

join(sequence) -> string
Construct a CSV record from a sequence of fields.
Non-string
elements will be converted to string.

Typical usage:

import csv
p = csv.parser()
file = open('afile.csv')
while 1:
line = file.readline()
if not line:
break
fields = p.parse(line)
if not fields:
# multi-line record
continue
# process the fields
[snip remainder of docs]
>
> can u plz tell me where to find the parser function definition, (used
> above)
> so that if possible i can provide a parameter for
> text qualifier or text separator or text delimiter..
> just as {field_sep = ','} (as given above)
>
> I want to handle string containing double quotes (")
> but the problem is that the default text qualifier is double quote
>
> Now if I can change the default text qualifier... to say pipe (|)
> the double quote inside the string may be ignored...
> plz refer to the example given in my previous query...
>

It *appears* from this message that you have data already in a file,
and that data is *NOT* (as some one has already told you) in standard
CSV format.

Let me explain: The magic spell for quoting a field in standard CSV
format is:
quote = '"'
sep = ','
twoquotes = quote + quote
if quote in fld:
fld = quote + fld.replace(quote, twoquotes) + quote
elif sep in fld:
fld = quote + fld + quote

Note carefully that if the quote character appears in the raw input
data, it must 

Re: Need Python for Linux (Suse 10.1)

2006-08-31 Thread Fredrik Lundh
Dick Moores wrote:

> I've got a friend interested in trying out Python. I sent him to 
> http://www.python.org/download/linux/ but he's uncertain as to what to 
> download. He's rather get a new download than use what was on his Suse 
> disk. His box is an x86.
> 
> Any chance Python 2.4.3 compressed source tarball 
>  would be 
> suitable for him?

absolutely.  unpack, type "./configure", and then "make altinstall", and 
you're off (use "python2.4" to start the newly installed interpreter).

alternatively, and recommended, is to grab the latest build from SuSE's 
package repository.



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


Re: How ahead are you guys in the (Python) real world?

2006-08-31 Thread stdazi
Ray wrote:
> Since I haven't used Python at work, I am using Python 2.5 right now.
> However I wonder, how fast are you guys moving from version to version
> at work? As an illustration my ex-company just moved to Java 5, which
> was released around... what, 2-3 years ago? (While I am running Java 6
> at home)
>
> Is it the same in the Python world? What version of Python is used in,
> say, Google? Is it even 2.4 yet?

Heya, here at my job 2.3 is a must , but the code *should* be as
compatible as possible with 2.2 too.

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


wxNotebook color change

2006-08-31 Thread mardif
Hi !

this is my problem:

I've a wxNotebook object, which contains 2 Panels.
On up, there is TAB section, I have 2 tabs.
I want to color the TAB section with ( for example ) red color.

I've tried with SetBackgroundColour() for wxNotebook object and for 2
panel inside, but it doesn't works.
why??

thx in advance!

bye

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


Re: How to avoid a warning message box when sending email via Outlook

2006-08-31 Thread Giles Brown
Tim Golden wrote:

> [Dermot Doran]
>
> | I'm very new to using win32com!  I just want to send an email
> | message via Outlook.  However, I keep getting an annoying
> | message box (generated by Outlook) indicating that my program
> | could be a virus.  Does anybody know how to get around this?
>
> As far as I've ever been able to tell, you're stuck with it.
> Obviously, in a sense, since otherwise any would-be virus /
> zombie program would simply turn the option off before using
> Outlook to send out its emails!

Can't remember the details, but last time  I looked (a year ago) you
could avoid this if you changed a setting for the user at the exchange
server.  I found this out by doing a bit of googling and
can't remember what I did, but managed to solve the same problem.

Giles

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


Using eval with substitutions

2006-08-31 Thread abhishek
>>> a,b=3,4
>>> x="a+b"
>>> eval(x)
7
>>> y="x+a"

Now I want to evaluate y by substituting for the evaluated value of x.
eval(y) will try to add "a+b" to 3 and return an error. I could do
this,
>>> eval(y.replace("x",str(eval(x
10

but this becomes unwieldy if I have
>>> w="y*b"
and so on, because the replacements have to be done in exactly the
right order. Is there a better way?

Thanks,
Abhishek

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


Re: Using eval with substitutions

2006-08-31 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote:

 a,b=3,4
 x="a+b"
 eval(x)
> 7
 y="x+a"
> 
> Now I want to evaluate y by substituting for the evaluated value of x.
> eval(y) will try to add "a+b" to 3 and return an error. I could do
> this,
 eval(y.replace("x",str(eval(x
> 10
> 
> but this becomes unwieldy if I have
 w="y*b"
> and so on, because the replacements have to be done in exactly the
> right order. Is there a better way?

instead of

x = "a+b"

do

x = "a+b"
x = eval(x)


or

x = eval("a+b")

(I'm afraid I don't really understand the point of your examples; what 
is it you're really trying to do here ?)



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


Re: Broadcast server

2006-08-31 Thread Matt Hammond
On Thu, 31 Aug 2006 10:14:15 +0100, <[EMAIL PROTECTED]> wrote:

> I would like to write a server with the low level API of python (
> socket+select and/or socket+thread ) that allow me to register client
> and update them every X seconds ( could be the time, the temperature, a
> stock quote, a message , ... ).
>
> How to write the server that keep hot connections with clients and
> update them when events are trigerred. I don't know how to begin this ,
> i look at the python doc but the doc is more related to client updating
> the server and i am not sure of the right design that could be use
> here.

Kamaelia ( http://kamaelia.sf.net/ ) - the project I'm working on, feels  
like it may be well suited to this kind of task. Its based around having  
individual components that pass messages to each other. So you can  
envisage an event source propogating a message to all subscribed clients  
quite easily.

Your source's of events can be components, that publish their events to a  
'backplane' - a kind of distribution board that replicates messages sent  
to it to all subscribers.

 from Axon.Component import component
 from Kamaelia.Util.Backplane import Backplane, subscribeTo, publishTo
 from Kamaelia.Util.PipelineComponent import pipeline

 class EventSource(component):
 def main(self):
 while 1:
 if event_happens:
 self.send( "EVENT HAPPENED!\n", "outbox")
 yield 1

 pipeline( EventSource(),
   publishTo("Events"),
 ).activate()

 Backplane("Events").activate()

You can have any number of event sources, all 'publishing' to the same  
backplane.

Then to handle clients connecting I'd create a server component, with a  
factory function that creates a component to handle each client  
connection. In this case, a component that 'subscribes' to messages coming  
 from the backplane:

 from Kamaelia.Chassis.ConnectedServer import SimpleServer

 def clientHandlerFactory():
 return subscribeTo("Events")

 SimpleServer(clientHandlerFactory).activate()

Then I'd start the system running:

 from Axon.Scheduler import scheduler

 scheduler.run.runThreads()

Things like the client handling could be extended relatively easily to  
marshall complex data types to strings, suitable for network transmission;  
or to manage clients choosing what data sources to subscribe to.

If you think this approach might work for you, I'm happy to give you a  
hand with getting Kamaelia up and running, and with learning how to write  
your own components to make the system more sophisticated.

We hang about on #kamaelia on freenode (irc) - please do drop in for a  
chat!

Hope this helps!


Matt
-- 
| Matt Hammond
| Research Engineer, Tech. Group, BBC, Kingswood Warren, Tadworth, Surrey,  
UK
| http://kamaelia.sf.net/
| http://www.bbc.co.uk/rd/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Syntax suggestion.

2006-08-31 Thread Roberto Bonvallet
samir wrote:
> Being a fond of Python, I had this idea: Why not making Python a Unix
> shell?
[...]
> So, why not making the use of parentheses when a function is one lined
> optional to have commands like this:
[...]
> Then, why not making the comma optional too when executing such
> instructions:
[...]
> And finally, why not making the string parameter "-less when it is the
> only parameter:

...so finally you get something that is exactly like any Unix shell, and
completely different to Python.  If you want Python to look like bash, work
like bash and have bash-like syntax, you should really consider using bash :)

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


Re: Broadcast server

2006-08-31 Thread swell
Hi Matt ,
  It sounds very interesting and i will definitely take a deeper look
but i was more considering something simpler as a learning exercise
more that finding a package that should already do what i want to
achieve.
I want to find the basic guidelines to write that kind of client/server
architecture and make some tests of different solutions(socket+select
or socket+thread or mix of them)

Your project seems very great and will try to read in to learn.

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


Re: wxNotebook color change

2006-08-31 Thread Rob Wolfe

mardif wrote:
> Hi !
>
> this is my problem:
>
> I've a wxNotebook object, which contains 2 Panels.
> On up, there is TAB section, I have 2 tabs.
> I want to color the TAB section with ( for example ) red color.
>
> I've tried with SetBackgroundColour() for wxNotebook object and for 2
> panel inside, but it doesn't works.
> why??

Presumably you forgot to refresh window. Try this:


import wx

app = wx.PySimpleApp()

frame = wx.Frame(None, -1, "Notebook")
nb = wx.Notebook(frame, -1)
form1 = wx.Panel(nb, -1)
nb.AddPage(form1, "Form1")
form2 = wx.Panel(nb, -1)
form2.SetBackgroundColour(wx.RED)
nb.AddPage(form2, "Form2")
nb.SetSelection(1)
frame.Refresh()
frame.Show(True)

app.MainLoop()


HTH,
Rob

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


Re: Using eval with substitutions

2006-08-31 Thread abhishek
Fredrik Lundh wrote:
> (I'm afraid I don't really understand the point of your examples; what
> is it you're really trying to do here ?)

A function is passed a bunch of string expressions like,
x = "a+b"
y=  "x*a"
z= "x+y"

where a and b are assumed to have been assigned values in the local
namespace. Now I have to evaluate another string such as,
"z+y+x"

So as you say, I could do:
x=eval(x), y=eval(y), z=eval(z) and finally eval("z+y+x") but the
problem is that the initial strings are in no particular order, so I
don't know the sequence in which to perform the first 3 evaluations. I
was wondering if there was a simple way to 'pattern-match' so that the
required substitutions like z->x+y->x+x*a->(a+b)+(a+b)*a could be done
automatically.

I apologise if this is still not quite clear.

Abhishek

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


Re: wxNotebook color change

2006-08-31 Thread mardif
No no!!!
Your example is OK, great!
but is not my problem:

If you set:

frame.SetBackgroundColour(wx.RED)

On unix, you can see that label "form1" and "form2" are grey, and
others elements are red.
But on Windows, on the same line of "form1" and "form2", the color is
not red, but grey as labels.

I want to color this space RED!!!

Rob Wolfe wrote:
> mardif wrote:
> > Hi !
> >
> > this is my problem:
> >
> > I've a wxNotebook object, which contains 2 Panels.
> > On up, there is TAB section, I have 2 tabs.
> > I want to color the TAB section with ( for example ) red color.
> >
> > I've tried with SetBackgroundColour() for wxNotebook object and for 2
> > panel inside, but it doesn't works.
> > why??
>
> Presumably you forgot to refresh window. Try this:
>
> 
> import wx
>
> app = wx.PySimpleApp()
>
> frame = wx.Frame(None, -1, "Notebook")
> nb = wx.Notebook(frame, -1)
> form1 = wx.Panel(nb, -1)
> nb.AddPage(form1, "Form1")
> form2 = wx.Panel(nb, -1)
> form2.SetBackgroundColour(wx.RED)
> nb.AddPage(form2, "Form2")
> nb.SetSelection(1)
> frame.Refresh()
> frame.Show(True)
> 
> app.MainLoop()
> 
> 
> HTH,
> Rob

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


Re: [ANN] ratfun-2.3 Polynomials and Rational Functions

2006-08-31 Thread Ludovic Aubry
On Sat, Aug 19, 2006 at 11:33:19AM -0500, Raymond L. Buvel wrote:
> The ratfun module provides classes for defining polynomial and rational
> function (ratio of two polynomials) objects. These objects can be used
> in arithmetic expressions and evaluated at a particular point.
> 
> Home page:  http://calcrpnpy.sourceforge.net/ratfun.html
> 
> Note: If you are using rpncalc-1.2 or later, this module is already
> included.  This release is for folks who don't want rpncalc.
> 
> Changes in 2.3
> 
> * Update the included clnum package.
> 
> * Improved the formatting of the string representation of a polynomial.
> 
> * Polynomial and rational function evaluation now works with array inputs.

En ayant jeté un oeil rapidement je dirais que ça fait rien de plus que
le module de Konrad de scientific python

Sinon ce que fait llgeometry necessite de manipuler des polynomes à
plusieurs variables ce que ni l'un ni l'autre ne font.

enfin, presque car le module de Konrad permet de définir et d'évaluer
des polynômes à plusieurs variables.

> -- 
> http://mail.python.org/mailman/listinfo/python-announce-list
> 
> Support the Python Software Foundation:
> http://www.python.org/psf/donations.html
> 

-- 
Ludovic Aubry LOGILAB, Paris (France).
http://www.logilab.com   http://www.logilab.fr  http://www.logilab.org
-- 
http://mail.python.org/mailman/listinfo/python-list


Tkinter listbox question

2006-08-31 Thread vedran_dekovic
Hi,
I need help about Tkinter listbox widget.I want,when somebody click on
any item(file)  in Listbox,then in new Label widget text must be
selected item from server.

my program (wrong example):

import ftputil
import Tkinter
root=Tkinter.Tk()
ftp=ftputil.FTPHost('some imaginary server')

def LabelWidget(event):
a=Tkinter.Label(root,text=)  # Text must be only name and file
format,example: sun.gif
a.grid()



b=Tkinter.Listbox(root)
b.insert(Tkinter.END,ftp._dir(''))
b.place()
c=Tkinter.Button(root,text='PRINT THIS FILE IN NEW LABEL WIDGET')
c.bind('',LabelWidget)
c.grid()
root.mainloop()


THANKS!!!

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


Re: Using eval with substitutions

2006-08-31 Thread Peter Otten
[EMAIL PROTECTED] wrote:

> Fredrik Lundh wrote:
>> (I'm afraid I don't really understand the point of your examples; what
>> is it you're really trying to do here ?)
> 
> A function is passed a bunch of string expressions like,
> x = "a+b"
> y=  "x*a"
> z= "x+y"
> 
> where a and b are assumed to have been assigned values in the local
> namespace. Now I have to evaluate another string such as,
> "z+y+x"
> 
> So as you say, I could do:
> x=eval(x), y=eval(y), z=eval(z) and finally eval("z+y+x") but the
> problem is that the initial strings are in no particular order, so I
> don't know the sequence in which to perform the first 3 evaluations. I
> was wondering if there was a simple way to 'pattern-match' so that the
> required substitutions like z->x+y->x+x*a->(a+b)+(a+b)*a could be done
> automatically.

Here is something to start with:

class EvalDict(object):
def __init__(self, namespace):
self.namespace = namespace
def __getitem__(self, key):
value = self.namespace[key]
if isinstance(value, str):
self.namespace[key] = value = eval(value, {}, self)
return value

def smart_eval(expr, namespace):
return eval(expr, {}, EvalDict(namespace))

def f():
a = 2
b = 3
x = "a+b"
y = "x*a"
z = "x+y"

return smart_eval("x + y + z", locals())

if __name__ == "__main__":
print f()

Beware of infinite recursion:

# RuntimeError: maximum recursion depth exceeded
smart_eval("a + b", dict(a="b", b="a")) 

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


Re: a question about my script

2006-08-31 Thread alper soyler
Hi,I changed the script as you wrote below:from ftplib import FTP
def handleDownload(block):
    file.write(block)
    print ".", ftp = FTP('ftp.genome.jp')
 print ftp.login()
 directory = 'pub/kegg/genomes'ftp.cwd(directory)k=0for direct in ftp.nlst():    curdir = '%s/%s' % (directory, direct)    ftp.cwd(curdir)    for filename in ftp.nlst():        if not filename.endswith('.pep'): continue        file = open(filename, 'wb')        ftp.retrbinary('RETR %s/%s'
 % (curdir, filename), handleDownload)        file.close()    k=k+1    print ftp.close()However, it gave the same error message:230 Anonymous access granted, restrictions apply.Traceback (most recent call last):  File "ftp1.0.py", line 18, in ?    ftp.cwd(curdir)  File "/usr/lib/python2.4/ftplib.py", line 494, in cwd    return self.voidcmd(cmd)  File "/usr/lib/python2.4/ftplib.py", line 246, in voidcmd    return self.voidresp()  File "/usr/lib/python2.4/ftplib.py", line 221, in voidresp    resp = self.getresp()  File "/usr/lib/python2.4/ftplib.py", line 216, in getresp    raise error_perm, respftplib.error_perm: 550 pub/kegg/genomes/aae: No such file or directoryHowever, in ftp.genome.jp/pub/kegg/genomes/  site, there is
 'aae' directory. What can be the reason?regards,alper- Original Message From: Gabriel Genellina <[EMAIL PROTECTED]>To: alper soyler <[EMAIL PROTECTED]>Cc: Python-list@python.orgSent: Tuesday, August 29, 2006 10:26:57 AMSubject: Re: a question about my scriptAt Tuesday 29/8/2006 03:55, alper soyler wrote:>I am trying to get some files from an ftp site by ftplib module and >I wrote the below script. However I have a problem. With my script, >I login to ftp.genome.jp site. then, I am changing the directory to >pub/kegg/genomes/afm and I am downloading "a.fumigatus.pep" file. >However, what I want is to connect pub/kegg/genomes directory and in >this directory there are 3 letters name files3 letters *files*? or 3 letters *directories*?>e.g. 'afm' and in
 each of these 3 letters files there is a file with >the extension of '.pep' like a.fumigatus.pep. I want to get these >'.pep' files from the 3 letter named files. If you help me I will be >very glad. Thanks you in advance.Do a cwd() starting one level above (that is, pub/kegg/genomes); using ftp.dir() you can get the subdirectories, then iterate over all of them, using another dir() to find the .pep files needed.>directory = 'pub/kegg/genomes/ afm'Is that whitespace intentional?(If you just want to download the files and don't need really a Python script, try wget...)Gabriel GenellinaSoftlab SRL __Preguntá. Respondé. Descubrí.Todo lo que querías saber, y lo que ni imaginabas,está en Yahoo! Respuestas
 (Beta).¡Probalo ya! http://www.yahoo.com.ar/respuestas-- 
http://mail.python.org/mailman/listinfo/python-list

Re: a question about my script

2006-08-31 Thread Fredrik Lundh
"alper soyler" wrote:

> directory = 'pub/kegg/genomes'
> ftp.cwd(directory)

> ftplib.error_perm: 550 pub/kegg/genomes/aae: No such file or directory

> However, in ftp.genome.jp/pub/kegg/genomes/  site, there is 'aae' directory.
> What can be the reason?

try doing the cwd in pieces:

for d in directory.split("/"):
ftp.cwd(d)

 



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


Re: Using eval with substitutions

2006-08-31 Thread Duncan Booth
[EMAIL PROTECTED] wrote:

> So as you say, I could do:
> x=eval(x), y=eval(y), z=eval(z) and finally eval("z+y+x") but the
> problem is that the initial strings are in no particular order, so I
> don't know the sequence in which to perform the first 3 evaluations. I
> was wondering if there was a simple way to 'pattern-match' so that the
> required substitutions like z->x+y->x+x*a->(a+b)+(a+b)*a could be done
> automatically.
> 
Sounds a bit of an odd thing to do, but:

>>> def evaluate(var, names):
expr = names[var]
names['__builtins__'] = {}
if isinstance(expr, basestring):
del names[var]
code = compile(expr, "<%s>"%var, "eval")
for v in code.co_names:
evaluate(v, names)
names[var] = eval(code, names, names)
del names['__builtins__']
return names[var]

>>> names = { 'a': 3, 'b': 2, 'x': 'a+b', 'y': 'x*a', 'z': 'x+y' }
>>> evaluate('z', names)
20
>>> names
{'a': 3, 'b': 2, 'y': 15, 'x': 5, 'z': 20}
>>> 

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


Re: a question about my script

2006-08-31 Thread alper soyler
Hi,I changed the script as you wrote below:from ftplib import FTP
def handleDownload(block):
    file.write(block)
    print ".", ftp = FTP('ftp.genome.jp')
 print ftp.login()
 directory = 'pub/kegg/genomes'ftp.cwd(directory)k=0for direct in ftp.nlst():    curdir = '%s/%s' % (directory, direct)    ftp.cwd(curdir)    for filename in ftp.nlst():        if not filename.endswith('.pep'): continue        file = open(filename, 'wb')        ftp.retrbinary('RETR %s/%s'
 % (curdir, filename), handleDownload)        file.close()    k=k+1    print ftp.close()However, it gave the same error message:230 Anonymous access granted, restrictions apply.Traceback (most recent call last):  File "ftp1.0.py", line 18, in ?    ftp.cwd(curdir)  File "/usr/lib/python2.4/ftplib.py", line 494, in cwd    return self.voidcmd(cmd)  File "/usr/lib/python2.4/ftplib.py", line 246, in voidcmd    return self.voidresp()  File "/usr/lib/python2.4/ftplib.py", line 221, in voidresp    resp = self.getresp()  File "/usr/lib/python2.4/ftplib.py", line 216, in getresp    raise error_perm, respftplib.error_perm: 550 pub/kegg/genomes/aae: No such file or directoryHowever, in ftp.genome.jp/pub/kegg/genomes/  site, there is
 'aae' directory. What can be the reason?regards,alper- Original Message From: Gabriel Genellina <[EMAIL PROTECTED]>To: alper soyler <[EMAIL PROTECTED]>Cc: Python-list@python.orgSent: Tuesday, August 29, 2006 10:26:57 AMSubject: Re: a question about my scriptAt Tuesday 29/8/2006 03:55, alper soyler wrote:>I am trying to get some files from an ftp site by ftplib module and >I wrote the below script. However I have a problem. With my script, >I login to ftp.genome.jp site. then, I am changing the directory to >pub/kegg/genomes/afm and I am downloading "a.fumigatus.pep" file. >However, what I want is to connect pub/kegg/genomes directory and in >this directory there are 3 letters name files3 letters *files*? or 3 letters *directories*?>e.g. 'afm' and in
 each of these 3 letters files there is a file with >the extension of '.pep' like a.fumigatus.pep. I want to get these >'.pep' files from the 3 letter named files. If you help me I will be >very glad. Thanks you in advance.Do a cwd() starting one level above (that is, pub/kegg/genomes); using ftp.dir() you can get the subdirectories, then iterate over all of them, using another dir() to find the .pep files needed.>directory = 'pub/kegg/genomes/ afm'Is that whitespace intentional?(If you just want to download the files and don't need really a Python script, try wget...)Gabriel GenellinaSoftlab SRL __Preguntá. Respondé. Descubrí.Todo lo que querías saber, y lo que ni imaginabas,está en Yahoo! Respuestas
 (Beta).¡Probalo ya! http://www.yahoo.com.ar/respuestas-- 
http://mail.python.org/mailman/listinfo/python-list

simultaneous copy to multiple media

2006-08-31 Thread lannsjo
I need a program that simultaneously can copy a single file (1 GB) from
my pc to multiple USB-harddrives.

I have searched the internet and only found one program that does this
on
http://mastermind.com.pl/multicopy/

but this link doesnt work anymore somebody that can help me, is
there any other programs out there.

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


Re: Segmentation Fault

2006-08-31 Thread John Savage
"pycraze" <[EMAIL PROTECTED]> writes:
>I would like to ask a question. How do one handle the exception due to
>Segmentation fault due to Python ?  Our bit operations and arithmetic
>manipulations are written in C and to some of our testcases we
>experiance Segmentation fault from the python libraries.

You don't happen to be using the MSDOS executable do you? I find I get
a segmentation violation with the MSDOS version when I try to print
coloured text. I think I have narrowed it down further: to the situation
where coloured text extends to or beyond the edge of the screen--maybe
it's the text wrapping that causes the seg fault.
-- 
John Savage   (my news address is not valid for email)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Coding style and else statements

2006-08-31 Thread Ben Finney
Pete Forman <[EMAIL PROTECTED]> writes:

> Ben Finney <[EMAIL PROTECTED]> writes:
>
> > Why not ensure that there is one return point from the function,
> > so the reader doesn't have to remind themselves to look for hidden
> > return points?
>
> There will always be more potential return points in languages that
> support exceptions.

I was specifically referring to 'return' points, i.e. points in the
function where a 'return' statement appears.

In the example to which I responded, the function had multiple
'return' statements, and an 'assert' to aid in finding out when none
of the return statements was hit. I'm making the point that if that
effort is being taken anyway, it's more readable to allow the reader
to see only *one* explicit return at the end, and not write any more
in the first place.

-- 
 \ "Ours is a world where people don't know what they want and are |
  `\willing to go through hell to get it."  -- Donald Robert Perry |
_o__)  Marquis |
Ben Finney

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


Re: wxNotebook color change

2006-08-31 Thread Rob Wolfe

mardif wrote:

> If you set:
>
> frame.SetBackgroundColour(wx.RED)
>
> On unix, you can see that label "form1" and "form2" are grey, and
> others elements are red.
> But on Windows, on the same line of "form1" and "form2", the color is
> not red, but grey as labels.
>
> I want to color this space RED!!!

Oh, I see now. I don't know if that is possible on windows.
SetBackgroundColour works differently on windows than on unix,
so probably native windows widget doesn't support this feature.
(but I can be wrong of course.)

Regards,
Rob

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


Problem when try to run a Python embedding documentation example

2006-08-31 Thread baitelli
Hi

where's "python24.lib" ?

I'm trying to test the example given at Python documentation:
5.1 Very High Level Embedding
I'm using Microsoft Visual C++ 6.0 and got the error:
LINK : fatal error LNK1104: cannot open file "python24.lib"
baitelli,r.
 _
 AVISO
   Esta mensagem é destinada exclusivamente a(s) pessoa(s) indicada(s)
   como destinatário(s), podendo conter informações confidenciais,
   protegidas por lei.
   A transmissão incorreta da mensagem não acarreta a perda de sua
   confidencialidade.
   Caso esta mensagem tenha sido recebida por engano, solicitamos que
   seja devolvida ao remetente e apagada imediatamente de seu sistema. É
   vedado a qualquer pessoa que não seja destinatário, usar, revelar,
   distribuir ou copiar ainda que parcialmente esta mensagem.
 _
 DISCLAIMER
   This message is destined exclusively to the intended receiver. It may
   contain confidential or legally protected information.
   The incorrect transmission of this message does not mean loss of its
   confidentiality.
   If this message is received by mistake, please send it back to the
   sender and delete it from your system immediately. It is forbidden to
   any person who is not the intended receiver to use, reveal,
   distribute, or copy any part of this message.
 _
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Problem when try to run a Python embedding documentation example

2006-08-31 Thread Fredrik Lundh
"baitelli" wrote:

> where's "python24.lib" ?

if you're using a standard python.org install, it's under

c:\python24\libs\python24.lib

 



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


Re: How to avoid a warning message box when sending email via Outlook

2006-08-31 Thread Dermot Doran
Hi Giles,
 
Yep, the admin can override this.  I've been doing some of my own hunting around and it would appear that you can:
- Resolve this if you have admin rights.
- Use Outlook Redemption http://www.dimastr.com/redemption/
- Use Extended MAPI
- Install ClickYes http://www.contextmagic.com/
- Have the Enterprise migrate to Linux!  Yes!!
 
Thanks for responding!
 
Cheers!!
 
Dermot.
 
P.S.
 
Apologies for top posting (doing this quickly via GMail)!  
On 31 Aug 2006 03:51:08 -0700, Giles Brown <[EMAIL PROTECTED]> wrote:
Tim Golden wrote:> [Dermot Doran]>> | I'm very new to using win32com!  I just want to send an email
> | message via Outlook.  However, I keep getting an annoying> | message box (generated by Outlook) indicating that my program> | could be a virus.  Does anybody know how to get around this?>
> As far as I've ever been able to tell, you're stuck with it.> Obviously, in a sense, since otherwise any would-be virus /> zombie program would simply turn the option off before using> Outlook to send out its emails!
Can't remember the details, but last time  I looked (a year ago) youcould avoid this if you changed a setting for the user at the exchangeserver.  I found this out by doing a bit of googling andcan't remember what I did, but managed to solve the same problem.
Giles--http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Python-list Digest, Vol 35, Issue 501

2006-08-31 Thread alper soyler
Trying to split the directories gave me the same error message with the previous one?Alper- Original Message From: [EMAIL PROTECTED]To: python-list@python.orgSent: Thursday, August 31, 2006 4:40:03 PMSubject: Python-list Digest, Vol 35, Issue 501Send Python-list mailing list submissions topython-list@python.orgTo subscribe or unsubscribe via the World Wide Web, visithttp://mail.python.org/mailman/listinfo/python-listor, via email, send a message
 with subject or body 'help' to[EMAIL PROTECTED]You can reach the person managing the list at[EMAIL PROTECTED]When replying, please edit your Subject line so it is more specificthan "Re: Contents of Python-list digest..."Today's Topics:   1. Tkinter listbox question ([EMAIL PROTECTED])   2. Re: Using eval with substitutions (Peter Otten)   3. Re: a question about my script (alper soyler)   4. Re: a question about my script (Fredrik Lundh)   5. Re: Using eval with substitutions (Duncan Booth)   6. Re: a question about my script (alper soyler)   7. simultaneous copy to multiple media ([EMAIL PROTECTED])From: [EMAIL PROTECTED]Precedence: listMIME-Version: 1.0To: python-list@python.orgDate: 31 Aug 2006 05:41:43
 -0700Message-ID: <[EMAIL PROTECTED]>Content-Type: text/plain; charset="iso-8859-1"Subject: Tkinter listbox questionMessage: 1Hi,I need help about Tkinter listbox widget.I want,when somebody click onany item(file)  in Listbox,then in new Label widget text must beselected item from server.my program (wrong example):import ftputilimport Tkinterroot=Tkinter.Tk()ftp=ftputil.FTPHost('some imaginary server')def LabelWidget(event):a=Tkinter.Label(root,text=)  # Text must be only name and fileformat,example: sun.gifa.grid()b=Tkinter.Listbox(root)b.insert(Tkinter.END,ftp._dir(''))b.place()c=Tkinter.Button(root,text='PRINT THIS FILE IN NEW LABEL
 WIDGET')c.bind('',LabelWidget)c.grid()root.mainloop()THANKS!!!Content-Transfer-Encoding: 7BitFrom: Peter Otten <[EMAIL PROTECTED]>Precedence: listMIME-Version: 1.0To: python-list@python.orgReferences: <[EMAIL PROTECTED]><[EMAIL PROTECTED]><[EMAIL PROTECTED]>Date: Thu, 31 Aug 2006 14:54:50 +0200Message-ID: <[EMAIL PROTECTED]>Content-Type: text/plain; charset=us-asciiSubject: Re: Using eval with substitutionsMessage: 2[EMAIL PROTECTED] wrote:> Fredrik Lundh wrote:>> (I'm afraid I don't really understand the point of your examples; what>> is it you're
 really trying to do here ?)> > A function is passed a bunch of string expressions like,> x = "a+b"> y=  "x*a"> z= "x+y"> > where a and b are assumed to have been assigned values in the local> namespace. Now I have to evaluate another string such as,> "z+y+x"> > So as you say, I could do:> x=eval(x), y=eval(y), z=eval(z) and finally eval("z+y+x") but the> problem is that the initial strings are in no particular order, so I> don't know the sequence in which to perform the first 3 evaluations. I> was wondering if there was a simple way to 'pattern-match' so that the> required substitutions like z->x+y->x+x*a->(a+b)+(a+b)*a could be done> automatically.Here is something to start with:class EvalDict(object):def __init__(self,
 namespace):self.namespace = namespacedef __getitem__(self, key):value = self.namespace[key]if isinstance(value, str):self.namespace[key] = value = eval(value, {}, self)return valuedef smart_eval(expr, namespace):return eval(expr, {}, EvalDict(namespace))def f():a = 2b = 3x = "a+b"y = "x*a"z = "x+y"return smart_eval("x + y + z", locals())if __name__ == "__main__":print f()Beware of infinite recursion:#
 RuntimeError: maximum recursion depth exceededsmart_eval("a + b", dict(a="b", b="a")) PeterFrom: alper soyler <[EMAIL PROTECTED]>Precedence: listMIME-Version: 1.0To: Python-list@python.orgIn-Reply-To: <[EMAIL PROTECTED]>Date: Thu, 31 Aug 2006 06:01:09 -0700 (PDT)Reply-To: alper soyler <[EMAIL PROTECTED]>Message-ID: <[EMAIL PROTECTED]>Content-Type: multipart/alternative; boundary="0-620705374-1157029269=:50849"Subject: Re: a question about my scriptMessage: 3Hi,I changed the script as you wrote below:from ftplib import FTP
def handleDownload(block):
    file.write(block)
    print ".", ftp = FTP('ftp.genome.jp')
 print ftp.login()
 directory = 'pub/kegg/genomes'ftp.cwd(directory)k=0for direct in ftp.nlst():    curdir = '%s/%s' % (directory, direct)    ftp.cwd(curdir)    for filename in ftp.nlst():        if not filename.endswith('.pep'): continue        file = open(filename, 'wb')        ftp.retrbinary('RETR %s/%s'
 % (curdir, filename), handleDownload)        file.close()    k=k+1    print ftp.close()However, it gave the same error message:230 Anonymous access granted, restrictions apply.Traceback (most recent call last):  File "ftp1.0.py", line 18, in ?    ftp.cwd(curdir)  File "/usr/lib/python2.4/ftplib.py", line 494, in cwd    return self.voidcmd(cmd)  File "/usr/lib/python2.4/ftpl

Re: How to avoid a warning message box when sending email via Outlook

2006-08-31 Thread Dermot Doran
Thanks Tim!
 
We have smtp bolted to the floor :-( 
On 31/08/06, Tim Golden <[EMAIL PROTECTED]> wrote:
[Dermot Doran]| looks like I might be back to the drawing board :-(  Thanks| for letting me know what your experiences have been.
Just to elaborate slightly on that experience, if all I wantto do is to send an email (ie not look up addresses on Contactsor do any fancy Outlook-related thing) then I just use an SMTPserver. Here at work the admins have Exchange set up as an
SMTP server, which may or may not be the case for you. At homeor from websites etc. I simply use whichever SMTP server I'dnormally send mail through.Obviously this won't do anything like keeping a copy in your
Sent Mail box etc. but it will at least work, and with a bitmore effort you may be able to do things like that manually.TJGBTW, people in this group will tend to frown on top-posting,even though we Outlook users have to work around Outlook's
tendency to offer it a [Reply] ;)This e-mail has been scanned for all viruses by Star. Theservice is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:http://www.star.net.uk--
http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Pros/Cons of Turbogears/Rails?

2006-08-31 Thread Jaroslaw Zabiello
[EMAIL PROTECTED] wrote:

> + SqlObject allows working with the DB tables without
> using SQL itself.

Rails has ActiveRecord ORM, which IMO has nicer and simpler
syntax than SQLObject. Rails has migrations, TB - not (Migrations is
versioning system for evolving database schema)

> + Likely to be faster because as far as I'm aware, Python
> is significantly faster.

Python is maybe faster, but with YARM (which is not stable yet) Ruby
will be about 10x faster. YARM is full virtual machine like Java.

> + Easy access to other libraries (such as the Python
> Imaging Library) that Ruby, being a relatively newer
> language, doesn't have equivalents to.

Ruby is not so young you think. It became more popular
when Rails has appeared.

> + Built-in default SQLite makes it easier to set up?

What? :) YAML is much easier.

> (as far as I can tell, Ruby requires MySql by default--don't
> know how easy this is to change.)

Change in config/database.yml driver: mysql to any you want,
like db2, postgres, sqlserver, sqlite, firebird, oracle etc. You can
change
default settings as well. See:  rails --help

> + I find the templating system somewhat cleaner; code in
> py: xml namespace allows pure .html templates, instead
> of equivalent of .rhtml files.

But rhtml is much more flexible because it can generate *any content*,
not only xml. But Rails has THREE template systems: rhtml (main), rxml
(for rss and xml generation) and rjs (for javascript and AJAX).

And last but not least, TG is based on poor, unstable and buggy
CherryPy server. We had huge problems with CherryPy. I think that
Django or Pylons are much better frameworks. IMO TG is no competition
for Rails at all. The only real competition is Django or Pylons.

-- 
Jaroslaw Zabiello
http://blog.zabiello.com

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


Re: Large LCD/Plasma TV Output

2006-08-31 Thread [EMAIL PROTECTED]
> If you want to try some fancy effects (alpha blending, 3D transitions),
> have a look at  PyOpenGL, or another OpenGL based library. There are
> lots of links on pygame.org.

I'm not looking for anything fancy. I guess my main concern is that
I've never really done any programming for fancy televisions and I was
a bit worry about resolutions, refresh rates, etc.

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


Re: How ahead are you guys in the (Python) real world?

2006-08-31 Thread skip

Jack> I came away from the thread with the opposite conclusion for
Jack> similar reasons.  People would use a 2.3.6 if their OS upgraded it
Jack> for them but those are the same people who won't upgrade to 2.4.x
Jack> because it involves testing.  2.3.5 isn't broken for them or they
Jack> would know it by now.  2.3.6 probably isn't broken for them but it
Jack> can't help -- or they would have noticed a bug by now.

In contrast, I generally do only a small amount of testing when a micro
release of Python comes out before inflicting it on our users and
developers, precisely because I have confidence that it only contains bug
fixes.  Since probably 2.2.1 there have been no new features in any micro
releases that I can recall and, up to this point at least, no regressions in
my experience.  Micro updates seem like a pretty safe bet to me.

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


Re: Any relational database design tool written in Python

2006-08-31 Thread skip

metaperl> I am hoping for something that can create database deltas.  

What is a database delta?  I know about SELECT, CREATE, INSERT, UPDATE,
joins, normalization, etc, but have never heard this term before.

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


Re: simultaneous copy to multiple media

2006-08-31 Thread Tim Chase
> I need a program that simultaneously can copy a single file (1
> GB) from my pc to multiple USB-harddrives.

Sounds like a pretty simple simple python script:
---
#!/bin/env python
def spew(source_file_name,
output_file_names,
block_size = 8*1024):
source = file(source_file_name, "rb")
output_files = [file(s, "wb") for s in output_file_names]
s = source.read(block_size)
while s:
for outfile in output_files:
outfile.write(s)
s = source.read(block_size)

for outfile in output_files:
outfile.close()
source.close()

if __name__ == '__main__':
from sys import argv
if len(argv) > 2:
spew(argv[1], argv[2:])
else: #print some usage/help
print "%s source_file dest_file1 [dest_file2 [dest_file3 
[...]]]" % argv[0]
---

Just call it with

bash> cd /mnt
bash> python spew.py file1.txt usb1/file1.txt usb2/file2.txt

for as many destinations as you want.  Adjust the blocksize as 
you see fit:

spew(argv[1], argv[2:], 1024*1024)

or whatever your favorite blocksize is.

It's not terribly graceful about error-checking, or prompting if 
any of the files exist previously, or if it can't write to any of 
the output files because for any reason (full disk, 
write-protected disk, destination path doesn't exist, etc). 
Thus, if there's a problem, you'll get a pretty backtrace that 
will allow you to solve all your problems ;)

-tkc





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


Re: all ip addresses of machines in the local network

2006-08-31 Thread Gabriel Genellina

At Wednesday 30/8/2006 21:54, damacy wrote:


in my program so far, multiple threads (255 threads in total) spawned
at once with each one of them trying to call socket.gethostbyaddr(ip)
function. i.e. if exception thrown, no machine found. i used .join() to
wait for the threads to terminate. it's fully working however the
problem is that it's too slow. it takes approx. 14 seconds to process
(i tried using 'ping' but it's even slower.).


Do you have control over the server program?
Use UPD to broadcast a message, and make the server answer on that.
Or google for ZeroConf, UPnP or other techniques used for service discovery.



Gabriel Genellina
Softlab SRL 






__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas


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

Re: Pros/Cons of Turbogears/Rails?

2006-08-31 Thread Jorge Godoy
"Jaroslaw Zabiello" <[EMAIL PROTECTED]> writes:

> [EMAIL PROTECTED] wrote:
>
>> + SqlObject allows working with the DB tables without
>> using SQL itself.
>
> Rails has ActiveRecord ORM, which IMO has nicer and simpler
> syntax than SQLObject. Rails has migrations, TB - not (Migrations is
> versioning system for evolving database schema)

TG supports SQL Alchemy as well.  With SQL Alchemy I believe you'll have a
better experience than with Rails' ORM.

With regards to Migrations, SQL Object does support something like that, but
you have to explicitly code it and then you can run sqlobject-admin upgrade
(or the equivalente tg-admin sql upgrade, since it is a wrapper...).

> But rhtml is much more flexible because it can generate *any content*,
> not only xml. But Rails has THREE template systems: rhtml (main), rxml
> (for rss and xml generation) and rjs (for javascript and AJAX).

Well, TG has a few templating systems...  MarkUp, Kid, Cheetah, ZPT, and
others.  You can choose the one that best fits your needs / brain.  You can
even have multiple template systems used depending on what was requested for
the same controller... 


Which one is better isn't of my concern.  I've already tested then and decided
what I want to use.  The best thing is try them and see what works.  You don't
have to choose only one -- but you have to use one per project to make it less
messy ;-)

-- 
Jorge Godoy  <[EMAIL PROTECTED]>
-- 
http://mail.python.org/mailman/listinfo/python-list


Timeline for Python?

2006-08-31 Thread Sebastian Bassi
Hello all,

I am working on a Python book, since it could be completed in about a
year (writing time + edition + publishing) or more, I would like to
know what version to target since I don't want to release a book that
will be outdated just after is printed.
I use 2.4 for everyday work but most webservers still carry 2.2 (and
most programs runs w/o any modification, since I don't tend to use new
features), but publishers know that people like to buy lasted version
books.
So, if the book is published in October 2007, should feature Python 3
or Python 2.5?
I did read http://www.python.org/dev/peps/pep-3000/ but I still not
sure about timeline.

Best regards,
SB.

-- 
Bioinformatics news: http://www.bioinformatica.info
Lriser: http://www.linspire.com/lraiser_success.php?serial=318
-- 
http://mail.python.org/mailman/listinfo/python-list


genetic algorithms package for python ?

2006-08-31 Thread Xiao Jianfeng
Hi all,

I am looking for a genetic algorithms package for Python.

I have googled the web before posting and found some links. The link of  
pygene(http://www.freenet.org.nz/python/pygene) cannot be opened.

I also tried the recipe on ASPN, but it is too simple for my 
application, and the ga model in SciPy, which is in testing in the 
"sandbox".

Are there any more genetic algorithms packages for Python ?

Thanks a lot!

xiaojf

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


Re: genetic algorithms package for python ?

2006-08-31 Thread Gary Herron
Xiao Jianfeng wrote:
> Hi all,
>
> I am looking for a genetic algorithms package for Python.
>
> I have googled the web before posting and found some links. The link of  
> pygene(http://www.freenet.org.nz/python/pygene) cannot be opened.
>
> I also tried the recipe on ASPN, but it is too simple for my 
> application, and the ga model in SciPy, which is in testing in the 
> "sandbox".
>
> Are there any more genetic algorithms packages for Python ?
>
> Thanks a lot!
>
> xiaojf
>
>   
Here's pointers to one in Lisp and another in Python. I know *nothing* 
about either one.

http://packages.debian.org/unstable/devel/cl-rsm-genetic-alg.html

http://home.gna.org/oomadness/en/genetic/

Enjoy,
Gary Herron



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


Re: a question about my script

2006-08-31 Thread Gabriel G

At Thursday 31/8/2006 10:01, alper soyler wrote:


I changed the script as you wrote below:


directory = 'pub/kegg/genomes'


Sorry, in the original comment I said "change it to be an absolute 
path" but didn't write it well.

This line should read:
directory = '/pub/kegg/genomes'



Gabriel Genellina
Softlab SRL 






__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas


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

Re: Any relational database design tool written in Python

2006-08-31 Thread Tim Chase
> metaperl> I am hoping for something that can create database deltas.  
> 
> What is a database delta?  I know about SELECT, CREATE, INSERT, UPDATE,
> joins, normalization, etc, but have never heard this term before.

There are two types of database deltas that I know of:  metadata 
deltas (changes to the structure of the database such as altering 
columns in tables, adding/removing tables, altering views/SPs, 
changing access-controls, etc) and data deltas (differences in 
data when the structures are the same).

A metadata some sort of "diff" between two copies of a database 
(say, your "production" and "development" databases), allowing 
you to bring your production database up to the point where your 
development database is.  A data-diff would be about the same as 
an incremental backup, allowing you copy new data from one 
database to another database with stale/older data on it.

I've written a couple simple database diffing scripts to synch 
production database to look like the development database 
snapshot.  None were complete scripts to synch everything, but 
just handled what I needed at the time (usually just altered or 
added tables/queries).

-tkc




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


Re: Timeline for Python?

2006-08-31 Thread Ben Sizer
Sebastian Bassi wrote:
> So, if the book is published in October 2007, should feature Python 3
> or Python 2.5?
> I did read http://www.python.org/dev/peps/pep-3000/ but I still not
> sure about timeline.

I get the impression that Python 3 will not be around Any Time Soon and
certainly not in just 12 or 13 months. The PEP does suggest that it
isn't likely to be around any time before  2008 at the earliest.

-- 
Ben Sizer

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


Re: How to avoid a warning message box when sending email via Outlook

2006-08-31 Thread Grant Edwards
On 2006-08-31, Tim Golden <[EMAIL PROTECTED]> wrote:
> [Dermot Doran]
>
>| I'm very new to using win32com!  I just want to send an email 
>| message via Outlook.  However, I keep getting an annoying 
>| message box (generated by Outlook) indicating that my program 
>| could be a virus.  Does anybody know how to get around this?  
>
> As far as I've ever been able to tell, you're stuck with it.

There is a DLL you can use to call Outlook to avoid that.

  http://www.dimastr.com/redemption/

It wraps the Outlook COM objects and accesses them in a way
that doesn't trigger the warning.  [The security BS is bypassed
if you call DLL entries directly from C/C++ instead of via the
COM interface.]

> Obviously, in a sense, since otherwise any would-be virus /
> zombie program would simply turn the option off before using
> Outlook to send out its emails!

Like most of Microsoft's "security" features, it provides zero
real protection and a lot of real annoyance.  Anybody who
really wants to can bypass it.  

"Where do you want to be frustrated today?"

-- 
Grant Edwards   grante Yow!  Today, THREE WINOS
  at   from DETROIT sold me a
   visi.comframed photo of TAB HUNTER
   before his MAKEOVER!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: GC and security

2006-08-31 Thread Les Schaffer
Paul Rubin wrote:

> GC simply releases the memory for other uses in the application.  It
> doesn't necessarily zero the memory.  


release is followed by some probability of eventual overwrite; check.

> 
> Just what attack are you trying to protect against, if swap space is
> less of a problem than leaving keys around in ram?

keys are on a USB drive key ring. gpg accesses the key ring as needed,
but in a separate process. and gpg is done with its work early on in our
app lifetime. comes back at end to encrypt and then app is done.


> Keep in mind that the weakest part of this application is likely to be
> the passphrase itself.  Is there a way to get rid of it?

we got some suggestions from other parts of this thread. or do you mean
getting rid of the need for a passphrase? the passhprase protects the
private key on the USB drive.

> Is this data on a laptop?  Why do you want to do encryption in the
> application, instead of using an encrypted file system?  

i looked at EFS and TrueCrypt.

There was some questions (from MySQL pro) about how MySQL writes would
interact with EFS. also, EFS seems to store key pairs on disk, and the
passphrase was limited to the Windows user login password.

i remember looking at TrueCrypt and deciding against it. couldn't see
how to interact with it via python script. vaguely recall being
dissatisfied with keys and passphrase.

but the main reason? we were asked to encrypt the MySQL tables carrying
sensitive information.


> Is there some
> obstacle to using a token (like a smart card) to hold the key?

USB drive holds the GPG key. the drive must be inserted at start of
application, and must be pulled after authentication otherwise the app
warns and shuts down. The USB drive carries a digital signature, and
also encrypted identifying information for the user.

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


Re: Pros/Cons of Turbogears/Rails?

2006-08-31 Thread Adam Jones

Jaroslaw Zabiello wrote:
> [EMAIL PROTECTED] wrote:
>
> > + SqlObject allows working with the DB tables without
> > using SQL itself.
>
> Rails has ActiveRecord ORM, which IMO has nicer and simpler
> syntax than SQLObject. Rails has migrations, TB - not (Migrations is
> versioning system for evolving database schema)

I don't really see TG sticking with SQLObject. In moving to SQLAlchemy
it would pick up not only a migration system but also a much more
flexible abstraction system due to the use of a Data Mapper pattern
instead of the Active Record pattern. There already is an
implementation of Active Record on top of that, so that benefit stays
as well.

>
> > + Likely to be faster because as far as I'm aware, Python
> > is significantly faster.
>
> Python is maybe faster, but with YARM (which is not stable yet) Ruby
> will be about 10x faster. YARM is full virtual machine like Java.

I tried to check out information on this, but the only docs I found
that looked like what I wanted were written in japanese. Do you have
any links discussing the status of this project? Does it make any
breaking changes to the Ruby implementation that will have to be fixed?
Has the RoR project already agreed to port to this when it is stable?

>
> > + Easy access to other libraries (such as the Python
> > Imaging Library) that Ruby, being a relatively newer
> > language, doesn't have equivalents to.
>
> Ruby is not so young you think. It became more popular
> when Rails has appeared.

Although that is true there are not as many libraries available for
Ruby as there are for Python. This will probably change as the language
gains popularity, but for right now it pays to look into library
support before considering anything else about the language.

>
> > + I find the templating system somewhat cleaner; code in
> > py: xml namespace allows pure .html templates, instead
> > of equivalent of .rhtml files.
>
> But rhtml is much more flexible because it can generate *any content*,
> not only xml. But Rails has THREE template systems: rhtml (main), rxml
> (for rss and xml generation) and rjs (for javascript and AJAX).

Kid can be used to generate xhtml, rss, xml, pretty much anything that
is xml-based. I have even seen it used to generate xul applications for
firefox. The only thing on your list that it doesn't do is javascript.
Personally I would rather learn one templating language that is able to
treat all of my xml as xml no matter what use it is put to.

>
> And last but not least, TG is based on poor, unstable and buggy
> CherryPy server. We had huge problems with CherryPy. I think that
> Django or Pylons are much better frameworks. IMO TG is no competition
> for Rails at all. The only real competition is Django or Pylons.

I have never had much in the way of problems with CherryPy. From what I
have heard the project has made a lot of improvements recently, so it
may have changed since you last took a look at it.

Actually that point right there is where I think TG is a lot more
competitive that you believe. When a new version of any of the
foundation projects comes out, or a better project to fill that
particular need, TG can absorb it in the next version. The TurboGears
developers can spend most of their time working on additional code that
makes the project more useful instead of bug fixes and minor feature
upgrades to the core components. This philosophy is proven to work for
most other open source projects, and I have yet to hear a good argument
why it would not be successful for a web framework.

-Adam

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


Re: Pros/Cons of Turbogears/Rails?

2006-08-31 Thread Christophe
Jaroslaw Zabiello a écrit :
> Python is maybe faster, but with YARM (which is not stable yet) Ruby
> will be about 10x faster. YARM is full virtual machine like Java.

Google doesn't find YARM and so, YARM does not exist. Care to provide an 
URL or something?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pros/Cons of Turbogears/Rails?

2006-08-31 Thread fuzzylollipop

Paul Boddie wrote:
> > fuzzylollipop wrote:
> > > uh, no, Python predates Ruby by a good bit
> > > Rails might be "older" than Turbogears but it still JUST went 1.0
> > > officially.
> > > It can't be called "mature' by any defintition.
>
> Version numbers are a fairly useless general metric of project
> maturity, taken in isolation.
>

But 1.0 releases do mean something, it means the DEVELOPER of the
package things it is just now ready for general consumption. That means
something regardless of what the number is.
Matter of fact, all major version releaese mean that, it is generally
understood thing. x.0 means this is now ready for non-beta general use.

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


Re: GC and security

2006-08-31 Thread Les Schaffer
Tim Peters wrote:

> Purely accidental -- nothing guaranteed -- details can (& do) change
> across releases.  Read obmalloc.c for a tour of the accidents du jour.

cool. thanks for the pointer!


> Not true, so be glad to forget it.

forget what???  ;-)


> A curious possibility:  if you do a debug build of Python, obmalloc.c
> arranges to overwrite all of an object's memory as soon as the object
> is reclaimed (by any means, refcounting or otherwise).  That wasn't
> for "security" (faux or otherwise), it's to make it easier to detect
> buggy C code referencing freed memory.

i liked the other Tim's suggestion of a secure string ;-)

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


Re: GC and security

2006-08-31 Thread Les Schaffer
Fredrik Lundh wrote:
> Fredrik Lundh wrote:
> 
>> a time (if that's possible; if not, you may need to write a custom
>> extension that builds a command string in a C-level buffer, runs the
>> command, and then overwrites the buffer before returning).

myself, i enjoy building C extensions, but would rather skip it for this
app.

> 
> on the other hand, subprocess seems to support the buffer interface, so
> the following slightly convoluted approach could be used instead of such
> an extension:
> 
 cmd = [101, 99, 104, 111, 32, 39, 104, 101, 108, 108, 111, 39]
 cmd = array.array("b", cmd) # build mutable buffer
 subprocess.call([buffer(cmd)], shell=True)
> 'hello'
 for i in range(len(cmd)): cmd[i] = 0 # nuke it

i'll see if we can fit this into our subprocess scheme. if so, this is
good enough for now. think we'll use this for the mysql password too.


> the secret text will be visible in memory during the subprocess call,
> but it won't linger around once the for-loop has finished.

good enough for current rock and roll.


> (don't forget to put a try/finally clause around the critical part)

okey doky.

Les Schaffer

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


Searching a string and extract all occurancies of a substring

2006-08-31 Thread Nico Grubert
Hi there,

in a text with no carriage returns I need to look for all occurancies of 
this string:

...

The ... can contain different values. I need to extract the string 
between  and .

Example text:
This is a test.  A test. 
/www/mydoc1 
And I need to extraxt /www/mydoc1 and /www/mydoc2 from this text.
/foo/bar/doc

 From this text I need to get a list with this:
  ["/www/mydoc1", "/foo/bar/doc"]

What's the best way to do this?


I'll need to use Python: 2.3.5

Thanks in advance,
Nico

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


Basic import Questions (with bonus profiling question)

2006-08-31 Thread Gregory Piñero
Hey Folks,

Some import questions that a search didn't turn up for me.

1. Will "from somemodule import onething" take as long to start up as
import somemodule?
2. Is there anyway I can get at onething more quickly?
3. If I put an import statement hidden away in some function, will
Python only do the import when that function is called?  If I say,
never use that function would that import statement affect performance
at all?

Ultimately I have IIS running python as a CGI script and it seems to
just be taking many seconds to load a small page.  I'm guessing the
issue is starting up the interpreter and loading all the modules.

BTW I know it would be better to profile the code but how do you
profile a CGI script?  I can't just pass it CGI parameters can I?  And
does profiling take into account the time of loading modules?

Thanks,

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


Re: Pros/Cons of Turbogears/Rails?

2006-08-31 Thread Lawrence Oluyede
Christophe <[EMAIL PROTECTED]> wrote:

> Google doesn't find YARM and so, YARM does not exist. Care to provide an
> URL or something?

it's YARV - http://www.atdot.net/yarv/

-- 
Lawrence - http://www.oluyede.org/blog
"Nothing is more dangerous than an idea
if it's the only one you have" - E. A. Chartier
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: sys.argv[0] doesn't always contain the full path of running script.

2006-08-31 Thread Joel Hedlund
 >> How can I find where exactly the current python script is running?
 >
> Doesnt __file__ attribute of each module contain the full filepath of
> the module?
 >

Yes indeed! But the path to the module will not be the same as the path to 
the script if you are currently in an imported module. Consider this:

my_script.py:
---
import my_module

---

my_module.py:
---
print __file__

---

Running "python test.py" now prints /path/to/my_module.py, not 
/path/to/my_script.py.

Cheers!
/Joel Hedlund
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Duck typing alows true polymorfisim

2006-08-31 Thread Tor Iver Wilhelmsen
The Ghost In The Machine <[EMAIL PROTECTED]> writes:

> Also, one language is very conspicuous by its absence: C#.

He does not date any of the updates, so it's unclear how recently it
has been updated (a lot of the web is stale, like a rotting tree in a
forest.)

> AmigaBasic -- Microsoft-sponsored Amiga variant

Well, at the time Microsoft were the makers of the de-facto BASIC
implementations - M-BASIC for CP/M, the various variants in VC-20 and
C-64 and later derivates of those, and many other home computers.
"Sponsored" should probably be "created" instead - I assume they were
paid for the job.

> Also, Java now has templates. (The implementation is pretty gross
> and has some quirks, IMO, but it's better than nothing.) C++ has a
> typing system ("type_of" or some such; I'd have to look) which
> yields little more than the mangled type name and static inheritance
> testing capabilities. Of course C++ doesn't have dynamic inheritance
> anyway.

There's the virtual stuff, and you could conceivably implement dynamic
inheritance via the bare-bones C layer - like function pointers. The
type information in C++ (RTTI) is optional.

> Dynamic type creation. I don't know if Java has this or not. One can
> of course attempt bytecode synthesis -- I think that's what BCEL
> uses -- but that's a bit of a hack.

Groovy could possibly be used for that; also IIRC Java 6 adds some
features for that. I seem to recall security implications being one
reason this ability wasn't included from the start.

> Dynamic method creation. Java does *not* have this. AIUI
> Smalltalk-80 does; one can take an existing class and add methods
> thereto.

Yes, but that's because a Smalltalk program lives inside a big binary
"image" that is mutable. Woe unto you if that big binary file gets
corrupted.

> Dynamic method deletion. I for one might only want this in the
> context of a "sandbox" but if one can create methods, one should be
> able to delete them as well if only because of undo.

The problem with deleting a method is whether the runtime can handle
it: Smalltalk has doesNotUnderstand:#aMessage, Java has
NoSuchMetohdError - what does C++ do? A zeroed virtual method would
cause a pure virtual method call error, which I guess C++ programmers
are trained to take into account. Also, if class A has a method and
you delet it in subclass B, it breaks the Liskov Substitution
Principle, there B should be able to function where an A is wanted.

> Dynamic method rename. This could lead to much madness but this
> might be useful during sandboxing.

A method's name and its "address" are distinct, but for dynamic method
dispatch, what about any other code that doesn't know the new name but
assumes the method is called the same?

> Dynamic inheritance. For those languages that support inheritance
> one might liken it to changing what the language inherits or
> implements on the fly. I don't know of any language apart from
> Smalltalk that can even think about allowing dynamic inheritance,
> but it's a thought.

If you can change a Perl class, er, module's @INC array I think that
would support it.

> Operator overload (e.g., C++'s operator ==()).

Or rather "dotless/prefix method invocation with the added baggage of
precedence rules". Smalltalk solves this by 1) not having those
precedence rules, 2) have dotless method invocation and 3)

> 
> Name overload. C does not have it; C++ and Java do. I suspect Ruby
> and Python do as well.

Are you referring to namespaces, ie. namespace isolation?

> Globals. Java has no globals as such, unless one counts class names.
> C is all globals, unless one counts statics.

Even the fully qualified classes are only "global" in the context of a
classloader and whatever classloaders it delegates to.

> Unnamed classes. new Runnable() { public void run() {...} } is
> Java's contribution. Can be useful.

Well, they do end up with a name after compilation. And you do not
want to open that can of worms since then you end up with Ruby and
Smalltalk users dragging out closures and C# and Lisp users dragging
out lambdas... :)

> Nested classes.

Generally that's just a namespace issue. In Java, a class Fie nested
inside Foo is the top-level class Foo$Fie with some compiler magic to
ensure it's used correctly, which leads to funny stuff like

Foo.Fie object = new Foo().new Fie();

which gets turned into the bytecode equivalent of

Foo$Fie object = new Foo$Fie(new Foo());

> Primitive types -- in other words, the int<->Integer dichotomy we
> all know and love in Java; such also exists in C++ and IINM C#. I'm
> not sure if Smalltalk has such a concept, or not; Smalltalk allows
> overrides on numbers. (In Java one might contemplate 2.toString(),
> for example!)

In Smalltalk you ask the 1 object to count to 10 for a loop. It makes
sense there, it would not feel "right" in the C family...

> Arbitrary integer size. The only language I know having this is
> Common LISP.

java.math.BigInteger, but the operations you can perf

HTTPS Login

2006-08-31 Thread Tom Grove
I am trying to login to a secure website and I am having some difficulty 
understanding the process.  Here is what I have with my limited 
knowledge of the subject:

##Start Code##
#!/usr/bin/env 
python  
 




import 
urllib  
 

import 
urllib2 
 




# 
Main
  

params = 
urllib.urlencode({  
   

"user" : 
"username", 
  

"pass" : 
"password"  


})  





req = urllib2.Request("https://web.site.com/default.aspx";, 
params)  
data = 
urllib2.urlopen(req)
 




for line in 
data.readlines():   


print line
##End Code##

This just doesn't seem to work.  It just brings me back to a login screen.

If you can lend a hand it would be much appreciated.

-Tom


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


Re: sys.argv[0] doesn't always contain the full path of running script.

2006-08-31 Thread Joel Hedlund
 > Running "python test.py" now prints /path/to/my_module.py, not
 > /path/to/my_script.py.

That should have been "python my_script.py". Sorry for the slip-up.

Cheers!
/Joel
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Searching a string and extract all occurancies of a substring

2006-08-31 Thread Gabriel Genellina

At Thursday 31/8/2006 12:44, Nico Grubert wrote:


in a text with no carriage returns I need to look for all occurancies of
this string:

...


Try Beautiful Soup, or if your input is simple enough, the re module.



Gabriel Genellina
Softlab SRL 






__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas


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

Re: Pros/Cons of Turbogears/Rails?

2006-08-31 Thread fuzzylollipop

Ray wrote:
> fuzzylollipop wrote:
> > uh, no, Python predates Ruby by a good bit
> > Rails might be "older" than Turbogears but it still JUST went 1.0
> > officially.
> > It can't be called "mature' by any defintition.
>
> But at least in most developers' perception ... 

nobody is talking about perception

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


Re: Pros/Cons of Turbogears/Rails?

2006-08-31 Thread Paul Boddie
fuzzylollipop wrote:
> Paul Boddie wrote:
> > > fuzzylollipop wrote:
> > > > uh, no, Python predates Ruby by a good bit
> > > > Rails might be "older" than Turbogears but it still JUST went 1.0
> > > > officially.
> > > > It can't be called "mature' by any defintition.
> >
> > Version numbers are a fairly useless general metric of project
> > maturity, taken in isolation.
>
> But 1.0 releases do mean something, it means the DEVELOPER of the
> package things it is just now ready for general consumption. That means
> something regardless of what the number is.

In various open source circles, the mere usage of 1.0 may indicate some
kind of stability, but not necessarily maturity, or at least the desire
of the developers to persuade users that the code is ready for them to
use. Consequently, there are numerous stable packages at 0.x because
the developers don't think they're near finished (ie. have produced a
mature system), numerous unstable packages at 1.x because the
developers want their 15 minutes of fame (GNOME 1.0 was apparently a
good example of this), and various packages at 3.x or 4.x that would
suggest a legacy of decades when they've probably only been in
existence for eighteen months at the most.

> Matter of fact, all major version releaese mean that, it is generally
> understood thing. x.0 means this is now ready for non-beta general use.

Agreed. Still, let's take some examples from the python.org Wiki's
WebFrameworks page to illustrate what I mean:

SkunkWeb (3.4.0), Zope (2.9.4 and 3.2.1), Plone (2.5), Karrigell (2.3),
CherryPy (2.2.1), Spyce (2.1), QP (1.8), Cymbeline (1.3.1), Django
(0.95), Webware (0.9.1), Pylons (0.9.1), TurboGears (0.8.9), PyLucid
(v0.7.0RC4), Paste (0.4.1), web.py (.138)

Now, just over half of the above have presumably passed some stability
threshold, and we could possibly even estimate the age of many of the
frameworks based on how high their version numbers are. However, note
that whilst Zope 3.2.1 is now presumably considered stable, something
like Zope 3.0 couldn't really be considered as mature as Zope 2.8 or
2.9 purely because of the nature of the code: a rewrite of the
architecture which, even if considered stable, cannot be considered
mature in comparison to its established predecessors with all the
accumulated expertise and experience associated with them.

Such comparisons of unequal things having the same name have also
affected projects like CherryPy, where 1.x and 2.x were apparently
quite different, and whilst CherryPy is currently at 2.2.1 and used by
other projects, it is described as unstable elsewhere in this thread -
contradicting various reports of successful large scale deployments, I
might add. Meanwhile, the original framework upstart, Webware, hasn't
even reached 1.0, yet it has been around for longer than many of the
others, whilst Pylons bears an identical version number.

Part of the difficulty in maintaining an overview such as the
WebFrameworks page arises from attempting to measure maturity,
stability, vitality and quality - something which some repositories
like Freshmeat attempt to tackle using various methods of measurement.
And as I was editing the version numbers recently, I did consider the
issue of whether they provided a reasonable impression of project
stability and/or maturity, but I rather feel that more considered
evaluations are the only way to get that kind of information.

Paul

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


How to Interpret Hotshot Stats

2006-08-31 Thread Gregory Piñero
Would someone mind giving me a quick explanation on what this is
telling me?  How much is 201 CPU seconds?  Watching the clock the run
seems to take 7 seconds all the way from clicking on the batch file to
run my hotshot script.  Does that mean most of that time was in
loading the interpreter?

Am I correct that there aren't any noticable bottlenecks here?

 43 function calls in 201.725 CPU seconds

   Ordered by: internal time, call count

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
1  200.889  200.889  201.725  201.725 index.py:74(main)
10.1870.1870.4300.430 content.py:458(handle_spage_browse
_customers)
10.1200.1200.2470.247 cgi.py:417(__init__)
10.0920.0920.1110.111 content.py:155(HTML_HEADER)
80.0750.0090.1180.015 cgi.py:576(getfirst)
20.0530.0270.0530.027 webutils.py:42(input_text)
80.0430.0050.0430.005 cgi.py:615(__contains__)
20.0420.0210.0420.021 webutils.py:28(input_form_header)
20.0400.0200.0400.020 webutils.py:33(input_form_footer)
10.0390.0390.0390.039 cgi.py:732(skip_lines)
50.0310.0060.0310.006 webutils.py:39(input_hidden)
10.0260.0260.0940.094 cgi.py:627(read_urlencoded)
10.0200.0200.0200.020 content.py:210(HTML_SIDEBAR)
10.0150.0150.0200.020 stringio.py:120(read)
10.0130.0130.0140.014 cgi.py:325(parse_header)
10.0110.0110.0110.011 stringio.py:54(__init__)
10.0090.0090.0090.009 cgi.py:190(parse_qsl)
20.0080.0040.0080.004 os.py:434(__contains__)
10.0070.0070.0070.007 content.py:245(HTML_FOOTER)
10.0050.0050.0050.005 stringio.py:38(_complain_ifclosed)

10.0020.0020.0020.002 cgi.py:331()
00.000 0.000  profile:0(profiler)

Thanks,

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


Re: Searching a string and extract all occurancies of a substring

2006-08-31 Thread Nico Grubert

> Try Beautiful Soup, or if your input is simple enough, the re module.

Hi Gabriel,

I first tried "HTMLParser" and wrote this short script:

from HTMLParser import HTMLParser
from htmlentitydefs import entitydefs

class MyDocParser(HTMLParser):

 def __init__(self):
 self.paths = []
 self.readingpaths = 0 # flag
 HTMLParser.__init__(self)

 def handle_starttag(self, tag, attrs):
 if tag == 'parameter':
 self.readingpaths = 1

 def handle_endtag(self, tag):
 if tag == 'parameter':
 self.readingpaths = 0

 def handle_data(self, data):
 if self.readingpaths:
 self.paths.append(data)

 def handle_entityref(self, name):
 " handle values like 'Home & Products' "
 if entitydefs.has_key(name):
 self.handle_data(entitydefs[name])
 else:
 self.handle_data('&' + name + ';')

 def handle_charref(self, name):
 """ handle values like 'Home & Products®'
 Ignores invalid character references
 """
 try:
 charnum = int(name)
 except ValueError:
 return

 if charnum < 1 or charnum > 255:
 return

 def get_paths(self):
 return self.paths


def parse_content(content):
 """ parse
 """

 parser = MyDocParser()
 parser.feed(content)

 paths = parser.get_paths()

 return paths

# /end

This works as long as there are no other  Tags in the content 
that I parse.


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


Re: genetic algorithms package for python ?

2006-08-31 Thread Thomas Samson
Xiao Jianfeng <[EMAIL PROTECTED]> writes:

> Hi all,
>
> I am looking for a genetic algorithms package for Python.
>
> I have googled the web before posting and found some links. The link
> of  pygene(http://www.freenet.org.nz/python/pygene) cannot be opened.

Strange, works for me...

>
> I also tried the recipe on ASPN, but it is too simple for my
> application, and the ga model in SciPy, which is in testing in the
> "sandbox".
>
> Are there any more genetic algorithms packages for Python ?
>

I am not (at all!) an specialist in genetic algorithms, but here are
some links :

http://pygp.sourceforge.net/
http://packages.qa.debian.org/g/genetic.html
and of course,
http://www.freenet.org.nz/python/pygene/

-- 
Thomas Samson
BOFH Excuse #420:
Feature was not beta tested
-- 
http://mail.python.org/mailman/listinfo/python-list


How to include and use a .NET DLL and namespace.

2006-08-31 Thread Caolan
Hello,
 
I am in need of importing in a .NET namespace from 
a built DLL. How do I get Python to pickup and recognise the namespace and 
classes in the DLL?
 
Thanks,
 
Caolan O'Domhnaill-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Searching a string and extract all occurancies of a substring

2006-08-31 Thread Nico Grubert
> This works as long as there are no other  Tags in the content 
> that I parse.

Got it.

I forgot to handle the 'attrs' parameter in handle_starttag().

Changed it to:

 def handle_starttag(self, tag, attrs):
 if tag == 'parameter':
 if attrs == [('key', 'infobox_path')]:
 self.readingpaths = 1

This works so far.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Basic import Questions (with bonus profiling question)

2006-08-31 Thread Fredrik Lundh
Gregory Piñero wrote:

> 1. Will "from somemodule import onething" take as long to start up as
> import somemodule?

yes; "from x import y" does an ordinary import of "x" under the hood.

> 2. Is there anyway I can get at onething more quickly?

not really, unless you're willing/able to refactor the module you're 
importing.

> 3. If I put an import statement hidden away in some function, will
> Python only do the import when that function is called?

correct.  "import" is an executable statement.

> If I say, never use that function would that import statement affect
 > performance at all?

nope.

> Ultimately I have IIS running python as a CGI script and it seems to
> just be taking many seconds to load a small page.  I'm guessing the
> issue is starting up the interpreter and loading all the modules.

several seconds?  sounds bad.  what does the following script print on 
your machine?

import time, subprocess, sys

t0 = time.time()
for i in range(10):
subprocess.call([sys.executable, "-c", "pass"])
print time.time() - t0



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


Re: get a line of text from a socket...

2006-08-31 Thread KraftDiner

Sybren Stuvel wrote:
> KraftDiner enlightened us with:
> > What makes asyncore.loop exit?
>
> Why ask questions about something you're unable to use, when I've
> given you something that does work?
>
Who said it didn't work?

> 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: Questoin about outlook calendar

2006-08-31 Thread Gallagher, Tim F (NE)


"Gallagher, Tim (NE)" wrote :
> import win32com.client
> import time
> import datetime
>
> outlook = win32com.client.Dispatch("Outlook.Application")
> namespace = outlook.GetNamespace("MAPI")
> appointments = namespace.GetDefaultFolder(9).Items
>
> #print appointments.count
> x = 4  # This is a number for one of the calendar entries
> print appointments[x]
> print appointments[x].start
> print appointments[x].end
> print appointments[x].RecurrenceState
> print appointments[x].EntryID
> print appointments[x].IsRecurring
> recItem = appointments[x].GetRecurrencePattern


> GetRecurrencePattern is a method, so at this point recItem
> is a reference to the method itself, rather than the result of calling
it.
> You'll need to add parens to actually call it.
>
>   Roger



OK, I am a little lost, I do not want anyone doing my work for me but
can you give me an example.

I am using this as an example to learn python.  

Thanks
-T

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


Re: Pros/Cons of Turbogears/Rails?

2006-08-31 Thread Jaroslaw Zabiello
On Thu, 31 Aug 2006 11:42:47 -0300, Jorge Godoy wrote:

> TG supports SQL Alchemy as well.  With SQL Alchemy I believe you'll have a
> better experience than with Rails' ORM.

I would not be so sure. I have tried to work with SQL Alchemy (using
Pylons) and I have been disappointed. :( It's syntax for selects is ugly
and not intuitive. Django ORM looks much better. SQLAlchemy has to be added
to Django as alternative ORM but *without breaking* current, clean API:
http://groups.google.com/group/django-developers/browse_thread/thread/5149e1c60dc65bff/a177bb34cfde1ec7

>> But rhtml is much more flexible because it can generate *any content*,
>> not only xml. But Rails has THREE template systems: rhtml (main), rxml
>> (for rss and xml generation) and rjs (for javascript and AJAX).
> 
> Well, TG has a few templating systems...  MarkUp, Kid, Cheetah, ZPT, and
> others.  You can choose the one that best fits your needs / brain.  

This is another topic. Rails can also use another third-party template
system (like Liquid which was inspired by Django). For me using many,
different template systems *for the same task* make no sense. Rails uses
three templates, but for *different tasks*. Its RJS is perfect for AJAX.
Really cool, simple, and almost no javascript is required. Just clean Ruby
for everything.

-- 
Jarosław Zabiełło
http://blog.zabiello.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Searching a string and extract all occurancies of a substring

2006-08-31 Thread Fredrik Lundh
Nico Grubert wrote:

> in a text with no carriage returns I need to look for all occurancies of 
> this string:
> 
> ...
> 
> The ... can contain different values. I need to extract the string 
> between  and .

is this XML, or just something that looks a little like XML ?



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


Re: Pros/Cons of Turbogears/Rails?

2006-08-31 Thread Jaroslaw Zabiello
On 31 Aug 2006 08:24:29 -0700, Adam Jones wrote:

> In moving to SQLAlchemy it would pick up not only a migration system but
> also a much more flexible abstraction system due to the use of a Data
> Mapper pattern instead of the Active Record pattern. 

What is the advantage of Data Mapper? I cannot find..

>> And last but not least, TG is based on poor, unstable and buggy
>> CherryPy server. We had huge problems with CherryPy. I think that
>> Django or Pylons are much better frameworks. IMO TG is no competition
>> for Rails at all. The only real competition is Django or Pylons.
> 
> I have never had much in the way of problems with CherryPy. From what I
> have heard the project has made a lot of improvements recently, so it
> may have changed since you last took a look at it.

We have created two quite big sites in CheerryPy in past and we have many
issues with its bad implementation. Sessions were useless, forks were
removed from early code without any warning. Maybe now it is better, but I
have lost any confidence in CherryPy quality.

-- 
Jarosław Zabiełło
http://blog.zabiello.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Subclassing Tkinter Buttons

2006-08-31 Thread Bob Greschke
I don't use classes much (mainly because I'm stupid), but I'd like to make a 
subclass of the regular Tkinter Button widget that simply adds spaces to the 
passed "text=" when the program is running on Windows (Linux, Solaris, Mac 
add a little space between the button text and the right and left edges of a 
button, Windows does not and it looks bad/can be hard to read).  Below is 
some pseudo code.  What should the guts of the BButton class be?  I can't 
work out how all of the arguments that would be passed to a regular Button 
call get handled.  *args and **kw confuse me and I can't seem to find simple 
enough examples in my mountain of books.

Thanks!

Bob


System = platform[:3].lower()
.
.
class BButton(Button):
if System == "win":
Make a button with " " before and after text
else:
Make a button using the passed text as is
.
.
BButton(Sub, text = "Hello", bg = "blue", fg = "yellow").pack(side = TOP)
BButton(Sub, bg = "yellow", bg = "blue", text = "World").pack(side = TOP)


On "lin", "sun", "dar":
[Hello]
[World]

On "win":
[ Hello ]
[ World ]


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


Re: Basic import Questions (with bonus profiling question)

2006-08-31 Thread Gregory Piñero
On 8/31/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> several seconds?  sounds bad.  what does the following script print on
> your machine?
>
> import time, subprocess, sys
>
> t0 = time.time()
> for i in range(10):
> subprocess.call([sys.executable, "-c", "pass"])
> print time.time() - t0

It prints 1.9213134
What does that mean?

By the way, I thought I was importing just a file path from a module
but like you said it was importing the entire module.  I got rid of
that import statement and the time dropped from 7 seconds to 1.5
seconds.

Any other tips for speeding up python load time for IIS?  (I mean
really simply tips, I don't have time anything soon to fool with
fastCGI for IIS or setting up ASP)

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


Re: simultaneous copy to multiple media

2006-08-31 Thread Claudio Grondi
[EMAIL PROTECTED] wrote:
> I need a program that simultaneously can copy a single file (1 GB) from
> my pc to multiple USB-harddrives.

Why not just use:
copy c:\file.ext u:\file.exe
  in one shell and in another
copy c:\file.ext v:\file.exe
where u: and v: are the USB drives?

There is usually not much gain on USB when on Windows, especially in 
case of a single file which fits into memory (and the file cache) to do 
it 'simultaneously'.
This subject was discussed here already in the past:

http://mail.python.org/pipermail/python-list/2005-March/271985.html

Claudio Grondi

> 
> I have searched the internet and only found one program that does this
> on
> http://mastermind.com.pl/multicopy/
> 
> but this link doesnt work anymore somebody that can help me, is
> there any other programs out there.
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: M$ windows python libs installed in arbitrary directories forcustomized python distributions

2006-08-31 Thread Georg Brandl
alf wrote:
> Robert Kern wrote:
>> alf wrote:
>> 
>>> Fredrik Lundh wrote:
>>>
 http://www.catb.org/~esr/faqs/smart-questions.html#writewell

 
>>>
>>>
>>> and  means?
>> 
>> 
>> It's his signature.
>> 
> 
> The sig is delimited by '-- \n'

Yes, and Earth is a disk.

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


Re: Basic import Questions (with bonus profiling question)

2006-08-31 Thread Fredrik Lundh
Gregory Piñero wrote:

>> several seconds?  sounds bad.  what does the following script print on
>> your machine?
>>
>> import time, subprocess, sys
>>
>> t0 = time.time()
>> for i in range(10):
>> subprocess.call([sys.executable, "-c", "pass"])
>> print time.time() - t0
> 
> It prints 1.9213134
> What does that mean?

that it takes just under two seconds to start the interpreter ten times. 
  not stunningly fast, but not too bad.

> By the way, I thought I was importing just a file path from a module
> but like you said it was importing the entire module.  I got rid of
> that import statement and the time dropped from 7 seconds to 1.5
> seconds.

what module is this?  if it takes 5.5 seconds to import a single module, 
something isn't quite right.



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


Re: How to avoid a warning message box when sending email via Outlook

2006-08-31 Thread Steve M

> [Dermot Doran]
>
> | I'm very new to using win32com!  I just want to send an email
> | message via Outlook.  However, I keep getting an annoying
> | message box (generated by Outlook) indicating that my program
> | could be a virus.  Does anybody know how to get around this?

The users in our office have a little program called ClickYes.exe that
sits in the system tray and automatically clicks yes when this pops up.
Hardly elegant but it solves their problem.

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


Re: Need Python for Linux (Suse 10.1)

2006-08-31 Thread James Oakley
On Thursday 31 August 2006 6:16 am, Dick Moores wrote:
>  I've got a friend interested in trying out Python. I sent him to 
> http://www.python.org/download/linux/ but he's uncertain as to what to
> download. He's rather get a new download than use what was on his Suse
> disk. His box is an x86.
>
>  Any chance Python 2.4.3 compressed source tarball would be suitable for
> him?

He already has it. Python is installed by default on most Linux distributions, 
including SUSE.

If he wants Python IDEs, libraries, and tools, he should open up YaST, 
select "Software Management", select the search filter, and enter python in 
the search box.

There's a ton of Python stuff on SUSE, and there's even more in my 
YaST-compatible repo at http://repos.opensuse.org/home:/jimfunk/ .

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


  1   2   >