IMDbPY 2.3 released

2005-12-05 Thread Davide Alberani
IMDbPY 2.3 is available (tgz, deb, rpm, exe) from:
  http://imdbpy.sourceforge.net/

IMDbPY is a Python package useful to retrieve and manage the data of
the IMDb movie database about both movies and people.

This is mainly a bugfixes release; some bugs in mobile, sql and http
data access systems were solved.


Platform-independent and written in pure Python (and few C lines), it
can retrieve data from both the IMDb's web server and a local copy of
the whole database.

IMDbPY package can be very easily used by programmers and developers
to provide access to the IMDb's data to their programs.
Some simple example scripts are included in the package; other
IMDbPY-based programs are available from the home page.


-- 
Davide Alberani [EMAIL PROTECTED] [PGP KeyID: 0x465BFD47]
http://erlug.linux.it/~da/
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

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


akismet 0.1.2, cgiutils 0.3.5, pathutils 0.2.3

2005-12-05 Thread Fuzzyman
Hello All,

A new release and two updates.

New akismet.py 0.1.2


Python Interface to the Akismet API
Version 0.1.2 4th December 2005
http://www.voidspace.org.uk/python/modules.shtml#akismet

`Akismet http://www.akismet.com`_ is a web service for recognising
spam comments. It promises to be almost 100% effective at catching
comment spam. They say that currently 81% of all comments submitted to
them are spam.

It's designed to work with the `Wordpress Blog Tool
http://wordpress.org/`_, but it's not restricted to that - so this is
a Python interface to the `Akismet API
http://akismet.com/development/api/`_.

You'll need a `Wordpress Key http://wordpress.com`_ to use it. This
script will allow you to plug akismet into any CGI script or web
application, and there are full docs in the code. It's extremely easy
to use, because the folks at akismet have implemented a nice and
straightforward {acro;REST;REpresentational State Transfer} API.

It also comes with an `example CGI
http://www.voidspace.org.uk/cgi-bin/akismet/test_akismet.py`_.

(Although the akismet feature of an example positive doesn't seem to
be working currently - there fault not mine :-)

You can read the full (Python) docs at :

* `akismet.py Docs
http://www.voidspace.org.uk/python/akismet_python.html`_

Download it here :

*
http://www.voidspace.org.uk/cgi-bin/voidspace/downman.py?file=akismet-0.1.2.zip


cgiutils 0.3.5 - pathutils 0.2.3
=

pathutils 0.2.3 November 26th 2005
cgiutils 0.3.5 November 26th 2005
http://www.voidspace.org.uk/python/recipebook.shtml#utils


These two modules contain functions and constants for *'general'* use.
They are
both included as part of the `Voidspace Pythonutils Package
http://www.voidspace.org.uk/python/modules.shtml#pythonutils`_ .
(A new release of pythonutils - containing these updated modules - is
due shortly).

**Pathutils** contains various functions for working with files and
paths. This
includes (amongst other thing) :

* Easy ways to iterate over files and directories
* A function to calculate a relative path from one location to another
* Several 'convenience' file reading/writing functions
* `py2exe http://www.py2exe.org`_ directory support
* A function for pretty printing file sizes
* A simple solution to cross-platform file locking
* Import from a specific location

See the `pathutils Homepage
http://www.voidspace.org.uk/python/pathutils.html`_.

**CGI utils** has (guess what... {sm;:?:}) various functions for use
with CGI.
It contains functions to do things that every CGI has to cope with.
They are
most useful for simple scripts, where a full blown framework would be
too
cumbersome.

It includes (amongst other thing) :

* Functions for receiving form submissions
* Cross platform functions to send emails (including creating
{acro;HTML}
  emails)
* A basic templating system
* A {acro;DNS;Domain Name System} blacklist lookup
* A function to generate a menu line for pages with lots of results

See the `cgiutils Homepage
http://www.voidspace.org.uk/python/cgiutils.html`_.

Download them here :

*
http://www.voidspace.org.uk/cgi-bin/voidspace/downman.py?file=utils.zip
(25k) (both modules)
*
http://www.voidspace.org.uk/cgi-bin/voidspace/downman.py?file=pathutils.py
(19k)}
*
http://www.voidspace.org.uk/cgi-bin/voidspace/downman.py?file=cgiutils.py
(20k)}

{small;The zip file has text versions of the docs for these two
modules.}

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

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


Re: oval

2005-12-05 Thread Peter Otten
Ben Bush wrote:

 is there any good material to read if I want to improve my
 understanding of working on interactive ways of dealing with shapes
 on the TKinter?

See http://wiki.python.org/moin/TkInter for a list of references. 
For me John Shipman's Tkinter Reference is normally sufficient.

Peter

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


Re: Tabs bad (Was: ANN: Dao Language v.0.9.6-beta is release!)

2005-12-05 Thread Sybren Stuvel
Steven D'Aprano enlightened us with:
 It seems to me that one tab per indent level is far more logical
 than some arbitrary number, N, of spaces, often a multiple of
 eight, or four, or two, per indent level, and hope that the number
 of spaces is a multiple of that arbitrary N. But maybe that's just
 me.

It's me too. One tab per indent makes perfect sense.

 went back to tabs, got frustrated with people complaining that
 indentation was being mangled by various webmail and News clients

This is about the only place where I use four spaces (typed as one
tab, expanded by Vim): email and Usenet. The reason? I don't want my
post to become too wide. If my stuff is read by someone with tab sizes
larger than four, it might become too wide, so to prevent that I use
spaces. For all other things (like real source code instead of a
pasted snippet) I use tabs.

 I'm almost fired up enough about this to start the Society For The
 Treatment Of Tabs As First Class Characters. *wink*

LOL count me in ;-)

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


Re: ADD HTML to the code

2005-12-05 Thread Fredrik Lundh
Little [EMAIL PROTECTED] wrote:

 Could someone tell me how to add some HTML tags to this program. I want
 to be able to change the background color, add some headers, and put a
 table below the map that will be displayed. Could someone please tell
 me how to add this to the current program.

the code reads the first part of the HTML from the googleHead.html file,
and the rest is added in the section that starts with the

# then add trailing html to finish page

comment.

assuming that you know how you want the HTML to look (styles and headers
should go into the googleHead file, the table into the trailing html part), a
text editor and the string chapters from the python tutorial should be enough
to get you going:

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

/F



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


Re: regexp non-greedy matching bug?

2005-12-05 Thread Fredrik Lundh
Aahz wrote:

 While you're technically correct, I've been bitten too many times by
 forgetting whether to use match() or search().  I've fixed that problem
 by choosing to always use search() and combine with ^ as appropriate.

that's a bit suboptimal, though, at least for cases where failed matches
are rather common:

C:\timeit -s import re; p = re.compile('b') p.match('a'*100)
10 loops, best of 3: 6.14 usec per loop

C:\timeit -s import re; p = re.compile('^b') p.match('a'*100)
10 loops, best of 3: 6.25 usec per loop

C:\timeit -s import re; p = re.compile('^b') p.search('a'*100)
10 loops, best of 3: 15.4 usec per loop

(afaik, search doesn't have any heuristics for figuring out if it can skip
the search, so it'll check ^ against all available positions)

on the other hand, benchmarking RE:s always results in confusing
results:

C:\timeit -s import re; p = re.compile('b') p.search('a'*100)
10 loops, best of 3: 4.32 usec per loop

(should this really be *faster* than match for this case ?)

/F



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


Re: Help needed: file writing problem with subprocess

2005-12-05 Thread Fredrik Lundh
Pekka Niiranen wrote:

 I am running Python script in W2K or in WinXP.
 The script is started from DOS prompt and writes text file to disk
 with codecs.open() in UTF8.

 The problem is: When script writes the file and tries to read it
 with by calling itself thru subprocess() the created files are
 NOT accessible because they have not been written into disk yet.
 fh.flush() and os.fsync() do not work.

 -- extract from myscript.py starts --

 fh = codecs.open(myfile.txt, w, utf8)
 fh.write(# Comment line\n)
 fh.writelines(some list)
 fh.flush()
 fh.close()

 then later:

 mycmd = %s -f %s % (myscript.py, myfile.txt)
 subprocess.call(mycmd, shell=True)

 This fails: myfile.txt is not yet written into disk
 and the myscript.py called thru subprocess fails.
 Only after the main script exits will myfile.txt occur
 into the directory.

this should of course work, and it sure works for me.

does this involve any unconventional file systems?  (file servers etc).

how much later is later ?

have you checked what the current directory is in all three cases?  (before
you create the file, before you call the script, and before you try to open the
file in the script).

/F



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


Re: Favorite flavor of Linux? (for python or anything else)

2005-12-05 Thread Mohammad Jeffry
another vote for Gentoo. It's my production/main OS now.
On 4 Dec 2005 23:21:55 -0800, malv [EMAIL PROTECTED] wrote:
In theory, this would do. I have tried this several times in the pastand found it very impractical to have to live with two Python versionson the same system, given that Python, like also Perl, is used by somany components. I may have done many things wrong but experience
taught me to better simplify things and live with one python versiononly. It mainly depends on the (huge amount of) time you can afford tostraighten out avoidable problems.I must say that since python 
2.3 and 2.4 I never tried dual setupsanymore. Indeed, Debian would be my preferred distro if it weren't forpython 2.3.malv--http://mail.python.org/mailman/listinfo/python-list
-- And whoever does an atom's weight of evil will see it.
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Detect character encoding

2005-12-05 Thread Michal
Thanks everybody for helpfull advices.

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


Re: ADD HTML to the code

2005-12-05 Thread Steve Holden
Fredrik Lundh wrote:
 Little [EMAIL PROTECTED] wrote:
 
 
Could someone tell me how to add some HTML tags to this program. I want
to be able to change the background color, add some headers, and put a
table below the map that will be displayed. Could someone please tell
me how to add this to the current program.
 
 
 the code reads the first part of the HTML from the googleHead.html file,
 and the rest is added in the section that starts with the
 
 # then add trailing html to finish page
 
 comment.
 
 assuming that you know how you want the HTML to look (styles and headers
 should go into the googleHead file, the table into the trailing html part), 
 a
 text editor and the string chapters from the python tutorial should be enough
 to get you going:
 
 http://docs.python.org/tut/tut.html
 

You might also want to think about the version below, which (though 
untested) uses rather commoner ways of expressing the same ideas:

 Publisher example 

def query(req, building=):
 # NOTE:  best way to understand this is to see the output,
 #  that is, to view source on the generated web page
 # read common header for any google mapping
 f = file('/home/ta/public_html/maplish/googleHead.html','r')
 t = f.read()
 f.close()
 # define the two buildings we know (because no SQL is done here)
 # Did I say two? Obviously there are six now ...
 # We just build the list as a single literal value
 buildings =  [
(cb, Cambus Office,  -91.552977, 41.659655),
(va/hardlib, VA/Hardin Library, -91.549501,41.662348),
(hancher, Hancher Auditorium,  -91.538214,41.669529),
(currier, Currier Hall,  -91.534996,41.666163),
(schaeffer, Schaeffer Hall,  -91.535296,41.660969),
(shospital, South Hospital,  -91.548900,41.658885)
 ]
 st = [t]  #  in case no buildings match, use empty string
 for a, b, c, d in buildings:
if building.lower() == a:
   # construct javascript, using Python %s to substitute names 
and data
   # see http://docs.python.org/lib/typesseq-strings.html if needed
   st.append('var bldg%s = new GPoint( %s, %s);\n' % (a, c, d)])
   st.append('var mrk%s = new GMarker( bldg%s );\n' % (a, a))
   st.append('var htm%s = %s;\n' % (a, b))
   st.append('GEvent.addListener(mrk%s,click,function() {' % a)
   st.append('mrk%s.openInfoWindowHtml(htm%s); });\n' % (a, a))
   st.append('map.addOverlay(mrk%s);\n' % a)
 # output markers, if any
 # then add trailing html to finish page
 trail = //]] /script /body /html
 return .join(st)+trail

Note that str is the name of a built-in data type, so I changed it to 
st.

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: Favorite flavor of Linux? (for python or anything else)

2005-12-05 Thread Fredrik Lundh
BartlebyScrivener wrote:

 Since it's a python board I'm most interested in the python
 implications. I thought you could use, say, a stable Debian
 distribution, and still download the newest version of Python
 to run on it.

works fine.

however, since applications shipped with the OS may depend on
the python version shipped with the OS, it's usually a good idea
to install newer releases with:

$ make altinstall

instead of the usual make install.

(altinstall does a standard install, but doesn't replace the python
command, so you have to use e.g python2.4 to start the new inter-
preter.  code using just python will still run the standard version).

if you want to mix and match on a finer level, it's probably best to
do only local installs, and tweak the path as necessary.

/F



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


Re: change color

2005-12-05 Thread Peter Otten
Ben Bush wrote:

 I tested the following code and wanted to make oval 2 become red after
 I hit the enter key but though the code did not report error, it did
 not change.
 from Tkinter import *
 root=Tk()
 canvas=Canvas(root,width=100,height=100)
 canvas.pack()
 canvas.create_oval(10,10,20,20,tags='oval1',fill='blue')
 canvas.create_oval(50,50,80,80,tags='oval2',fill='yellow')
 def turnRed(self, event):
 event.widget[activeforeground] = red
 self.button.bind(Enter, self.turnRed)
 canvas.tag_bind('oval2',func=turnRed)
 root.mainloop()

The Enter event is triggered when you enter a shape with the mouse
pointer, not when you press the key. 
It seems you cannot associate keypress events with shapes, only with the
whole canvas.

Here is some code for you to play with.

import Tkinter

def turnRed(event):
canvas.itemconfigure(oval2, fill=red)

def turnYellow(event):
canvas.itemconfigure(oval2, fill=yellow)

def keypress(event):
print you pressed return or enter
if oval2 in canvas.gettags(current):
canvas.itemconfigure(current, fill=green)

root = Tkinter.Tk()

canvas = Tkinter.Canvas(root, width=100, height=100)
canvas.pack()
canvas.create_oval(10, 10, 20, 20, tags=oval1, fill=blue)
canvas.create_oval(50, 50, 80, 80, tags=oval2, fill=yellow)

canvas.tag_bind(oval2, Enter, turnRed)
canvas.tag_bind(oval2, Leave, turnYellow)

canvas.bind(Key-Return, keypress)
canvas.bind(Key-KP_Enter, keypress)

canvas.focus_set()
root.mainloop()

Try pressing Return with the mouse pointer over oval2 and elsewhere on the
canvas. 

Peter

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


Re: Putting in an html table

2005-12-05 Thread bruno at modulix
Little wrote:
 Could someone start me on putting in a table into this code, and some
 HTML tags. I would to make the table below the map and have a header at
 the top. Thanks for the help.
 
  Publisher example 
 
 def query(req, building=):
 # NOTE:  best way to understand this is to see the output,
 #  that is, to view source on the generated web page
 # read common header for any google mapping
 f = file('/home/ta/public_html/maplish/googleHead.html','r')

Never hardcode a path.

 t = f.read()
 f.close()
 # define the two buildings we know (because no SQL is done here)
 buildings =  [ (cb, Cambus Office,  -91.552977, 41.659655)
 ]
 buildings +=  [ (va/hardlib, VA/Hardin Library, -91.549501,
 41.662348) ]
 buildings +=  [ (hancher, Hancher Auditorium,  -91.538214,
 41.669529) ]
 buildings +=  [ (currier, Currier Hall,  -91.534996,
 41.666163) ]
 buildings +=  [ (schaeffer, Schaeffer Hall,  -91.535296,
 41.660969) ]
 buildings +=  [ (shospital, South Hospital,  -91.548900,
 41.658885) ]

# avoid useless operations
 buildings =  [
   (cb, Cambus Office,  -91.552977, 41.659655),
   (va/hardlib, VA/Hardin Library, -91.549501, 41.662348),
   (hancher, Hancher Auditorium,  -91.538214, 41.669529),
   (currier, Currier Hall,  -91.534996, 41.666163) ,
   (schaeffer, Schaeffer Hall,  -91.535296, 41.660969),
   (shospital, South Hospital,  -91.548900, 41.658885)
]


 str = ''  #  in case no buildings match, use empty string
# don't use 'str' as an identifier, it will shadow the builtin str type.


 for x in buildings:
a,b,c,d = x   # isolate all the tuple components into a,b,c,d
if building.lower() == a:

If what you want is to find the building matching the one given as
argument, you should build a dict, not a list of tuples.

 buildings =  {
   cb : (Cambus Office,  -91.552977, 41.659655),
   va/hardlib : (VA/Hardin Library, -91.549501, 41.662348),
   hancher : (Hancher Auditorium,  -91.538214, 41.669529),
   currier : (Currier Hall,  -91.534996, 41.666163) ,
   schaeffer : (Schaeffer Hall,  -91.535296, 41.660969),
   shospital : (South Hospital,  -91.548900, 41.658885)
}

Now you don't need to loop and compare, a simple :
buildings.get(building.lower())
should be enough

(NB : Anyway, this dict should not be hardcoded. Put this in a separate
conf file, in a db, or whatever, but keep it out of the code.)


   # construct javascript, using Python %s to substitute names
 and data
   # see http://docs.python.org/lib/typesseq-strings.html if
 needed
   str =  'var bldg%s = new GPoint( %s, %s);\n' % (a, c, d)
   str += 'var mrk%s = new GMarker( bldg%s );\n' % (a, a)
   str += 'var htm%s = %s;\n' % (a, b)
   str += 'GEvent.addListener(mrk%s,click,function() {' % a
   str += 'mrk%s.openInfoWindowHtml(htm%s); });\n' % (a, a)
   str += 'map.addOverlay(mrk%s);\n' % a

string concatenation is not an efficient idiom. In a loop, the common
idiom is to use a list and join it, but here I guess a triple quoted
string and simple templating trick would be better.


 # output markers, if any
 t = t + str
 # then add trailing html to finish page
 trail = //]] /script /body /html
 t = t + trail
 return t

This is definitevely not how I would do HTML/js in Python. There are a
lot of templating / HTML generation tools available, that allow to
cleanly separate logic from presentation.

-- 
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: Installing Eric?

2005-12-05 Thread malv
Kenneth McDonald wrote:
 I'm wondering if anyone has experience/tips to offer on installing
 Eric on OS X and XP. Installation on both seems to require a number
 of steps, some of them seeming potentially fragile, and I'm wondering
 if I'm looking at a job of perhaps hours (days?), or if everyone
 manages in just a few minutes.

 Thanks,
 Ken
Basic reference: http://www.die-offenbachs.de/detlev/eric3.html.
Install of course Python-2.4.1:
http://python.org/ftp/python/2.4.1/python-2.4.1.msi
You need to install Qt, Sip, QScintilla and PyQt.
For linux things are easy. Install KDE (along with gnome if you want)
and everything will be there ready for eric3 installation.


On Windows, you need to somehow get Qt. Besides a commercial license or
an educational license (check with university) there exist 2
possibilitees for Qt free: (1) Qt4 free but I'm not sure about the
status of the announced PyQt; and (2) Qt3 GPL. PyQt has everything you
need for these possibilities, except for the GPL.
For the free GPL download:
http://www.quadgames.com/download/pythonqt/PyQtGPL10.exe. This will
give you everything at once:
Qt 3.3.4 (derived from http://kde-cygwin.sourceforge.net/)
Sip 4.1.1
QScintilla 1.62
PyQt 3.13

After this get
http://prdownloads.sourceforge.net/eric-ide/eric-3.8.0.tar.gz?download
Unpack into a directory under your python2.4 directory.
Then issue 'python install.py' and you should be ready to go (eric will
set itself up under site-packages)
malv

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


Re: ADD HTML to the code

2005-12-05 Thread bruno at modulix
Little wrote:
 Could someone tell me how to add some HTML tags to this program. I want
 to be able to change the background color, add some headers, and put a
 table below the map that will be displayed. Could someone please tell
 me how to add this to the current program. Thanks in advance.
 
(snip)
Do yourself a favor : check the various templating tools available,
choose one that fits you taste, and stop embedding half-baked html in
your Python code.


-- 
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: Efficient lookup in list of dictionaries

2005-12-05 Thread bruno at modulix
David Pratt wrote:
(snip)
 Can someone advise a more efficient lookup when using lists of
 dictionaries. Many thanks.
 
 
 TEST_CONSTANTS = [
 {'color':'red', 'shape':'octagon'},
 {'color':'yellow', 'shape':'triangle'},
 {'color':'green', 'shape':'circle'}]

COLOR_INDEX = dict([(item['color'], item) for item in TEST_CONSTANT])
SHAPE_INDEX = dict([item['shape'], item) for item in TEST_CONSTANT])

def getShapeForColor(color):
  return COLOR_INDEX.get(color, {'shape':None})['shape']

def getColorForShape(shape):
  return SHAPE_INDEX.get(color, {'color': None})['color']

This of course assume that there are no duplicate colors nor shapes.

-- 
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: what's wrong with lambda x : print x/60,x%60

2005-12-05 Thread bruno at modulix
Gary Herron wrote:
 Mohammad Jeffry wrote:
 
 Dear All,

 Can't a lambda uses the input parameter more then once in the lambda
 body?
 eg:
 lambda x : print x/60,x%60

 I tried with def and it works but got syntax error with lambda. Below
 is an interactive sample:
 
 
 Lambda evaluates a single *expression* and returns the result.  As print
 is a statement it does not qualify (and would provide nothing to return
 even if it did).  So just use a def. 

or use sys.stdout.write in your lambda:
import sys
lambda x : sys.stdout.write(%d %d\n % (x/60, x%60))

 It is constantly pointed out on
 this list that the lambda provides no extra expressive power, 

They do, when one need a very trivial callable for callbacks - which is
probably the main (if not the only) use case.

 it is
 merely a shortcut and, as you just found out, a rather restrictive one
 at that.

Of course.


-- 
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: Death to tuples!

2005-12-05 Thread Antoon Pardon
Op 2005-12-02, Bengt Richter schreef [EMAIL PROTECTED]:
 On 2 Dec 2005 13:05:43 GMT, Antoon Pardon [EMAIL PROTECTED] wrote:

On 2005-12-02, Bengt Richter [EMAIL PROTECTED] wrote:
 On 1 Dec 2005 09:24:30 GMT, Antoon Pardon [EMAIL PROTECTED] wrote:

On 2005-11-30, Duncan Booth [EMAIL PROTECTED] wrote:
 Antoon Pardon wrote:


Personnaly I expect the following pieces of code

  a = const expression
  b = same expression

to be equivallent with

  a = const expression
  b = a

But that isn't the case when the const expression is a list.

 ISTM the line above is a symptom of a bug in your mental Python source 
 interpreter.
 It's a contradiction. A list can't be a const expression.
 We probably can't make real progress until that is debugged ;-)
 Note: assert const expression is a list should raise a mental exception ;-)

Why should const expression is a list raise a mental exception with
me? I think it should have raised a mental exception with the designer.
If there is a problem with const list expression, maybe the language
shouldn't have something that looks so much like one?


This seems to go against the pythonic spirit of explicit is
better than implicit.
 Unless you accept that '[' is explicitly different from '(' ;-)


It also seems to go against the way default arguments are treated.
I suspect another bug ;-)

The question is where is the bug? You can start from the idea that
the language is how it was defined and thus by definition correct
and so any problem is user problem.

You can also notice that a specific construct is a stumbling block
with a lot a new people and wonder if that doens't say something
about the design.

 Do you want
 to write an accurate historical account, or are you expressing discomfort
 from having had to revise your mental model of other programming languages
 to fit Python? Or do you want to try to enhance Python in some way?

If there is discomfort, then that has more to do with having revised
my mental model to python in one aspect doesn't translate to
understanding other aspects of python enough.

 An example?

Well there is the documentation about function calls, which states
something like the first positional argument provided will go
to the first parameter, ... and that default values will be used
for parameters not filled by arguments. Then you stumble on
the build in function range with the signature:

  range([start,] stop[, step])

Why if you only provide one arguments, does it go to the second
parameter?

Why are a number of constructs for specifying/creating a value/object
limited to subscriptions? Why is it impossible to do the following:

  a = ...
  f(...)
  a = 3:8
  tree.keys('a':'b')

Why is how you can work with defaults in slices not similar with
how you work with defaults in calls. You can do:

  lst[:7]

So why can't you call range as follows:

  range(,7)


lst[::] is a perfect acceptable slice, so why doesn't, 'slice()' work?

Positional arguments must come before keyword arguments, but when
you somehow need to do the following:

  foo(arg0, *args, kwd = value)

You suddenly find out the above is illegal and it should be written

  foo(arg0, kwd = value, *args)


people are making use of that rule too much, making the total language
less pratical as a whole.
 IMO this is hand waving unless you can point to specifics, and a kind of
 unseemly propaganda/innuendo if you can't.

IMO the use of negative indexing is the prime example in this case.
Sure it is practical that if you want the last element of a list,
you can just use -1 as a subscript. However in a lot of cases -1,
is just as out of bounds as an index greater than the list length.

At one time I was given lower en upperlimit for a slice from a list,
Both could range from 0 to len - 1. But I really needed three slices,
I needed lst[low:up], lst[low-1,up-1] and lst[low+1,up+1].
Getting lst[low+1:up+1] wasn't a problem, The way python treated
slices gave me just what I wanted, even if low and up were to big.
But when low or up were zero, the lst[low-1,up-1] gave trouble.

If I want lst[low:up] in reverse, then the following works in general:

  lst[up-1 : low-1 : -1]

Except of course when low or up is zero.


Of course I can make a subclass list that works as I want it, but IMO that
is the other way around. People should use a subclass for special cases,
like indexes that wrap around, not use a subclass to remove the special
casing, that was put in the base class.

Of course this example fits between the examples above, and some of
those probably will fit here too.

 or what are we pursuing?

What I'm pursuing I think is that people would think about what
impractical effects can arise when you drop purity for practicallity.
 I think this is nicely said and important. I wish it were possible
 to arrive at a statement like this without wading though massive 
 irrelevancies ;-)

Well I hope you didn't have to wade such much this time.

 BTW, I am participating in this thread more out of interest in

Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-05 Thread JohnBMudd
  It seems to me that the tabs-vs-spaces thing is really about who controls
the indentation: with spaces, it's the writer, and with tabs, it's the
reader.

Agreed.


  if [scope by indent] really is scaring off
potential converts, then a dumbed-down dialect of python which uses
curly
brackets and semicolons might be a useful evangelical tool.

Yes, that's how I see it too.

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


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-05 Thread anthon

D H wrote:


 How is that a problem that some editors use 8 columns for tabs and
 others use less?  So what?
 A bigger problem I see is people using only 2 or 3 spaces for indenting.
   That makes large amounts of code much less readable.  And of course it
 is a problem if you mix tabs and spaces at the beginning of the same line.
 Tabs are easier to type (one keystroke each) and lead to visually better
 results (greater indentation unless you like hitting 8 spaces for each
 indent level).

Where does that misconception that 2-3 spaces for indenting makes
things less readable come from? There was an article in Comm. of the
ACM on research into readability back in 1984 or so, that indicated 2-4
spaces has very similar readability and 8 spaces significantly less
than that. IIRC they took care of personal preferences/what one was
used to in the research. So disallowing tabs which could be set to 8
spaces (positions?) does make sense to me.
I switched from using 2 to using 4 spaces for Python recently, and the
big pain was to deal with lines that no longer fitted in 80 columns :-(

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


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-05 Thread Ben Sizer
Tom Anderson wrote:
 Which is not to say that it's a bad idea - if it really is scaring off
 potential converts, then a dumbed-down dialect of python which uses curly
 brackets and semicolons might be a useful evangelical tool.

If we're going to be creating evangelical tools, I think a decent
description or tutorial explaining why scoping through indentation is a
better idea, rather than capitulating to the ignorance of those who
won't try something different.

If you repeat a piece of functionality, you factor it out into a single
function.
If you repeat a piece of data, you normalise it into a separate table
or object.
If you consistently find yourself having to enter a new scope and
indent at the same time, and close scopes and unindenting at the same
time, the sensible approach is to combine these concepts into one.

Surely any programmer worthy of the term can see benefits to the
approach when it is not just mentioned as a bizarre and arbitrary
limitation of the language.

-- 
Ben Sizer

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


Is there an equivalent to Java Webstart in Python?

2005-12-05 Thread Nic Bar
Hi everybody,
I want to develop a WEB based Python user appication that nees to be
downloaded and started grom a web server using a browser.
Does anybody know if there is an equivalent of Java WebStart for
python applications?

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


Re: libxml2 and XPath - Iterate through repeating elements?

2005-12-05 Thread Jean-Roch SOTTY
Le Vendredi 2 Décembre 2005 18:31, [EMAIL PROTECTED] a écrit :
 I'm trying to iterate through repeating elements to extract data using
 libxml2 but I'm having zero luck - any help would be appreciated.

 My XML source is similar to the following - I'm trying to extract the
 line number and product code from the repeating line elements:

 order xmlns=some-ns
   header
 orderno123456/orderno
   /header
   lines
 line
   lineno1/lineno
   productcodePENS/productcode
 /line
 line
   lineno2/lineno
   productcodeSTAPLER/productcode
 /line
 line
   lineno3/lineno
   productcodeRULER/productcode
 /line
   /lines
 /order
The result of an xpath evaluation is a list of node, which you can 
perform 
another xpatheval() on :

import libxml2
doc = libxml2.parseFile(XmlFile)
root = doc.getRootElement()
line_nodes = root.xpathEval('lines/line')
for line_node in line_nodes:
print line_node.xpathEval('lineno')[0].content
print line_node.xpathEval('productcode')[0].content
doc.freeDoc()

-- 
Cordially

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


Re: Is there an equivalent to Java Webstart in Python?

2005-12-05 Thread James
Use Jython or IronPython.
(Almost) One click web deployment is only available for Java and .NET
platforms at the moment.

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


Re: Efficient lookup in list of dictionaries

2005-12-05 Thread David Pratt
This is a lot less clumsy and can easily be used in a class which is 
very nice!
Many thanks bruno and Rob E for this good advice.

Regards,
David

On Monday, December 5, 2005, at 05:31 AM, bruno at modulix wrote:

 David Pratt wrote:
 (snip)
 Can someone advise a more efficient lookup when using lists of
 dictionaries. Many thanks.


 TEST_CONSTANTS = [
 {'color':'red', 'shape':'octagon'},
 {'color':'yellow', 'shape':'triangle'},
 {'color':'green', 'shape':'circle'}]

 COLOR_INDEX = dict([(item['color'], item) for item in TEST_CONSTANT])
 SHAPE_INDEX = dict([item['shape'], item) for item in TEST_CONSTANT])

 def getShapeForColor(color):
   return COLOR_INDEX.get(color, {'shape':None})['shape']

 def getColorForShape(shape):
   return SHAPE_INDEX.get(color, {'color': None})['color']

 This of course assume that there are no duplicate colors nor shapes.

 -- 
 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

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


Re: SOLVED: Help needed: file writing problem with subprocess

2005-12-05 Thread pekka niiranen
Fredrik Lundh wrote:
 Pekka Niiranen wrote:
 
 
I am running Python script in W2K or in WinXP.
The script is started from DOS prompt and writes text file to disk
with codecs.open() in UTF8.

The problem is: When script writes the file and tries to read it
with by calling itself thru subprocess() the created files are
NOT accessible because they have not been written into disk yet.
fh.flush() and os.fsync() do not work.

-- extract from myscript.py starts --

fh = codecs.open(myfile.txt, w, utf8)
fh.write(# Comment line\n)
fh.writelines(some list)
fh.flush()
fh.close()

then later:

mycmd = %s -f %s % (myscript.py, myfile.txt)
subprocess.call(mycmd, shell=True)

This fails: myfile.txt is not yet written into disk
and the myscript.py called thru subprocess fails.
Only after the main script exits will myfile.txt occur
into the directory.
 
 
 this should of course work, and it sure works for me.
 
 does this involve any unconventional file systems?  (file servers etc).
 
 how much later is later ?
 
 have you checked what the current directory is in all three cases?  (before
 you create the file, before you call the script, and before you try to open 
 the
 file in the script).
 
 /F
 
 
 
The problem was that full pathname to mytext.txt -file was wrong and my
handmade error message about it was misleading. Furthermore, Windows
Explorer showed created file on screen after considerable delay
(5sec) which made me think file was never created. Seems, that due to
operating system delays one cannot rely on his own eyes about
files true existence during script run.

Just one question more; how can I spawn/open another Dos -window
with subprocess()?

Thanks anyways,

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


Re: Is there an equivalent to Java Webstart in Python?

2005-12-05 Thread Nic Bar
The problem with Jython is that I can only live inside the aplet
virtual machine,
I need a full features application with access to the local computer
resources.
Regarding IronPyhton, there is no released version yet.
I am looking for something that can be used now and plataform
independent (assuming the correct version of python is already
installed on the local computer)

Thanks

Nic


On 5 Dec 2005 02:45:04 -0800, James [EMAIL PROTECTED] wrote:

Use Jython or IronPython.
(Almost) One click web deployment is only available for Java and .NET
platforms at the moment.

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


Re: Creating referenceable objects from XML

2005-12-05 Thread Diez B. Roggisch
Michael Williams wrote:
 I'm looking for a quality Python XML implementation.  All of the DOM
 and SAX implementations I've come across so far are rather
 convoluted.

Welcome to the wonderful world of XML.

 I need it to somehow convert my XML to intuitively referenceable
 object.  Any ideas?  I could even do it myself if I knew the
 mechanism by which python classes do this (create variables on the fly).

You've been given the advice to use ElementTree - I can only second
that.

But if for whatever reason you do want to do it yourself (or for future
use), the

getattr/setattr

functions are what you are looking for. Look them up in TFM.

Regards,

Diez

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


Re: what's wrong with lambda x : print x/60,x%60

2005-12-05 Thread Bengt Richter
On Mon, 05 Dec 2005 10:38:25 +0100, bruno at modulix [EMAIL PROTECTED] wrote:

Gary Herron wrote:
 Mohammad Jeffry wrote:
 
 Dear All,

 Can't a lambda uses the input parameter more then once in the lambda
 body?
 eg:
 lambda x : print x/60,x%60

 I tried with def and it works but got syntax error with lambda. Below
 is an interactive sample:
 
 
 Lambda evaluates a single *expression* and returns the result.  As print
 is a statement it does not qualify (and would provide nothing to return
 even if it did).  So just use a def. 

or use sys.stdout.write in your lambda:
import sys
lambda x : sys.stdout.write(%d %d\n % (x/60, x%60))

 It is constantly pointed out on
 this list that the lambda provides no extra expressive power, 

They do, when one need a very trivial callable for callbacks - which is
probably the main (if not the only) use case.

 it is
 merely a shortcut and, as you just found out, a rather restrictive one
 at that.

Of course.

If you think lambda is restrictive, you can use dumbda:

  def dumbda(src):
 ... d = {}
 ... exec src in d
 ... for k,v in d.items():
 ... if callable(v): return v
 ... else:
 ... raise ValueError('dumbda produced no callable from:\n%s'%src)
 ...
  f = dumbda(def foo(x): print 'foo(%r)'%x)
  f('hello foo')
 foo('hello foo')

I'd prefer an anonymous def though ;-)

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


Re: Favorite flavor of Linux? (for python or anything else)

2005-12-05 Thread BartlebyScrivener
Thank you, malv  Frederik, for the warnings. I am learning Python on
windows with the hope of moving to Linux. I would have just assumed the
new Python would be backward compatible and didn't realize how
dependent the os was on the old version.. At least now I am aware of
the issues.

bs

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


akismet 0.1.2, cgiutils 0.3.5, pathutils 0.2.3

2005-12-05 Thread Fuzzyman
Hello All,

A new release and two updates.

New akismet.py 0.1.2


Python Interface to the Akismet API
Version 0.1.2 4th December 2005
http://www.voidspace.org.uk/python/modules.shtml#akismet

`Akismet http://www.akismet.com`_ is a web service for recognising
spam comments. It promises to be almost 100% effective at catching
comment spam. They say that currently 81% of all comments submitted to
them are spam.

It's designed to work with the `Wordpress Blog Tool
http://wordpress.org/`_, but it's not restricted to that - so this is
a Python interface to the `Akismet API
http://akismet.com/development/api/`_.

You'll need a `Wordpress Key http://wordpress.com`_ to use it. This
script will allow you to plug akismet into any CGI script or web
application, and there are full docs in the code. It's extremely easy
to use, because the folks at akismet have implemented a nice and
straightforward {acro;REST;REpresentational State Transfer} API.

It also comes with an `example CGI
http://www.voidspace.org.uk/cgi-bin/akismet/test_akismet.py`_.

(Although the akismet feature of an example positive doesn't seem to
be working currently - there fault not mine :-)

You can read the full (Python) docs at :

* `akismet.py Docs
http://www.voidspace.org.uk/python/akismet_python.html`_

Download it here :

*
http://www.voidspace.org.uk/cgi-bin/voidspace/downman.py?file=akismet-0.1.2.zip


cgiutils 0.3.5 - pathutils 0.2.3
=

pathutils 0.2.3 November 26th 2005
cgiutils 0.3.5 November 26th 2005
http://www.voidspace.org.uk/python/recipebook.shtml#utils


These two modules contain functions and constants for *'general'* use.
They are
both included as part of the `Voidspace Pythonutils Package
http://www.voidspace.org.uk/python/modules.shtml#pythonutils`_ .
(A new release of pythonutils - containing these updated modules - is
due shortly).

**Pathutils** contains various functions for working with files and
paths. This
includes (amongst other thing) :

* Easy ways to iterate over files and directories
* A function to calculate a relative path from one location to another
* Several 'convenience' file reading/writing functions
* `py2exe http://www.py2exe.org`_ directory support
* A function for pretty printing file sizes
* A simple solution to cross-platform file locking
* Import from a specific location

See the `pathutils Homepage
http://www.voidspace.org.uk/python/pathutils.html`_.

**CGI utils** has (guess what... {sm;:?:}) various functions for use
with CGI.
It contains functions to do things that every CGI has to cope with.
They are
most useful for simple scripts, where a full blown framework would be
too
cumbersome.

It includes (amongst other thing) :

* Functions for receiving form submissions
* Cross platform functions to send emails (including creating
{acro;HTML}
  emails)
* A basic templating system
* A {acro;DNS;Domain Name System} blacklist lookup
* A function to generate a menu line for pages with lots of results

See the `cgiutils Homepage
http://www.voidspace.org.uk/python/cgiutils.html`_.

Download them here :

*
http://www.voidspace.org.uk/cgi-bin/voidspace/downman.py?file=utils.zip
(25k) (both modules)
*
http://www.voidspace.org.uk/cgi-bin/voidspace/downman.py?file=pathutils.py
(19k)}
*
http://www.voidspace.org.uk/cgi-bin/voidspace/downman.py?file=cgiutils.py
(20k)}

{small;The zip file has text versions of the docs for these two
modules.}

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


Re: Eclipse best/good or bad IDE for Python?

2005-12-05 Thread Fabio Zadrozny
John J. Lee wrote:

Aaron Bingham [EMAIL PROTECTED] writes:
  

[EMAIL PROTECTED] wrote:


[...ex-emacs user explains switch to Eclipse...]
  

The killer PyDev feature for me is pylint integration.  Being informed 
immediately when you mistype a variable name is a big timesaver.  Also 



I now find it difficult to mis-type variable names in Emacs, since I
have F4 bound to dabbrev-expand.  I also do standard things like using
query-replace when renaming.  Actually, something like dabbrev-expand
is perhaps the one thing I would find indispensible switching to any
other editor -- I wonder if Eclipse/PyDev has it?

(dabbrev-expand searches backwards in the current buffer to find
'words' that are completions of the word you're typing immediately
before the cursor position (then back and forth in all other buffers
if search in the current buffer failed...), until it finds a
completion; then you can repeat the command to cycle through all other
possible completions.)
  


Yes, Eclipse has it by default (not a pydev work): Alt+/



  

nice is the refactoring support (although this it is possible to 
integrate BicycleRepairMan! with Emacs, I found it easier to use in 
Eclipse).


[...]

Refactoring and the general 'semantic slant' certainly seems the
interesting bit about Eclipse (that and the fact that Emacs is a bit
old and hairy, and Eclipse is growing a big user base like Emacs).

Not entirely sure Lisp-Java is progress, though.
  


Well, actually, pydev does some things with python too (code-completion 
for builtins and bicycle repair man integration), and it would be 
extremely simple to add some scripting capabilities with jython too, so, 
I don't really think you'd be tied to 'only java' -- altough its core 
will always be.


John

  


Cheers,

Fabio

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


Re: Is there an equivalent to Java Webstart in Python?

2005-12-05 Thread Renato
What use is Java WebStart, exactly?

Just make a .exe installer with everything (for windows), using for
example py2exe and InnoSetup, and a distutils compliant package for the
others.

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


Re: Eclipse best/good or bad IDE for Python?

2005-12-05 Thread malv
As bicycle repair man integration keeps popping up as a distinct
feature of jave-based PyDev, let it be known that other IDE's also have
this.
For example, non-java Eric has had  bicycle repair man integration
for a very long time.

Personally, in spite of intense programming in python, I've never
encountered a real need for the bicycle gimmick.

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


e: Favorite flavor of Linux? (for python or anything else)

2005-12-05 Thread Michael Williams
I'd say Ubuntu.  It has one of the most intuitive package management systems, and manual installation of software seems to work very well.On Dec 5, 2005, at 2:00 AM, [EMAIL PROTECTED] wrote:From: "Mike C. Fletcher" [EMAIL PROTECTED] Date: December 5, 2005 12:56:13 AM EST To: python-list@python.org Subject: Re: Favorite flavor of Linux? (for python or anything else) Reply-To: [EMAIL PROTECTED]   Brett Hoerner wrote:  I have to add another vote for Gentoo.  And another here.  Portage (the Python-coded package-management system) does a very good job.  I tend to use fairly conservative settings as well, Gentoo's just nice and stable as a general rule, I don't care about ultimate speed or tweaking the code much, I just find that building everything from source (but without the headaches) tends to make things work together well.  As far as Python support goes, Gentoo tends to work very well for Python packages, Pygame and wxPython on AMD64, for instance, install flawlessly out of the box (where others seem to have problems)... in fact most of the major packages install reliably.  There's a key note that you might miss regarding the Python updating process, namely that you have to run python-updater to rebuild all of your packages for the new Python version, but once you know that, Pythonicity in Gentoo is pretty straightforward.  Anyway, just a vote that's trying very hard to keep on-topic for the python list, Mike  --  -- 
http://mail.python.org/mailman/listinfo/python-list

Double decoding of strings??

2005-12-05 Thread manuzhai
Hi all,

I have a bit of a problem. I'm trying to use Python to work with some
data which turns out to be garbage. Ultimately, I think the solution
will be to .decode('utf-8') a string twice, but Python doesn't like
doing this the second time. That could possibly be understandable, but
then why does the unicode object have a .decode() method at all?

I get 'WVL Algemeen Altru\xc3\x83\xc2\xafsme genormeerd Afbeelden' at
first.
I .decode('utf-8') this to u'WVL Algemeen Altru\xc3\xafsme genormeerd
Afbeelden'.
I then try to .decode('utf-8') this again, but that gives an error:

Traceback (most recent call last):
  File stdin, line 1, in ?
  File C:\Program Files\Python\lib\encodings\utf_8.py, line 16, in
decode
return codecs.utf_8_decode(input, errors, True)
UnicodeEncodeError: 'ascii' codec can't encode characters in position
18-19: ordinal not in range(128)

If I copy/paste 'WVL Algemeen Altru\xc3\xafsme genormeerd Afbeelden'
and try to .decode('utf-8') it, that works fine, and it gets me the
result I want, which is u'WVL Algemeen Altru\xefsme genormeerd
Afbeelden'.

Why does it work this way? How can I make it work?

Regards,

Manuzhai

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


Re: Double decoding of strings??

2005-12-05 Thread Peter Otten
[EMAIL PROTECTED] wrote:

 Ultimately, I think the solution will be to .decode('utf-8') a string
 twice 

Try


Altru\xc3\x83\xc2\xafsme.decode(utf8).encode(latin1).decode(utf8)
u'Altru\xefsme'
 print _
Altruïsme

Peter

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


Capturing output from stderr

2005-12-05 Thread Doru-Catalin Togea
Hi!

On solaris, I call a program from python with

os.system(some command  outputFile.txt )

This redirects the output of some command's stdout to outputFile.txt. 
However I need to redirect or somehow capture the output from some 
command's stderr to this file too. How can I do that?

Thanks,
Catalin


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


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-05 Thread JohnBMudd
 a decent description or tutorial...  is better

Sound good but...  we're programmers, not documentation specialist or
motivational speakers.  Why, when I suggest fixing a design defect with
code, do so many programmers want to respond with... documentation and
arguments instead of code?

From The Design of Everyday Things, docs are a sign of poor design.
Even a single word, such as the word Push on the face of a door, is
an indication that the design can be improved.  Please, rethink the
design instead of trying to compensate with more documentation.  

John

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


How to ping in Python?

2005-12-05 Thread Nico Grubert
Hi there,

I could not find any ping Class or Handler in python (2.3.5) to ping a 
machine.
I just need to ping a machine to see if its answering. What's the best 
way to do it?

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


Re: Why my modification of source file doesn't take effect whendebugging?

2005-12-05 Thread Christophe
Fredrik Lundh a écrit :
 Christophe wrote:
 
 
import only reads the file the first time it's called.  Every import
call after that looks up the module in memory.  This is to prevent
circular dependencies between modules from creating infinite loops.
You need to use the reload() function:

As a matter of fact, it would help a lot if that stupid behaviour of
Idle was dropped. I'm sure I'm not the only one who lost lots of time
because of that bug. Yes I call it a bug.
 
 
 in the version of IDLE I have on this machine, if I modify my script and
 run it again (using F5), things work exactly as expected.
 
 if I modify my script and import it into a clean shell (ctrl-F6), things work
 exactly as expected.
 
 the only way to get the buggy behaviour you're describing is to attempt
 to run your program by importing it as a module more than once into an
 existing python shell process.  in that case, import works in the same way
 as it always works.
 
 after all, import isn't designed to run programs, it's designed to import
 modules.  if you want to run stuff in IDLE, why not just use the run
 command ?

F5 is designed to run the current open file. Sane people won't assume 
that pressing twice the F5 key will yield different. Sane people will 
assume that when you edit file1.py and press F5, it reparses the file, 
but when you edit file2.py and press F5 with file1.py it won't work. Why 
make it different ? Why make is so that I have to select the shell 
window, press CTRL+F6, select the file1.py and press F5 just so that it 
works as expected ?

Idle is ok when you edit a single .py file. As soon as I need to edit 2 
.py files with one using the other, I'm glad I have other editors which 
spanw a clean shell each time I run the current file.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Creating referenceable objects from XML

2005-12-05 Thread Gerard Flanagan

Michael Williams wrote:
 Hi All,

 I'm looking for a quality Python XML implementation.  All of the DOM
 and SAX implementations I've come across so far are rather
 convoluted.  Are there any quality implementations that will (after
 parsing the XML) return an object that is accessible by name? Such as
 the following:




 xml = 
 book
   titleMyBook/title
   authorthe author/author
 /book
 





 And after parsing the XML allow me to access it as so:

 book.title

 I need it to somehow convert my XML to intuitively referenceable
 object.  Any ideas?  I could even do it myself if I knew the
 mechanism by which python classes do this (create variables on the fly).

 Thanks in advance!

Michael

Here's an approach to ElementTree that worked for me.  It's not generic
or anything and a bit brittle (eg. it won't handle missing nodes) but
maybe for a simple, flat schema or for a prototype?

All the best

Gerard

(TOY CODE - NOT TESTED MUCH)

from elementtree import ElementTree

class ElementWrapper(object):

def __tostring(self):
return ElementTree.tostring(self.element)

def __fromstring(self, xml):
self.element = ElementTree.fromstring(xml)

xml = property( __tostring, __fromstring )

def __init__(self, element=None):
self.element = element

def __str__(self):
return self.xml

def parse(self, infile):
tree = ElementTree.parse(infile)
self.element = tree.getroot()

def write(self, outfile):
ElementTree.ElementTree(self.element).write(outfile)

###


from elementtree.ElementTree import Element
from elementwrapper import ElementWrapper

xmlns = 'http://schemas/email/0.1'


class MailDocument(ElementWrapper):

def __build_element(self):
root = Element('{%s}Mail' % xmlns)
root.append( Element('{%s}Date' % xmlns) )
root.append( Element('{%s}From' % xmlns) )
root.append( Element('{%s}Subject' % xmlns) )
root.append( Element('{%s}To' % xmlns) )
root.append( Element('{%s}Cc' % xmlns) )
root.append( Element('{%s}Body' % xmlns) )
root.append( Element('{%s}Attachments' % xmlns) )
self.element =  root

#
#Properties
#
def __get_uid(self):
return self.element.get('id')

def __set_uid(self, id=''):
self.element.set('id', id)

def __get_date(self):
return self.element[0].text

def __set_date(self, value=''):
self.element[0].text = value

def __get_from(self):
addr = self.element[1].get('address')
nm = self.element[1].get('name')
return addr, nm

def __get_subject(self):
return self.element[2].text

def __set_subject(self, value=''):
self.element[2].text = value

def __get_body(self):
return self.element[5].text

def __set_body(self, value=''):
self.element[5].text = value

uid = property( __get_uid, __set_uid )
From = property( __get_from)
subject = property( __get_subject, __set_subject )
date = property( __get_date, __set_date )
body = property( __get_body, __set_body )

def set_from_header(self, address='', name=''):
self.element[1].set('address', address)
self.element[1].set('name', name)
#
#End Properties
#

#
#Lists
#
def add_to_header(self, address='', name=''):
self.__add_mailto( self.element[3], address, name )

def remove_to_header(self, index):
elem = self.element[3][index]
self.element[3].remove(elem)

def add_cc_header(self, address='', name=''):
self.__add_mailto( self.element[4], address, name )

def remove_cc_header(self, index):
elem = self.element[4][index]
self.element[4].remove(elem)

def add_attachment(self, filename='', fileuri='', filetype=''):
elem = Element({%s}Uri % xmlns, value=fileuri, type=filetype
)
elem.text = filename
self.element[6].append( elem )

def remove_attachment(self, index):
elem = self.element[6][index]
self.element[6].remove(elem)

def __add_mailto(self, element, Address='', Name=''):
element.append( Element({%s}mailto % xmlns, address=Address,
name=Name ) )

def get_to_headers(self):
hdrs = []
for item in self.element[3]:
hdrs.append( ( item.get('address'), item.get('name') ) )
return hdrs

def get_cc_headers(self):
hdrs = []
for item in self.element[4]:
hdrs.append( (item.get('address'), item.get('name') ) )
return hdrs

def get_attachments(self):
ret = []
for item in self.__element[6]:
hdrs.append( (item.text, item.get('value'),
item.get('type') ) )
return hdrs
#
#End Lists

Re: Capturing output from stderr

2005-12-05 Thread Doru-Catalin Togea
On Mon, 5 Dec 2005, Doru-Catalin Togea wrote:

Found a solution:

os.system(some command 1out.txt 2err.txt)

 On solaris, I call a program from python with

   os.system(some command  outputFile.txt )

 This redirects the output of some command's stdout to outputFile.txt. 
 However I need to redirect or somehow capture the output from some 
 command's stderr to this file too. How can I do that?

 Thanks,
 Catalin




-- 

  == 
  We are what we repeatedly do.  
   Excellence, therefore, is not an act  
  but a habit.   
  == 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why my modification of source file doesn't take effectwhendebugging?

2005-12-05 Thread Fredrik Lundh
Christophe wrote:

 F5 is designed to run the current open file. Sane people won't assume
 that pressing twice the F5 key will yield different. Sane people will
 assume that when you edit file1.py and press F5, it reparses the file,
 but when you edit file2.py and press F5 with file1.py it won't work. Why
 make it different ? Why make is so that I have to select the shell
 window, press CTRL+F6, select the file1.py and press F5 just so that it
 works as expected ?

I'm not sure I follow here: in the version of IDLE I have here, pressing
F5 will save the current file and run it.  If you've edit other parts of the
application, you have to save those files (Control-S) and switch to the
main script before pressing F5, but that's only what you'd expect from
a run this module command.

(being able to bind F5 to a specific script might be practical, of course,
but I'm don't think that's what you're complaining about.  or is it?)

 Idle is ok when you edit a single .py file. As soon as I need to edit 2
 .py files with one using the other, I'm glad I have other editors which
 spanw a clean shell each time I run the current file.

In the version of IDLE I have, that's exactly what happens (that's what
the RESTART lines are all about).

Is there some secret setting somewhere that I've accidentally managed
to switch on or off to get this behaviour?

/F 



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


BayPIGgies: December 8, 7:30pm (IronPort)

2005-12-05 Thread Aahz
The next meeting of BayPIGgies will be Thurs, December 8 at 7:30pm at
Ironport.

JJ will demonstrate GCipher, a simple application that shows how to
combine Glade/PyGTK, the async module, and a plugin architecture.

BayPIGgies meetings alternate between IronPort (San Bruno, California)
and Google (Mountain View, California).  For more information and
directions, see http://baypiggies.net/


Before the meeting, we sometimes meet at 6pm for dinner.  Discussion of
dinner plans is handled on the BayPIGgies mailing list.  

Advance notice:  We need speakers for January and later.  Please send
e-mail to [EMAIL PROTECTED] if you want to suggest an agenda (or
volunteer to give a presentation).
-- 
Aahz ([EMAIL PROTECTED])   * http://www.pythoncraft.com/

Don't listen to schmucks on USENET when making legal decisions.  Hire
yourself a competent schmuck.  --USENET schmuck (aka Robert Kern)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to ping in Python?

2005-12-05 Thread Peter Hansen
Nico Grubert wrote:
 I could not find any ping Class or Handler in python (2.3.5) to ping a 
 machine.
 I just need to ping a machine to see if its answering. What's the best 
 way to do it?

Either use something like os.system() to call the ping executable, or 
try using Google (e.g. python ping would have produced apparently 
useful results for you).

-Peter

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


Re: python university search

2005-12-05 Thread Paolo Alexis Falcone
On Sun, 04 Dec 2005 17:12:45 -0800, josh wrote:

 [pardon me if this is not the appropriate list]
 
 hello,
 
 i am interested in doing an undergraduate major in computer science
 that mainly focuses on python as a programming language..
 
 i am not a very bright student and neither do i have the money to
 think about universities like caltech, stanford etc. i am looking for
 a university that is easy to get admitted in and yet i can get good
 knowledge and education out of it.
 
 also english is not my first language and i feel that acts against me,
 but i do have a strong desire to learn.
 
 i have read the tutorials in python.org and understand the python
 programming syntax but i feel that only a computer science class is
 going to teach me how to program and apply advance concepts.  if any
 of you happen to know good video tutorials or self study materials or
 tips  that can act as an alternative to going to college, would you
 please mind sharing or selling for something reasonable.

Try looking for these online references:
* http://www.aduni.org - website of the defunct ArsDigita University. They
have a plethora of resources that can be downloaded, or obtained in a
couple of DVD's
* http://www.ibiblio.org/obp/thinkCSpy - How to think like a Computer
Scientist: Learning with Python (checkout their bibliography too.
* http://mitpress.mit.edu/sicp/ - Structure and Interpretation of Computer
Programs. Not Python, but should give you a good material for functional
programming - which is another paradigm that Python also supports.

Try reading these (buy/steal :D) from your library:
* The Art of Computer Programming (D. Knuth). 3 volumes and a fascicle of
an upcoming volume. Very terse reading, but should you overcome this,
you're on the way to computing greatness

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


Constructing RFC2822 Message

2005-12-05 Thread Narendra
Hi All,

This is narendra from india doing my engineering.

i need to develop an E-mail client in python,which connects to my MTA
on port 25 and sends email from there.

I was able to do that but my e-mail is ending in bulk when i'm trying
to senf to hotmail/msn.

here im giving the code of my program.
**
import socket,string
import sys
import time
from email import Encoders
import email.Message
import email.Utils
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
# Reading IPConfig File
clientSendingPort = 9000
headuni = '000119-000257-454777-'
headadd  = 555650
i = 0
def read(infile):
try:
flopen = open(infile,'r')
flines = flopen.readlines()
flopen.close()
return flines
except IOError:
print sys.exc_info()

if len(sys.argv) != 3:
print 'Usage: IPAuditMain.py IPConfig File Name Email Address
File Name'
sys.exit()
try:
ipConfigLines = read(sys.argv[1])
emailAddConfigLines = read(sys.argv[2])
print(reading is over)
for line in ipConfigLines:
print(hello)
print line
clIpAddress,injectIPAddress,extnIP,fromadd =
string.split(line,',')
print clIpAddress,injectIPAddress,extnIP
print(how come)

timestamp=time.strftime([%y%m%d-%H%M%S],time.localtime(time.time()))
headerUnq = str(headuni) + timestamp
headadd =  headadd + 5;
print headerUnq
for recptEmailAdd in emailAddConfigLines:
print(wt happened)
print recptEmailAdd
soc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print socket created
soc.bind((clIpAddress,clientSendingPort))
#print soc.recv(9867)
print after binding
soc.connect((injectIPAddress, 25)) # SMTP
print recptEmailAdd
i = i +1
clientSendingPort = clientSendingPort + 1
soc.send(mail from:+fromadd+\n)
print soc.recv(9869)
soc.send(rcpt to:+ recptEmailAdd +\n)
print soc.recv(9869)
soc.send(data\n)
print soc.recv(9869)
print headerUnq
msg = MIMEBase('multipart','alternative')
msg['X-PVIQ'] = headerUnq
msg['Date']=email.Utils.formatdate(localtime=1)
#msg['Return-Path'] = fromadd
msg['Subject'] = 'Our convo zt'+extnIP
msg['From'] = fromadd
msg['To'] = recptEmailAdd
msg.preamble = 'You will not see this in a MIME-aware mail
reader.\n'
msg.epilogue = ''
outer = MIMEText('\nHai Bob '+
   'What are you doing?
\n\nRegards,',_subtype='plain')
msg.attach(outer)
print(narendra u got here)
soc.send(msg.as_string(0))
print(u have sent the data )
soc.send(\n.\n)
print(quit)
print  soc.recv(9869)
clientSendingPort = clientSendingPort + 1
soc.close()
except IOError:
print sys.exc_info()
except:
print 'Exception Found. Unable to process'
***

Can anyone please help me out how to fix the problem.

Thanks,
Narendra

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


Re: reddit.com rewritten in Python

2005-12-05 Thread Peter Hansen
Jay Parlar wrote:
 reddit.com, which was formerly implemented in LISP (and somewhat famous 
 for that fact) has just *relaunched* and is now written in Python!
 
 They haven't given their reasons yet, but I'll certainly be interested 
 to see why.

On that last issue, the post at 
http://reddit.com/blog/2005/12/night-of-living-python.html says:

For all you Lispers, stay tuned for a longer post about why we 
rewrote in Python.

-Peter

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


Re: Constructing RFC2822 Message

2005-12-05 Thread jepler
On Mon, Dec 05, 2005 at 06:27:44AM -0800, Narendra wrote:
 I was able to do that but my e-mail is ending in bulk when i'm trying
 to senf to hotmail/msn.

Perhaps this is an over-zealous filter on the hotmail/msn side, not a
problem with Python.

I don't know for sure, but some news stories indicate that without the
presence of a special DNS record, microsoft treats messages as spam--
e.g. http://news.zdnet.com/2100-1009-5758365.html

Jeff


pgpiCUTsOPQDx.pgp
Description: PGP signature
-- 
http://mail.python.org/mailman/listinfo/python-list

appending messages in imaplib

2005-12-05 Thread [EMAIL PROTECTED]
So I have the unfortunate task of migrating several hundred users from
local mail (mbox and mh) up to an exchange server as part of wearisome
SOX compliance nonsense.

I thought the best path through this thicket would be to knock up a
quick python script using imaplib to replicate folder structures on the
IMAP server and copy the mails accross.

Accessing the IMAP server is great. I can log in, search for mail,
change folder and fetch mail. but I just can't seem to get .append() to
work. Here is a quick example.

server = IMAP4(mail01)
server.login(huw-l,x)
('OK', ['LOGIN completed.'])
server.create(Migration)
('OK', ['CREATE completed.'])
#using a mail client I can verify that the folder was created
server.select(Inbox)
'OK'
r,data = server.fetch('220','(RFC822)')
#data now contains a real mail message off the server
message = data
server.append(Migration,None,None,message)

at which point it just sits there and does nothing. Any ideas greatly
appreciated. I'm assuming that it has something to do with the way I'm
passing it the message but I don't really know where to go from here.

Thanks,
Huw

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


Re: getting data off a CDrom

2005-12-05 Thread Larry Bates
[EMAIL PROTECTED] wrote:
 Hi there,
 
 I'm trying to load data from 2 different CD drives to compare the data
 on them to see if they are identical.  I've found the WinCDRom module
 online but it doesn't seem to give access to the data at all. The only
 thing it seems to do is check if there is a readable cd in a specific
 drive.
 
 Any ideas/suggestions/flames?
 
 Thanks,
 
 Julien
 
The two CDROMs should show up with drive letters attached (Windows) on
your machine.  Just open the files on both machines as you would any other
file:

fp1=open(r'D:\filename1', 'r')
fp2=open(r'E:\filename2', 'r')

You could:

1) use md5 to calculate checksums on both files and compare

or

2) you could use difflib instead see:

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

difflib probably works best if the files are text files.

3) do something custom to compare the files, but I would
try 1) and 2) first.

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


Re: Is there an equivalent to Java Webstart in Python?

2005-12-05 Thread Nic Bar
The idea is that I don't want to have the user installing anything in
his machine.
The only thing he/she may install is the virtual machine.
THis way I can modify the application as necessary without the need to
redeploy on each and one of the installed machines.

Nic



On 5 Dec 2005 04:02:45 -0800, Renato [EMAIL PROTECTED]
wrote:

What use is Java WebStart, exactly?

Just make a .exe installer with everything (for windows), using for
example py2exe and InnoSetup, and a distutils compliant package for the
others.

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


Re: how to handle two forms in cgi?

2005-12-05 Thread lli
Hi Steve,

Thank you for your information. Your idea is helpful for me.
By the way, could I use hiden to handle this case?



Laya

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


Re: Is there an equivalent to Java Webstart in Python?

2005-12-05 Thread David Wahler
Nic Bar wrote:
 The problem with Jython is that I can only live inside the aplet
 virtual machine,
 I need a full features application with access to the local computer
 resources.
 Regarding IronPyhton, there is no released version yet.
 I am looking for something that can be used now and plataform
 independent (assuming the correct version of python is already
 installed on the local computer)

All JWS does is download a few jar files and run them locally. I would
think it would be pretty easy to write a simple script that would take
an application from a zip file, expand it to a temporary directory and
run it with Python. Then all you have to do is give the zip files a
custom extension (maybe .par, for Python archive?) and associate that
extension with your script on the users' machines. But if you're asking
if something like this is included with Python out of the box, then the
answer is not as far as I know, sorry.

-- David

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


Re: Is there no compression support for large sized strings in Python?

2005-12-05 Thread Christopher Subich
Fredrik Lundh wrote:
 Christopher Subich wrote:


I have access to an itanium system with a metric ton of memory.  I
-think- that the Python version is still only a 32-bit python
 
 
 an ILP64 system is a system where int, long, and pointer are all 64 bits,
 so a 32-bit python on a 64-bit platform doesn't really qualify.
 

Did a quick check, and int is 32 bits, while long and pointer are each 64:
Python 2.2.3 (#1, Nov 12 2004, 13:02:04)
[GCC 3.2.3 20030502 (Red Hat Linux 3.2.3-42)] on linux2
Type help, copyright, credits or license for more information.
  import struct
  struct.calcsize('i'),struct.calcsize('l'),struct.calcsize('P')
(4, 8, 8)

So, as of 2.2.3, there might still be a problem.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why my modification of source file doesn't take effectwhendebugging?

2005-12-05 Thread Christophe
Fredrik Lundh a écrit :
 Christophe wrote:
 
 
F5 is designed to run the current open file. Sane people won't assume
that pressing twice the F5 key will yield different. Sane people will
assume that when you edit file1.py and press F5, it reparses the file,
but when you edit file2.py and press F5 with file1.py it won't work. Why
make it different ? Why make is so that I have to select the shell
window, press CTRL+F6, select the file1.py and press F5 just so that it
works as expected ?
 
 
 I'm not sure I follow here: in the version of IDLE I have here, pressing
 F5 will save the current file and run it.  If you've edit other parts of the
 application, you have to save those files (Control-S) and switch to the
 main script before pressing F5, but that's only what you'd expect from
 a run this module command.
 
 (being able to bind F5 to a specific script might be practical, of course,
 but I'm don't think that's what you're complaining about.  or is it?)
 
 
Idle is ok when you edit a single .py file. As soon as I need to edit 2
.py files with one using the other, I'm glad I have other editors which
spanw a clean shell each time I run the current file.
 
 
 In the version of IDLE I have, that's exactly what happens (that's what
 the RESTART lines are all about).
 
 Is there some secret setting somewhere that I've accidentally managed
 to switch on or off to get this behaviour?

What I remember ( but maybe it was changed in recent Idle versions ) was 
that when your project has a main.py which imports a module.py, when you 
run your project once, any later changes you make in module.py won't be 
taken into account.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: XML and namespaces

2005-12-05 Thread uche . ogbuji
Alan Kennedy:

These namespace declaration nodes, i.e. attribute nodes in the
xml.dom.XMLNS_NAMESPACE namespace, are a pre-requisite for any
namespaced DOM document to be well-formed, and thus naively
serializable.

The argument could be made that application authors should be protected
from themselves by having the underlying DOM library automatically
create the relevant namespace nodes.

But to me that's not pythonic: it's implicit, not explicit.

My vote is that the existing xml.dom.minidom behaviour wrt namespace
nodes is correct and should not be changed.


Andrew Clover also suggested an overly-legalistic argument that current
minidom behavior is not a bug.

It's a very strange attitude that because a behavior is not
specifically proscribed in a spec, that it is not a bug.  Let me try a
reducto ad absurdum, which I think in this case is a very fair
stratagem.  If the code in question:

 document = xml.dom.minidom.Document()
 element = document.createElementNS(DAV:, href)
 document.appendChild(element)
DOM Element: href at 0x1443e68
 document.toxml()
'?xml version=1.0 ?\nferh/'

(i.e. ferh rather than href), would you not consider that a minidom
bug?

Now consider that DOM Level 2 does not proscribe such mangling.

Do you still think that's a useful way to determine what is a bug?

The current, erroneous behavior, which you advocate, is of the same
bug.  Minidom is an XML Namespaces aware API.  In XML Namespaces, the
namespace URI is *part of* the name.  No question about it.  In Clark
notation the element name that is specified in

element = document.createElementNS(DAV:, href)

is {DAV:}href.  In Clark notation the element name of the document
element in the created docuent is href.  That is not the name the
user specified.  It is a mangled version of it.  The mangling is no
better than my reductio of reversing the qname.  This is a bug.  Simple
as that.  WIth this behavior, minidom is an API correct with respect to
XML Namespaces.

So you try the tack of invoking pythonicness.  Well I have one for
ya:

In the face of ambiguity, refuse the temptation to guess.

You re guessing that explicit XMLNS attributes are the only way the
user means to express namespace information, even though DOM allows
this to be provided through such attributes *or* through namespace
properties.  I could easily argue that since these are core properties
in the DOM, that DOM should ignore explicit XMLNS attributes and only
use namespace properties in determining output namespace.  You are
guessing that XMLNS attributes (and only those) represent what the user
really means.  I would be arguing the same of namespace properties.

The reality is that once the poor user has done:

element = document.createElementNS(DAV:, href)

They are following DOM specification that they have created an element
in a namespace, and you seem to be arguing that they cannot usefully
have completed their work until they also do:

element.setAttributeNS(xml.dom.XMLNS_NAMESPACE, None, DAV:)

I'd love to hear how many actual minidom users would agree with you.

It's currently a bug.  It needs to be fixed.  However, I have no time
for this bewildering fight.  If the consensus is to leave minidom the
way it is, I'll just wash my hands of the matter, but I'll be sure to
emphasize heavily to users that minidom is broken with respect to
Namespaces and serialization, and that they abandon it in favor of
third-party tools.

--
Uche Ogbuji   Fourthought, Inc.
http://uche.ogbuji.nethttp://fourthought.com
http://copia.ogbuji.net   http://4Suite.org
Articles: http://uche.ogbuji.net/tech/publications/

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


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-05 Thread Rick Wotnaz
[EMAIL PROTECTED] wrote in
news:[EMAIL PROTECTED]: 

 a decent description or tutorial...  is better
 
 Sound good but...  we're programmers, not documentation
 specialist or motivational speakers.  Why, when I suggest fixing
 a design defect with code, do so many programmers want to
 respond with... documentation and arguments instead of code?
 
From The Design of Everyday Things, docs are a sign of poor
design. 
 Even a single word, such as the word Push on the face of a
 door, is an indication that the design can be improved.  Please,
 rethink the design instead of trying to compensate with more
 documentation.  
 

So, for instance, even a single character (like an opening or 
closing bracket or a semicolon) is an indication that the design 
can be improved. Please, rethink your opposition instead of trying 
to impose your design defect on a better, cleaner design.

Seriously. What you call a design defect and what other call a 
design feature are one and the same. 

I will concede this much: I would like a guarantee that helpful 
software would not strip leading whitespace (as has happened with 
some mail clients), which trashes logic-by-indention. 

Alternatively, it might be useful to have brackets and semicolons 
to overcome sadistic software interactions, but I don't *really* 
expect Python to be willing and able to predict and prevent all the 
crazy things other programs might do. And I certainly hope that 
Python doesn't ever *require* the brackets and semicolons that add 
so little value and so much clutter.

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


Re: XML and namespaces

2005-12-05 Thread uche . ogbuji
I wrote:

The reality is that once the poor user has done:

element = document.createElementNS(DAV:, href)

They are following DOM specification that they have created an element
in a namespace, and you seem to be arguing that they cannot usefully
have completed their work until they also do:

element.setAttributeNS(xml.dom.XMLNS_NAMESPACE, None, DAV:)

I'd love to hear how many actual minidom users would agree with you.


Of course (FWIW) I meant

element.setAttributeNS(xml.dom.XMLNS_NAMESPACE, xmlns, DAV:)

--
Uche Ogbuji   Fourthought, Inc.
http://uche.ogbuji.nethttp://fourthought.com
http://copia.ogbuji.net   http://4Suite.org
Articles: http://uche.ogbuji.net/tech/publications/

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


Re: Favorite flavor of Linux? (for python or anything else)

2005-12-05 Thread Luis M. Gonzalez
It's not only about having python installed. It's also about the tools
that come with the distro.
I've played with Ubuntu's live Cd a little bit, and I saw it comes with
a lot of python related software, such as Boa Constructor, several
ides, editors, etc...
I ignore if other distros count with them as well..
Luis

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


Re: distutils problem windows xp python 2.4.2

2005-12-05 Thread [EMAIL PROTECTED]
Hello,

It give the same error result:
D:\testprogram\distutils problemsetup build
running build
running build_ext
*** Failed: error: The .NET Framework SDK needs to be installed before
building extensions for Python.
Attempting to patch distutils.msvccompiler and retry:
running build
running build_ext
*** Failed: error: The .NET Framework SDK needs to be installed before
building extensions for Python.
Attempting to patch distutils.msvccompiler and retry:

This is inside my setup.py
#from distutils.core import setup, Extension
#
#module = Extension('pr', sources = ['prmodule.c'])
#setup(name = 'Pr test', version = '1.0', ext_modules = [module])
#

__version__ = '0.3'

from distutils.core import setup, Extension

for attempts in range(2):
try:
setup(name='Pr test', version='1.0',
  ext_modules=[Extension('pr', ['prmodule.c'])])
except SystemExit, e:
print '*** Failed:', e.args[0]
else:
break   # Successful (avoid the retry)


print 'Attempting to patch distutils.msvccompiler and retry:'

import distutils.msvccompiler

class BatReader(object):
def __init__(self, batch_filename):
self.source = open(batch_filename, 'rU')

def getsets(self):
'''Get all command lines which are SET commands.'''
self.source.seek(0)
for line in self.source:
try: command, rest = line.split(None, 1)
except ValueError: continue # Set a=b splits fine
if command.lower() == 'set':
try: key, value = rest.split('=', 1)
except ValueError: continue # breaking a=b;c;d
elif command.lower() == 'path':
key, value = command, rest #path x == set path=x
yield key, value.rstrip()

def paths(self, pathkey):
'''Find the file paths using our getsets methods.'''
keyed = pathkey.upper()
for key, paths in self.getsets():
if key.upper() == keyed:
elements = paths.split(';')
if elements[-1].upper() == keyed.join('%%'):
return elements[: -1]
return elements

class MSVCCompiler(distutils.msvccompiler.MSVCCompiler):
_patho = BatReader(r'C:\Program Files\Microsoft Visual Studio
8\VC\bin\vcvars32.bat') # or vcvars32.bat or ...
def get_msvc_paths(self, path, platform='x86'):
if path == 'library': path = 'lib'
return self._patho.paths(path)

distutils.msvccompiler.MSVCCompiler = MSVCCompiler
# OK, patched it, now go try again.

Yours,
pujo

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


Re: appending messages in imaplib

2005-12-05 Thread Laurent Pointal
[EMAIL PROTECTED] wrote:
 So I have the unfortunate task of migrating several hundred users from
 local mail (mbox and mh) up to an exchange server as part of wearisome
 SOX compliance nonsense.
 
 I thought the best path through this thicket would be to knock up a
 quick python script using imaplib to replicate folder structures on the
 IMAP server and copy the mails accross.

[zip]


Have you tried to search for mbox2imap ?

On google the first link is... a Python script.

http://home.tiscali.cz:8080/~cz210552/distfiles/mbox2imap.py

And there are other entries...



Looking for mh2imap seem quasi unproductive.

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


Re: Eclipse best/good or bad IDE for Python?

2005-12-05 Thread Fabio Zadrozny
John J. Lee wrote:

Fabio Zadrozny [EMAIL PROTECTED] writes:
[...]
  

I must also warn you that I'm its current maintainer, and it is *my* 
favorite IDE :-)


[...]
  

But in the end, as I said, it is a subjective matter, so, you'll have to 
decide it for yourself.



Hey, Fabio, can this be true:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=15820

|--- Comment #4 From Chris McLaren  2003-01-08 10:43  [reply] ---
|
|this is not a key bindings issue anymore - key bindings can be fully 
|customized but vi emulation requires special support from the editor. closing 
|this pr - best step is to try and lobby vi emulation to the draft proposal.



They're kidding, right???  Can it be possible there's no free vi mode
for Eclipse??  If something so basic is missing from the core stuff,
gives me little hope emacs will be displaced as the Big Beast of
editors anytime soon...
  

Well, I remember seeing one that was free (altough this was more than a 
year ago -- I don't really use vi, so, I searched it just out of 
curiosity), but if you searched and it was not found... I don't know, 
maybe its author decided to make it commercial? Still, I'm pretty sure 
there was one...

The basis in Java makes me worry a tiny bit too.  First, Lisp plus the
'programmers scratch their own itch' model seems to have been very
successful in letting people Get the Job Done in Emacs.  More
important, I fear licensing issues will keep away Emacs hackers who
might otherwise switch and make the platform more usable for other
Emacs refugees.

  

Being java, does not worry me that much... there are already many vms 
aside from suns (including gcj), and I think that if you do not want to 
program in java, adding scripting layers for jython, jruby, etc should 
be fairly easy (given that someone has the time to do it).


John

  

Fabio

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


Re: Constructing RFC2822 Message

2005-12-05 Thread Narendra
Thanks jep for the quick response.But when im sending with different
program written in java i was able to send into inbox.

So i thought problem was with the python code only.

Narendra

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


Re: Creating referenceable objects from XML

2005-12-05 Thread Laurent Pointal
Michael Williams wrote:
 Hi All,
 
 I'm looking for a quality Python XML implementation.  All of the DOM 
 and SAX implementations I've come across so far are rather  convoluted. 
 Are there any quality implementations that will (after  parsing the XML)
 return an object that is accessible by name? Such as  the following:
 
 
 
 
 xml = 
 book
 titleMyBook/title
 authorthe author/author
 /book
 
 
 
 
 
 
 And after parsing the XML allow me to access it as so:
 
 book.title
 
 I need it to somehow convert my XML to intuitively referenceable 
 object.  Any ideas?  I could even do it myself if I knew the  mechanism
 by which python classes do this (create variables on the fly).
 
 Thanks in advance!

Another tool (ElementsTree already quoted): Amara
( http://uche.ogbuji.net/uche.ogbuji.net/tech/4suite/amara/ )

[never tested but bookmarked as it seem interresting]

A+

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


Re: Favorite flavor of Linux? (for python or anything else)

2005-12-05 Thread malv
Any popular distro would. No one is really superior from this angle.
You will always find that you will from time to time have to download
software and/or versions that didn't come with your distro. This is
mostly no problem, especially not with python related software.

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


Re: Eclipse best/good or bad IDE for Python?

2005-12-05 Thread Fabio Zadrozny
malv wrote:

As bicycle repair man integration keeps popping up as a distinct
feature of jave-based PyDev, let it be known that other IDE's also have
this.
For example, non-java Eric has had  bicycle repair man integration
for a very long time.

Personally, in spite of intense programming in python, I've never
encountered a real need for the bicycle gimmick.

  

Hi...

Yeap, bicycle repair man is used by many IDEs (that's what it was meant 
for, right)?
As for refactoring, it is something you only miss after having used it 
(and yes, the one provided by bicycle repair man is still in its 
childhood when compared to tools available for java, but python 
compensates that in its ease of programming -- until a certain point, 
because if you had tools as good as the ones for java, it would make 
programming in python even more enjoyable). And sure, you can do it 
manually, but why bother when you have tools to do it?

Cheers,

Fabio

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


Re: python university search

2005-12-05 Thread Rocco Moretti
josh wrote:
 
 hello,
 
 i am interested in doing an undergraduate major in computer science
 that mainly focuses on python as a programming language..

It's your life, so you can live it as you choose, but I think you're 
missing the point of an undergraduate education if you focus too much on 
  Python programming at this point.

Undergraduate education is (should be) about breadth. Python has a place 
there, but it isn't the be-all, end-all. There are some concepts for 
which Python isn't well suited in teaching (functional programing, logic 
programing, operating system programing, etc.). I'd hope that you go to 
a high-quality University that understands this, and teaches *concepts*, 
not programing languages.

In the long run, it will (likely) be better for you to go to a 
University where they don't even use Python, but solidly teach concepts, 
rather than one that's so into Python that they neglect topics that are 
taught poorly in Python.

Even if you never use Python as an undergraduate, if you have a good 
grounding in the fundamental concepts, it should be (relatively) easy 
for you to take what you've learned in (scheme/ML/prolog/assembly/forth) 
and apply it to Python. You'll have plenty of time to specialize on 
Python as a graduate student/young professional.

Just my two cents.
-- 
http://mail.python.org/mailman/listinfo/python-list


hash()

2005-12-05 Thread John Marshall
Hi,

For strings of  1 character, what are the chances
that hash(st) and hash(st[::-1]) would return the
same value?

My goal is to uniquely identify multicharacter strings,
all of which begin with / and never end with /.
Therefore, st != st[::-1].

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


Re: Bitching about the documentation...

2005-12-05 Thread skip

 Gee, I wonder if I typed sort into the search box on the wiki it
 might turn up something useful?  Well, what do you know?
 
 2 results of about 4571 pages. (0.19 seconds)
 
 1. HowTo/Sorting
 2. SortingListsOfDictionaries

rurpy Are we talking about the same Search box (at the top right of the
rurpy wiki page, and labeled search?  Well, yes I did enter sort
rurpy and got (as I said) a long list of archived maillist postings.

Probably.  There are two search buttons, Title and Text.  Always try the
Title search first, as it only searches page titles.  If that is unhelpful,
then try the Text search.  That searches the bodies of the pages.  I
generally never use that search, preferring instead to use Google's
site:wiki.python.org ... restricted search which is going to apply their
page rank algorithms to the hits (and be faster to boot).  I don't know how
hard it would be to modify the wiki's Text button so it executes the
appropriate Google search.  Probably not too hard.  I'll look.

rurpy Well, I'm not totally sure but I think I would be willing to a
rurpy least try contributing something.  A large amount of the time I
rurpy waste when writing Python programs is directly attributable to
rurpy poor documentation.  (To be fair Python is not the only software
rurpy with this problem.)

rurpy But, the standard responce of don't complain, fix it yourself
rurpy is bogus too.  There are plenty of people on this list willing to
rurpy sing python's praises, for balance, there should be people
rurpy willing to openly point out python's flaws.  Documentation is
rurpy certainly one of them.  And I was correcting a posting that
rurpy explicitly said there was exceptionaly good information in that
rurpy Howto.  That was just plain wrong.

Sure, feel free to point of flaws.  Just don't let that be the only way you
contribute.  Over time the value of your criticism (valid or not) will be
discounted.

The preferred way to correct problems with the documentation is to submit a
bug report to SourceForge.  Many of the active developers (including those
who do write most of documentation) don't necessarily track c.l.py closely,
so postings here often will get lost because people can't attend to them
immediately.

The problem with marching in here and saying fix the docs is that you are
an unknown quantity (I certainly don't recognize your email address and as
far as I've seen you never sign your posts.  I don't believe I've ever seen
contributions from you either.  (Can't double-check right now because
SourceForget is basically unresponsive.)  The combination makes you look
suspiciously like a troll.  I doubt that's the case.  Troll detectors are
notorious for generating false positives.  Still, my threat assessment level
got raised.

Operating under the rurpy's-not-a-troll assumption, your posts suggest to me
that you don't understand how Python is developed.  Behind the scenes lots
of documentation *does* get written.  In my experience it hass generally not
been written by people who whine, fix the docs.  In short, there seems to
be no shortage of people willing to castigate the Python developers for
poor documentation.  There does appear to be a shortage of people willing to
actually roll up their sleeves and help.

The other thing to remember is that most of the people who wind up writing
the documentation don't personally need most of the documentation they
write.  After all, they are generally the authors of code itself and are
thus the experts in its use.  It's tough to put yourself in the shoes of a
novice, so it's tough to write documentation that would be helpful for new
users.  It's extremely helpful if new users submit documentation patches as
they figure things out.  It's generally unnecessary to write large tomes.
Often all that's needed is a few sentences or an example or two.

Skip

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


Re: Why my modification of source file doesn't take effect when debugging?

2005-12-05 Thread Dave Hansen
On Fri, 02 Dec 2005 18:04:15 +0100 in comp.lang.python, Christophe
[EMAIL PROTECTED] wrote:

infidel a écrit :
I'm using the Windows version of Python and IDLE. When I debug my .py
file, my modification to the .py file does not seem to take effect
unless I restart IDLE. Saving the file and re-importing it doesn't help
either. Where's the problem?
 
 
 import only reads the file the first time it's called.  Every import
 call after that looks up the module in memory.  This is to prevent
 circular dependencies between modules from creating infinite loops.
 You need to use the reload() function:

As a matter of fact, it would help a lot if that stupid behaviour of 
Idle was dropped. I'm sure I'm not the only one who lost lots of time 
because of that bug. Yes I call it a bug.

But, if you are editing a Python Module in Idle, and press F5 to run
the module, the interpreter is restarted for you.  So what's the
problem?

I would consider it a far greater problem if Idle _didn't_ do that --
it could mean you module worked when you were debuggining it because
of some initialization that doesn't get performed in a clean start.

Regards,
-=Dave

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


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-05 Thread Magnus Lycka
[EMAIL PROTECTED] wrote:
 Where does that misconception that 2-3 spaces for indenting makes
 things less readable come from? There was an article in Comm. of the
 ACM on research into readability back in 1984 or so, that indicated 2-4
 spaces has very similar readability and 8 spaces significantly less
 than that. IIRC they took care of personal preferences/what one was
 used to in the research. So disallowing tabs which could be set to 8
 spaces (positions?) does make sense to me.
 I switched from using 2 to using 4 spaces for Python recently, and the
 big pain was to deal with lines that no longer fitted in 80 columns :-(

Bigger indentation steps *are* more obvious, but on the other
hand, smaller indentation allows you to use more indentation
levels without using up all of your line width. (Using more than
80 chars per line is typically a bad idea.)

In general, I find that you rarely need so many indentation
levels in Python as in e.g. C or C++. I rarely run out of line
width in Python, even though I use 4 space indents and use fairly
long names. Remember that you can freely break lines within pairs
of (), [] and {}, and that adjacent string literals are concatenated.

If you try to squeeze something like...

self.logger.log(log_level, Blaha bla bla bla bla
at: %s:%i caused a %s with message\n%s\n %
(file_name, row, error, error_message))

...into one line, it doesn't matter what indentation depth you use...
-- 
http://mail.python.org/mailman/listinfo/python-list


Learning Python...

2005-12-05 Thread Falc
Hi there...

I have been looking at learning Python, so far it looks like an
absolutely grat language. I am having trouble finding some free
resources to learn Python from. I am on windows and the only experience
I have with programming is with PHP.

I have been trying to look at the free online book Dive Into Python
but this is far too difficult for me as it explains it in caparison
with C++ or Java.
I like the book called A Byte Of Python
(http://www.byteofpython.info) but it's made for version 2.3 (Would
this matter anyway?).
So if you have any books you could reccomend me that would rock, I
can't really afford a book so if online that would be excellent.

Thanks in Advance.

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


Re: how to handle two forms in cgi?

2005-12-05 Thread Fuzzyman

[EMAIL PROTECTED] wrote:
 Hi Dan,

 Sure. You are right. When I correct this according to your idea, it
 works now. Thank you very much. But I have second problem. When users
 run second form, other people can see adress in users' browers and know
 how to run the second form, so they don't need to run login form. How I
 can handle this case? How I can let users run login form firstly, then
 they can run second form(search form)?

 By the way I use python to write cgi.


You can use logintools to add a user authentication framework to any
CGI with very little work.

This lets you control who is able to login (whether or not new users
can sign up and you have an interface to create/invite new users).

It will also prevent any script being run unless the user is logged in.
It uses cookeis for authentication and can be added to a standard CGI
with as little as two lines of code.

It is designed for exactly the problem you have.

http://www.voidspace.org.uk/python/logintools.html

All the best,

Fuzzyman
http://www.voidspace.org.uk/python/index.shtml
 Any help is appriciated!

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


Re: newbie - needing direction

2005-12-05 Thread Scott David Daniels
[EMAIL PROTECTED] wrote:
 Thanks for the advice,
 The reason for the choice of my particular test project is that it is
 in the direction that I want to go in so choosing some other won't do.
 I've looked briefly at PyGame but this means I have to learn a lot
 besides what I want to do.
 
 I thought that maybe my project could be accomplishied using Tkinter
 (or possibly wxPython) and PIL. Am I on the wrong track, or should I
 invest my time into PyGame even if I don't plan to make games?
 
 Bob
 
What you do not understand is that your project requires you to read the 
screen under your lens and track the position on the screen.  Those
things are all aspects of the OS and display system, not the language.
So, you'll have to figure out a lot about your system while you are
still unsure of the language itself.  That is why we are saying this is
too tough a first project.  Reduce your problem: make a movable circle
on a canvas.  Next put a background picture under the circle of the
canvas.  Then try to your magnification trick on the background.  Only
after you can do all of that should you try to get onto the desktop.

Don't be so concerned about having to learn too much -- that learning
is the whole point of initial projects.  You don't know what you need
to know now, so you are not in a position to make a well-informed choice
of what you need to know.

-- 
-Scott David Daniels
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to ping in Python?

2005-12-05 Thread dudeman
Try the PyNMS libraries:
http://freshmeat.net/projects/pynms/

It has a ping module. If all you need is the ping module, maybe you
could just look through that code and see if it's relatively simple to
impliment yourself.

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


Re: Eclipse best/good or bad IDE for Python?

2005-12-05 Thread malv
It would not be misplaced in a python forum to draw your attention to
Bruce A. Tate's book:
Beyond Java, publ O'Reilly Sep. 2005, ISBN 0-596-10094-9.

Bruce explains why: ... Java is abandoning its base, and conditions
are ripe for an alternative to emerge.

Personally, I have never felt any need in Python to have to fall back
on Java tools in order to program  in a more efficient manner. The less
clutter, the better!

malv

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


How to manage event of COM objects...

2005-12-05 Thread Laurent
Hello,

I'm currently trying to use event from a win32 application using it's
COM interface.

To connect to the application I use:

class MyApp_InterfaceManager (Thread):
  ...
  def run (self):
# First we initialize the COM libraries for current thread
pythoncom.CoInitialize()
#Then we connect to the app with event handling...
self.app = DispatchWithEvents('MyApp',MyApp_AppEvents)

class MyApp_AppEvents:
  OnHalt:
print halt event...

From here all is ok when the OnHalt event arrives the print is called.
The problem I have is that I need that MyApp_AppEvents class knows the
thread object to call a thread function when the event occurs(for
example I need to toggle a flag)

I've got no idea how to do that!
Anyone has encoutered the problem?
I've tryied to use getevents but with no result...
Help!

Best regards,

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


Re: Why my modification of source file doesn't take effect when debugging?

2005-12-05 Thread Christophe
Dave Hansen a écrit :
 On Fri, 02 Dec 2005 18:04:15 +0100 in comp.lang.python, Christophe
 [EMAIL PROTECTED] wrote:
 
 
infidel a écrit :

I'm using the Windows version of Python and IDLE. When I debug my .py
file, my modification to the .py file does not seem to take effect
unless I restart IDLE. Saving the file and re-importing it doesn't help
either. Where's the problem?


import only reads the file the first time it's called.  Every import
call after that looks up the module in memory.  This is to prevent
circular dependencies between modules from creating infinite loops.
You need to use the reload() function:

As a matter of fact, it would help a lot if that stupid behaviour of 
Idle was dropped. I'm sure I'm not the only one who lost lots of time 
because of that bug. Yes I call it a bug.
 
 
 But, if you are editing a Python Module in Idle, and press F5 to run
 the module, the interpreter is restarted for you.  So what's the
 problem?
 
 I would consider it a far greater problem if Idle _didn't_ do that --
 it could mean you module worked when you were debuggining it because
 of some initialization that doesn't get performed in a clean start.
 
 Regards,
 -=Dave
 

Well, I'm happy to see that Idle now restarts the interpreter by default 
when you press F5. I guess I might consider using it again after all 
that time :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Use python to test Java and Windows (dll) applciations

2005-12-05 Thread Cameron Laird
In article [EMAIL PROTECTED],
jb [EMAIL PROTECTED] wrote:
Hello everybody:

I need help, and please let me know if python is the language of choice
to implement following functionalities:

I am trying to test a Java application and a C++ (win32) application.

I want to be able to write python code to mimic user interaction with
the application.  Interaction could be mouse or keyboard
movement/events using which I want to be able to select Menus and
execute them. Please let me know if this is feasible using Python, if
yes, please refer me to a good resource.
.
.
.
Yes and no.

To think of Python in this context is a healthy instinct.

The whole category of mimic user interaction is deeply
problematic, though.  The simple-minded Python-oriented answer
to give is, use Pamie or Watsup.  You might do best, though,
to start by reading URL: http://wiki.tcl.tk/8813 .

To pursue this further, we'd need to explore what exactly
Java and C++ mean in your situation.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Learning Python...

2005-12-05 Thread Klaus Alexander Seistrup
Falc wrote:

 So if you have any books you could reccomend me that would rock, I
 can't really afford a book so if online that would be excellent.

Have you looked into:
  http://wiki.python.org/moin/BeginnersGuide
  http://python.org/doc/Intros.html

Cheers,

-- 
Klaus Alexander Seistrup
Copenhagen, Denmark
http://seistrup.dk/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-05 Thread JohnBMudd
  even a single character (like an opening or closing bracket or a semicolon) 
 is an indication that the design can be improved.

Close, there are two principles for good design: Afford proper use and
Don't afford improper use.  I could argue that not having to type extra
characters falls into the first category and so is part of why Python
is a better design.  Not having to type extra characters makes it
easier (affords me) to enter source code in the first place and there's
less to maintain in the long run.  That's probably why nobody in the
thread, including myself, has advocated *require* the brackets.

But, like a lot of solutions, in solving one problem Python has
created another one.  Many people, for whatever reasons, feel that the
solution (scope by indent) prevents them from using the tool.  Hence
Python has not really made it easier to type and maintain source code
for the general audience, it's has only polarized the audience.  There
are many people who would say it definitely does NOT afford proper use.


Python is the superior design, today.  But, like Betamax tape format,
Python isn't mainstream yet.  And, sadly, maybe it never will be.  I
want that changed.  I want Python to take over the world so I don't
have to beg my next boss to let me use it.  And if adding an optional
dumbed-down format will help then that might be an improvement in the
big picture.  

John

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


Re: Learning Python...

2005-12-05 Thread Laurent
Falc wrote:
 Hi there...
 
 I have been looking at learning Python, so far it looks like an
 absolutely grat language. I am having trouble finding some free
 resources to learn Python from. I am on windows and the only experience
 I have with programming is with PHP.
 
 I have been trying to look at the free online book Dive Into Python
 but this is far too difficult for me as it explains it in caparison
 with C++ or Java.
 I like the book called A Byte Of Python
 (http://www.byteofpython.info) but it's made for version 2.3 (Would
 this matter anyway?).
 So if you have any books you could reccomend me that would rock, I
 can't really afford a book so if online that would be excellent.
 
 Thanks in Advance.
 

I must recommend you Learning Python from O'reilly that is an
excellent book but not free...This is the only one I've read about python.
For byteofpython I haven't read it but if it covers python 2.3 sure it
is sufficient to learn python as 2.4 has just introduced some new
advanced features.

Also take a look at:
http://www.awaretek.com/tutorials.html
Good examples that will help you in your learning.

Dive into python must be read _after_ you've read and tryied a little
python :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Installing Eric?

2005-12-05 Thread Scott David Daniels
malv wrote:
...
 Install of course Python-2.4.1:
 http://python.org/ftp/python/2.4.1/python-2.4.1.msi

These days you want 2.4.2.  Within a number (2.4.X), the
only changes are bugfixes, so go for the largest available.
When we go to 2.5, there will be some changes to adapt to,
those differences leave something to choose.  You should
always feel free to grab the most recent matching the first
two digits.

--Scott David Daniels
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: timeit's environment

2005-12-05 Thread Scott David Daniels
[EMAIL PROTECTED] wrote:

 Since I've been bitching about documentation in another
 thread, I'm curious...  Would it be obvious to anyone of
 low to intermediate python skills that using global would
 not work in this case?  Would it be obvious that using an
 import is the answer?  Or can I blame this partially on the
 documentation? :-)  I think the scoping issue could have
 at least been mentioned in the Timer class or timeit method
 descriptions.  There is no mention there of exactly what
 environment the code is run in.

Perhaps you could write a paragraph or two that would have
informed you and send it to the destination mentioned on the
documentation page.


-- 
-Scott David Daniels
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-05 Thread Richard Brodie

Tom Anderson [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

 Which is not to say that it's a bad idea - if it really is scaring off 
 potential converts, then a dumbed-down dialect of python which uses curly 
 brackets and semicolons might be a useful evangelical tool.

I doubt it: a lot of people have asserted something similar over
the years but I don't remember anyone ever bothering to post
a patch (and if someone has it disappeared without a ripple).

I'm sure some folk can remember local coding styles that suggested
using BEGIN and END as macros for curly brackets in C because
{ and } aren't intuitive. 


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


Re: Constructing RFC2822 Message

2005-12-05 Thread Steve Holden
Narendra wrote:
 Thanks jep for the quick response.But when im sending with different
 program written in java i was able to send into inbox.
 
 So i thought problem was with the python code only.
 
 Narendra
 
Are you sending from a Windows XP client? If so the firewall may be 
getting in your way. (It may already trust Java).

You don't report the actual error, so it's difficult to say waht's going 
wrong.

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: Bitching about the documentation...

2005-12-05 Thread bonono

[EMAIL PROTECTED] wrote:
 Sure, feel free to point of flaws.  Just don't let that be the only way you
 contribute.  Over time the value of your criticism (valid or not) will be
 discounted.
 
That is quite interesting, if it is true.

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


Re: how to handle two forms in cgi?

2005-12-05 Thread Steve Holden
[EMAIL PROTECTED] wrote:
 Hi Steve,
 
 Thank you for your information. Your idea is helpful for me.
 By the way, could I use hiden to handle this case?
 
 
 
 Laya
 
Yes, some systems have done that, some have used a component of the URL 
path, but you have to remember that the hidden items are available to 
anyone using view source in their browser (or writing a client program 
to do the equivalent thing), so your mechanism will be quite obvious to 
hackers.

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: ANN: Dao Language v.0.9.6-beta is release!

2005-12-05 Thread Paul McNett
[EMAIL PROTECTED] wrote:
 Python is the superior design, today.  But, like Betamax tape format,
 Python isn't mainstream yet.  And, sadly, maybe it never will be.  I
 want that changed.  I want Python to take over the world so I don't
 have to beg my next boss to let me use it.  And if adding an optional
 dumbed-down format will help then that might be an improvement in the
 big picture.  

I couldn't disagree more. I most certainly do *not* want Python to take over 
the 
world. I want .NET and Java to prevail, so that large companies with money to 
throw away at such technologies will continue to do so, and so that I can still 
fly in under the radar to my small clients and be able to provide them with the 
simplest solution that works at a price they can afford and a price that I can 
live on. Having .NET and Java in the world makes me into more of a hero when I 
can swoop in and get the real business problem solved using Python.

Now, say Python were to usurp everything else and become the dominant language. 
Everyone would learn Python. Python would become all the rage and get all the 
hype. Sun, Oracle, Microsoft, IBM, Apple, and SCO would all evangelize on their 
new Python initiatives. Microsoft would attempt to release their version with 
just a few non-standard things added on. Sun would sue them for not sticking 
with standards. Books and articles would be written. Middle-level management 
would start identifying places that Python is deficient in their eyes. CIO 
Insight would start making recommendations. Everyone would be pumping so much 
energy into so many different places that, like Java, Python would stall out 
and 
be consumed by its own hype, and the programmers that made Python what it is 
would burn out on it (read: they'd be busy counting all their stock options).

Plus, there would now be a deluge of Python programmers in the market place, 
competing with my billing rate.

No, I like Python just where it is, thank you very much. If someone doesn't 
want 
to give Python a second look because of their own bigoted ideas, I say Python 
doesn't want that type of person to begin with. Perhaps that sounds a bit 
elitist, but if people would just put their preconceptions aside, they'd 
quickly 
realize that Python really does get block indentation (and a whole host of 
other 
things besides) right.

-- 
Paul McNett
http://paulmcnett.com
http://dabodev.com

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


Re: Learning Python...

2005-12-05 Thread Falc
I am going to read A Byte Of Python and possibly a few others
afterwards. I sure will read Dive into Python.

Thanks a lot guys, it's beed a great help.

I'll buy Learning Python when I can but I'm on a *very* tight budget
at the moment. 
Thanks again. :)

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


Re: Installing Eric?

2005-12-05 Thread malv
Thanks Scott. I missed that doing cut  paste.

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


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-05 Thread Steve Holden
[EMAIL PROTECTED] wrote:
 even a single character (like an opening or closing bracket or a semicolon) 
 is an indication that the design can be improved.
 
 
 Close, there are two principles for good design: Afford proper use and
 Don't afford improper use.  I could argue that not having to type extra
 characters falls into the first category and so is part of why Python
 is a better design.  Not having to type extra characters makes it
 easier (affords me) to enter source code in the first place and there's
 less to maintain in the long run.  That's probably why nobody in the
 thread, including myself, has advocated *require* the brackets.
 
 But, like a lot of solutions, in solving one problem Python has
 created another one.  Many people, for whatever reasons, feel that the
 solution (scope by indent) prevents them from using the tool.  Hence
 Python has not really made it easier to type and maintain source code
 for the general audience, it's has only polarized the audience.  There
 are many people who would say it definitely does NOT afford proper use.
 
 
 Python is the superior design, today.  But, like Betamax tape format,
 Python isn't mainstream yet.  And, sadly, maybe it never will be.  I
 want that changed.  I want Python to take over the world so I don't
 have to beg my next boss to let me use it.  And if adding an optional
 dumbed-down format will help then that might be an improvement in the
 big picture.  
 
But you don't want it to be Python, is all.

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: reddit.com rewritten in Python

2005-12-05 Thread Harald Armin Massa
Yeah! Another web framework for Python!

Now we can prouldy say: Python: the only language with more web
frameworks than keywords

Harald

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


Re: reddit.com rewritten in Python

2005-12-05 Thread Harald Armin Massa
Yeah! Another web framework for Python!

Now we can proudly say: Python: the only language with more web
frameworks than keywords

Harald

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


Re: Constructing RFC2822 Message

2005-12-05 Thread Tim Williams (gmail)
On 5 Dec 2005 06:27:44 -0800, Narendra [EMAIL PROTECTED] wrote:
Hi All,This is narendra from india doing my engineering.i need to develop an E-mail client in python,which connects to my MTAon port 25 and sends email from there.I was able to do that but my e-mail is ending in bulk when i'm trying
to senf to hotmail/msn.

Hotmail score spam/junk/ on several criteria. Including
whether the msg has a msg-id (yours doesn't) and whether the
envelope sender and recipient(s) match the header sender and
recipient(s). Have a look at the headers from spam and not
spam in your hotmail account to see what sort of headers each type has
(or hasn't).

Also, you may be better off using smtplib for the sending
portion, the error types will be more informative if there
is a connection or sending issue.

HTH :)
-- Tim Williams
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: hash()

2005-12-05 Thread Scott David Daniels
John Marshall wrote:
 For strings of  1 character, what are the chances
 that hash(st) and hash(st[::-1]) would return the
 same value?

Why not grab a dictionary and do the stats yourself?

--Scott David Daniels
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bitching about the documentation...

2005-12-05 Thread skip

 Sure, feel free to point of flaws.  Just don't let that be the only
 way you contribute.  Over time the value of your criticism (valid or
 not) will be discounted.

bonono That is quite interesting, if it is true.

Let me rephrase.  The discounting I referred to is largely subconcious.
When it is concious it's a roll of the eyes or a thought like, Oh that
whiner again.  I don't have time for this right now.  And the 'd' key gets
hit.  I didn't mean to imply some sort of smoke-filled backroom where the
developers decide whose inputs to listen to.

Everybody applies such filters whether they think about it or not.  Here are
a couple of mine:

Xah Lee?  Hit the 'd' key.

Tim Peters? Read it no matter what the subject says.

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


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-05 Thread JohnBMudd
 If someone doesn't want
 to give Python a second look because of their own bigoted ideas, I say Python
 doesn't want that type of person to begin with.

Some days I feel the same way.  I've described Python as a filter where
only the best get through.  That's leads to a concentration of talent
and good taste which has great value and can even eclipse any
shortcomings in the flawed tool that initially drew the crowd together.
 This is from a paper I started a long time ago, entitled The Value of
Bad Design.  I never finished it but I do think it might be valid.

John

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


  1   2   3   >