Problema con le RE....

2006-01-09 Thread Alessandro
Problema con le RE
Ho questa stringa "3 HOURS,  22 MINUTES, and  28 SECONDS" e la devo
'dividere' nelle sue tre parti "3 HOURS", "22 MINUTES", "28 SECONDS".
La cosa mi viene molto con le RE...(inutile la premessa che sono molto
alle prime armi con RE e Python)
Qesito perchè se eseguo questo codice

>>>>regex=re.compile("[0-9]+ (HOUR|MINUTE|SECOND)")
>>>>print regex.findall("22 MINUTE, 3 HOUR,  AND  28 SECOND")
ottengo come output:

>>>> ['MINUTE', 'HOUR', 'SECOND']

e non come mi aspettavo:

>>>> ['3 MINUTE', '22 HOUR', '28 SECOND']

Saluti e grazie mille...
Alessandro

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


Re: Problema con le RE....

2006-01-09 Thread Alessandro
Thanks for the reply it's ok!!!
The language? I selected the wrong newsgroup in my
newsreader!!!...sorry...

Thanks...

Alessandro...

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


closing a "forever" Server Socket

2007-01-18 Thread alessandro
Hi all,

This is my framework for create TCP server listening forever on a port
and supporting threads:


import SocketServer

port = 
ip = "192.168.0.4"
server_address = (ip, port)

class ThreadingTCPServer(SocketServer.ThreadingMixIn,
SocketServer.TCPServer): pass

class Handler(SocketServer.BaseRequestHandler):
def handle(self):
# my handler

print "Listening for events at " + ip + ":" + str(port)
monitor_server = ThreadingTCPServer(server_address, Handler)

try:
monitor_server.serve_forever()
except KeyboardInterrupt:
monitor_server.socket.close()
print "Bye."


This server will not run as a daemon and for quitting you have to send
the SIGINT signal with Ctrl-C. It will rise the KeyboardInterrupt
exception, during its handling I simply close the socket and print a
message.

I want to ask if someone knows a better way for closing a "forever
server" or if there is a lack in my design.

Thank you!

Alessandro

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


Re: closing a "forever" Server Socket

2007-01-22 Thread alessandro
thanks

infact the server_forever() method is only a serve() method inside an
infinite loop.

many thanks again,

Alessandro

Matimus ha scritto:

> > I want to ask if someone knows a better way for closing a "forever
> > server" or if there is a lack in my design.
>
> Generally you don't create a 'forever server'. You create an 'until I
> say stop' server. I would do this by looking at the 'serve_forever'
> method, and implementing my own 'serve_until_?' method that is similar,
> but will stop if a flag is set. Then you have to create a method for
> setting that flag. It could be as simple as a keypress, or you could
> add a quit method to your dispatcher that sets the flag when a certain
> address is visited. That second method probably needs some added
> security, otherwise anybody can just visit 'your.server.com/quit' and
> shut it down.

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


Re: closing a "forever" Server Socket

2007-01-22 Thread alessandro
Oh my God! it's really so complicated?

3 modules (threading, SocketServer, select) only for design a way to
shutdown a TCP server
...but they told me that python was easy... :)

I'm working on a simulator and I have a monitor server that collects
information. I can shutdown it using Ctrl-C from the keyboard but for
my purpose could be very nice if I introduce a timer. So I could launch
my monitor like this:

./monitor 100

and my monitor will run for 100 seconds. For this I'm using the Timer
class provided by threading module, I have implemented a function like
this:

def shutdown():
sys.exit()

but it doesen't work because the server remain alive...maybe
SocketServer create immortal server...
I need only to close my application, there is a way to force the server
thread to close?

thanks!
Alessandro



Laszlo Nagy ha scritto:

> alessandro írta:
> > thanks
> >
> > infact the server_forever() method is only a serve() method inside an
> > infinite loop.
> >
> > many thanks again,
> >
> Here is a snipped that show a "software terminateable threading TCP
> socker server". The "server" object is a SocketServer instance,
> server_stopped is a threading.Event instance. You should also import the
> "select" module.
>
> srvfd = server.fileno()
> while not server_stopped.isSet():
> ready = select.select([srvfd], [], [], 1) # Give one second
> for incoming connection so we can stop the server in seconds
> if srvfd in ready[0]:
> server.handle_request()
> else:
> pass  # log('No incoming connection, retrying')

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


Re: replacing numbers in LARGE MATRIX with criterium in 2 columns (a--> b)

2009-05-04 Thread Alessandro
On May 4, 2:38 pm, Alexzive  wrote:
> Hello,
> I have this matrix [20*4 - but it could be n*4 , with n~100,000] in
> file "EL_list" like this:
>
> 1,  1,  2,  3
>  2,  4,  1,  5
>  3,  5,  1,  6
>  4,  7,  5,  6
>  5,  8,  7,  9
>  6,  8,  5,  7
>  7, 10,  9,  7
>  8, 10, 11, 12
>  9,  7, 13, 10
> 10, 14, 15, 16
> 11, 14, 17, 15
> 12, 17, 14, 18
> 13, 13, 16, 10
> 14, 16, 15, 11
> 15, 16, 11, 10
> 16, 19, 20, 21
> 17, 22, 15, 20
> 18, 17, 20, 15
> 19, 23, 20, 24
> 20, 25, 24, 20
>
> I would like to replace some numbers in "EL_list" but only in columns
> 2,3,4 using the criterium by line in file "criterium" (column 1 are
> the new numbers, column 2 the old ones).
>
> 1   1
> 2   3
> 3   5
> 4   12
> 5   13
> 6   14
> 7   15
> 8   16
> 9   17
> 10  18
> 11  19
> 12  10
> 13  21
> 14  22
> 15  23
> 16  24
> 17  25



>
> For example all the 7 have to replaced by 15 and so on..
>

ERRATA: for example, all the 15 have to replaced by 7 and so on..
--
http://mail.python.org/mailman/listinfo/python-list


Re: writing on file not until the end

2009-05-25 Thread Alessandro
On May 25, 8:38 am, Peter Otten <__pete...@web.de> wrote:
> Alexzive wrote:
> > I am a newby with python. I wrote the following code to extract a text
> > from a file and write it to another file:
>
> > linestring = open(path, 'r').read() #read all the inp file in
> > linestring
>
> > i=linestring.index("*NODE")
> > i=linestring.index("E",i)
> > e=linestring.index("*",i+10)
> > textN = linestring[i+2:e-1] # crop the ELement+nodes list
> > Nfile = open("N.txt", "w")
> > Nfile.write(textN)
>
> > unfortunately when I check N.txt some lines are missing (it only crop
> > until "57, 0.231749688431, 0.0405121944142" but I espect the final
> > line to be "242, 0.2979675, 0.224605896461". I check textN and it has
> > all the lines until "242..")
>
> > when I try Nfile.write(textN) again it writes some more lines but
> > still not all!
> > what is wrong whit this?
>
> Do you check the contents of the resulting file by feeding it to another
> program?
>
> > 53, 0.170973146505, 0.0466686190136
> > 57, 0.231749688431, 0.0405121944142
> > t60, 0.250420691759, 0.0399644155193
> > 58, 0.234883810317, 0.0488399925217
> > 61, 0.2666025, 0.03541845
>
> There's a "t" at the start of the line after the last line you claim to see,
> so maybe your input file is corrupt and your reader stumbles over that line.
>
> Peter

Thank you all for replying.

- yes, I oversaw the "t" at "60, 0.250420691759, 0.0399644155193". I
then removed it for the following tests
- changing from "e-1" to "e" apparently solved the problem, BUT I then
realized it was just because a second access to the file (still open)
seems to be the real solution --> after Nfile.close() e retrying with
"e" instead of "e-1" the problem is still there.
- I also tryied to inizialize e and i to zero --> nothing changes
- until now, the only solution which works is to repeat the code while
the file is still open, which means a quite redundant code:

linestring = open(path, 'r').read()
i=linestring.index("*NODE")
i=linestring.index("E",i)
e=linestring.index("*",i+10)
textN = linestring[i+2:e-1] # crop the ELement+nodes list
Nfile = open("N.txt", "w")
Nfile.write(textN)

linestring = open(path, 'r').read()
i=linestring.index("*NODE")
i=linestring.index("E",i)
e=linestring.index("*",i+10)
textN = linestring[i+2:e-1] # crop the ELement+nodes list
Nfile = open("N.txt", "w")
Nfile.write(textN)

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


Re: writing on file not until the end

2009-05-25 Thread Alessandro
On May 25, 10:58 am, John Machin  wrote:
> On May 25, 6:30 pm, Alessandro  wrote:
>
>
>
> > On May 25, 8:38 am, Peter Otten <__pete...@web.de> wrote:
>
> > > Alexzive wrote:
> > > > I am a newby with python. I wrote the following code to extract a text
> > > > from a file and write it to another file:
>
> > > > linestring = open(path, 'r').read() #read all the inp file in
> > > > linestring
>
> > > > i=linestring.index("*NODE")
> > > > i=linestring.index("E",i)
> > > > e=linestring.index("*",i+10)
> > > > textN = linestring[i+2:e-1] # crop the ELement+nodes list
> > > > Nfile = open("N.txt", "w")
> > > > Nfile.write(textN)
>
> > > > unfortunately when I check N.txt some lines are missing (it only crop
> > > > until "57, 0.231749688431, 0.0405121944142" but I espect the final
> > > > line to be "242, 0.2979675, 0.224605896461". I check textN and it has
> > > > all the lines until "242..")
>
> > > > when I try Nfile.write(textN) again it writes some more lines but
> > > > still not all!
> > > > what is wrong whit this?
>
> > > Do you check the contents of the resulting file by feeding it to another
> > > program?
>
> > > > 53, 0.170973146505, 0.0466686190136
> > > > 57, 0.231749688431, 0.0405121944142
> > > > t60, 0.250420691759, 0.0399644155193
> > > > 58, 0.234883810317, 0.0488399925217
> > > > 61, 0.2666025, 0.03541845
>
> > > There's a "t" at the start of the line after the last line you claim to 
> > > see,
> > > so maybe your input file is corrupt and your reader stumbles over that 
> > > line.
>
> > > Peter
>
> > Thank you all for replying.
>
> > - yes, I oversaw the "t" at "60, 0.250420691759, 0.0399644155193". I
> > then removed it for the following tests
> > - changing from "e-1" to "e" apparently solved the problem, BUT I then
> > realized it was just because a second access to the file (still open)
> > seems to be the real solution --> after Nfile.close() e retrying with
> > "e" instead of "e-1" the problem is still there.
> > - I also tryied to inizialize e and i to zero --> nothing changes
> > - until now, the only solution which works is to repeat the code while
> > the file is still open, which means a quite redundant code:
>
> > linestring = open(path, 'r').read()
> > i=linestring.index("*NODE")
> > i=linestring.index("E",i)
> > e=linestring.index("*",i+10)
> > textN = linestring[i+2:e-1] # crop the ELement+nodes list
> > Nfile = open("N.txt", "w")


I closed and restarted the python console. Now this code (with added
"Nfile.close()" at the end) seems to work properly:

linestring = open(path, 'r').read()
i=linestring.index("*NODE")
i=linestring.index("E",i)
e=linestring.index("*",i+10)
textN = linestring[i+2:e-1]
Nfile = open("N.txt", "w")
Nfile.write(textN)
Nfile.close()

thanks, Alex
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Writing to ms excel

2008-08-31 Thread Alessandro

John Machin wrote:

xlrd is still doing what it was designed to do: read (not "interface
with") Excel xls files. There is a currently active project to add


Can xlrd *read* xls files?
As far as I have used PyExecelerator, it can only *create* xls file.

I'm viewing the xlrd sources, but I can't find the file loading function 
and there is no examples about it.


I'm going to join the python-excel group


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


Re: Writing to ms excel

2008-08-31 Thread Alessandro

John Machin wrote:

"""xlrd is still doing what it was designed to do: read Excel ... xls
files."""


oops... I had downloaded the sources from 
"https://secure.simplistix.co.uk/svn/xlwt/trunk";


eh, xlWT .. obviously I cant find an "open" function in it..


Could you possibly be viewing the source for xlwt (wt being an
abbreviation of WriTe)? xlwt is a fork of pyExcelerator. 


I have written about pyExcelerator 'cause the code refers to it! :-)

I think I will try to use xlrd/xlwt.
I have joined the group, I will let you know


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


check path.exists() with a "converted" path

2010-09-27 Thread Alessandro
Hi, I'm a python newbie with a problem too hard to tackle.

I have a string defining a path, were all the spaces have been
converted to underscores.
How can I find if it corresponds to a real path?

e.g. a string like '/some/path_to/directory_1/and_to/directory_2'
with a real path: '/some/path_to/directory 1/and_to/directory 2'

notice that the real path can contain BOTH spaces and underscores.

How can I feed it to os.path.exists() ???

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


Re: check path.exists() with a "converted" path

2010-09-27 Thread Alessandro
people, you're great - best newsgroup I've ever been!

I think I'll go with the glob suggestion - works like a charm!!!

thank you...


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


Re: alphanumeric list

2011-03-16 Thread not1xor1 (Alessandro)

Il 15/03/2011 09:10, yqyq22 ha scritto:


I would like to put an alphanumeric string like this one
EE472A86441AF2E629DE360 in a list, then iterate inside the entire
string lenght and change each digit with a random digit.
Do u have some suggestion? thanks a lot


hi

I'm not an experienced python programmer but the following code should 
work:


# you need to import the random module to get random numbers
import random

# convert the string in a list (as string are read-only)
l = list('EE472A86441AF2E629DE360')
# initialize the random generator
random.seed()
# index
i = 0
# loop through the characters in the list
for c in l:
# if the current character is a digit
if c.isdigit():
# get a random integer in the 0-9 range
# convert it to a string and replace the old value
l[i] = str(random.randint(0,9))
# increment the list index
i +=1
# convert the modified list back to string and display it
print(''.join(l))

--
bye
!(!1|1)
--
http://mail.python.org/mailman/listinfo/python-list


Re: words relating to networks that I should probably know

2005-09-22 Thread Alessandro Bottoni
John Walton wrote:

> Hello, again.  I'm back with my instant messenger
> project.  My teacher has assigned us to write our
> papers, excluding the procedure, results, and
> conclusion.  One of my topics is going to be networks.
>  Does anyone know a list of words relating to
> networking/networks that I should know for this
> project?  Not the definitions, but just the words; I
> can look up the definitions on webopedia.  It would be
> appreciated.  Thanks!
> -John

Have a look at http://en.wikipedia.org (search "network" and "TPC/IP").

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


Re: c/c++ and python

2005-09-29 Thread Alessandro Bottoni
Mattia Adami wrote:

> Hi to all!
> I have a little problem. I want to develop an application in c/c++ that
> creates a window with gtk+ accordinly to the information on a xml file.
> The funcions that are called for manage the event should be written in
> python. I don't know how to do it, can you help me? Is it possible?
> Thanks a lot!

Yes, it is possible. Most likely, you will have to embed a Python
interpreter in your app. Have a look at the Extending&Embedding section of
the Python manual.

As an alternative, you can use your C++ code as an extension of Python (a
module). Again, have a look at the Extending&Embedding section of the
Python manual.

BTW: are you aware of the existence of PyGTK and wxPython?

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


Re: where to post python code?

2005-09-30 Thread Alessandro Bottoni
[EMAIL PROTECTED] wrote:

> the question it - where should i post the code to?
> It's not big enough to justify a source forge project, nor is it small
> enough to be considered a receipt fit for ASPN's Python Cookbook.

Maybe "The Vaults of Parnassus" at www.vex.net is the right place for it.

HTH

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


parsing WSDL

2005-01-27 Thread Alessandro Crugnola
Hi to all.
Is there a way, maybe using 4suite, to read a wsdl file and find for
every method all the input/output params and their type?
-- 
http://mail.python.org/mailman/listinfo/python-list


Do a "Python beginners e-mail list" exist?

2005-07-07 Thread Alessandro Brollo
Far from a professional programmer, I'm simply a
newbie Python user. Two basic questions:

1. I don't want to post banal questions about Python
to main Python list. Does a "banal Python questions
list" or a "Python beginners list" exist?

2. There is somewhere a very patient fellow willing to
be my free "python tutor" by personal e-mailing
outside the mail list? . The ideal candidate would be
someone, sharing with me some other fields of interest
(I'm a middle-aged Italian pathologist, with some
dBase III and dBase IV past programming experience,
and I like nature and mainly horses). 

Thanks

Alessandro Brollo







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


Is there a better/simpler logging module?

2005-08-08 Thread Alessandro Bottoni
I just tried to use the python standard logging module in a small program
and I found myself lost among all those features, all those configuration
options and so on.

Is there any better/simpler logging module around?
What do you use for logging in your programs?

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


Examples and tutorials about popen2/3, smtplib/multipart and icq/jabber?

2005-08-09 Thread Alessandro Bottoni
Is there any good tutorial/example about popen2 and popen3? I have to
execute a given command on Linux and Windows from within a Python program.
If possible, on Linux I would like to be able to set the executing user
(setuid) and the niceness level of the command. (and yes: I know it is a 
dangerous feature...)

Is there any good tutorial/example about smtplib and MIME multipart
messages? I need to send a bunch of e-mail messages (possibly in HTML
format) to many diverse recipients, each message with one or more
attachements (typically PDF files). 

BTW: how about using Twisted Matrix for this task? I heard it is able to
send e-mail messages asynchronously (leaving free the invoking program to
go on just after the call to the "send_msg" function).

Is there any good tutorial/example about Jabber or ICQ and Python? I have to
send a bunch of instant messages (possibly with one or more file and/or one
or more URL attached to them in some way) to many diverse recipients (I
normally do not use ICQ and/or Jabber and I know them very little. Any
advise or suggestion about this task is greatly welcome).

Thanks in advance

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


Re: Running one Python program from another as a different user

2005-08-13 Thread Alessandro Bottoni
Jeff Schwab wrote:

> [EMAIL PROTECTED] wrote:
>> Thanks, that looks very promising...
>> Is there a solution for pre-Python v2.4? I have to have code that works
>> on 2.x, 0<=x<=4. Do I just use the os.popen instead?
> 
> import os
> 
> def run_as(username):
>  pipe = os.popen("su %s" % username, 'w')
>  pipe.write("whoami")
> 
> 
> if __name__ == "__main__":
>  import sys
>  for user in sys.argv[1:]:
>  run_as(user)

Jeff, may I suggest you to write down a new recipe for the ASPN Python
Cookbook based on these code snippets? This is exactly the kind of thing
the people is happy to find at ASPN.

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


Re: GUI tookit for science and education

2005-08-15 Thread Alessandro Bottoni
Mateusz ?oskot wrote:
 
> I'd like to ask some scientists or students
> which GUI toolkit they would recommend
> to develop scientific prototypes (for education and
> testing some theories).
> I think such toolkit should fill a bit different
> needs and requirements:
> - very simple to learn
> - easy to install
> - beautyfiers and advanced features are not required like OpenGL,
> direct access to Windows GDI subsystem, beauty look and skinning
> - multiplatform required

First, have a look at:
- wxWidgets (http://www.wxwidgets.org)
- wxPython (http://www.wxpython.org)

Or, as a second choice:
- FLTK (http://www.fltk.org/)
- PyFLTK (http://pyfltk.sourceforge.net)

There are many others GUI toolkit around. Just search Google for
"multiplatform Python GUI toolkit" or something like that.
 
> Let's say someone has big amount of algorithms and
> statistical models implemented in Pascal
> (not well designed console apps).
> Now he want to move on using better and modern language
> and GUI toolkit.
> Python is seleceted as user friendly and simple
> language, Pascal successor.

There was a python to pascal automatic converter at:

http://no.spam.ee/~andreie/software/py2pas/english-index.html

(Now offline)

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


Re: Creating a graphical interface on top of SSH. How?

2005-08-17 Thread Alessandro Bottoni
John F. wrote:

> I want to write a client app in Python using wxWindows that connects to
> my FreeBSD server via SSH (using my machine account credentials) and
> runs a python or shell script when requested (by clicking a button for
> instance).
> 
> Can someone give me some advice on how to create a "graphical shell"
> per se?

Well, a "graphical shell" is just a wxWidgets application that exposes a few
widgets (buttons, list, whatever). Each widget has a "event" associated to
it and this event can trigger whatever command, even a remote command on
your FreeBSD server (via ssh). As a consequence:
- create your user interface (I suggest you to use wxPython and wxGlade for
this)
- associate to each and every widget a "event handler"
- make your event handlers call your scripts on your FreeBSD machine via SSH
(use PySSH or Conch for this)

Python has a couple of good implementation of SSH:
http://pyssh.sourceforge.net/
http://twistedmatrix.com/projects/conch/
Both of them are well documented.

You can find a small example here:
http://www.palovick.com/code/python/python-ssh-client.php

Do not use wxWidgets directly. You would have to re-create a lot of
Python-wxWidgets integration that already exists. Use wxPython instead
(www.wxpython.org). There is a quite good GUI builder for wxPython that is
called wxGlade. It can generate XML files that are easier to maintain than
C o Python code.

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


Re: up to date books?

2005-08-18 Thread Alessandro Bottoni
John Salerno wrote:

> hi all. are there any recommendations for an intro book to python that
> is up-to-date for the latest version?

I do not know how much up-to-date they are but I have to suggest you these
books:

- Learning Python
By Mark Lutz and David Ascher
published by O'Reilly
Most likely the best introductory book on Python

- Python Cookbook
By Alex Martelli and David Ascher
published by O'Reilly
By far the most useful book on Python after your first week of real use of
this language

Also, the fundamental
- Programming Python (the 2nd edition ONLY)
By Mark Lutz
published by O'Reilly
Is very useful for understanding the most inner details of Python

> would reading a book from a year or two ago cause me to miss much?

No. Python did not changed too much since rel. 1.5. You can still use a book
published in 2001 as a introductory book (as I do). The changes are
exhaustively described both in the official documentation and in the very
fine "what's new in..." articles written by Andrew Kuchlin for every new
release (see www.python.org).

CU

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


Re: Some questions

2005-08-18 Thread Alessandro Bottoni
Titi Anggono wrote:
> 1. Can we use Tkinter for web application such as Java?

What do you mean? If you want to build up a GUI (something like a HTML page)
for a web-based application, you can do it with TKinter. Your TKinter app
can connect to a web server (or any other kind of server) using the
standard Python networking libraries.

If you want to make a web application (a server-side application similar to
the ones you can create with JSP or EJB) you do not need Tkinter at all.
Just use Python itself (see Albatross, Webware and Quixote for a few
web-app frameworks for Python).

> 2. I use gnuplot.py module for interfacing with
> gnuplot in linux. Can we make the plot result shown in
> web ? I tried using cgi, and it didn't work.

The ability to display a image (in this case a GNUPlot plot) on a web page
depends on the browser. Normally, you have to install a specific plug-in
for displaying not-standard types of images on a web page, like it happens
with Macromedia Flash.

I do not know if exists any GNUPlot plug-in for the most common web
browsers. Maybe you can save your plot in a format that is compatible with
the existing viewers, like GIF, TIFF or JPEG. Have a look at GNUPlot
documentation for this.

HTH

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


Re: Python for Webscripting (like PHP)

2005-08-18 Thread Alessandro Bottoni
Florian Lindner wrote:
> How suitable is Python for these kind of projects? What do think? Does the
> stdlib offers all basic functions for this kind of requirements?

Python is extremely well suited for the web-app development and the STDLib
supply most of what you need for this task. As a matter of fact, the easy 
development of web applications was one of the main focuses of the Python
community since Rel 1.0. Thanks to the hard work of its supporters, Python
is now widely considered one of the best tool you can use for developing
web applications, even better than PHP.

Have a look at these chapters of the official Python documentation to get
convinced of what I'm saying:
Chap. 11: Internet Protocols and Support
Chap. 12: Internet Data Handling
Chap. 13: Structured Mark-Up Languages Processing

(Python has even been told to be used by Yahoo! and Google, among others,
but nobody was able to demonstrate this, so far)

Despite this, keep in mind that developing a _real_world_ web application
without the right tools (session management and templating, in particular)
is quite hard, no matter which language you use (even with PHP).

Have a look at the many web frameworks mentioned at http://www.python.org/
and at http://www.vex.net/parnassus/ and choose the one you feel best
suited for your task.

Among these web framework, a couple of them deserve a particular attention:

Maki is a XML based framework, very similar to the java-based Cocoon:
http://maki.sourceforge.net/
http://cocoon.apache.org/

Albatross is aimed to stateful applications:
http://www.object-craft.com.au/projects/albatross/

Regarding the template engine, the best one I'm aware of is Cheetah:
http://www.cheetahtemplate.org/

A last word: beware of PSP (Python Server Pages). If used in the wrong way,
this tool (like the original Java Server Pages) can make a real mess of
your code (because of the inextricable tangle of Python and HTML code you
can create).

CU

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


Which Python library for Jabber?

2005-08-18 Thread Alessandro Bottoni
[I just asked this on Jabber Dev but I did get very few answers. Please,
excuse me for this kind of a cross-posting and give me some advise, if you
can.]

Which Python library would you use for developing a small Jabber client?

jabber.py (seems to be dead since 2003)
http://jabberpy.sourceforge.net/

pyxmpp (looks like the "official" python library)
http://pyxmpp.jabberstudio.org/

xmpp.py (a russian alternative. Very well documented and apparently quite
complete)
http://xmpppy.sourceforge.net/ 

Anything else?

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


Re: New to python

2005-08-18 Thread Alessandro Bottoni
pcaro8a wrote:
> I am new to python I am trying to install the numeric library and I
> get the following error:
> 
> error: Python was built with version 6 of Visual Studio, and
> extensions need to
> be built with the same version of the compiler, but it isn't installed.
> 
> Do I need Visual Studio to make this work or is there any other reason
> for this message?

Well, the message is clear: the Python interpreter and PyNumeric were not
built with the same version of the MS compiler. Did you get both of them
from the same repository? Did you check the python version required by
PyNumeric before installing it? If so, try to contact the PyNum people and
ask for help.

BTW: to fix this problem, you should either:
1) borrow a copy of VC6.X and (re)compile PyNumeric with it (or find someone
that can do this for you on the Net. Do not look at me: I'm using Linux.)
2) compile both the Python interpreter and PyNumeric with the same compiler,
using a compiler of your choice (as long as it is a supported ANSI C
compiler)

Given the open source nature of Python you _could_ download its source and
recompile the interpreter with the compiler of your choice. You can do the
same with its extensions. Unfortunately, as you can imagine, compiling the
interpreter and its extension from their sources can be quite hard, in
particular if you have to use a compiler other from the standard (MSVC on
Windows, I think).

Should you be forced to recompile your stuff, have a look at the
www.python.org site and at the official documentation. You will find a
section devoted to the task of compiling python from source with a list of
the supported compilers (and have a experienced C programmer at hand, if
possible).

HTH

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


Re: Database of non standard library modules...

2005-08-19 Thread Alessandro Bottoni
Robert Kern wrote:

> Jon Hewer wrote:
>> Is there an online database of non standard library modules for Python?
> 
> http://cheeseshop.python.org/pypi
> 

Actually, there are many other Python source code and apps repositories.
Here a few links, just in case you was not aware of them:

http://mu.arete.cc/pcr/
http://www.vex.net/parnassus/
http://pythonical.sourceforge.net/
http://www.strout.net/python/intro.html 

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


Re: Network Programming Information

2005-08-22 Thread Alessandro Bottoni
John Walton wrote:

> Hello. It's me again.  Thanks for all the help with
> the Python Networking Resources, but does anyone know
> what I'll need to know to write a paper on Network
> Programming and Python.  Like terminology and all
> that.  Maybe I'll have a section on socketets, TCP,
> Clients (half of the stuff I don't even know what it
> means).  So, does anyone know any good websites with
> Network Programming information.  Thanks!

John,
I think this book contains everything you need to know both for writing a
paper and for writing code:

Foundations of Python Network Programming
by John Goerzen

http://www.amazon.com/exec/obidos/tg/detail/-/1590593715/qid=1124694590/sr=2-1/ref=pd_bbs_b_2_1/103-4249885-5594254?v=glance&s=books

It is a fine book and a good investement.

CU

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


Re: win32 - associate .pyw with a file extension...

2005-08-22 Thread Alessandro Bottoni
[EMAIL PROTECTED] wrote:

> Hello!
> 
> I'm trying to associate a file extension to my wxPython script so that
> all I have to do is double click on the file and my python script will
> load up with the path of that file.
> 
> For instance, I've associated all .py files to be opened up with
> emacs.exe.  If I double click on a .py file, emacs.exe would open up
> with that file in its buffer.
> 
> Is there a way to do this with a non-exe (wxPython script)?  Everytime
> I try to associate a certain file extension (right clicking file->Open
> with->Choose program) with my python script (.pyw) windows states that
> I do not have a valid win32 program.  Is there a way to do this with a
> python script?  Thank you for your time.


As long as I can see, you are trying to associate your .pyw extension
directly with your python script, let say "MyProgram.pyw". This cannot work
because Windows does not know how to run MyProgram.pyw itself. You have to
associate the .pyw extension with the python interpreter. The name of your
script has to be passed to python on the command line (together with its
command line parameter). That is, Windows has to be requested to executed
this command line:

c:/.../python_directory/python.exe MyProgram.pyw FirstParam SecondParam

Most likely, you are trying to execute this, instead:

c:/.../MyPrograDir/MyProgram.pyw FirstParam SecondParam

HTH

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


Re: New Arrival to Python

2005-08-25 Thread Alessandro Bottoni
Norm Goertzen wrote:

I can just answer about books:

> -Programming Python, 2nd Edition; Mark Lutz
Quite good. Exhaustive and authoritative. The 1st edition was questionable
but the second one is very fine.

> -Python Standard Library; Fredrik Lundh
Quite a need for a beginner. The HTML docu of Python is huge and a little
bit confusing at first. This book can avoid you a lot of search-and-read
work.

> -Python & XML; Fred L. Drake, Jr., Christopher A. Jones
Required if you plan to work with XML. (there are other books regarding this
topic, anyway)

> -Python Cookbook; Alex Martelli, David Ascher
The most useful book after your first week of real work with python.

> -Learning Python, 2nd Edition; David Ascher, Mark Lutz
Excellent primer. Probably too elementar for a professional programmer.

> -Python Programming on Win32; Mark Hammond, Andy Robinson
Excellent book for Windows users. Exhaustive and clear.

> -Text Processing in Python; David Mertz
Very interesting book on a very common programming task. Read it if you have
time.

> -Python Cookbook, 2nd Edition; David Ascher, Alex Martelli, Anna
> Ravenscroft
I have the 1st edition and it is very fine. The second one can just be
better.

HTH

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


Re: Embedding Python in other programs

2005-08-26 Thread Alessandro Bottoni
Thomas Bartkus wrote:

> Name: lib64python2.4-devel
> Summary: The libraries and header files needed for Python development
> 
> Description: The Python programming language's interpreter can be extended
> with dynamically loaded extensions and can be embedded in other programs.
> This package contains the header files and libraries needed to do these
> types of tasks.
> --
> 
> 
> *** The Python programming language's interpreter ... can be embedded in
> other programs. ***
> 
> That's very intriguing!
> But I can't seem to locate much information about this.
> 
> Can anyone direct me to greater enlightenment?
> Thomas Bartkus

There is a section of the official documentation devoted to extending and
embedding python:

http://docs.python.org/ext/ext.html 

There are a few articles on this topics on the web, as well. Search
"embedding python" with Google.
---
Alessandro Bottoni
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Integrate C source in a Python project

2005-08-26 Thread Alessandro Bottoni
billiejoex wrote:

> Hi all.
> I was wondering if it ispossible to integrate C source in a python
> project.
> 
> Best regards

Yes, of course. Have a look here:

http://docs.python.org/ext/ext.html

There are two nice tools for this:

SWIG
http://www.swig.org/Doc1.1/HTML/Python.html

SIP
http://www.river-bank.demon.co.uk/docs/sip/sipref.html

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


Re: Any projects to provide Javascript-style client-side browser access via Python?

2005-08-27 Thread Alessandro Bottoni
Kenneth McDonald wrote: 
> So anyone know if there are projects underway on this?

As long as I know, Mozilla (as Firefox, Thunderbird and Sunbird) can host
Python as an internal scripting language thanks to PyXPCOM (the Python
binding to the XPCOM cross-platform COM technology used by Mozilla). In
this case, you have to recompile Mozilla from source to enable the PyXPCOM
support (that is: you will end up having a "custom" Mozilla to distribute
to your users).

Have a look at www.mozilla.org and www.mozdev.org and/or search for PyXPCOM
on Google.

(Most likely, something like that is available for Konqueror and others
Linux browsers, as well)

HTH

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


Re: Python library/module for MSAccess

2005-08-27 Thread Alessandro Bottoni
Christos Georgiou wrote:
> I think the OP wants to *use* .mdb files on a linux system without using
> any msjet*.dll libraries.

Looks like you need a .mdb driver for the Python DB-API. Have a look here:
http://www.python.org/topics/database/
http://www.mayukhbose.com/python/ado/ado-connection.php (ADO)
http://www.vex.net/parnassus/ (Python Vaults of Parnassus)

Have a look at Kexi, as well (KDE based, no Python involved): 
http://www.koffice.org/kexi/
http://www.kexi-project.org/

HTH

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


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

2005-09-01 Thread Alessandro Bottoni
wen wrote:

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

No, please, don't say that. It is _not_ Python's fault.

PyMol is a _large_ and _complex_ piece of software. I would be happy to
understand a _very small_ part of its source code after having studied
Python for just a week or so.

Python is one of the easiest programming language around but it cannot make
simple a complex task like molecular design or molecular dynamic (I'm a
chemist and I can understand your disappointment).

You will have to wait _months_ before being able to understand such a
complex piece of software well enough to be able to play with its source
code. But... do you really need to play with the source code of this
program? Do you really have to tweak its code to fit your needs? Could not
be enough to write some plug-in, some wrapper or some other kind of
"external" program? This would be much easier.

HTH

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


Decrypting GPG/PGP email messages

2005-09-01 Thread Alessandro Bottoni
I know you will shake you head sadly but... I really have to perform such a
suicidal task (even if for a short time and just for internal use).

I have to send by email (over the open internet) a XML file containing
_system commands_ (yes: the kind of stuff like "rm -dfr /") to a server and
have a Python program sitting on this server, fetching and parsing the
e-mail message and executing the commands (maybe with _root privileges_).

Of course, I want to be sure that only the allowed people is able to send
such dangerous messages to my server so I will ask my users to encrypt and
digitally sign their messages using Thunderbird, Enigmail and GPG as
described in this very fine tutorial:

http://goldenspud.com/webrog/archives/2005/03/10/encrypt-encrypt/

So far, so good, but I still have a couple of doubts about the server side:

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

2) I did not find any mention of _encrypted attachments_ on the Net. Does
anybody know of a tutorial or a guide that explains how to encrypt (with
Thunderbird/Enigmail) and decrypt (with Python) the (ANSI text) files
attached to a email message?

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


Re: Are there free molecular libraries written in python ?

2005-09-01 Thread Alessandro Bottoni
Xiao Jianfeng wrote:

> Hi,
> 
> Are there any free libraries for the analysis and manipulation of
> molecular structural models, implemented in the Python programming
> language ?
> 
> Thanks.

What about the followings? 
MMTK = http://starship.python.net/crew/hinsen/MMTK/
PyMol = http://pymol.sourceforge.net/ (Just model visualization, I'm afraid)
Chimera = http://www.cgl.ucsf.edu/chimera/

Other projects you should be aware of:
SciPy = http://www.scipy.org/
BioPython = http://biopython.org/scriptcentral/

Other Python/Science resources and articles:
http://starship.python.net/crew/hinsen/
http://www.dalkescientific.com/writings/PyCon2004.html
http://www.foretec.com/python/workshops/1998-11/demosession/dalke.html
http://www.swig.org/papers/Py97/beazley.html

And, of course, have a look at these Python software repositories:
http://www.python.org/pypi
http://www.vex.net/parnassus/

And at these generic software repositories:
http://freshmeat.net/
http://sourceforge.net/
(search or browse for scientific/chemistry)

HTH

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


Help for NewBies at WikiBooks

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

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

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

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


Re: Decrypting GPG/PGP email messages

2005-09-03 Thread Alessandro Bottoni
Piet van Oostrum wrote:
> What benefit is there in encrypting the messages? It would only prevent
> people intercepting the message from seeing what's inside, but it won't
> give you any additional protection on the server.

You are right. Bad guys can still try to send garbage to my system and, with
some luck, can mess everything up. After reading your message I decided to
add some more control over what the remote user can do and how he can reach
the server:
- a list of allowed users (based on e-mail identity plus OTP, see below)
- a list of allowed commands (still with root-level ones, I'm afraid)
- chroot for the most dangerous commands, when possible
It is still dangerous but, frankly, I could not do any better.

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

You are right again. As a consequence, I decided to add a one-time-password
to the encrypted message, in order to be sure of the sender identity and of
the uniqueness of the message (the OTP works as a sequence item identifier,
as well).

I'm going to use my own implementation of OTP because the existing mechanism
are devoted to protect the remote login channel and cannot be easily
adapted to my weird e-mail-based mechanism. Anyway, I'm going to use a
(encrypted) very long pseudo-random alpha-numeric sequence as a OTP so it
should be quite safe.

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

Thanks for this info. I'm studying it.

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


Is there anything "better" than impalib/poplib?

2005-09-07 Thread Alessandro Bottoni
Is there any module or interface that allow the programmer to access a
imap4/pop3 server in a more pythonic (or Object Oriented) way than the
usual imaplib and popolib? 

I mean: is there any module that would allow me to query the server for
specific messages (and fetch them) in a way similar to a OODB?

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


Re: determine if os.system() is done

2005-09-07 Thread Alessandro Bottoni
Xah Lee wrote: 
> of course, i can try workarounds something like os.system("gzip -d
> thiss.gz && tail thiss"), but i wish to know if there's non-hack way to
> determine when a system process is done.

Well, if you use a function of the "popen" family, you get some kind of
return value from the subprocess on your "output" pipe. You should be able
to determine if your subprocess has terminated by examining (parsing) this
output pipe.

If you use os.system(), you should get a single return value (usually "None"
or a error code) that you can use for this task.

In both cases, you may have to use a loop (sleep(x)) to wait for the return
value (and check it) from within your code.

Have a look at the docu of the os.process module for details. (Maybe the
newer "subprocess" module is a better choice...)

HTH

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


Re: Is it possible to detect if files on a drive were changed without scanning the drive?

2005-09-12 Thread Alessandro Bottoni
Claudio Grondi wrote:
> After connecting a drive to the system (via USB
> or IDE) I would like to be able to see within seconds
> if there were changes in the file system of that drive
> since last check (250 GB drive with about four million
> files on it).
> 
> How to accomplish this? (best if providing
> directly a Python receipe for it :-)
> Do available file systems have something like
> archive attribute assigned to the root directory
> of the drive?
> I suppose not. Am I right?

On Linux there is the FAM (File Alteration Module) for this, as long as I
know. Maybe Python has a wrapper/binding for it.

> I ask this question having Microsoft Windows 2000
> and Windows proprietary NTFS file system in mind,
> but I am also interested to know it about Linux or
> Unix file systems.

As long as I know, on Windows there are a few specific "hooks" to perform
such a task. They are provided by the MS API for the NTFS/HPFS file
systems. I do not think Python implements anything so "low level", anyway.
Check the docu to be sure.

> I know, that looking for the archive attribute of the
> top directories doesn't help when the change
> happened to files somewhere deeper in the
> hierarchy of directories.

Right. It does not help.

Consider this: if are accessing a network file system, you can intercepts
the calls to the virtualization layer (NFS or NetBIOS). Most likely, Python
can support you in performing this task.

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


Re: Unfortunate newbie questions!

2005-09-12 Thread Alessandro Bottoni
> -   What book or doc would you recommend for a thorough
>thrashing of object oriented programming (from a Python
>perspective) for someone who is weak in OO? In other
>words, how can someone learn to think in an OO sense,
>rather than the old linear code sense? Hopefully, heavy
>on problems and solutions!

If OOP is the problem, you could try this:
Object Oriented Analysys
Peter Coad, Edward Yourdon
Prentice Hall
Old by quite informative

As an alternative, have a look at the following ones.

Thinking in Python:
http://www.mindview.net/Books/TIPython

Dive into Python:
http://diveintopython.org/

How to Think Like a Computer Scientist:
http://www.ibiblio.org/obp/thinkCSpy/

>  -  In college, I came to admire the Schaum's Outline book
>approach--again heavy on problems and solutions! What's
>the closest Python equivalent?

Maybe this:

Python Cookbook
Alex Martelli, David Ascher
O'Reilly

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


Re: PyGTK or wXPython?

2005-09-13 Thread Alessandro Bottoni
Rod W wrote:

> I'm just starting out on Python but my primary goal is to provide
> applications with some user interface (GUI).
> 
> Can someone point me to a good comparison of whether I should use
> wxPython (with wxGlade I assume) or PyGTK (with Glade I assume)?
> 
> I'd prefer open source (not necessarily GPL though) tools.
> 
> Rod

Both the wxWidgets and the GTK web sites have some good comparison sheet
and/or a "why I should use this platform" page. Many reviews and articles
can be found on the web by searching for "PyGTK wxPython comparison" or
"Python GUI toolkits".

Anyway, the main difference between PyGTK and wxPython is the type of GUI
that is generated on Windows. PyGTK uses the Windows porting of GTK and has
its own Look&Feel (similar to Gnome, I could say). wxPython, like
wxWidgets, uses the native MFC widgets and have the same Look&Feel of any
other MFC application (indistiguishable from any other native Windows app).
On Linux, PyGTK and wxPython are equivalent because both use GTK for
rendering the GUI. (I do not use/program/own any McOS system, so I cannot
tell you anything about the Apple Platform).

Beside this, wxPython (and wxWidgets) is often told to be more complete, 
better documented and better supported than GTK/PyGTK.

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


O'Reilly book on Twisted

2005-09-14 Thread Alessandro Bottoni
Most likely, you are already aware of this but, just in case...

O'Reilly is going to publish a nook on Twisted:

http://www.oreilly.com/catalog/twistedadn/

http://www.amazon.com/exec/obidos/tg/detail/-/0596100329/qid=1126714644/sr=1-1/ref=sr_1_1/102-3430080-1376942?v=glance&s=books

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


Re: Python on AIX 4.3.

2005-09-14 Thread Alessandro Bottoni
David Gutierrez wrote:

> Hello Everyone,
> I'm trying to install Python on an aix 4.3.3. but keep on getting a failed
> attempt with the following errors.
> 
> ld: 0711-317 ERROR: Undefined symbol: .pthread_mutex_lock
> ld: 0711-317 ERROR: Undefined symbol: .pthread_mutex_unlock
> ld: 0711-317 ERROR: Undefined symbol: .pthread_cond_signal
> ld: 0711-317 ERROR: Undefined symbol: .pthread_cond_wait
> ld: 0711-317 ERROR: Undefined symbol: .pthread_mutex_destroy
> ld: 0711-317 ERROR: Undefined symbol: .pthread_cond_destroy
> ld: 0711-317 ERROR: Undefined symbol: .pthread_mutex_init
> ld: 0711-317 ERROR: Undefined symbol: .pthread_cond_init
> ld: 0711-317 ERROR: Undefined symbol: .pthread_self
> ld: 0711-317 ERROR: Undefined symbol: .pthread_attr_init
> ld: 0711-317 ERROR: Undefined symbol: .pthread_attr_setscope
> ld: 0711-317 ERROR: Undefined symbol: .pthread_create
> ld: 0711-317 ERROR: Undefined symbol: .pthread_attr_destroy
> ld: 0711-317 ERROR: Undefined symbol: .pthread_detach
> ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more
> information.
> collect2: ld returned 8 exit status
> make: 1254-004 The error code from the last command is 1.
 
Are you trying to install a posix-thread- (pthread) -enabled Python
interpreter on a not-pthread machine? It looks like the pthread module is
missing.

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


Re: IDE, widget library

2005-09-15 Thread Alessandro Bottoni
Thomas Jollans wrote:

> I a looking for a python IDE for gnu/linux that :
> - has decent sytax highlighting (based on scintilla would be neat)
> - has basic name completition, at least for system-wide modules
> - has an integrated debugger
> - is open source, or at least free of charge

There are a few nice IDEs at www.wxwidgets.org. Have a look at the
"applications" page. I just use Kedit or Gedit.

> an integrated GUI designer would of course be cool, but cannot be
> counted as a requirement.

Have a look at Glade (with PyGTK) or wxGlade (with wxPython).

> With that I come to the second question:
> What cross-platform GUI libraries are there ? cross-platform meaning
> functional and free on (at least) X11 and Win32
> PyQT obviously doesn't count because qt3 is not free on windows.
> Tk is ugly. (how well) is Tile supported with python ?
> does PyGTK/Glade work on win32 ?

Try wxPython (Based on wxWidgets). Really "free" (LGPL'ed = MIT license) on
all platforms, well-engineered, documented and supported, native look&feel
on all platform. Need anything else? ;-)

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


Re: Python game coding

2005-09-18 Thread Alessandro Bottoni
Lucas Raab wrote:

> Saw this on Slashdot
> (http://developers.slashdot.org/article.pl?sid=05/09/17/182207&from=rss)
> and thought some people might be interested in it. Direct link to the
> article is
>
http://harkal.sylphis3d.com/2005/08/10/multithreaded-game-scripting-with-stackless-python/
> 

Very interesting! 

BTW: I wonder if and when someone will use stackless python or pygame as a
basis for developing a _visual_ development environment for 2D
games/multimedia like Macromedia Director. It would be a killer app.

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


Re: Python game coding

2005-09-18 Thread Alessandro Bottoni
Diez B. Roggisch wrote:

> Diez B. Roggisch wrote:
>> 
>>> Very interesting!
>>> BTW: I wonder if and when someone will use stackless python or pygame
>>> as a
>>> basis for developing a _visual_ development environment for 2D
>>> games/multimedia like Macromedia Director. It would be a killer app.
>> 
>> 
>> Blender. It currently doesn't use stacklass AFAIK, but that shouldn't be
>> too hard to fix.
> 
> Oop - I read 3d instead of 2d.. Hm, 3d _can_ do 2d, so just don't allow
> your cameras do fancy stuff like rotating :)
> 
> Diez

Very interesting, anyway, both in 2D and in 3D. It looks like I have to
study Blender a little bit... :-)

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


regular expression for javadoc style comment

2004-12-16 Thread Alessandro Crugnola
Hi all,
i need to use a regular expression to match javadoc style comments in a file,
something like
/**
 * Constructs a new Call instance.
 *
 * @param object the object the Function shall be executed on
 * @param func the Function that shall be executed
 * @throws IllegalArgumentException if neigther the object or the 
function is not available.
 */
i'm finiding many difficulties to write a valid regular expression
ale
--
http://mail.python.org/mailman/listinfo/python-list


ANN: pytest-nodev v0.9.3 - Test-driven code search

2016-02-25 Thread Alessandro Amici
I am pleased to announce the release of the new beta release of
pytest-nodev (was pytest-wish) a test-driven code search plugin for pytest:

https://pytest-nodev.readthedocs.org/en/stable/quickstart.html

Changes:
- renamed the package to pytest-nodev from pytest-wish (sorry!)
- refuse to run potentially dangerous `--wish-from-all` by default and...
- ... document how to run inside a container to safely enable all the
features
- simpler command line usage
- more documentation and references to the academic research on the
test-driven code search subject

Development effort is directed to fixing bugs and writing better
documentation before the 1.0 release. Help is welcomed and appreciated:

https://github.com/nodev-io/pytest-nodev

User questions are best directed to
http://stackoverflow.com/search?q=pytest-nodev and general questions can be
sent to pytest-...@python.org.

Thanks,
Alessandro
-- 
https://mail.python.org/mailman/listinfo/python-list


Create a cookie with cookielib

2007-02-03 Thread Alessandro Fachin
Hi, i am trying to forge a new cookie by own with cookielib. But i don't
still have success. This a simply code:

import cookielib, urllib, urllib2
login = 'Ia am a cookie!'
cookiejar = cookielib.CookieJar()
urlOpener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar))
values = {'user':login}
data = urllib.urlencode(values)
request = urllib2.Request("http://localhost/cookie.php";, data)
url = urlOpener.open(request)
print url.info()
page = url.read(50)
print page
print cookiejar

the output of this is:

Date: Sat, 03 Feb 2007 10:20:05 GMT
Server: Apache
X-Powered-By: PHP/5.1.6
Set-Cookie: user=Alex+Porter; expires=Sat, 03-Feb-2007 11:20:05 GMT
Content-Length: 11
Connection: close
Content-Type: text/html; charset=UTF-8

Array
(
)
]>

And here is the code of cookie.php that i've create for this example:




if anyone could help... Thank you
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Create a cookie with cookielib

2007-02-04 Thread Alessandro Fachin
Matthew Franz wrote:

> I'm not sure what you mean be forge, but if you mean set an arbitrary
> cookie manually (vs. one that was provided by the server).  just use
> add_header() in http://docs.python.org/lib/request-objects.html

Yes is exactly what i want to do... i don't known because i looked at
cookielib to set cookie data, cookie are simply http header :) Inserting
values with add_header() or addheaders() it works. Thank you

> It may be possible to use CookieJar for this purpose but I've only
> used it for manipulating cookies set by the server...
> 
> And  I would agree that Python cookie APIs are less intuitive than
> what are available in others such as Jakarta HttpClient
> 
> - mdf


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


Re: Create a cookie with cookielib

2007-02-04 Thread Alessandro Fachin
John J. Lee wrote:

> Fine, but see my other post -- I think you misunderstand how cookies
> work.

Maybe you misunderstand me... While i wrote "cookie are simply http
header :)" i want to said that i've look at wrong thing, cookielib are not
needed... Anyway thank you for help, regards.

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


urllib2 request htaccess page through proxy

2007-02-11 Thread Alessandro Fachin
I write this simply code that should give me the access to private page with
htaccess using a proxy, i don't known because it's wrong... 


import urllib,urllib2

#input url
url="http://localhost/private/file";

#proxy set up
proxy_handler = urllib2.ProxyHandler({'http': 'http://myproxy:'})

#htaccess set up
user="matteo"
password="matteo"
passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
passman.add_password(None, url, user, password)
authhandler = urllib2.HTTPBasicAuthHandler(passman)

opener = urllib2.build_opener(proxy_handler,authhandler)
urllib2.install_opener(opener)

#open the url
req=urllib2.Request(url)
data=urllib2.urlopen(req).read()
print data

i get no access on access.log from apache2 and nothing from the proxy in
tcpdump log. If i use only the proxy with a page that doesn't use htaccess
it works... if anyone could help,regards...




Traceback (most recent call last):
  File "proxy.py", line 22, in ?
data=urllib2.urlopen(req).read()
 
File 
"/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/urllib2.py",
line 130, in urlopen
return _opener.open(url, data)
 
File 
"/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/urllib2.py",
line 364, in open
response = meth(req, response)
 
File 
"/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/urllib2.py",
line 471, in http_response
response = self.parent.error(
 
File 
"/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/urllib2.py",
line 396, in error
result = self._call_chain(*args)
 
File 
"/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/urllib2.py",
line 337, in _call_chain
result = func(*args)
 
File 
"/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/urllib2.py",
line 741, in http_error_401
host, req, headers)
 
File 
"/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/urllib2.py",
line 720, in http_error_auth_reqed
return self.retry_http_basic_auth(host, req, realm)
 
File 
"/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/urllib2.py",
line 730, in retry_http_basic_auth
return self.parent.open(req)
 
File 
"/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/urllib2.py",
line 364, in open
response = meth(req, response)
 
File 
"/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/urllib2.py",
line 471, in http_response
response = self.parent.error(
 
File 
"/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/urllib2.py",
line 402, in error
return self._call_chain(*args)
 
File 
"/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/urllib2.py",
line 337, in _call_chain
result = func(*args)
 
File 
"/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/urllib2.py",
line 480, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 401: Authorization Required




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


sorting mesh data an from abaqus simulation

2009-02-02 Thread Alessandro Zivelonghi
Hello there :) ,

I am a python newbie who needs help with tables(lists?) and other data
structures. My mechanical engineering simulation program (Abaqus) use a
Python env to access model data and results from a simulation. For me a
model means a "mesh" of that model, i.e. a lists of nodes and elements which
discretized the CAD model.
In Abaqus each mesh has the following structure (see "
http://www.tecnopolis.eu/upload/mesh.inp";):

- a list of NODES in form of a table ( nodelabel_n, coordinatex,
coordinatey)

- and a list of ELEMENTS also in form of a table. Each element refers to
three nodes (which must be in the list of nodes) and the table looks like
this

 (elementlabel_n, node_n1, node_n2, node_n3)

Through following py script I can access all nodes (--> *N*) and elements
(--> *EL*) from the "mesh-1.odb" file (
http://www.tecnopolis.eu/upload/mesh-1.odb) where the simulation results are
stored.

*from odbAccess import *
from odbSection import *

nameodb = 'mesh-1'


path = '/onepath/' + nameodb + '.odb'
odb = openOdb(path)

**N = odb.rootAssembly.instances['PART-1-1'].nodes
*
*EL = odb.rootAssembly.instances['PART-1-1'].elements
*
Info:
to get a node label, for example the label of the node object n5 in the list
Ntop:  *Ntop[5].label*
to get the x coordinates of that node: *Ntop[5].coordinates[0]*

In particular I am interested in the node subset "TOP" (which represents all
the nodes at the top of my model)

*Ntop = odb.rootAssembly.instances['PART-1-1'].nodeSets['TOP'].nodes
*
Problem:
1) the list of nodes Ntop contains all the node labels [2673,   2675,
2676,   2677,   2678,   3655,   3656, 119939, 124154, 127919] already
ordered in ascending order.
What I need is the same list *ordered by coordinate_x* of each node, i.e.
from left to right in the model (unfortunately, for example node 124154
cames before node 3656 in the model, if you read the model from left to
right)


1b) I don't understand which kind of data are EL, N, Ntop (list?) and how
can I sort Ntop  with the criterium based on coordinate_x (coordinate[0])

Many thanks, Alex

-- 







> Alessandro Zivelonghi
>
> http://www.tecnopolis.eu
>
> skype: alexzive
>
> "Energy and persistence conquer all things."
> Benjamin Franklin (1706 - 1790)
>
--
http://mail.python.org/mailman/listinfo/python-list


Re: locate items in matrix (index of lists of lists)

2009-03-20 Thread Alessandro Zivelonghi
Many Thanks guys!

and what if I need to look ONLY into the second and third columns,
excluding the first item of each rows?

for example if x = 3 I need to get  [0] and not [0,1]

many thanks, Alex


2009/3/20 Tino Wildenhain :
> Alexzive wrote:
>>
>> Hello there,
>>
>> let's suppose I have the following matrix:
>>
>> mat = [[1,2,3], [3,2,4], [7,8,9], [6,2,9]]
>>
>> where [.. , .. , ..] are the rows.
>>
>> I am interested into getting the "row index" of all the matrix rows
>> where a certain number occurs.
>> For example for 9 I should get 2 and 3 (starting from 0).
>> For 10 I should get an error msg (item not found) and handle it.
>>
>> How to get the"row indexes" of found items?
>>
>> In practice I am looking for an equivalent to "list.index(x)" for the
>> case "lists of lists"
>
> Actually you are not ;) list.index(x) gives you the index of the
> first occurence of the item.
>
> So what you seem to want is a list of indexes to the lists where
> your item is contained.
>
> Something like:
>
> x=9
>
> [idx for idx,row in enumerate(mat) if x in row]
>
> should do.
>
>>
>>
>> PS: this is just a simplified example, but I have actually to deal
>> with large matrices [~50 * 4]
>
> This is something I'd consider either reordering your data (for example
> into dictionary) or look at scipy/numpy.
>
> Regards
> Tino
>



-- 
=
Alessandro Zivelonghi Ziller

Max-Planck-Institut für Plasmaphysik, Garching, DE
Middle-Age Fusion Engineer
===
http://www.tecnopolis.eu
skype: alexzive
" I'm sure that in 1985 plutonium is available in every corner drug
store, but in 1955 it's a little hard to come by"
Dr. D.Brown
--
http://mail.python.org/mailman/listinfo/python-list


Re: locate items in matrix (index of lists of lists)

2009-03-20 Thread Alessandro Zivelonghi
this seems to work. Thanks!
Alex

x= 3
indices = [i for i, row in enumerate(mat) if x in row[1:]]

2009/3/20 Chris Rebert :
> On Fri, Mar 20, 2009 at 4:34 AM, Alessandro Zivelonghi
>  wrote:
>> Many Thanks guys!
>>
>> and what if I need to look ONLY into the second and third columns,
>> excluding the first item of each rows?
>>
>> for example if x = 3 I need to get  [0] and not [0,1]
>
> indices = [i for i, row in enumerate(mat) if 1<= i <= 2 and 3 in row[1:]]
>
> Cheers,
> Chris
>
> --
> I have a blog:
> http://blog.rebertia.com
>



-- 
=
Alessandro Zivelonghi Ziller

Max-Planck-Institut für Plasmaphysik, Garching, DE
Middle-Age Fusion Engineer
===
http://www.tecnopolis.eu
skype: alexzive
" I'm sure that in 1985 plutonium is available in every corner drug
store, but in 1955 it's a little hard to come by"
Dr. D.Brown
--
http://mail.python.org/mailman/listinfo/python-list


Regexp problem when parsing a string

2010-03-21 Thread Alessandro Marino
I'm a beginner and I was trying to write a program to parse recursively all
file names in a directory specified as parameter. The problem is that I get
a "None" printed to stdout when a file is positively matched. While when the
file name doesn't match the regexp the output seems ok.

C:\>c:\python.exe g:\a.py sample
> foo - bar.txt , first part is: foo
None
skipping: foo.txt

Instead I expect an output like this one:

C:\>c:\python.exe g:\a.py sample
> foo - bar.txt , first part is: foo
None
skipping: foo.txt

Could anyone help me to figure out why "None" appears in the putput?

Thanks and regards,
Ale


a.py
Description: Binary data
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: reading XML file using python

2010-05-17 Thread Alessandro Molari
I can suggest you the lxml library at http://codespeak.net/lxml/

I've already used it and I think it works very well, it's more pythonic 
than the built-in xml library

For a simple use of xml functionalities you can read 
http://codespeak.net/lxml/tutorial.html


Alessandro Molari

On Monday 17 May 2010 10:34:51 shanti bhushan wrote:
> Hi ,
> i am new to python.i want to read the XML file using python it ,by
> using DOm or SAX any of them.
> I want to read the http://www.google.com(any hyper text) from XML 
and
> print that.
> please give me the sample program for this.
> regards
> Shanti Bhushan
> Bangalore,India
-- 
http://mail.python.org/mailman/listinfo/python-list


subclassing str

2010-11-06 Thread not1xor1 (Alessandro)

Hi,

I'd like to know what is the best way to subclass str
I need to add some new methods and that each method (both new and str 
ones) return my new type


For instance I've seen I can do:


class mystr(str):

   def between(self, start, end):
  i = self.index(start) + len(start)
  j = self.index(end, i) + len(end)
  return self[i:j], self[j:]

   def replace(self, old, new='', count=-1):
  return mystr(str.replace(self, old, new, count))

if __name__ == '__main__':

   s = mystr('one two  four')
   print s
   print type(s)
   b,r = s.between('<', '>')
   print b
   print r
   print type(b)
   print type(r)
   c = s.replace('three', 'five')
   print c
   print type(c)


when I ran it I get:

one two  four

three>
 four


one two  four



I guess that if I had redefined the slice method even 'between' would 
have returned 


I wonder if I have to redefine all methods one by one or if there is a 
sort of hook to intercept all methods calls and just change the return 
type


thanks

--
bye
!(!1|1)
--
http://mail.python.org/mailman/listinfo/python-list


Re: subclassing str

2010-11-07 Thread not1xor1 (Alessandro)

Il 07/11/2010 07:41, Chris Rebert wrote:


You could subclass UserString instead of str; all of UserString's
methods seem to ensure that instances of the subclass rather than just
plain strs or UserStrings are returned. See
http://docs.python.org/library/userdict.html#UserString.UserString


I'll have a look at it, thanks


But you should also consider whether your additions absolutely *must*
be methods. Merely instead defining some functions that take strings
as parameters is obviously a simpler, and probably more performant,
approach.


I regularly save web pages (mostly scientific research abstracts) from 
various web sites and use a python script to strip them of ads and 
unneeded informations, embedding the images directly in the html file 
(as base64 encoded data) and at times joining multiple pages into just one


since those sites often change the format of their files I've to 
modify my script accordingly


I'm already using plain functions, but thought that wrapping most of 
them in a str subclass would let me save some time and yield cleaner 
and more manageable code



If you insist on subclassing str, there's no such hook; you'll have to
override all the methods yourself.*


I'll try this route too (at least for the methods I need)
thanks for your help
--
bye
!(!1|1)
--
http://mail.python.org/mailman/listinfo/python-list


Re: subclassing str

2010-11-10 Thread not1xor1 (Alessandro)

Il 09/11/2010 03:18, Lawrence D'Oliveiro ha scritto:


How exactly does

a.f(b, c)

save time over

 f(a, b, c)


unfortunately in real world you have:

objId = objId.method(args)

vs.

objId = moduleName.method(objId, args)

I know you can use "from moduleName import *", but IMHO that produces 
code much harder to manage and extend

--
bye
!(!1|1)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Building Time Based Bins

2005-03-20 Thread alessandro -oggei- ogier
MCD wrote:
> This goes on throughout a 12hr. period. I'd like to be able to place
> the low and high values of the additional fields in a single line
> divided into 5min intervals. So it would look something like this >>
> 
> 1235 22 88
> 1240 31 94

what about a sane list comprehension madness ? 

lines = """\
1231 23 56
1232 25 79
1234 26 88
1235 22 34
1237 31 85
1239 35 94
"""

input = lines.split('\n') # this is your input

div = lambda x: (x-1)/5

l = dict([
(div(x), []) for x,y,z in [
tuple([int(x) for x in x.split()]) for x in input if x
]
])

[
l[x[0]].append(x[1]) for x in
[
[div(x), (x,y,z)] for x,y,z in
[
tuple([int(x) for x in x.split()]) for x in input if x
]
]
]

print [
[max([x[0] for x in l[j]]),
 min([x[1] for x in l[j]]),
 max([x[2] for x in l[j]])
] for j in dict([
(div(x), []) for x,y,z in [
tuple([int(x) for x in x.split()]) for x in input
if x
]
  ]).keys()
]


i think it's a bit memory hungry, though

cya,
-- 
Alessandro "oggei" Ogier <[EMAIL PROTECTED]>
gpg --keyserver pgp.mit.edu --recv-keys EEBB4D0D


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


about application deployment

2007-03-09 Thread Alessandro de Manzano
Hello,

I'ld ask you all about deployment of python applications.

Sometimes (if not most times..) I would make deployment easy (easier)
for my customers (and for me too...)

What I mean, would be very useful to have a "jar-like" archive/single
file / multiple platform in order to deploy also complex applications
with many modules.

I know about "py2exe", it's nice but it's Windows only, I would need
something multiplatform or at least available also for other platforms
(*nix, Mac maybe, ...)

My impression is that Python is a great language but a bit "messy"
about on field deployment...

What am I missing ? :)
What are your experiences (and solutions ?) for this issues ?

Many thanks in advance!


bye!

Ale

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


Re: pythonize this!

2010-06-16 Thread Alessandro [AkiRoss] Re
On Jun 15, 1:49 pm, superpollo  wrote:
> goal (from e.c.m.): evaluate
> 1^2+2^2+3^2-4^2-5^2+6^2+7^2+8^2-9^2-10^2+...-2010^2, where each three
> consecutive + must be followed by two - (^ meaning ** in this context)


My functional approach :)

from operator import add
from functools import reduce

def square(l):
  return (v**2 for v in l)

def sign(l, s):
  i = 0
  for v in l:
yield s[i % len(s)] * v
i += 1

print reduce(add, sign(square(xrange(1, 2011)), [1, 1, 1, -1, -1]))

(536926141)

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


Re: pythonize this!

2010-06-16 Thread Alessandro [AkiRoss] Re
On Jun 15, 2:37 pm, Peter Otten <__pete...@web.de> wrote:
> >>> from itertools import cycle, izip
> >>> sum(sign*i*i for sign, i in izip(cycle([1]*3+[-1]*2), range(1, 2011)))

Wow!! :D
I didn't knew cycle, great! With that i can reduce my solution (which
isn't still elegant as your) to:

print reduce(add,imap(mul, cycle([1, 1, 1, -1, -1]), (v**2 for v in
xrange(1, 2011

(536926141)
~Aki
-- 
http://mail.python.org/mailman/listinfo/python-list