[ANN] Pydev and Pydev Extensions 1.0.2 release

2006-02-17 Thread Fabio Zadrozny
Hi All,

Pydev and Pydev Extensions 1.0.2 have been released

Check http://www.fabioz.com/pydev for details on Pydev Extensions

and http://pydev.sf.net has for details on Pydev

Highlights in Pydev Extensions:
---

- New feature in the debugger: the console is available for probing when 
in 'suspendend mode'
- New feature in code analysis: Provided a way to consider tokens that 
should be in the globals
- Halt fix when too many matches where found in the go to definition.
- Code analysis minor bugs fixed.
- Error when opening browser fixed.


Highlights in Pydev:
---

- Jython debugging now working.
- Code coverage does not report docstrings as not being executed.
- Freeze when making a 'step-in' fixed in the debugger.
- Grammar generated with javacc version 4.0


Cheers,

Fabio

-- 
Fabio Zadrozny
--
Software Developer

ESSS - Engineering Simulation and Scientific Software
www.esss.com.br

Pydev Extensions
http://www.fabioz.com/pydev

PyDev - Python Development Enviroment for Eclipse
http://pydev.sf.net
http://pydev.blogspot.com


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

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


Dejavu 1.4.0 (Python ORM) release

2006-02-17 Thread Robert Brewer
Title: Dejavu 1.4.0 (Python ORM) release






Dejavu 1.4.0
http://projects.amor.org/dejavu/


I'm extremely pleased to announce the release of Dejavu 1.4.0,
a pure-Python Object-Relational Mapping library. Dejavu allows
you to create, query, and manage persistent data using your
existing knowledge of Python programming.


Features


* Data queries are expressed using pure Python; no SQL,
 no operator hacks, and no need to wrap code in strings.
* Data may be transparently stored in PostgreSQL, MySQL,
 SQLite, Access, or SQL Server databases, as well as
 in flat files (using shelve), and caching proxies.
 You can create and combine custom storage systems
 for your own integration and performance needs.
* Easy associations between Unit classes.
* Full thread-safety for reliable use in web applications
 and other concurrent environments.
* Views, sorting, cross-tabs, and other analysis tools.
* Unit Collections, plus Engines and Rules to form powerful
 end-user query and reporting interfaces.


What's new in 1.4
-

* Full LEFT, RIGHT, and INNER JOIN support.
* Optimized and introspectable To-One and To-Many associations.
* Arbitrary names for Unit.ID's (primary keys).
* Support for multiple ID's (primary keys).
* A new Schema class and other upgrade-management tools.
* Default values for UnitProperties.
* New logging hooks to help debug SQL and other storage issues.
* Fixes to support Python 2.4 bytecode and other changes.
* Inheritance support (all subclasses are recalled).
* Vastly-improved test suite.
* New recur module included, with a threaded Worker class.
* Better support for update triggers.


Dejavu is in the Public Domain, and you may use it anywhere with
no obligation whatsoever.

User documentation and a full Trac site are available at:
http://projects.amor.org/dejavu/


Robert Brewer
System Architect
Amor Ministries
[EMAIL PROTECTED]



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

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


ANN: Python Enthought Edition Version 0.9.2 Released

2006-02-17 Thread Travis N. Vaught
Enthought is pleased to announce the release of Python Enthought Edition 
Version 0.9.2 (http://code.enthought.com/enthon/) -- a python 
distribution for Windows.  This is a kitchen-sink-included Python 
distribution including the following packages/tools out of the box:

Numeric 24.2
SciPy 0.3.3
IPython 0.6.15
Enthought Tool Suite 1.0.2
wxPython 2.6.1.0
PIL 1.1.4
mingw 20030504-1
f2py 2.45.241_1926
MayaVi 1.5
Scientific Python 2.4.5
VTK 4.4
and many more...


0.9.2 Release Notes Summary
---
Version 0.9.2 of Python Enthought Edition is the first to include the 
Enthought Tool Suite Package (http://code.enthought.com/ets/). Other 
changes include upgrading to Numeric 24.2, including MayaVi 1.5 (rather 
than 1.3) and removing a standalone PyCrust package in favor of the one 
included with wxPython. Also, elementtree and celementtree have been 
added to the distribution. Notably, this release is still based on 
Python 2.3.5 and still includes SciPy 0.3.3. You'll also notice that we 
have changed the version numbering to a major.minor.point format (from a 
build number format).

see full release notes at:
http://code.enthought.com/release/changelog-enthon0.9.2.shtml

Best,

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

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


Re: file.read problem

2006-02-17 Thread wscrsurfdude
Try opening the file in 'rbU' mode. This will use universal newline mode
and convert all carriage returns to line feeds.

I tried this, but as you say, now there are 0x0A bytes extra in my
files, is there also a possibility to let all these things out, and
just get the file.

I am working on a script to get parts of raw data out of a file, and
the data I read has to be the data written in the file without CR or
LF.

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


Re: getting the line just before or after a pattern searched

2006-02-17 Thread bonono

[EMAIL PROTECTED] wrote:
 hi

 i have a file something like this

 abcdefgh
 ijklmnopq
 12345678
 rstuvwxyz
 .
 .
 .
 12345678
 .

 whenever i search the file and reach 12345678, how do i get the line
 just above and below ( or more than 1 line above/below) the pattern
 12345678 and save to variables? thanks

I would try something similar to the pairwise recipe here :

http://www.python.org/doc/2.4.2/lib/itertools-recipes.html

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


Re: Databases and python

2006-02-17 Thread Jonathan Gardner
About the filename ID - word ID table: Any good database (good with
large amounts of data) will handle the memory management for you. If
you get enough data, it may make sense to get bothered with PostgreSQL.
That has a pretty good record on handling very large sets of data, and
intermediate sets as well. Again, I can't speak about BDBs, but
something in the back of my head is saying that the entire table is
loaded into memory. If so, that's not good for large sets of data.

About base255: You can think of strings as numbers. At least, that's
how your computer sees them. Converting a number to base255 is really
silly. If it's a series of bytes (like a Python string is) then base255
is a string. You want to use an incremented number for the ID because
there are some indexes that deal with this kind of data very, very
well. If you have your number spread out like a shotgun, with clusters
here and there, the index might not be very good.

About using many tables: The best answer you are going to get is a
bunch of files---one for each word---with the names or IDs of the
files. You can store these in a single directory, or (as you'll find
out to be more efficient) a tree of directories. But this kind of data
is useless for reverse lookups. If you really do have so much data,
start using a real database that is designed to handle this kind of
data efficiently. The overhead of SQL parsing and network latency soon
gets dwarfed by lookup times anyway.

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


Re: file.read problem

2006-02-17 Thread wscrsurfdude

Farshid Lashkari wrote:
  I am working on a script to get parts of raw data out of a file, and
  the data I read has to be the data written in the file without CR or
  LF.

 So you just want to remove all the linefeeds? This should work then:

 data = data.replace('\n','')

 -Farshid

The problem is if I remove the linefeeds, I also delete readout data if
it is 0x0A, and I don't want this, because the files I readout has to
be a part of the original data. Another idea??

But still my question is why is the:
f = open('myfile,'r')
a = f.read(5000)
working in linux??

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


Re: Determing whether two ranges overlap

2006-02-17 Thread Paul McGuire

Robin Haswell wrote:
 Hey guys

 I was wondering if you could give me a hand with something. If I have two
 tuples that define a range, eg: (10, 20), (15, 30), I need to determine
 whether the ranges overlap each other.

def overlap(a,b):
return a[0] = b[0] = a[1] or b[0] = a[0] = b[1]

-- Paul

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


Re: Merging two lists of data (Pythonic way)

2006-02-17 Thread Steven D'Aprano
On Thu, 16 Feb 2006 12:30:47 -0800, SMB wrote:

 I know I could do this with two for loops, but am looking for a better 
 solution maybe involving list comprehension.

What's wrong with for loops? Why do you think they are unPythonic?


-- 
Steven.

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


Re: pymssql and date format

2006-02-17 Thread Steve Holden
[EMAIL PROTECTED] wrote:
 hi
 i am using pymmsql to query a date column in MSSQL database table.
 However the result shows for example
 (datetime.datetime(2006, 2, 16, 17, 50, 19) which is supposed to be
 2006-02-16 17:50:19.000
 anyway to correct query a date column using pymssql so that it gives
 the correct date format? thanks
 
It doesn't return a format, it returns a value. I presume you are saying 
that you don't like the way the value prints? Use str() on it:

   str(datetime.datetime(2006, 2, 16, 17, 50, 19))
'2006-02-16 17:50:19'

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: Question about xmlrpc and threading

2006-02-17 Thread Martin P. Hellwig
David Hirschfield wrote:
cut
 My question was whether this is allowed? Can two calls be made via the 
 same ServerProxy instance while a request is already underway?
 
 Clearer?
 -Dave
 
cut

Much, and my preliminary answer is, I have no clue :-)
But knowing that python will throw an exceptions when something is not 
allowed and that we can analyze if the logic of the program breaks we do 
can build a test case!

I've taken the opportunity, but I might be as wrong was I am right (and 
still won't know which one it was):

So, I expect that when something un-allowed happens it will throw an 
exception and otherwise that the workflow on the server should resemble 
the work flow on the client:

So i created an async server with only one function (which is even worse 
  then your question):
def doSomething(self,threadID):
randomWait= random.randrange(0,10)
time.sleep(randomWait)
print(Thread %s has slept for %s seconds % threadID,randomWait))
returnValue = Thread %s has slept for %s seconds % 
(threadID,randomWait)
return returnValue

and a threaded client:
class testThread(threading.Thread):
 def run(self):
 xmlrpclib.server = xmlrpclib.ServerProxy(http://localhost:8080;)
 x=xmlrpclib.server
 print(x.doSomething(self.getName()))

for i in range(100):
 testThread().start()

So when I run that I except that the output on the server is the same as 
the one on the client with an error margin within the second range 
(which would indicate that a certain thread has been scheduled a little 
earlier then the other), guess what the output of the two was?

Well I say this much, most of them where in sync (within the error 
margin) so I conclude that your question is answered with , yes you can 
have a call when another one is processed without intervening with each 
other( if you want that).

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


Re: mod_python and open HTTP connection

2006-02-17 Thread Kane
 Does mod_python time out after a minute ?

No, but the browser may timeout.  Sending a periodic bit-o-data on a
long running page is a good idea anyway (so the user knows it is still
working).

If I leave  an HTTP connection open so that the content keeps loading inside 
the
browser window indefinately, and if I close the browser window, the
mod_python process is terminated, right?

In general this is not an issue.  However it depends to some degree on
what your mod_python program is doing.  Here is a really, REALLY feeble
example w/publisher:

def ping(req, target_ip):
  import commands
  output = commands.getoutput('ping -c 1 %s' % target_ip)
  return output

Even if the user closes the window or hits 'stop' the process stays
until the ping finishes.  In this example this is merely annoying (10k
pings takes almost 3 hours) but if it had been 'fping -el %s' instead
you would be in real trouble (since it would never exit).

Restarting apache clears such zombie processes.

btw, 'ping' as written above is horrible.  If a code review turned
_that_ up on production someone would be fired, along with whoever
hired them, whoever ate lunch with them and anyone that waves goodbye.

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


Installing python on lynxOS

2006-02-17 Thread Bryce Cooper
I'm trying to install python2.4.2 onto lynxOS 4.0.0. with gcc 2.95.3. I was wondering if anyone who has done this before could give me some pointers.I'm currently getting the following error when running make:
 gcc -o python Module/python.o libpython2.4.a -lsocket -lm called2:ld returned 1 exit status libpython2.4.a(pystate.o):In function 'PyThreadState_New': Python2.4.2/pystate.c:191: undefined reference to '_PyGILState_NoteThreadState'
 called2:ld returned 1 exit statusI checked pystate.c and the function _PyGILState_NoteThreadState is defined in the file, so I'm a bit lost here.-- Bryce
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: calculating on matrix indices

2006-02-17 Thread Kirk McDonald
Brian Blais wrote:
 Hello,
 
 In my attempt to learn python, migrating from matlab, I have the 
 following problem. Here is what I want to do, (with the wrong syntax):
 
 from numpy import *
 
 t=arange(0,20,.1)
 x=zeros(len(t),'f')
 
 idx=(t5)
 tau=5
 x[idx]=exp(-t[idx]/tau)  # ---this line is wrong (gives a TypeError)
 
 #--
 
 what is the best way to replace the wrong line with something that 
 works: replace all of the values of x at the indices idx with 
 exp(-t/tau) for values of t at indices idx?
 
 I do this all the time in matlab scripts, but I don't know that the 
 pythonic preferred method is.
 
 
 
 thanks,
 
 bb
 
 

You're specifying the type of x but not of t. You need to change the 
line where you assign t to:

t = arange(0, 20, .1, 'f')

I'm not sure why it doesn't figure that own on its own (since it 
obviously does hold floats), but this does cause it to work.

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


Re: Seaching Active Directory via ADO

2006-02-17 Thread LittlePython
To be more clear, something like this example but in python. I have tryed to
convert something very simular to this
but have failed.

 -- SCRIPT CONFIGURATION --
strBase=  LDAP://BaseDN;
strFilter  = Filter;
strAttrs   = AttrList;
strScope   = Scope
' -- END CONFIGURATION -

set objConn = CreateObject(ADODB.Connection)
objConn.Provider = ADsDSOObject
objConn.Open Active Directory Provider
set objComm = CreateObject(ADODB.Command)
objComm.ActiveConnection = objConn
objComm.Properties(Page Size) = 1000
objComm.CommandText = strBase  strFilter  strAttrs  strScope
set objRS = objComm.Execute
objRS.MoveFirst
while Not objRS.EOF
Wscript.Echo objRS.Fields(0).Value
objRS.MoveNext
wend




LittlePython [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 I am have trouble finding a simple working example of  using ADO to search
 Active Directory. I am hoping someone could point me to a generic working
 script that connects to AD and pulls up a recordset to help me get started
 into the right direction in learning ADO, ADSI on Python.




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


Re: Mac OS X Installation Problem

2006-02-17 Thread Alex Martelli
Matt wrote:

 Hi Everybody,
 
 1) Does OS X have a thing like the Add/Remove Programs control panel on
 Windows XP?

Nope.  You install stuff by running packages (installers) or dragging
.app files to Applications, uninstall it normally by dragging them to
Trash.


 My Tiger system had Python v2.3.5 on it and I threw the files in the trash and

Very unwise move -- now your fax functionality (which Apple implemented
using their own special system build of Python 2.3.5) is unlikely to
work, for example.

 installed v2.4.1, which is working fine as far as I can tell. However, when I
 type python at the command line, I get command not found so,
 
 2) How do I get OS X to recognize python at the command line?

Edit a ~/.bashrc file to add /usr/local/bin to your PATH.


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


file.read problem

2006-02-17 Thread wscrsurfdude
f = open('myfile,'r')
a = f.read(5000)

When I do this I get the first 634 bytes. I tried using the:
f = open('myfile,'rb')
option, but now there are a few 0x0D bytes extra in myfile. 0x0D =
Carriage return. How can I make a program that not puts in the 0x0D
bytes in windows.

In linux the first 2 lines are working perfectly.

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


Re: file.read problem

2006-02-17 Thread Farshid Lashkari
 I am working on a script to get parts of raw data out of a file, and
 the data I read has to be the data written in the file without CR or
 LF.

So you just want to remove all the linefeeds? This should work then:

data = data.replace('\n','')

-Farshid

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


Re: define loop statement?

2006-02-17 Thread Xavier Morel
Rene Pijlman wrote:
 David Isaac:
 I would like to be able to define a loop statement
 (nevermind why) so that I can write something like

 loop 10:
do_something

 instead of

 for i in range(10):
do_something

 Possible?  If so, how?
 
 Yes. By implementing a compiler or an interpreter for your programming
 language. Or a preprocessor that converts your language to Python, or some
 other suitable intermediate language. Or a programmer, that converts your
 pseudocode and some coffee to the desired algorithm :-)
 
Or by hacking through the Python source and creating his own somehow 
pythonish but absolutely not python language
-- 
http://mail.python.org/mailman/listinfo/python-list


SonicWALL Configuration

2006-02-17 Thread D
Is it possible to write a Python script to modify/configure a SonicWALL
firewall?  Or, has anyone written any useful utilities for the units
(i.e. parsing the TSR reports, etc.)?  Thanks!

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


Re: Seaching Active Directory via ADO

2006-02-17 Thread Roger Upole
It usually means the domain you specified can't be found.

   Roger

LittlePython [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Do you know what this may mean?

 C:\Documents and Settings\Administrator\Desktop\pytestADOSeach.py
 Traceback (most recent call last):
   File C:\Documents and
Settings\Administrator\Desktop\pytest\ADOSeach.py,
 lin
 e 6, in ?
 rs,rc=c.Execute(
   File COMObject ADODB.Connection, line 3, in Execute
   File C:\Python24\Lib\site-packages\win32com\client\dynamic.py, line
258,
 in
 _ApplyTypes_
 result = self._oleobj_.InvokeTypes(*(dispid, LCID, wFlags, retType,
 argTypes
 ) + args)
 pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'Provider',
 'Tabl
 e does not exist.', None, 1240640, -2147217865), None)

 C:\Documents and Settings\Administrator\Desktop\pytest
 Roger Upole [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  You could also accomplish the same thing using the
  Command object, but this way is usually more concise
  for plain Sql.
 
   Roger
 
  LittlePython [EMAIL PROTECTED] wrote in message
  news:[EMAIL PROTECTED]
   I notice there is no adodb.command. This is not required?
   Thx for the example!
   Roger Upole [EMAIL PROTECTED] wrote in message
   news:[EMAIL PROTECTED]
Here's a short example that uses ADO to search for a
user by wildcard.
   
import win32com.client
c = win32com.client.Dispatch(ADODB.Connection)
c.Open(Provider=ADSDSOObject)
   
rs,rc=c.Execute(
SELECT adspath, title, name
From 'LDAP://DC=yourdomain, DC=COM'
where objectClass='user' and name='Roger*'
)
   
while not rs.EOF:
for f in rs.Fields:
print f.Name, f.Value
rs.MoveNext()
   
hth
  Roger
   
LittlePython [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Thanks but I was looking more for ADO com object than ADSI or
ldap.
 For some strange reason it is very hard to locate any working
 scripts
   that
 use ADO  to connect and search AD. Is there an issue with ADO and
  python
 when connecting to AD?
 I have try to build one myself with no luck. I think my problem is
  with
 adodb.command calls.

 Thanks for your response.

 alex23 [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  Heya,
 
  There are a couple of examples on the O'Reilly site. These two
are
  taken from 'Active Directory Cookbook', the first uses a COM
 object
  while the second uses a native LDAP module:
 
 

   
  
 

http://www.rallenhome.com/books/adcookbook/src/18.6-rootdse_python_com.py.tx
 t
 

   
  
 

http://www.rallenhome.com/books/adcookbook/src/18.6-rootdse_python_ldap.py.t
 xt
 
  This might give you a start.
 
  - alex23
 


   
   
   
== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure
Usenet
   News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World!
 120,000+
   Newsgroups
= East and West-Coast Server Farms - Total Privacy via
Encryption
   =
  
  
 
 
 
  == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet
 News==
  http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+
 Newsgroups
  = East and West-Coast Server Farms - Total Privacy via Encryption
 =






== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet 
News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ 
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Evil, evil wxPython (and a glimmer of hope)

2006-02-17 Thread Ben Finney
[EMAIL PROTECTED] [EMAIL PROTECTED] writes:
 I rarely do GUIs, and reminded myself today why that is the case
 (simply, it's not fun).

Programming C++ in Python isn't much fun, true.

 However, it should be pretty easy to write small wrapper over the
 wxPython api.
 [...]
 wxPython is great as it is (a simple wrapper for a C++ toolkit) and the
 basic design is ok  proven, I'm just too lazy to use it in its current
 form.

Fortunately, you're not alone in that thought. The wxPython project's
explicit goal is to make wxPython feel as much like wxWidgets as
feasible.

For those that want wxPython to feel more like Python than C++, Hans
Nowak started the 'wax' wrapper:

Simply put, Wax is a GUI toolkit. It sits on top of wxPython,
removing some of the low-level aspects of that GUI, and adding
some useful abstractions.

The goal is that Wax should be easier to use than wxPython, but
just as feature-rich. Maybe even more so.

The actual situation is different. Frankly, I don't have the time
to work on this project very much. That's why I only add new
features when I need them. Some of my other projects (Firedrop,
Sourcery, etc) use Wax, so over time, when I need more controls, I
add them. On the other hand, a subset of controls is there, and is
usable.

URL:http://zephyrfalcon.org/labs/dope_on_wax.html
URL:http://zephyrfalcon.org/labs/wax.html

The web content is a bit sparse; fortunately the code has seen more
love than the web pages. Wax was the focus of a couple of Google
Summer of Code projects, and new life seems to have been gained as a
result.

-- 
 \ We are not gonna be great; we are not gonna be amazing; we are |
  `\gonna be *amazingly* amazing!  -- Zaphod Beeblebrox, _The |
_o__)Hitch-Hiker's Guide To The Galaxy_, Douglas Adams |
Ben Finney http://www.benfinney.id.au/
-- 
http://mail.python.org/mailman/listinfo/python-list


days since epoch

2006-02-17 Thread eight02645999
hi
how can i get the number of days since epoch using the time module?
or do i have to manually do the arithmetic?
thanks

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


Re: Databases and python

2006-02-17 Thread Jonathan Gardner
About indexes everywhere: Yes, you don't have to be a DB expert to know
that indexes everywhere is bad. But look at this example. There are
really two ways that the data is going to get accessed in regular use.
Either they are going to ask for all files that have a word (most
likely) or they are going to see which words are in a file.

I'm going to have to name the tables now, aren't I? Here's a simple
schema:

words

word_id
word

files
--
file_id
filename

word_files
--
file_id
word_id

If you are going to lookup by word, you'll need an index on words.word.
You'll also need an index on word_files.word_id. And then you'll need
an index on files.file_id.

If you are going to lookup by file, you'll need an index on
files.filename, word_files.file_id, and words.word_id.

So it ends up in this situation you need indexes everywhere.

Now, when you are doing the initial population, you should drop all the
indexes you don't need during population. That means everything but
words.word has to go. (You'll need to find the word_id for previously
seen words.) After the initial population, then is the time to build
and add the indexes. it's much faster to build an index when you have
the entire set of data in front of you than to do it piece-by-piece.
Some indexes actually get built better than they would've piecemeal.

Unfortunately this is no longer strictly topical to Python. But if you
free your mind from thinking in terms of SQL databases and look at
indexes as dicts or whatnot, then you can see that this is really a
general programming problem.

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


Re: days since epoch

2006-02-17 Thread [EMAIL PROTECTED]
As suggested by Alex the datetime module makes this easy:

py import datetime
py epoch = datetime.datetime.utcfromtimestamp(0)
py print epoch
1970-01-01 00:00:00
py today = datetime.datetime.today()
py d = today - epoch
py print d
13196 days, 9:50:44.266200
py print d.days # timedelta object
13196

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


Re: file.read problem

2006-02-17 Thread Fredrik Lundh
wscrsurfdude wrote:

 Try opening the file in 'rbU' mode. This will use universal newline mode
 and convert all carriage returns to line feeds.

 I tried this, but as you say, now there are 0x0A bytes extra in my
 files, is there also a possibility to let all these things out, and
 just get the file.

 I am working on a script to get parts of raw data out of a file, and
 the data I read has to be the data written in the file without CR or
 LF.

what kind of file are you reading?  if it's a text file, it's supposed to have
LF in it (or CR LF if you read it in binary mode); the LF:s are there to tell
you where each line ends.

if it's a binary file, open with mode rb.

/F



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


restricted mode (2.4.2)

2006-02-17 Thread Wojciech Pawlikowski
Hey,
I work on some project where main part (core) is coded in C
(for speed) and the rest is in Python. Python API is used
to launch python modules without using any exec() system()
calls (thread safe). During debugging I found that
many of Python modules fails to work because restricted mode:

Traceback (most recent call last):
   File ../modules/scan/dns_forward.py, line 167, in scan_element
 d = DNSForward(domainname)
   File ../modules/scan/dns_forward.py, line 20, in __init__
 self.__r = dns.resolver.Resolver()
   File /usr/lib/python2.4/site-packages/dns/resolver.py, line 270, in 
__init__
 self.read_resolv_conf(filename)
   File /usr/lib/python2.4/site-packages/dns/resolver.py, line 295, in 
read_resolv_conf
 f = open(f, 'r')
IOError: file() constructor not accessible in restricted mode

Is there any way to avoid this mode ?

-- 
___
* Wojciech Pawlikowski  :: wojtekp AT gmail.com ::  GG: 4155781 *
* http://www.knockdownhc.com   ||  http://www.kingofthehillhc.com *
*  Loved by a few, Hated by many, But respected by ALL  *
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: embedding python in HTML

2006-02-17 Thread Paul Boddie
Rene Pijlman wrote:
 John Salerno:
 [Python alternative for PHP]
 So to do this with Python, do I simply integrate it into the HTML as
 above, with no extra steps?

 You'd need something like the PHP engine, that understands Python rather
 than PHP.

[...]

 There's also PSP:
 http://www.ciobriefings.com/psp/

For straight Python Server Pages without advertising various (and
possibly quite different) technologies, take a look at mod_python's
implementation:

http://www.modpython.org/
http://www.modpython.org/live/current/doc-html/pyapi-psp.html

I haven't actually used this particular implementation - I'm not a fan
of embedding programming languages in HTML - but I imagine that it's
one of the more actively developed projects of its kind.

Paul

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


Re: Open Relay Test

2006-02-17 Thread Martin P. Hellwig
D wrote:
 Nope, quite the contrary..I'm looking to write a simple program for a
 client of mine that will, among other things, verify that their
 clients' email servers do not have open relays.
 
I usually test it like this:

[EMAIL PROTECTED]:~ telnet mail.huygenslyceum.nl smtp
Trying 172.16.64.12...
Connected to mail.huygenslyceum.nl.
Escape character is '^]'.
220 mail.huygenslyceum.nl ESMTP Sendmail 8.12.11/8.12.11; Fri, 17 Feb 
2006 10:03:46 +0100 (CET)
~ helo 172.16.64.1
250 mail.huygenslyceum.nl Hello [172.16.64.1], pleased to meet you
~ mail from: [EMAIL PROTECTED]
250 2.1.0 [EMAIL PROTECTED] Sender ok
~ rcpt to: [EMAIL PROTECTED]
550 5.7.1 [EMAIL PROTECTED] Relaying denied. IP name lookup 
failed [172.16.64.1]

To get a more verbose explanation, google for smtp + telnet.

hth
-- 
mph

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


Re: Pulling all n-sized combinations from a list

2006-02-17 Thread [EMAIL PROTECTED]

[EMAIL PROTECTED] wrote:
 hi,

 I'm not sure why this hasn't come up yet, but this seems to beg for
 list comprehensions, if not generator expressions.  All of the
 following run in under 2 seconds on my old laptop:

  alph = 'abcdefghijklmnopqrstuvwxyz'
  len([''.join((a,b,c,d)) for a in alph for b in alph for c in alph for d 
  in alph])
 456976
  len([''.join((a,b,c,d)) for a in alph for b in alph for c in alph for d 
  in alph
 ...  if (a=b and b=c and c=d)])
 23751
  len([''.join((a,b,c,d)) for a in alph for b in alph for c in alph for d 
  in alph
 ...  if (a!=b and b!=c and c!=d and d!=a and b!=d and a!=c)])
 358800
  len([''.join((a,b,c,d)) for a in alph for b in alph for c in alph for d 
  in alph
 ...  if (ab and bc and cd)])
 14950

Well, _I_ was using them in my original program to create the
conditionals, but not for the loops. So if we combine your idea
to use list comprehensions for the loop with my list comprehensions
of the conditionals, we aren't limited to asking for only 4-letter
words.

And it runs faster than my original.

Thanks.

def ooloop6(a, n, perm=True, repl=True):
if (not repl) and (nlen(a)): return
r0 = range(n)
r1 = r0[1:]
if perm and repl:  # ok
v = ','.join(['c%s' % i for i in r0])
f = ' '.join(['for c%s in a' % i for i in r0])
e = ''.join([p = [''.join((,v,)) ,f,]])
exec e
return p
if (not perm) and repl:# ok
v = ','.join(['c%s' % i for i in r0])
f = ' '.join(['for c%s in a' % i for i in r0])
i = ' and '.join(['(c%s=c%s)' % (j,j-1) for j in r1])
e = ''.join([p = [''.join((,v,)) ,f, if ,i,]])
exec e
return p
if perm and (not repl):# ok
v = ','.join(['c%s' % i for i in r0])
f = ' '.join(['for c%s in a' % i for i in r0])
i = ' and '.join([' and '.join(['(c%s!=c%s)' % (j,k) for k in
range(j)]) for j in r1])
e = ''.join([p = [''.join((,v,)) ,f, if ,i,]])
exec e
return p
if (not perm) and (not repl):  # ok
v = ','.join(['c%s' % i for i in r0])
f = ' '.join(['for c%s in a' % i for i in r0])
i = ' and '.join(['(c%sc%s)' % (j,j-1) for j in r1])
e = ''.join([p = [''.join((,v,)) ,f, if ,i,]])
exec e
return p

p = ooloop6('abcdefghijklmnopqrstuvwxyz',4,True,True)
print
print len(p)
p = ooloop6('abcdefghijklmnopqrstuvwxyz',4,False,True)
print
print len(p)
p = ooloop6('abcdefghijklmnopqrstuvwxyz',4,True,False)
print
print len(p)
p = ooloop6('abcdefghijklmnopqrstuvwxyz',4,False,False)
print
print len(p)


456976

23751

358800

14950



 
 cheers,
 Jess

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


Re: Determing whether two ranges overlap

2006-02-17 Thread Robin Haswell
Thanks guys, you've all been very helpful :-)

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


Re: Job advert: Your help needed

2006-02-17 Thread Paul Rubin
Andrew Koenig [EMAIL PROTECTED] writes:
  Paul Boots
  [EMAIL PROTECTED]
  +354 664 1748
 
 Iceland?  really??

Gonna go try to get a chess match?  ;-)

Mike Jittlov likes the place too.  I thought of him immediately but
AFAIK he doesn't use Python.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Seaching Active Directory via ADO

2006-02-17 Thread alex23
Heya,

There are a couple of examples on the O'Reilly site. These two are
taken from 'Active Directory Cookbook', the first uses a COM object
while the second uses a native LDAP module:

http://www.rallenhome.com/books/adcookbook/src/18.6-rootdse_python_com.py.txt
http://www.rallenhome.com/books/adcookbook/src/18.6-rootdse_python_ldap.py.txt

This might give you a start.

- alex23

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


Re: Pulling all n-sized combinations from a list

2006-02-17 Thread jess . austin
hi,

I'm not sure why this hasn't come up yet, but this seems to beg for
list comprehensions, if not generator expressions.  All of the
following run in under 2 seconds on my old laptop:

 alph = 'abcdefghijklmnopqrstuvwxyz'
 len([''.join((a,b,c,d)) for a in alph for b in alph for c in alph for d in 
 alph])
456976
 len([''.join((a,b,c,d)) for a in alph for b in alph for c in alph for d in 
 alph
...  if (a=b and b=c and c=d)])
23751
 len([''.join((a,b,c,d)) for a in alph for b in alph for c in alph for d in 
 alph
...  if (a!=b and b!=c and c!=d and d!=a and b!=d and a!=c)])
358800
 len([''.join((a,b,c,d)) for a in alph for b in alph for c in alph for d in 
 alph
...  if (ab and bc and cd)])
14950

cheers,
Jess

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


PyProtocols, Components, and Inheritance

2006-02-17 Thread Terry Hancock
I've been discussing PyProtocols with a a friend
collaborating with me on a SF game project, about
the benefits and design concept of component architecture,
and I'm a little confused by what I'm learning.

I learned the concepts of component architecture from
the Zope project, where if I'm not mistaken, components
are essentially python mix-in classes, and you make
a class from components by using multiple inheritance
and document this with an interface declaration:

So in this model, I have (let's say):

Interfaces: IVehicle, IAnimal
these are special (non-class) objects,
even though their declarations look like class
declarations

Components: Vehicle, Animal (each provide these interfaces)
these are just ordinary python classes

Then I can make a class by combining components:

class Horse(Animal, Vehicle):
implements(IAnimal, IVehicle)
pass

(This is an interactive fiction engine, so it would be
reasonable to think of a horse both as an animal and
as a means of transportation -- but it's just an example).

However, this is apparently not how PyProtocols works.

The PP way apparently looks something like this:

Components: are special (non-class?) objects (just like
interfaces?)

So I need something like:

class Vehicle(Component):
#... implementation snipped
pass

class Animal(Component):
#... implementation snipped
pass

then I use it by making a class:

class Horse(object):
pass

and only then do I attach components:

Horse.addComponent(Vehicle)
Horse.addComponent(Animal)

To me, this looks like madness. Aren't we just reinventing
multiple inheritance with obtuse syntax?  Why is multiple
inheritance such a bad thing? (I can see that it can be
abused, but ISTM that real trouble comes not from broad,
shallow multiple inheritance as in the component model, but
from deep inheritance chains (as one is forced to do in
single-inheritance languages)).

Anyway, my question is WHY? I know PyProtocols is
fairly popular, so there must be some benefit to this, 
but I'd really like to hear what it's supposed to be.

My friend seems to think there is a great evil in
doing it with multiple inheritance, yet the PyProtocols
way seems to be kind of complex. I had erroneously
assumed that PyProtocols and Zope component models
were more-or-less equivalent, with PP being perhaps
a bit more complete (for example, PP's interface module is
apparently a superset of Zope's).

I realize that at some level we're just having a cultural
conflict since we learned different versions of this
concept, but I would like to make a real attempt to
understand where he's coming from.  (And yes, of course
I've asked him, but since he only knows the PP way of
doing this, I don't think he's able to tell me -- I guess
we need an interpreter. ;-) ).

I feel like there's something going on here that
I just don't get.

Is there someone out there who can give me a PyProtocols
advocate's PoV on this? Can you tell me why PP's approach is
better than Zope's? (Or perhaps what you think it is
more appropriate for?).  Anyway, c.l.python seemed like the
(neutral) place to ask since this is comparing two major
python packages.

Cheers,
Terry



-- 
Terry Hancock ([EMAIL PROTECTED])
Anansi Spaceworks http://www.AnansiSpaceworks.com

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


Re: embedding python in HTML

2006-02-17 Thread Kirk McDonald
John Salerno wrote:
 bruno at modulix wrote:
 
 You've got to understand that Python is *not* a 'ServerPage' language
 (- php, asp, jsp etc) in itself. Your server can now run python, fine,
 but *how* ? CGI ? FastCGI ? mod_python ? other ? (hint: it's probably
 just plain old CGI...)
 
 
 So does that mean I need to have something further on the server? Or is 
 this something I can do on my end? How do I find out what I need?

If you really want to use Python as a server page language, mod_python 
has support for Python Server Pages via its PSP handler:

Python Server Pages:
http://modpython.org/live/current/doc-html/pyapi-psp.html

PSP handler:
http://modpython.org/live/current/doc-html/hand-psp.html

This of course means your server needs to have mod_python installed and 
configured. (Consult your server administrator.) However, I've always 
found PSP to be somewhat fiddly, and mixing any serious code with the 
HTML text is hardly pretty.

A more common (and bare-metal) approach is CGI. In CGI, a request for a 
page runs a script, the output of which is the HTML page. I think this 
only requires that the server has Python installed, which you have said 
is the case. Python has signifigant standard library support for writing 
CGI.

You should examine Python's standard cgi module:
http://python.org/doc/2.4.2/lib/module-cgi.html
That page also has some nice examples to get you started.

And maybe its Cookie module, if you ever feel like messing with cookies:
http://python.org/doc/2.4.2/lib/module-Cookie.html

Slightly less bare-metal is using mod_python directly (rather than via 
its PSP module). This is probably preferable to plain CGI if mod_python 
is available, as it caches scripts as long as they are not changed. This 
is faster than reading them off the disk every time. By and large, 
mod_python's API replaces (or at least wraps) the standard library's CGI 
support if you go this route. Again, this is only available if your 
server has mod_python installed, which may or may not be the case.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Job advert: Your help needed

2006-02-17 Thread Andrew Koenig
Paul Boots [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

 Paul Boots
 [EMAIL PROTECTED]
 +354 664 1748

Iceland?  really??


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


define loop statement?

2006-02-17 Thread David Isaac
I would like to be able to define a loop statement
(nevermind why) so that I can write something like

loop 10:
do_something

instead of

for i in range(10):
do_something

Possible?  If so, how?

Thanks,
Alan Isaac


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


Re: file.read problem

2006-02-17 Thread wscrsurfdude
if it's a binary file, open with mode rb.
You are right about opening it in the rb mode (flaw in the start post),
but also when I do this in windows in front of every 0x0A is put a
0x0D. I found a explanation why it is working in linux it is below in
my post.

But what i get of this that in windows in front of every 0x0A is put a
0x0D as a line feed. II have to get rid of these. But if there is
already binary data in my original file with the data 0x0D0A the 0x0D
also is deleted, someone has an idea??


The whole subject of newlines and text files is a murky area of non
standard implementation by different operating systems. These
differences have their roots in the early days of data communications
and the control of mechanical teleprinters. Basically there are 3
different ways to indicate a new line:

 Carriage Return (CR) character ('\r')
 Line Feed (LF) character ('\n')
 CR/LF pair ('\r\n').
All three techniques are used in different operating systems. MS DOS
(and therefore Windows) uses method 3. Unix (including Linux) uses
method 2. Apple in its original MacOS used method 1, but now uses
method 2 since MacOS X is really a variant of Unix.

So how can the poor programmer cope with this multiplicity of line
endings? In many languages she just has to do lots of tests and take
different action per OS. In more modern languages, including Python,
the language provides facilities for dealing with the mess for you. In
the case of Python the assistance comes in the form of the os module
which defines a variable called linesep which is set to whatever the
newline character is on the current operating system. This makes adding
newlines easy, and rstrip() takes account of the OS when it does its
work of removing them, so really the simple way to stay sane, so far as
newlines are concerned is: always use rstrip() to remove newlines from
lines read from a file and always add os.linesep to strings being
written to a file.

That still leaves the awkward situation where a file is created on one
OS and then processed on another, incompatible, OS and sadly, there
isn't much we can do about that except to compare the end of the line
with os.linesep to determine what the difference is.
##

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


Re: web crawler in python or C?

2006-02-17 Thread Steve Holden
abhinav wrote:
 Hi guys.I have to implement a topical crawler as a part of my
 project.What language should i implement
 C or Python?Python though has fast development cycle but my concern is
 speed also.I want to strke a balance between development speed and
 crawler speed.Since Python is an interpreted language it is rather
 slow.The crawler which will be working on huge set of pages should be
 as fast as possible.One possible implementation would be implementing
 partly in C and partly in Python so that i can have best of both
 worlds.But i don't know to approach about it.Can anyone guide me on
 what part should i implement in C and what should be in Python?
 
Get real. Any web crawler is bound to spend huge amounts of its time 
waiting for data to come in over network pipes. Or do you have plans for 
massive parallelism previously unheard of in the Python world?

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: Evil, evil wxPython (and a glimmer of hope)

2006-02-17 Thread snoe

[EMAIL PROTECTED] wrote:
 I rarely do GUIs, and reminded myself today why that is the case
 (simply, it's not fun).

 I implemented a simple TreeCtrl, and had to implement my own 'children'
 method, of all things!

 Here it is:

 def children(self,node):
 c = []
 nc,cookie = self.GetFirstChild(node)
 while 1:
 info = self.GetItemText(nc)
 c.append((info,nc))

 nc, cookie= self.GetNextChild(node,cookie)
 if not nc.IsOk():
 break

 return c


 And it even fails with zero children. This is as unpythonic as it gets.

 However, it should be pretty easy to write small wrapper over the
 wxPython api. I'm thinking of wrapping or injecting additional methods
 to TreeCtrl that start with lowercase letters and return something
 sensible, with reasonable methods. Something like:

 root = self.AddRoot(root dir) # root is normal wx TreeCtrl root
 tree = EasyWx(root)   # now tree is our wrapped, more fun root
 for c in tree.children():
   print c.name

 # etc. etc.

 This is a bit like Brian Orendorff's path module that turns something
 low level to something you can use easily, without throwing you into a
 world of frameworks, toolkits and whatnot. I can see there are things
 like Wax or PythonCard, but they are still too frameworky, and you
 don't use them to extend wxPython, you use *them* and they use
 wxPython. I'd basically like to rely on something that is there for the
 long haul (plain wxPython API) but only use convenience wrappers *on my
 own initiative*, as it seems convenient. Just like I'd use the path
 module.

 wxPython is great as it is (a simple wrapper for a C++ toolkit) and the
 basic design is ok  proven, I'm just too lazy to use it in its current
 form.

Take a look at dabo, II think they're doing exactly what you're
describing.
http://blog.dabodev.com/

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


Re: question about scope

2006-02-17 Thread bruno at modulix
John Salerno wrote:
 Here's a sentence from Learning Python:
 
 Names not assigned a value in the function definition are assumed to be
 enclosing scope locals (in an enclosing def), globals (in the enclosing
 module's namespace) or built-in (in the predefined __builtin__ names
 module Python provides.
 
 I have trouble reading this sentence. First, I don't understand if the
 word 'enclosing' is a verb or an adjective.

second one

 The whole flow of the
 sentence seems convoluted.

A bit, yes. In short: if a name is used in a function whithout having
been previously assigned in the body of this function, then this name is
looked up first in the enclosing functions definitions (python's
functions can be nested), then in the global (read : module) namespace,
then in the built-in namespace.

And if it's not found, it raises a NameError !-)

 But my real question is this, which is related to the above:
 
 Name references search at most four scopes: local, then enclosing
 functions (if any), then global, then built-in.
 
 I understand what global and built-in are, and I thought I understood
 the concept of local too, but when I got to this sentence (and the
 previous sentence), I became confused about the first two scopes. What's
 the difference between 'local' and 'enclosing functions'? 

This:

def outer_function():
  a = a in outer
  def inner_function():
 print in inner, a = %s % a
  inner_function()


Python functions can be nested (bis).

I thought that
 the only way to create a local namespace was if there *was* a function
 definition,

Yes. But since functions definitions can be nested...

 so now I'm confused by the apparent difference that the
 authors are referring to. What's an example of a local scope without
 having a function definition?

I don't know.

 Loops and if statements, perhaps?

Nope, AFAICT.

 And feel free to dissect that first sentence up above, because I just
 don't get it.

Done.



-- 
bruno desthuilliers
python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Seaching Active Directory via ADO

2006-02-17 Thread LittlePython
Thanks but I was looking more for ADO com object than ADSI or ldap.
For some strange reason it is very hard to locate any working scripts that
use ADO  to connect and search AD. Is there an issue with ADO and python
when connecting to AD?
I have try to build one myself with no luck. I think my problem is with
adodb.command calls.

Thanks for your response.

alex23 [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Heya,

 There are a couple of examples on the O'Reilly site. These two are
 taken from 'Active Directory Cookbook', the first uses a COM object
 while the second uses a native LDAP module:


http://www.rallenhome.com/books/adcookbook/src/18.6-rootdse_python_com.py.tx
t

http://www.rallenhome.com/books/adcookbook/src/18.6-rootdse_python_ldap.py.t
xt

 This might give you a start.

 - alex23



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


Re: Open Relay Test

2006-02-17 Thread Steven D'Aprano
On Fri, 17 Feb 2006 00:40:51 -0500, Steve Holden wrote:

 D wrote:
 Hi all .. how could one test to see if an open relay exists on a
 specific email server?
 
 I bet spammers would love someone to answer that question for them. You 
 wouldn't be planning spam, by any chance?

The spammers already know how to look for open relays. Unlike the original
poster, they know how to use Google. *wink*

Besides, not just spammers want to detect open relays. Many people like to
block mail from open relays.



-- 
Steven.

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


Re: Safe Python Execution

2006-02-17 Thread Jean-Paul Calderone
On Thu, 16 Feb 2006 07:59:03 -0800, Alex Martelli [EMAIL PROTECTED] wrote:
Graham [EMAIL PROTECTED] wrote:

 I've been messing around with trying to get a small sandbox like
 environment where i could execute python code in a safe way.
 Basically what the old restricted execution module attempted to do.
 I've written a small amount of code to get custom interpreter running,
 but i'm not really sure if its safe.

 The way i'm controlling functionality is with some games and exec, so
 if 'code' was the text code you wanted to execute i run:

 exec code in {'__builtins__':None}

 obviously this doesn't give you much to play with, but it does remove
 file access and importing as far as i can tell. Can anyone think of a
 hack around this? I assume if it was this easy it would be a module
 already but i figured i would ask.

I suggest compiling the code and examining the names used in the code
object (co_names attribute of the code object which compile returns) --
refuse to execute the code if it mentions, defines or uses any special
name (starting and ending with two underscores).  That, plus removing
almost all builtins as you do here, should be a good start.

A good start, perhaps, but still in need of a good finish.


exec 'print ' + ''.join(map(chr, [
95, 95, 98, 117, 105, 108, 116, 105, 110, 115, 95, 95]))


You can come up with a long list of restrictions to impose, and maybe that will 
be good enough.  But making it /perfect/ is a Herculean task, as is maintaining 
it as new Python releases are made, and auditing it every time you add a new 
piece of code to your system.

Just keep that in mind if you decide to pursue this.

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


Evil, evil wxPython (and a glimmer of hope)

2006-02-17 Thread [EMAIL PROTECTED]
I rarely do GUIs, and reminded myself today why that is the case
(simply, it's not fun).

I implemented a simple TreeCtrl, and had to implement my own 'children'
method, of all things!

Here it is:

def children(self,node):
c = []
nc,cookie = self.GetFirstChild(node)
while 1:
info = self.GetItemText(nc)
c.append((info,nc))

nc, cookie= self.GetNextChild(node,cookie)
if not nc.IsOk():
break

return c


And it even fails with zero children. This is as unpythonic as it gets.

However, it should be pretty easy to write small wrapper over the
wxPython api. I'm thinking of wrapping or injecting additional methods
to TreeCtrl that start with lowercase letters and return something
sensible, with reasonable methods. Something like:

root = self.AddRoot(root dir) # root is normal wx TreeCtrl root
tree = EasyWx(root)   # now tree is our wrapped, more fun root
for c in tree.children():
  print c.name

# etc. etc.

This is a bit like Brian Orendorff's path module that turns something
low level to something you can use easily, without throwing you into a
world of frameworks, toolkits and whatnot. I can see there are things
like Wax or PythonCard, but they are still too frameworky, and you
don't use them to extend wxPython, you use *them* and they use
wxPython. I'd basically like to rely on something that is there for the
long haul (plain wxPython API) but only use convenience wrappers *on my
own initiative*, as it seems convenient. Just like I'd use the path
module.

wxPython is great as it is (a simple wrapper for a C++ toolkit) and the
basic design is ok  proven, I'm just too lazy to use it in its current
form.

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


Is there anything like ASP.NET for Python web apps ?

2006-02-17 Thread rytoy
That is dragging web 'controls' to the page in design mode, binding
controls to datasources,  and writing code for events like page_load
or  button1_click ?

I need to write a few small cross-platform, data-driven web apps 
(and I really hate J2EE...)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: define loop statement?

2006-02-17 Thread Georg Brandl
David Isaac wrote:
 I would like to be able to define a loop statement
 (nevermind why) so that I can write something like
 
 loop 10:
 do_something
 
 instead of
 
 for i in range(10):
 do_something
 
 Possible?  If so, how?

It's not possible to create a new statement, with suite
and indentation rules without hacking the interpreter or
resorting to alternative bytecode compilers such as pyc.

Creating a _function_ named loop is easy as Jonathan's
answer shows.

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


Re: Merging two lists of data (Pythonic way)

2006-02-17 Thread Dave Hansen
On Thu, 16 Feb 2006 12:51:24 -0800 in comp.lang.python, SMB
[EMAIL PROTECTED] wrote:


Jonathan Gardner [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 codes = map(lambda x: x[0], list1)
 for d in list2:
  if d['code'] in codes:
d['VERIFIED'] = 1

 Is this what you were looking for?


That is exactly what I was looking for.  I will have to take a look at map.

You might also look at list comprehensions.  Replacing the first line
in the above with

   codes = [x[0] for x in list1]

should yield the same result.

Regards,
-=Dave

-- 
Change is inevitable, progress is not.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: file.read problem

2006-02-17 Thread wscrsurfdude
I have the solution, the flaw was not in the opening of the file, but
in the writing of the file. Stupid me, i opened it with mode rb, but
wrote it with w instead of with wb

Everybody thanks for helping me.

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


Re: Merging two lists of data (Pythonic way)

2006-02-17 Thread Gerard Flanagan
Dave Hansen wrote:
 On Thu, 16 Feb 2006 12:51:24 -0800 in comp.lang.python, SMB
 [EMAIL PROTECTED] wrote:

 
 Jonathan Gardner [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  codes = map(lambda x: x[0], list1)
  for d in list2:
   if d['code'] in codes:
 d['VERIFIED'] = 1
 
  Is this what you were looking for?
 
 
 That is exactly what I was looking for.  I will have to take a look at map.

 You might also look at list comprehensions.  Replacing the first line
 in the above with

codes = [x[0] for x in list1]

 should yield the same result.

 Regards,
 -=Dave

 --
 Change is inevitable, progress is not.


What about :

A = [ a[0] for a in LIST1 ]
for d in [ d for d in LIST2 if d['code'] in A ]:
d['VERIFIED'] = 1

?

Gerard

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


Re: Evil, evil wxPython (and a glimmer of hope)

2006-02-17 Thread Pietro Campesato
As you just said, wxPython is ...(a simple wrapper for a C++
toolkit): it is
oriented toward the C++ style/mindset.

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


Re: file.read problem

2006-02-17 Thread Steven D'Aprano
On Fri, 17 Feb 2006 00:15:31 -0800, wscrsurfdude wrote:

 
 Farshid Lashkari wrote:
  I am working on a script to get parts of raw data out of a file, and
  the data I read has to be the data written in the file without CR or
  LF.

 So you just want to remove all the linefeeds? This should work then:

 data = data.replace('\n','')

 -Farshid
 
 The problem is if I remove the linefeeds, I also delete readout data if
 it is 0x0A, and I don't want this, because the files I readout has to
 be a part of the original data. Another idea??

Er, have I understood you correctly? You seem to be saying that some
linefeeds are significant data, and some are not, and you want somebody to
tell you how to remove the insignificant linefeed = end of line
characters without removing the significant linefeed = important data
characters.

That's easy:

from blackmagic import readmymind, dowhatiwant
fp = file(data, rb)
readmymind()
data = dowhatiwant(fp.read())

You'll need Python 3.0 for the blackmagic module.

*wink*

Seriously, if this is your problem, then you will have no choice but to
carefully analyse the file yourself, looking at each linefeed and tossing
it away if it is insignificant. We can't tell you how to do that, because
we don't know which linefeeds are data and which are not.



 But still my question is why is the:
 f = open('myfile,'r')
 a = f.read(5000)
 working in linux??

Why shouldn't it work in Linux? The question should be, why is it not
working in Windows? (When did my code is broken become the excepted
state of affairs, and my code works the mystery that needs solving?)

I wonder whether there is a ctrl-Z in your data, and Windows is
interpreting that as end of file.


-- 
Steven.

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


Re: question about scope

2006-02-17 Thread Fredrik Lundh
John Salerno wrote:

  I understand what global and built-in are, and I thought I understood
  the concept of local too, but when I got to this sentence (and the
  previous sentence), I became confused about the first two scopes. What's
  the difference between 'local' and 'enclosing functions'?

 I guess maybe I jumped the gun. Here's some stuff later in the chapter
 that I think explains it for me:

 --
 Note that the second 'E' scope lookup layer -- enclosing defs or lambdas
 -- technically can correspond to more than one lookup layer. It only
 comes into play when you nest functions within functions.*

 * The scope lookup rule was known as the LGB rule in the first edition
 of this book. The enclosing def layer was added later in Python, to
 obviate the task of passing in enclosing scope names explicitly -- 
 something usually of marginal interest to Python beginners.
 --

that footnote is slightly misleading, though -- there's no way to pass
in enclosing scope names in Python.  what you can do is to pass in
*objects* into an inner scope, using the default argument syntax.  an
example:

var = global

def func1(arg):
print var

def func2(arg, var=var):
print var

here, func1's var is bound to the *name* of the outer variable, so if
the variable is changed, it will print the new value.

in contrast, func2's var is bound to the *value* that the outer variable
had when the def statement was executed, so it will print the same thing
every time you call it, even if the outer variable is changed.

what the note refers to in modern python, the name binding (in func1)
also works as expected if you nest scope:

var = 0 # global

def outer():

var = 1 # local to outer, enclosing in func1

def func1(arg):
print var #enclosing in today's python, global in old pythons

def func2(arg, var=var):
print var

func1() # prints 1 in today's python, 0 in old pythons
func2() # prints 1 in all versions

var = 2

func1() # prints 2 in today's python, 0 in old pythons
func2() # prints 1

(I hope this didn't confuse things even more.)

/F



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


Re: calculating on matrix indices

2006-02-17 Thread Robert Kern
Brian Blais wrote:
 Hello,
 
 In my attempt to learn python, migrating from matlab, I have the following 
 problem. 
 Here is what I want to do, (with the wrong syntax):
 
 from numpy import *
 
 t=arange(0,20,.1)
 x=zeros(len(t),'f')
 
 idx=(t5)
 tau=5
 x[idx]=exp(-t[idx]/tau)  # ---this line is wrong (gives a TypeError)
 
 #--
 
 what is the best way to replace the wrong line with something that works: 
 replace all 
 of the values of x at the indices idx with exp(-t/tau) for values of t at 
 indices idx?

The traceback tells you exactly what's wrong:

In [7]: x[idx] = exp(-t[idx]/tau)
---
exceptions.TypeError Traceback (most recent call
last)

/Users/kern/ipython console

TypeError: array cannot be safely cast to required type

In [8]: t.dtype
Out[8]: dtype('f8')

In [9]: x.dtype
Out[9]: dtype('f4')

In [10]: exp(-t[idx]/tau).dtype
Out[10]: dtype('f8')

The righthand-side is in double precision, but you are trying to stuff it into a
single-precision array. numpy can't do that conversion without losing precision,
so it raises a TypeError. If you really wanted x to be single precision, then
you would explicitly do the conversion on the righthand-side.

In [11]: x[idx] = exp(-t[idx]/tau).astype(float32)

In [12]: x
Out[12]:
array([ 0.,  0.,  0.,  0.,  0.,
0.,  0.,  0.,  0.,  0.,
0.,  0.,  0.,  0.,  0.,
0.,  0.,  0.,  0.,  0.,
0.,  0.,  0.,  0.,  0.,
0.,  0.,  0.,  0.,  0.,
0.,  0.,  0.,  0.,  0.,
0.,  0.,  0.,  0.,  0.,
0.,  0.,  0.,  0.,  0.,
0.,  0.,  0.,  0.,  0.,
0.,  0.36059493,  0.35345468,  0.34645581,  0.33959553,
...
0.02024191,  0.0198411 ,  0.01944822,  0.01906312,  0.01868564],
dtype=float32)

However, I suspect that you wanted x to be the same precision as t, which
defaults to double precision just like Python.

In [13]: x = zeros(len(t), float)

In [14]: x[idx] = exp(-t[idx]/tau)

In [15]: x
Out[15]:
array([ 0.,  0.,  0.,  0.,  0.,
0.,  0.,  0.,  0.,  0.,
0.,  0.,  0.,  0.,  0.,
0.,  0.,  0.,  0.,  0.,
0.,  0.,  0.,  0.,  0.,
0.,  0.,  0.,  0.,  0.,
0.,  0.,  0.,  0.,  0.,
0.,  0.,  0.,  0.,  0.,
0.,  0.,  0.,  0.,  0.,
0.,  0.,  0.,  0.,  0.,
0.,  0.36059494,  0.35345468,  0.34645581,  0.33959553,
...
0.02024191,  0.01984109,  0.01944821,  0.01906311,  0.01868564])

BTW, because using arange with floating point steps is somewhat unreliable
because it's floating point. You may want to use linspace() instead.

In [16]: linspace?
Type:   function
Base Class: type 'function'
String Form:function linspace at 0x6e21f0
Namespace:  Interactive
File:
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/numpy-0.9.5.2085-py2.4-macosx-10.4-ppc.egg/numpy/lib/function_base.py
Definition: linspace(start, stop, num=50, endpoint=True, retstep=False)
Docstring:
Return evenly spaced numbers.

Return 'num' evenly spaced samples from 'start' to 'stop'.  If
'endpoint' is True, the last sample is 'stop'. If 'retstep' is
True then return the step value used.

-- 
Robert Kern
[EMAIL PROTECTED]

In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die.
  -- Richard Harter

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


Re: Python 3000 deat !? Is true division ever coming ?

2006-02-17 Thread Steven D'Aprano
On Thu, 16 Feb 2006 20:55:42 -0800, seb.haase wrote:

 I don't think Because this change might break code, it's being
 introduced very gradually. Python 2.2 begins the transition, but the
 switch won't be complete until Python 3.0.   says enough.

I'm not sure what else should be said.

 Should I start using
 from __future__ import division in my modules ?

I don't know. Do you use integer or floating point division? Do you like
writing float(x)/y instead of just x/y?

 I fear that it might make my code unreadable (people would not expect
 this when reading somewhere in the middle of the module !!!)

Anybody using Python *should* be aware of the division issue. As soon as
they see a division, it is their responsibility to *find out what it
means*. That doesn't require much work: they can scroll up to the
beginning of the module and look at the first few lines. That's not hard.

Anybody person who is unwilling to scroll to the start of the module or
use their text editor to search for from __future__ import division
shouldn't be programming.

I'll allow for the occasional newbie who somehow has missed out on
learning about true division, but that's no reason to not implement
features in the language. The cost of confusing a newbie once in a month
of Sundays is far less than the benefit of introducing true division.


-- 
Steven.

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


Re: Sendmail ok signal?

2006-02-17 Thread Dan Stromberg
On Thu, 16 Feb 2006 07:36:18 -0800, Gaz wrote:

 Hey. I looked at the Sendmail help and did not find a property where i
 can get an ok signal when the email is finally sent. I need something
 like that to show a Processing, please stand by screen when the
 server is sending an email, and when the email is out, another screen
 appears with an Email sent message.
 
 Do you know an alternative to the ok from the sendmail to do this?

It depends on how you're talking to the mail server.

If you're opening a pipe to /usr/lib/sendmail recipient-list or
/usr/sbin/sendmail recipient-list (some *ix hosts have one, or the
other, or both - few have neither), then I believe about all you have to
go on is the exit status from the subprocess.

If you're connecting to host:25/tcp, then you get an informative return
code each time you issue an SMTP command.  You can get this same effect,
more or less, by opening a pipe to /usr/lib/sendmail -bs or
/usr/sbin/sendmail -bs as well.

And yes, sendmail and other MTA's that speak SMTP will accept
responsibility for a message well before it gets to its final destination.
However, once they accept the message, they are to do everything in their
power to make sure the message doesn't get lost, even if it means having
to deliver it twice instead of 0 times.  They'll write things to disk even
when it'd be faster to just leave it in memory and past it along via the
network, for example - because otherwise a power failure might mean a
message would get lost.



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


Re: Python 3000 deat !? Is true division ever coming ?

2006-02-17 Thread seb . haase
Thanks for the replies,
But to point out what the subject of this thread is (sorry for the typo
;-)  :
There is a PEP  (proposal 238) to change Python so that
5/2  WOULD do the true division  -- and obviously break lots of code.

Just type this in your python interpeter:
 from __future__ import division
 5/2
2.5

I'm not asking why it _doen't_ work like Matlab.
I'm wondering  what the chances are that what Rocco Moretti is
referring to
(http://www.python.org/doc/2.2.3/whatsnew/node7.html)
is really  planned to be persued...

I don't think Because this change might break code, it's being
introduced very gradually. Python 2.2 begins the transition, but the
switch won't be complete until Python 3.0.   says enough.

Should I start using
from __future__ import division in my modules ?
I fear that it might make my code unreadable (people would not expect
this when reading somewhere in the middle of the module !!!)

Thanks,
Sebastian Haase

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


Re: Python 3000 deat !? Is true division ever coming ?

2006-02-17 Thread Magnus Lycka
Gregory Piñero wrote:
 I knew about that approach.  I just wanted less typing :-(

It's enough to introduce one float in the mix.
1.*a/b or float(a)/b if you don't want one more
multiplication.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Evil, evil wxPython (and a glimmer of hope)

2006-02-17 Thread [EMAIL PROTECTED]
Ben Finney wrote:

 The web content is a bit sparse; fortunately the code has seen more
 love than the web pages. Wax was the focus of a couple of Google
 Summer of Code projects, and new life seems to have been gained as a
 result.

I'm glad to hear that, however, I just took a look at the mailing list:

http://sourceforge.net/mailarchive/forum.php?thread_id=9696120forum_id=44351


I am going to take a break from blogging and my personal
projects.  This includes Wax.  In other words, Wax development will be
on hold for a while.  During this time, I might still address urgent
bugs and such, but I don't plan to add new features.


Things like this raise a bit of concern about the survivability of the
project. I wouldn't mind if it was a relatively independent component
but it *is* one that is heavily dependent on wxPython...

Also, I have some issues with the design (I don't know how misguided
they may in fact be, as you can see I'm a complete wx newbie). I'd like
the wax classes to be mixins instead of superclasses, so I could just
add them to the inheritance hierarchy if I needed the features... then,
if wax suddenly went belly-up, I could just remove the mixins and
reimplement the parts that use those, yielding a plain wxpython app.
The method names, also, could be more_pythonic() so I could easily tell
wax stuff from wx stuff. This would be insane if we were talking about
a standard windowing system of some kind, but we have to recognize
that we are dealing with volatile third party code here.

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


Re: Is there anything like ASP.NET for Python web apps ?

2006-02-17 Thread Ravi Teja
If what you want is a web IDE that supports visual development, no
standalone Python IDE has such support. But you can use Python in IDEs
that do support these features.

1.) ActiveGrid (http://www.activegrid.com/) - closest visual web IDE
where Python is a first class member.
2.) Use ASP.NET with Boo or IronPython. Not seamless IDE-wise.
3.) Wait for Coyote to finish (https://coyote.dev.java.net/). It is
still J2EE but you get to use Python. Netbeans, unlike JDev does not
have data bound widgets available.

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


Re: Python, Forms, Databases

2006-02-17 Thread Jeff Reavis
You should check out Spyce:
http://spyce.sourceforge.net/

It will work under CGI as well as Fast CGI, ModPython, or its own built
in server.

It also has an ASP/JSP like syntax:
http://spyce.sourceforge.net/docs/doc-lang_asp.html

If you plan on getting a new hosting company you might also want to
look at TurboGears and Django.

-jjr

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


Re: question about scope

2006-02-17 Thread John Salerno
Fredrik Lundh wrote:
 John Salerno wrote:
 
 But my real question is this, which is related to the above:

 Name references search at most four scopes: local, then enclosing
 functions (if any), then global, then built-in.

 I understand what global and built-in are, and I thought I understood
 the concept of local too, but when I got to this sentence (and the
 previous sentence), I became confused about the first two scopes. What's
 the difference between 'local' and 'enclosing functions'?
 
 consider a nested function:
 
 var1 = global
 
 def outer():
 
 var2 = enclosing
 
 def inner():
 
 var3 = local
 
 print var1, var2, var3
 
 inner() # call it
 
 inside inner, var1 refers to the global variable, var2 to the enclosing
 variable (which is local to outer), and var3 to the local variable.
 
 enclosing scope locals are also called free variables.
 
 /F
 
 
 

Thanks guys. It seems like nested functions were what the authors had in 
mind, so that makes a lot more sense now.

But as far as ifs and loops, is there such a thing as scope in them? For 
example, if I assign a variable within an if statement, is it usable 
anywhere else?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pythonic way of 'b = list(a); b.append(4)

2006-02-17 Thread Steven D'Aprano
On Thu, 16 Feb 2006 08:04:43 -0800, szabi wrote:

 Hi!
 
 I have a list of three values and want to call a function with four
 parameters. I would like
 to write something like:
 
 a = [1, 2, 3]
 f(*a, 4)
 
 This is syntactically wrong, so is there a function which appends a
 value to a list and
 returns the new value, so that I could write something like this:
 
 f(list(a).functional_append(4))

Sure there is, just not as a list method. Python is a programming
language, you can write any function you like:

def functional_append(L, extra):
Return a new list consisting of extra appended to the items of L.
return L + [extra]

Now call it like this:

f(functional_append(a, 4))

But in fact you can now optimize the functional_append away by just doing
this:

f(*a+[4])

and it will work.


-- 
Steven.

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


Re: question about scope

2006-02-17 Thread Jean-Paul Calderone
On Thu, 16 Feb 2006 15:18:29 GMT, John Salerno [EMAIL PROTECTED] wrote:
 [snip]

I understand what global and built-in are, and I thought I understood
the concept of local too, but when I got to this sentence (and the
previous sentence), I became confused about the first two scopes. What's
the difference between 'local' and 'enclosing functions'? I thought that
the only way to create a local namespace was if there *was* a function
definition, so now I'm confused by the apparent difference that the
authors are referring to. What's an example of a local scope without
having a function definition? Loops and if statements, perhaps?

print dir # comes from __builtins__
dir = 10
print dir # comes from globals
def foo():
dir = 10
print dir # comes from locals
def bar():
print dir # comes from enclosing scope - foo's scope

Hope this helps,

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


Re: file.read problem

2006-02-17 Thread Fredrik Lundh
wscrsurfdude wrote:

 if it's a binary file, open with mode rb.

 You are right about opening it in the rb mode (flaw in the start post),
 but also when I do this in windows in front of every 0x0A is put a
 0x0D. I found a explanation why it is working in linux it is below in
 my post.

 But what i get of this that in windows in front of every 0x0A is put a
 0x0D as a line feed. II have to get rid of these.

if you open a file in binary mode (rb), you get the data that's in the
file.  no more, no less.  if someone's adding CR to the files, that happens
before you opened them in Python.

have you, perhaps, copied binary files between the systems using FTP
in text mode?  if so, you've damaged the files, and there's no way to fix
them, in general.

/F



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


Re: define loop statement?

2006-02-17 Thread Rene Pijlman
David Isaac:
I would like to be able to define a loop statement
(nevermind why) so that I can write something like

loop 10:
do_something

instead of

for i in range(10):
do_something

Possible?  If so, how?

Yes. By implementing a compiler or an interpreter for your programming
language. Or a preprocessor that converts your language to Python, or some
other suitable intermediate language. Or a programmer, that converts your
pseudocode and some coffee to the desired algorithm :-)

-- 
René Pijlman
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Merging two lists of data (Pythonic way)

2006-02-17 Thread SMB

Jonathan Gardner [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 codes = map(lambda x: x[0], list1)
 for d in list2:
  if d['code'] in codes:
d['VERIFIED'] = 1

 Is this what you were looking for?


Actually, this is not exactly what I was looking for.  I failed to realize 
what map did, in this case using the labmda x: x[0] on each item of the list 
returning a list of the key numbers.  The problem is that the changes made 
to my dictionary (in my example dictionary[VERIFIED]=1) needs to be based 
on the other values in each list in LIST1.

In my example LIST1 was defined as
[[5L, 1L, 1L, 'Personal Information'], [14L, 2L, 1L, '']]

So, the dictionary changes would be involving mylist[1:] for each mylist in 
LIST1 based on the comparison to mylist[0]...

Thank again 


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


Re: Evil, evil wxPython (and a glimmer of hope)

2006-02-17 Thread [EMAIL PROTECTED]
snoe wrote:

 Take a look at dabo, II think they're doing exactly what you're
 describing.
 http://blog.dabodev.com/

Dabo appear to be doing way more than what I want, with database access
etc.

My ideal module, when implemented, would be extremely small as far as
the size of code goes. I'm using path.py as an example:

http://www.jorendorff.com/articles/python/path/path.py

   def dirs(self, pattern=None):
 D.dirs() - List of this directory's subdirectories.

return [p for p in self.listdir(pattern) if p.isdir()]

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


RE: Some general questions about using stdin,stdout....

2006-02-17 Thread asdsd sir
thank you very much for your help...
my big mistake,was to believe that | is the pipe symbol for both,unix and 
python...
it is really annoying,how such a simple thing can mess things

Thank you for clearing this out.

_
Free blogging with MSN Spaces  http://spaces.msn.com/?mkt=nl-be

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


Re: ANN: Release of NumPy 0.9.5

2006-02-17 Thread Travis E. Oliphant
Thomas Gellekum wrote:
 Travis E. Oliphant [EMAIL PROTECTED] writes:
 
 
  -  Improvements to numpy.distutils
 
 
 Stupid questions: is it really necessary to keep your own copy of
 distutils and even install it? What's wrong with the version in the
 Python distribution? How can I disable the colorized output to get
 something more readable than yellow on white (well, seashell1)?
 

Yes --- distutils does not provide enough functionality.

Besides, it's not a *copy* of distutils.  It's enhancements to 
distutils.  It builds on top of standard distutils.

I don't know the answer to the colorized output question.  Please post 
to [EMAIL PROTECTED] to get more help and/or make 
suggestions.

-Travis



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


Re: mod_python and open HTTP connection

2006-02-17 Thread grahamd

Charles wrote:
 Hello, I'm think about using mod_python for a project but I need to make
 sure: Does mod_python time out after a minute ? (I hope not).

Mod_python itself doesn't time out. If such a thing happened it
would be because of how Apache, some intermediate proxy or
the client is configured.

 If I leave
 an HTTP connection open so that the content keeps loading inside the
 browser window indefinately, and if I close the browser window, the
 mod_python process is terminated, right?

If the mod_python handler is periodically writing data back to the
browser, at the point the socket connection from the client closes,
the attempt to write data back to the client by the mod_python
handler will result in an IOError exception being raised. Presuming
that your handler code doesn't catch this and ignore it, it should
cause the handler to abort.

Note though that it doesn't cause any process to be terminated as
that is not how Apache/mod_python work. It will cause just that
current request to be terminated. That thread of control can then
be reused to handle a subsequent request.

BTW, for tricky questions on mod_python you are better of using
the mod_python mailing list. Details on the mod_python web site.

Graham

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


Re: define loop statement?

2006-02-17 Thread bearophileHUGS
David Isaac:
 I would like to be able to define a loop statement
 (nevermind why) so that I can write something like

 loop 10:
 do_something

 instead of

 for i in range(10):
 do_something

 Possible?  If so, how?

It seems that you are looking for macros; maybe Logix language
(www.livelogix.net/logix) or Boo (boo.codehaus.org) can solve your
problem.
Otherwise you can do it with very different languages like Lisp or
Scheme (with a different syntax) and maybe Dylan too.

If you tell us your purpose, maybe we can suggest you a
better/different solution.

Bye,
bearophile

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


Re: Pyserial never read

2006-02-17 Thread jdhmistey
I don't know alot about python but I could help you with english?
eventhough it was really good

best regards-
Just

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


Re: Seaching Active Directory via ADO

2006-02-17 Thread LittlePython
I notice there is no adodb.command. This is not required?
Thx for the example!
Roger Upole [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Here's a short example that uses ADO to search for a
 user by wildcard.

 import win32com.client
 c = win32com.client.Dispatch(ADODB.Connection)
 c.Open(Provider=ADSDSOObject)

 rs,rc=c.Execute(
 SELECT adspath, title, name
 From 'LDAP://DC=yourdomain, DC=COM'
 where objectClass='user' and name='Roger*'
 )

 while not rs.EOF:
 for f in rs.Fields:
 print f.Name, f.Value
 rs.MoveNext()

 hth
   Roger

 LittlePython [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  Thanks but I was looking more for ADO com object than ADSI or ldap.
  For some strange reason it is very hard to locate any working scripts
that
  use ADO  to connect and search AD. Is there an issue with ADO and python
  when connecting to AD?
  I have try to build one myself with no luck. I think my problem is with
  adodb.command calls.
 
  Thanks for your response.
 
  alex23 [EMAIL PROTECTED] wrote in message
  news:[EMAIL PROTECTED]
   Heya,
  
   There are a couple of examples on the O'Reilly site. These two are
   taken from 'Active Directory Cookbook', the first uses a COM object
   while the second uses a native LDAP module:
  
  
 

http://www.rallenhome.com/books/adcookbook/src/18.6-rootdse_python_com.py.tx
  t
  
 

http://www.rallenhome.com/books/adcookbook/src/18.6-rootdse_python_ldap.py.t
  xt
  
   This might give you a start.
  
   - alex23
  
 
 



 == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet
News==
 http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+
Newsgroups
 = East and West-Coast Server Farms - Total Privacy via Encryption
=


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


Re: Open Relay Test

2006-02-17 Thread D
Nope, quite the contrary..I'm looking to write a simple program for a
client of mine that will, among other things, verify that their
clients' email servers do not have open relays.

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


zope 3.2 and imprt errors

2006-02-17 Thread zunbeltz
Hi,

I've installed zope3.2 froma tarball. It has been installed in
/usrlocal/Zope-3-2. I am developing a package under
~/zope3instance/lib/python/  (which is my instance directory). My
PYTHONPATH
is:

/home/zunbeltz/libs/python/:/usr/local/Zope-3.2.0/lib/python:/home/zunbeltz/zope3instance/lib/python:/home/zunbeltz/pycontrol

I have the following error

Python 2.4.2 (#2, Sep 30 2005, 21:19:01)
[GCC 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu8)] on linux2
Type help, copyright, credits or license for more information.
 from zope.app import container
 container.interfaces
Traceback (most recent call last):
  File stdin, line 1, in ?
AttributeError: 'module' object has no attribute 'interfaces'
 container.interfaces.IContained
Traceback (most recent call last):
  File stdin, line 1, in ?
AttributeError: 'module' object has no attribute 'interfaces'

the file whre zope.app.container is :

/usr/local/Zope-3.2.0/lib/python/zope/app/container/__init__.pyc

And in this directory there is a module named interfaces

I'm becoming crazy, I don't know where is the problem.
Any idea?
Thanks in advance

Zunbeltz

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


RE: Win32_Process.Create -- not starting process

2006-02-17 Thread Tim Golden
[abcd]

| Tim,
| I am skipping using the batch file and only executing the python
| script directly...and so far it works fine.
| 
| So now I have:
| pid, retVal =
| wmi.WMI(1.2.3.4).new(Win32_Process).Create(CommandLine=c:
| \python\python.exe
| c:\some_script.py)
| 
| Thanks again...not sure why when using the batch file to start it
| wouldnt always work, but as long is it works now!

Thanks for letting me know. Hope it continues to work
for you.

BTW, I would recommend you either to use a raw string
for that command line (rc:\python\python.exe c:\xx.py) or
to double up your slashes (c:\\python\\python.exe c:\\xx.py).
As it happens \p has no special meaning that I'm
aware of, but better safe than sorry...

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


embedding python in HTML

2006-02-17 Thread John Salerno
I'm hoping someone can give me the basics for how to do very simple 
things with Python scripts from within my HTML. For example, I know that 
I can do this in PHP:

h1Here is a header/h1
?php include(file.html); ?// include some external html
pMore html/p

So to do this with Python, do I simply integrate it into the HTML as 
above, with no extra steps? Also, which symbols do I use to denote 
Python language?

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


preserving POST data

2006-02-17 Thread Steve Young
Lets say that I'm filling out a form and the information gets sent to  another server first for some processing(before the one that it  "should" go to). But from there, I want that intermediate server to be  able to preserve this POST data using python so it can still retrieve  the page that was originally requested (with some modifications from  the intermediate server). Is there a way to do this with python? Thanks  for the help.-Steve  
		Brings words and photos together (easily) with 
PhotoMail  - it's free and works with Yahoo! Mail.-- 
http://mail.python.org/mailman/listinfo/python-list

Merging two lists of data (Pythonic way)

2006-02-17 Thread SMB
I have two lists of data like the following:

LIST1
 [[5L, 1L, 1L, 'Personal Information'], [14L, 2L, 1L, '']]

LIST2
[{'code': 5L, 'name': 'First Name', 'value': [''], 'label': 'First Name', 
'width': 0L, 'separator': ',', 'height': 0L, 'type': 2L, 'order': 1L}, 
{'code': 14L, 'name': 'Last Name', 'value': [''], 'label': 'Last Name', 
'width': 0L, 'separator': ',', 'height': 0L, 'type': 2L, 'order': 2L}, 
{'code': 16L, 'name': 'Job Title', 'value': [], 'label': 'Job Title', 
'width': 40L, 'separator': '', 'height': 0L, 'type': 2L, 'order': 3L}]

The important comparison values here are list[0] for each list in LIST1 and 
dictionary[code] for each dictionary in LIST2.

What I am doing is looking for a pythonic way to parse the LIST2 code 
values and make appropriate changes to to each dictionary if the code 
value is the first element of a list in LIST1.

The final result may look like this given that the change is adding a new 
key/value of VERIFIED/1 for the matches.
LIST3
 [{'VERIFIED':1,'code': 5L, 'name': 'First Name', 'value': [''], 'label': 
'First Name', 'width': 0L, 'separator': ',', 'height': 0L, 'type': 2L, 
'order': 1L}, {'VERIFIED':1,'code': 14L, 'name': 'Last Name', 'value': [''], 
'label': 'Last Name', 'width': 0L, 'separator': ',', 'height': 0L, 'type': 
2L, 'order': 2L}, {'code': 16L, 'name': 'Job Title', 'value': [], 'label': 
'Job Title', 'width': 40L, 'separator': '', 'height': 0L, 'type': 2L, 
'order': 3L}]

I know I could do this with two for loops, but am looking for a better 
solution maybe involving list comprehension.

Any pointers are appreciated.
Thanks 


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


Re: web crawler in python or C?

2006-02-17 Thread Ravi Teja
This is following the pattern of your previous post on language choice
wrt. writing a mail server. It is very common for beginers to over
emphasize performance requirements, size of the executable etc. More is
always good. Right? Yes! But at what cost?

The rule of thumb for all your Python Vs C questions is ...
1.) Choose Python by default.
2.) If your program is slow, it's your algorithm that you need to check
first. Python strictly speaking will be slow because of its dynamism.
However, most of whatever is performance critical in Python is already
implemented in C. And the speed difference of well written Python
programs with properly chosen extensions and algorithms is not far off.
3.) Remember that you can always drop back to C where ever you need to
without throwing all of your code. And even if you had to, Python is
very valuable as a prototyping tool since it is very agile. You would
have figured out what you needed to do by then, that rewriting it in C
will only take a fraction of the time compared to if it was written in
C directly.

Don't even start with asking the question, is it fast enough? till
you have already written it in Python and it turns out that it is not
running fast enough despite correctness of your code. If it does, you
can fix it relatively easily. It is easy to write bad code in C and
poorly written C code performance is lower than well written Python
code performance.

Remember Donald Knuth's quote.
Premature optimization is the root of all evil in programming.

C is a language intended to be used when you NEED tight control over
memory allocation. It has few advantages in other scenarios. Don't
abuse it by choosing it by default.

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


Re: define loop statement?

2006-02-17 Thread Xavier Morel
Rene Pijlman wrote:
 David Isaac:
 I would like to be able to define a loop statement
 (nevermind why) so that I can write something like

 loop 10:
do_something

 instead of

 for i in range(10):
do_something

 Possible?  If so, how?
 
 Yes. By implementing a compiler or an interpreter for your programming
 language. Or a preprocessor that converts your language to Python, or some
 other suitable intermediate language. Or a programmer, that converts your
 pseudocode and some coffee to the desired algorithm :-)
 
Or by hacking through the Python source and creating his own somehow 
pythonish but absolutely not python language
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: question about scope

2006-02-17 Thread Brian van den Broek
John Salerno said unto the world upon 16/02/06 09:18 AM:

snip

 Name references search at most four scopes: local, then enclosing 
 functions (if any), then global, then built-in.
 
 I understand what global and built-in are, and I thought I understood 
 the concept of local too, but when I got to this sentence (and the 
 previous sentence), I became confused about the first two scopes. What's 
 the difference between 'local' and 'enclosing functions'? I thought that 
 the only way to create a local namespace was if there *was* a function 
 definition, so now I'm confused by the apparent difference that the 
 authors are referring to. What's an example of a local scope without 
 having a function definition? Loops and if statements, perhaps?
 
 And feel free to dissect that first sentence up above, because I just 
 don't get it.

Does this help?

IDLE 1.1.2
  scope = Global
  def test():
scope = enclosing
def nested_test():
print scope
nested_test()


  test()
enclosing
  def test2():
scope = enclosing
def nested_test():
scope = nested
print scope
nested_test()


  test2()
nested
 

Best,

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


Re: Seaching Active Directory via ADO

2006-02-17 Thread Roger Upole
Here's a short example that uses ADO to search for a
user by wildcard.

import win32com.client
c = win32com.client.Dispatch(ADODB.Connection)
c.Open(Provider=ADSDSOObject)

rs,rc=c.Execute(
SELECT adspath, title, name
From 'LDAP://DC=yourdomain, DC=COM'
where objectClass='user' and name='Roger*'
)

while not rs.EOF:
for f in rs.Fields:
print f.Name, f.Value
rs.MoveNext()

hth
  Roger

LittlePython [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Thanks but I was looking more for ADO com object than ADSI or ldap.
 For some strange reason it is very hard to locate any working scripts that
 use ADO  to connect and search AD. Is there an issue with ADO and python
 when connecting to AD?
 I have try to build one myself with no luck. I think my problem is with
 adodb.command calls.

 Thanks for your response.

 alex23 [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  Heya,
 
  There are a couple of examples on the O'Reilly site. These two are
  taken from 'Active Directory Cookbook', the first uses a COM object
  while the second uses a native LDAP module:
 
 

http://www.rallenhome.com/books/adcookbook/src/18.6-rootdse_python_com.py.tx
 t
 

http://www.rallenhome.com/books/adcookbook/src/18.6-rootdse_python_ldap.py.t
 xt
 
  This might give you a start.
 
  - alex23
 





== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet 
News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ 
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Seaching Active Directory via ADO

2006-02-17 Thread Rudy Schockaert
You could also use the excellent active_directory module of Tim Golden (http://tgolden.sc.sabren.com/python/active_directory.html)Your query would then become:
import active_directoryfor person in active_directory.search (objectClass='user',name='Roger*'):  print person.displayName
On 2/17/06, Roger Upole [EMAIL PROTECTED] wrote:
Here's a short example that uses ADO to search for auser by wildcard.import win32com.clientc = win32com.client.Dispatch(ADODB.Connection)c.Open(Provider=ADSDSOObject)rs,rc=
c.Execute(SELECT adspath, title, nameFrom 'LDAP://DC=yourdomain, DC=COM'where objectClass='user' and name='Roger*')while not rs.EOF:for f in rs.Fields
:print f.Name, f.Valuers.MoveNext()hthRogerLittlePython [EMAIL PROTECTED] wrote in messagenews:[EMAIL PROTECTED]
... Thanks but I was looking more for ADO com object than ADSI or ldap. For some strange reason it is very hard to locate any working scripts that use ADOto connect and search AD. Is there an issue with ADO and python
 when connecting to AD? I have try to build one myself with no luck. I think my problem is with adodb.command calls. Thanks for your response. alex23 
[EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]  Heya,   There are a couple of examples on the O'Reilly site. These two are
  taken from 'Active Directory Cookbook', the first uses a COM object  while the second uses a native LDAP module:  
http://www.rallenhome.com/books/adcookbook/src/18.6-rootdse_python_com.py.tx t http://www.rallenhome.com/books/adcookbook/src/18.6-rootdse_python_ldap.py.t
 xt   This might give you a start.   - alex23 == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups= East and West-Coast Server Farms - Total Privacy via Encryption =--
http://mail.python.org/mailman/listinfo/python-list-- It is not economical to go to bed early to save the candles if the result is twins. - Chinese Proverb 
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: mod_python help!

2006-02-17 Thread Olivier
treelife a écrit :
 I'm getting and internal server error when | run the following
 mod_python script.  I am actually trying to run Django.
 
 Script:
 
 from mod_python import apache
 
 def handler(req):
 req.content_type = 'text/plain'
 req.write(Under Construction)
 return apache.OK



You just cant't import mod_python.apache from the command line.
To run your scripts, you usually do things like (not tested):

try:
 from mod_python import apache
 APACHE = True
except ImportError:
 # for when I'm outside Apache
 APACHE = False


class DummyRequest:
 Simulates a request object

 def write(self, mstr):
 print mstr

 # you may need some other things...


def handler(req):
 req.content_type = 'text/plain'
 req.write(Under Construction)
 if APACHE:
 return apache.OK


##
if __name__ == __main__:
 req = DummyRequest()
 handler(req)


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


Re: Does python have an internal list/dictionary of functions?

2006-02-17 Thread Raymond Hettinger
[Carl J. Van Arsdall]
 basically we have:

  def functA():
 ...  pass

   functA
 function functA at 80db128

 And what I'd like to do is:

  __internalFuncDict__['functA']
 function functA at 80db128

globals()['functA']

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


Re: Win32_Process.Create -- not starting process

2006-02-17 Thread abcd
Tim Golden wrote:
 BTW, I would recommend you either to use a raw string
 for that command line (rc:\python\python.exe c:\xx.py) or
 to double up your slashes (c:\\python\\python.exe c:\\xx.py).
 As it happens \p has no special meaning that I'm
 aware of, but better safe than sorry...


i used double slashes, i guess i didn't type it correctly here.
Thanks for the reminder though.

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


Antigen found Exceeded Internet Timeout virus

2006-02-17 Thread ANTIGEN_MAIL
Title: Antigen found Exceeded Internet Timeout virus





Antigen for Exchange found Body of Message infected with Exceeded Internet Timeout virus.
The file is currently Detected. The message, Re: Jython socket typecasting problems, was
sent from [EMAIL PROTECTED] and was discovered in IMC Queues\Inbound
located at Prism Payment Technologies/PRISMTSS/MAIL.



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

Re: Open Relay Test

2006-02-17 Thread Ben Finney
D [EMAIL PROTECTED] writes:
 Hi all .. how could one test to see if an open relay exists on a
 specific email server?

Use the Distributed Sender Blackhole List service:

URL:http://dsbl.org/

They have client programs to make it easy to use the service to test
mail systems for vulnerabilities:

URL:http://dsbl.org/programs

-- 
 \ Buy not what you want, but what you need; what you do not need |
  `\   is expensive at a penny.  -- Cato, 234-149 BC, Relique |
_o__)  |
Ben Finney http://www.benfinney.id.au/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: embedding python in HTML

2006-02-17 Thread John Salerno
Rene Pijlman wrote:
 John Salerno:
 [Python alternative for PHP]
 So to do this with Python, do I simply integrate it into the HTML as 
 above, with no extra steps? 
 
 You'd need something like the PHP engine, that understands Python rather
 than PHP.

My web server can run Python, fortunately. Now that they've turned it on 
for me, I wanted to try it out, but I didn't know how to go about 
writing a bit of code to stick into an HTML file.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Databases and python

2006-02-17 Thread Dan Stromberg
On Thu, 16 Feb 2006 10:09:42 +0100, Rene Pijlman wrote:

 Dan Stromberg:
is there a python database interface that would allow me to define a 
-lot- of tables?  Like, each word becomes a table, and then the fields 
in that table are just the filenames that contained that word.
 
 Give ZODB a try. 
 http://www.zope.org/Wikis/ZODB/FrontPage
 http://www.python.org/workshops/2000-01/proceedings/papers/fulton/zodb3.html

Aside from object persistence, what would this add for me?

Is each object saved in a separate file, or are they bunched together into
one or more files?

 My first attempt would be: a BTree with the word as key, and a 'list of
 filenames' as value.
 http://www.zope.org/Wikis/ZODB/FrontPage/guide/node6.html#SECTION00063

This is basically what I'm doing now, except the most recently used lists
of filenames are kept in RAM to avoid going from on disk string to in
memory list to on disk string quite as much.

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


Re: Python advocacy in scientific computation

2006-02-17 Thread Peter Tillotson
Hi,

Like it - an area that doesn't come out strongly enough for me is 
Python's ability to drop down to and integrate with low level 
algorithms. This allows me to to optimise the key bits of design in 
python very quickly and then if I still need more poke i can drop down 
to low level programming languages. Optimise design, not code unless I 
really need to.

To be fair the same is at least partly true for Java ( though supporting 
JNI code scares me ) but my prototyping productivity isn't as high.

The distributed / HPC packages may also be worth noting - PyMPI and 
PyGlobus.

p

Michael Tobis wrote:
 Someone asked me to write a brief essay regarding the value-add
 proposition for Python in the Fortran community. Slightly modified to
 remove a few climatology-related specifics, here it is.
 
 I would welcome comments and corrections, and would be happy to
 contribute some version of this to the Python website if it is of
 interest.
 
 ===
 
 The established use of Fortran in continuum models such as climate
 models has some benefits, including very high performance and
 flexibility in dealing with regular arrays, backward compatibility with
 the existing code base, and the familiarity with the language among the
 modeling community. Fortran 90 and later versions have taken many of
 the lessons of object oriented programming and adapted them so that
 logical separation of modules is supported, allowing for more effective
 development of large systems. However, there are many purposes to which
 Fortran is ill-suited which are increasingly part of the modeling
 environment.
 
 These include: source and version control and audit trails for runs,
 build system management, test specification, deployment testing (across
 multiple platforms), post-processing analysis, run-time and
 asynchronous visualization, distributed control and ensemble
 management. To achieve these goals, a combination of shell scripts,
 specialized build tools, specialized applications written in several
 object-oriented languages, and various web and network deployment
 strategies have been deployed in an ad hoc manner. Not only has much
 duplication of effort occurred, a great deal of struggling up the
 learning curves of various technologies has been required as one need
 or another has been addressed in various ad hoc ways.
 
 A new need arises as the ambitions of physical modeling increase; this
 is the rapid prototyping and testing of new model components. As the
 number of possible configurations of a model increases, the expense and
 difficulty of both unit testing and integration testing becomes more
 demanding.
 
 Fortunately, there is Python. Python is a very flexible language that
 has captured the enthusiasm of commercial and scientific programmers
 alike. The perception of Python programmers coming from almost any
 other language is that they are suddenly dramatically several times
 more productive than previously, in terms of functionality delivered
 per unit of programmer time.
 
 One slogan of the Python community is that the language fits your
 brain. Why this might be the case is an interesting question. There
 are no startling computer science breakthroughs original to the
 language, Rather, Python afficionados will claim that the language
 combines the best features of such various languages as Lisp, Perl,
 Java, and Matlab. Eschewing allegiance to a specific theory of how to
 program, Python's design instead offers the best practices from many
 other software cultures.
 
 The synergies among these programming modes is in some ways harder  to
 explain than to experience. The Python novice may nevertheless observe
 that a single language can take the place of shell scripts, makefiles,
 desktop computation environments, compiled languages to build GUIs, and
 scripting languages to build web interfaces. In addition,  Python is
 useful as a wrapper for Fortran modules, facilitating the
 implementation of true test-driven design processes in Fortran models.
 
 Another Python advocacy slogan is batteries included. The point here
 is that (in part because Python is dramatically easier to write than
 other languages) there is a very broad range of very powerful standard
 libraries that make many tasks which are difficult in other languages
 astonishingly easy in Python. For instance, drawing upon the standard
 libraries (no additional download required)  a portable webserver
 (runnable on both Microsoft and Unix-based platforms) can be
 implemented in seven lines of code. (See
 http://effbot.org/librarybook/simplehttpserver.htm ) Installation of
 pure python packages is also very easy, and installation of mixed
 language products with a Python component is generally not
 significantly harder than a comparable product with no Python
 component.
 
 Among the Python components and Python bindings of special interest to
 scientists are the elegant and powerful matplotlib plotting package,
 which began by emulating and now 

Re: Some general questions about using stdin,stdout....

2006-02-17 Thread Steve Holden
asdsd sir wrote:
 thank you very much for your help...
 my big mistake,was to believe that | is the pipe symbol for both,unix and 
 python...
 it is really annoying,how such a simple thing can mess things
 
 Thank you for clearing this out.
 
It is indeed annoying when assumptions we carry from one environment 
turn out to be untrue for another. I can almost hear the unspoken 
thought (But Perl is similar to shell scripting in this way, so why 
aren't other languages?) - though I may be doing you a disservice 
assuming that you know anything about Perl.

You will find as your programming experience increases that the 
different languages you learn are appropriate for different purposes, 
and have different advantages and disadvantages. Python excels at 
expressing algorithms in an unambiguous and easily-readable way. It's 
worth taking the time to learn it, and you are clearly already on your way.

I look forward to reading your next question. Welcome to comp.lang.python.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Add a month

2006-02-17 Thread novin01
Hi, this is probably a really simple question but...
How do you add a month to a datetime date in python? It would be nice
if  you could do something like:

d = datetime.date(2006,2,17)
dm = datetime.timedelta(months=1)
d_new = d + dm

but timedelta doesn't have a 'months' setting. Am I missing some easy
method or do I have to code a work around myself??

Thanks in advance for the help!

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


Re: mod_python and open HTTP connection

2006-02-17 Thread Charles
On Thu, 16 Feb 2006 21:35:13 -0300, Kane [EMAIL PROTECTED] wrote:

 btw, 'ping' as written above is horrible.  If a code review turned
 _that_ up on production someone would be fired, along with whoever
 hired them, whoever ate lunch with them and anyone that waves goodbye.

Really? Wow... Gotta be carefull from now on...


-- 
Charles.

Desenvolvimento e criação de sites: www.auriance.com
Hospedagem de sites e servidores dedicados: www.auriance.net
-- 
http://mail.python.org/mailman/listinfo/python-list


Does python have an internal list/dictionary of functions?

2006-02-17 Thread Carl J. Van Arsdall
Python Gurus:

Let me elaborate a bit more on this question.  Basically, I want to know 
if there is some data structure in python that maps a string function 
name to an address of a function or something to that nature.

If this is confusing, let me describe what I want to do and see if 
anyone has any ideas.

basically we have:

 def functA():
...  pass

  functA
function functA at 80db128

And what I'd like to do is:

 __internalFuncDict__['functA']
function functA at 80db128

This is just for a little experimental project of mine, any help or 
pointers to the proper pages in the manual would be greatly 
appreciated.  Basically, I know that I can create something like this if 
I have to but I was very much hoping that something already existed 
somewhere that I could get to via python or by writing a C extension.

Thanks in advance!

-carl


-- 

Carl J. Van Arsdall
[EMAIL PROTECTED]
Build and Release
MontaVista Software

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


Terminating a function

2006-02-17 Thread Astan Chee
Hi,
Im rather new to threads in python but Im trying to terminate a function 
call (or the execution of the function) after a certain period of time 
has passed.
Do i need to use threads with this? if i do, how do i go about doing it?
Thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Add a month

2006-02-17 Thread Raymond Hettinger
[EMAIL PROTECTED]
 Hi, this is probably a really simple question but...
 How do you add a month to a datetime date in python? It would be nice
 if  you could do something like:

 d = datetime.date(2006,2,17)
 dm = datetime.timedelta(months=1)
 d_new = d + dm

 but timedelta doesn't have a 'months' setting. Am I missing some easy
 method or do I have to code a work around myself??

You need to code you own version.

It was not included with datetime.timedelta() because the definition is
ambiguous (i.e. what date is one month after Jan 30th?).


Raymond

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


  1   2   3   >