Re: Exploring outlook using python

2005-08-25 Thread Do Re Mi chel La Si Do
Hum...

If it's Outlook, look for COM/Dispatch, with PyWin32
If it's Outlook-Express, search a MAPI module, like said Peter Hansen.

@-salutations

Michel Claveau



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


Re: Newbie question: Sub-interpreters for CAD program

2005-08-25 Thread Terry Hancock
On Wednesday 24 August 2005 09:12 pm, Peter Hansen wrote:
 Terry Hancock wrote:
 I have a strong EE and hardware background (hence my need to write a
 CAD program that doesn't piss me off), but not a CS background.
  
  You probably ought to consider starting with something existing like
  the Gnu EDS project -- but I'm assuming you probably already know
  about that.
 
 Or even http://www.pythoncad.org/ which, although probably for 
 mechanical CAD work (I haven't looked at it, don't really know), is 
 surely a good place to get ideas of what Python can do in this area.

No, I doubt it.  PythonCAD is a 2D mechanical CAD drawing system.
I don't think it would be anywhere near what this guy wants.  They're
just different applications. He's looking for an electronic CAD system or
EDA, I'm pretty sure (or looking to write one, rather).

Anybody that says he's not looking for a CAD program but looking
for a CAD program that doesn't piss me off is probably a power-user. ;-D

Not a reflection on PythonCAD, though -- it's a pretty cool project,
I recommend it to anyone interested in exploring general purpose
2D CAD drawing systems.  Among other advantages, it is written in
Python, so probably somewhat easier to script (haven't tried, though),
and it uses a self-defined XML format for CAD drawings, which is an
interesting standards move, given that free CAD formats have hitherto 
been pretty limited, leaving professionals stuck with proprietary binary
formats, and not very happy with them (there are technical reasons for
not liking the DXF format which is a free format, albeit created by
AutoDesk).

At present I believe that PythonCAD is about on par with QCAD, but
I'd bet on PythonCAD for potential, because of these design advantages.

Cheers,
Terry


--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com

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


Re: Bug in string.find; was: Re: Proposed PEP: New style indexing,was Re: Bug in slice type

2005-08-25 Thread en.karpachov
On Thu, 25 Aug 2005 00:05:18 -0400
Steve Holden wrote:

 What on earth makes you call this a bug? And what are you proposing that 
 find() should return if the substring isn't found at all? please don't 
 suggest it should raise an exception, as index() exists to provide that 
 functionality.

Returning -1 looks like C-ism for me. It could better return None when none
is found.

index = Hello.find(z)
if index is not None:
 # ...

Now it's too late for it, I know.

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


Re: while c = f.read(1)

2005-08-25 Thread Antoon Pardon
Op 2005-08-24, Magnus Lycka schreef [EMAIL PROTECTED]:
 Antoon Pardon wrote:
 I think he did, because both expression are not equivallent
 unless some implicite constraints make them so. Values where
 both expressions differ are:
 
   start1=67, stop1=9, start2=10, stop2=29

 Ouch! That didn't occur to me. How sloppy to just assume that
 time periods can't end before they start.

I have no trouble that you assume a time period starts before
it ends.

But two pieces of code that only give the same result under
particular assumptions are not equivallent. For all I know
his code might work without this assumption and thus be
usefull in circumstances where yours is not.

Maybe someone uses a convention where time intervals that
stop before they start can have some meaning.

Equivallent code IMO always gives the same results, not
only under the particular constraints you are working with.

 I'll shut up now. You win,
 I'm obviously the idiot here, and Python's must be
 redesigned from ground up. Pyrdon maybe?

If I ever design a language it'll be called: 'Queny'

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


Re: Should I move to Amsterdam?

2005-08-25 Thread Adriaan Renting
Thank you for your praise of my little country, but depending on your 
definition, the Netherlands might not be as civil as you assume. A lot of my 
foreign collegues commplain about how rude the dutch can be.
Countries like sweden or japan seem to have much better manners.
As to which countries have been civilized for the longest time, the Netherlands 
wouldn't rank very high there either, China, Greece or Egypt have been 
civilized much longer.

I do think however that New york should have it's name reverted to New 
Amsterdam ;-)

 
Tom Anderson [EMAIL PROTECTED] 08/24/05 6:49 pm  
On Wed, 24 Aug 2005, Armin Steinhoff wrote: 
 
Adriaan Renting wrote: 
 
Wade [EMAIL PROTECTED] 08/24/05 2:31 pm  
 
http://www.slate.com/id/2124561/entry/2124562/ Nice little series by 
Seth Stevenson for Americans daydreaming about emigration. Somewhere, 
anywhere ... maybe Amsterdam?  I've never been to the Netherlands 
myself, but it sounds very civilized. 
 
What a joke ... Amsterdam is 'civilized' since several hundreds of years 
:) 
 
Indeed. Perhaps we should rename it Old New York to reinforce the point :). 
 
But yes, the Netherlands is a highly civilised country - up there with 
Denmark and Canada, and above the UK, France or Germany, IMNERHO. I'm not 
going to bother comparing it to the US! 
 
tom 
 
-- 
This should be on ox.boring, shouldn't it? 
-- 
http://mail.python.org/mailman/listinfo/python-list 

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


Re: Command Line arguments

2005-08-25 Thread Tim Roberts
michael [EMAIL PROTECTED] wrote:

I have a question about Windows based python (2.4 and later).

For example, if I make a script called test.py like so:

import sys
print sys.argv

then run it:

python test.py this is a test

I see a list with 

['test.py', 'this', 'is', 'a', 'test']


All is good!

BUT...

If i make .py extensions be run as exes (by setting the .py extension to
be executable with PATHEXT setting in environment variables, the Python
program will run, but NO arguments are passed!

For example, after setting .py extension to be executable, i get this:

test this is a test

I get ['test.py]. NO arguments are passed. 

NOTE: This can NOT be blamed on Windows in my mind because Python2.2 and
earlier works FINE.

It is a configuration problem.  Bring up a Command Shell and run the assoc
and ftype commands like this:

  C:\Tmpassoc .py
  .py=Python.File

  C:\Tmpftype Python.File
  Python.File=C:\Apps\Python24\python.exe %1 %*

  C:\Tmp

The KEY part of that is the %* at the end of the Python.File defintion.
That tells the system to insert the rest of the command line parameters at
that point.  If you have ONLY the %1, the command will run but no
parameters will be forwarded.  If so, you can fix this by typing:

  C:\Tmpftype Python.File=C:\Apps\Python24\python.exe %1 %*

Substituting your own path, of course.
-- 
- Tim Roberts, [EMAIL PROTECTED]
  Providenza  Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


same menu point is activated

2005-08-25 Thread OllieZ
Hi all

Im trying to learn wxpython by some samples and Ive come across this.
After change EVT_MENU lines from
EVT_MENU(self, ID_OPEN, self.OnOpen) to
self.Bind(wx.EVT_MENU, self.OnOpen)

It can run, but the menu points all trigger the openfile dialog.
Seems like the last bind rules them all.
What am i doing wrong?

All the best

OllieZ

Code below

import wx
import os
ID_ABOUT=101
ID_OPEN=102
ID_BUTTON1=110
ID_EXIT=200

class MainWindow(wx.Frame):
def __init__(self,parent,id,title):
self.dirname=''
wx.Frame.__init__(self,parent,wx.ID_ANY, title,
style=wx.DEFAULT_FRAME_STYLE|
wx.NO_FULL_REPAINT_ON_RESIZE)
self.control = wx.TextCtrl(self, 1, style=wx.TE_MULTILINE)
self.CreateStatusBar() # A Statusbar in the bottom of the
window
# Setting up the menu.
filemenu= wx.Menu()
filemenu.Append(ID_OPEN, Open, Open a file to edit)
filemenu.AppendSeparator()
filemenu.Append(ID_ABOUT, About, Information about this
program)
filemenu.AppendSeparator()
filemenu.Append(ID_EXIT,Exit, Terminate the program)
# Creating the menubar.
menuBar = wx.MenuBar()
menuBar.Append(filemenu,File) # Adding the filemenu to the
MenuBar
self.SetMenuBar(menuBar)  # Adding the MenuBar to the Frame
content.
self.Bind(wx.EVT_MENU, self.OnAbout)
self.Bind(wx.EVT_MENU, self.OnExit)
self.Bind(wx.EVT_MENU, self.OnOpen)
# EVT_MENU(self, ID_OPEN, self.OnOpen)


self.sizer2 = wx.BoxSizer(wx.HORIZONTAL)
self.buttons=[]
for i in range(0,6):
self.buttons.append(wx.Button(self, ID_BUTTON1+i, Button
+`i`))
self.sizer2.Add(self.buttons[i],1,wx.EXPAND)

# Use some sizers to see layout options
self.sizer=wx.BoxSizer(wx.VERTICAL)
self.sizer.Add(self.control,1,wx.EXPAND)
self.sizer.Add(self.sizer2,0,wx.EXPAND)

#Layout sizers
self.SetSizer(self.sizer)
self.SetAutoLayout(1)
self.sizer.Fit(self)

self.Show(1)

def OnAbout(self,e):
d = wx.MessageDialog( self,  A sample editor \n
 in wxPython,About Sample Editor,
wx.OK)
# Create a message dialog box
d.ShowModal() # Shows it
d.Destroy() # finally destroy it when finished.

def OnExit(self,e):
self.Close(True)  # Close the frame.

def OnOpen(self,e):
 Open a file
dlg = wx.FileDialog(self, Choose a file, self.dirname, ,
*.*, wx.OPEN)
if dlg.ShowModal() == wx.ID_OK:
self.filename=dlg.GetFilename()
self.dirname=dlg.GetDirectory()
f=open(os.path.join(self.dirname, self.filename),'r')
self.control.SetValue(f.read())
f.close()
dlg.Destroy()


app = wx.PySimpleApp()
frame = MainWindow(None, -1, Sample editor)
app.MainLoop()

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


Re: Jargons of Info Tech industry

2005-08-25 Thread CBFalconer
Mike Schilling wrote:
 Mike Meyer [EMAIL PROTECTED] wrote in message
 Mike Schilling [EMAIL PROTECTED] writes:
 l v [EMAIL PROTECTED] wrote in message
 Xah Lee wrote:

 (circa 1996), and email should be text only (anti-MIME, circa 1995),

 I think e-mail should be text only.  I have both my email and
 news readers set to display in plain text only.  It prevents
 the marketeers and spammers from obtaining feedback that my
 email address is valid.  A surprising amount of information
 can be obtained from your computer by allowing HTML and all
 of it's baggage when executing on your computer. Phishing
 comes to my mind first and it works because people click the
 link without looking to see where the link really takes them.

 A formatting-only subset of HTML would be useful for both e-mail
 and Usenet posts.

 Used to be people who wanted to send formatted text via email
 would use rich text. It never really caught on. But given that
 most of the people sending around formatted text are using
 point-n-click GUIs to create the stuff, the main advantage of
 HTML - that it's easy to write by hand - isn't needed.
 
 But the other advantage, that it's an existing and popular
 standard, remains.

However, for both e-mail and news, it is totally useless.  It also
interferes with the use of AsciiArt, while opening the recipient to
the dangers above.

-- 
If you want to post a followup via groups.google.com, don't use
 the broken Reply link at the bottom of the article.  Click on 
 show options at the top of the article, then click on the 
 Reply at the bottom of the article headers. - Keith Thompson


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


Setting the encoding in pysqlite2

2005-08-25 Thread Michele Simionato
An easy question, but I don't find the answer in the docs :-(
I have a sqlite3 database containing accented characters (latin-1).
How do I set the right encoding? For instance if I do this:

#-*- encoding: latin-1 -*-
from pysqlite2 import dbapi2 as sqlite
import os

DBFILE=/tmp/example.db

def writedb(conn):
c = conn.cursor()
c.executescript(
create table example (word char(20));
insert into example values (così);
)
c.close()

def readdb(conn):
c = conn.cursor()
c.execute(select * from example;)
#print c.fetchall()
c.close()

if __name__ == __main__:
conn = sqlite.connect(DBFILE)
writedb(conn)
readdb(conn)
conn.close()
os.remove(DBFILE)

I get UnicodeDecodeError: 'utf8' codec can't decode byte 0xec in
position 3: unexpected end of data
(notice, even if the 'print' statement is commented.


Michele Simionato

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


Re: Externally-defined properties?

2005-08-25 Thread Michele Simionato
Well, I have used factories of properties external to the class many
times,
and they work pretty well.

  Michele Simionato

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


Re: Setting the encoding in pysqlite2

2005-08-25 Thread Renzo
Michele Simionato ha scritto:
 An easy question, but I don't find the answer in the docs :-(
 I have a sqlite3 database containing accented characters (latin-1).
 How do I set the right encoding? For instance if I do this:
 

Hi,
i usually use this string method:

encode([encoding[,errors]])

An example:

cur.execute(
insert into tab(
field1,
field2)
 values (?,?)
  , (myvar1.encode('utf8'),\
myvar2.encode('utf8')))

Bye,
Renzo
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Should I move to Amsterdam?

2005-08-25 Thread Paul Dale

But yes, the Netherlands is a highly civilised country - up there with 
Denmark and Canada, and above the UK, France or Germany, IMNERHO. I'm not 
going to bother comparing it to the US!
  

How strange that you put Canada so high on your list.
-- 
http://mail.python.org/mailman/listinfo/python-list


How to start PEP process?

2005-08-25 Thread Kenneth McDonald
Should I just put a Proposed PEP message here? Or is there a more  
formal way?

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


Re: Email client in Pyhton

2005-08-25 Thread knaren
Thanks micheal, for help.
I think this could solve most of problem.

-- 
K Naren,MeTel Team.
http://www.midascomm.com/

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


How to start a DTS Package on MS-SQL-Server?

2005-08-25 Thread Adrian Pettitt



I found this subject 
line in a post to this list on Jan 30, 2004. Does anybody know if this is 
possible?

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

Re: pipes like perl

2005-08-25 Thread max(01)*
many thanks to all the fellows who cared to answer!

bye

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


overload builtin operator

2005-08-25 Thread Shaun
Hi,

I'm trying to overload the divide operator in python for basic arithmetic.
eg. 10/2 ... no classes involved.

I am attempting to redefine operator.__div__ as follows:

 # my divide function
 def safediv(a,b):
 return ...

 # reassign buildin __div__
 import operator
 operator.__div__ = safediv

The operator.__dict__ seems to be updated OK but the '/' operator still  
calls buildin __div__

Does anyone know if this is possible and if I'm going along the correct  
path with my attempts above?
Is it possible to do this using a C extention?

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


Re: loop in python

2005-08-25 Thread km
Hi all,

 What you are comparing is either IO times (the print loop program),
 where Perl beats C - which means that Perl's IO have been written at a
 very low level instead of relying on the stdlib's IO - 

i'd like to know  what aspects are really coded in very low level for python ? 
regards,
KM


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


newbie question: convert a list to one string

2005-08-25 Thread martijn
H!

I'm searching for the fastest way to convert a list to one big string.

For example:
test = ['test','test2','test3']

print unlist(test)
 test test2 test3 (string)


I know I can make a loop like below but is that the fastest/best option
?

def unlist(test):
output=''
for v in test:
output = output+ +v
return output


Thanks for helping,
GC-Martijn

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


Get datatype of a column

2005-08-25 Thread Jitu
Hi

does anyone know how to get a column type from a database using jdbc
and python?

thanks

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


Re: How to start PEP process?

2005-08-25 Thread Martin v. Löwis
Kenneth McDonald wrote:
 Should I just put a Proposed PEP message here? Or is there a more 
 formal way?

See PEP 1.

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


Re: How to start PEP process?

2005-08-25 Thread Robert Kern
Kenneth McDonald wrote:
 Should I just put a Proposed PEP message here?

Proposed Python Enhancement Proposal? A bit redundant, don't you
think?  :-)

I think pre-PEP is the usual term.

 Or is there a more  
 formal way?

Not until you get to the post-pre-PEP stage. By all means, please do
post it here and get some feedback before formally submitting it.

-- 
Robert Kern
[EMAIL PROTECTED]

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

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


wanna stop by my homemade glory hole?

2005-08-25 Thread Jennifer
my husband is installing an extra bathroom poolside.  there is a perfect size 
hole (unless you have a huge cock) to stick your dick through into the adjoing 
room.  come around the side of my house(perfect if you look like a repair man) 
enter into the unfisnished bathroom and I'll service you from the other side.  
you can leave when your done, no talking or small talk.  i want to do this 
before the hole gets patched up. its been a huge fantasy of mine ever since 
I've seen a glory hole online. you can email me for a time convienient for you. 
im home all-day most days so my schedule is open. do you prefer a certain color 
of lipstick? check out my pic and email here under kallegirl26 
www.no-strings-fun.net/kallegirl26 
ready and waiting, me ;o)


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


Re: newbie question: convert a list to one string

2005-08-25 Thread Robert Kern
[EMAIL PROTECTED] wrote:
 H!
 
 I'm searching for the fastest way to convert a list to one big string.
 
 For example:
 test = ['test','test2','test3']
 
 print unlist(test)
 
test test2 test3 (string)
 
 
 
 I know I can make a loop like below but is that the fastest/best option
 ?
 
 def unlist(test):
 output=''
 for v in test:
 output = output+ +v
 return output

' '.join(test)

-- 
Robert Kern
[EMAIL PROTECTED]

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

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


Re: Doubt C and Python

2005-08-25 Thread Ben Sizer
Grant Edwards wrote:
 On 2005-08-23, praba kar [EMAIL PROTECTED] wrote:
  What why it is more efficient.  Kindly let me
  know with some details.

 Have you read _any_ of the thread?  A number of people have
 already explained in detail why programming in Pything is more
 efficient.   Please read the responses you've already gotten.

Grant,

Going by the Google Groups timestamps that I see, there's a good chance
that none of the other responses were visible to the OP when the above
followup was posted.

-- 
Ben Sizer

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


Re: newbie question: convert a list to one string

2005-08-25 Thread martijn
Thanks that's what i need.

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


MySQLdb module, method executemany with anything other than strings?

2005-08-25 Thread olekristianvillabo
The method cursor.executemany is there in order to avoid multiple calls
to cursor.execute().

I have tried, with success, to do like every single example (that I
have found on the www) on the subject shows, to use a insert statement
on the form:
statement = INSERT INTO table (colA,colB,colC) values (%s,%s,%s)

and pass in a list containing tuples
list = [('bla','bla','bla'),('bla','bla','bla'),('bla','bla','bla')]

on the form

cursor.executemany(statement,list)

This works fine for all strings, but I have never been able to insert a
single integer or a float using this method. I get an error message
reporting that float (or an int) is required.

Statement is then of course changed to something like
statement = INSERT INTO table (colA,colB,colC) values (%s,%i,%f)
list = [('bla',1,0.65),('bla',3,3.7),('bla',3,0.9)]

Havee anybody experienced similar problems?
Am I doing something wrong?
Any feedback is greatly appreciated.


Here is som real output from the interpreter:
 statement = 'insert into testtable3 (url,probability) values (%s,%f)'
 l
[('url1', 0.98999), ('url2', 0.89001)]
 cursor.executemany(statement,l)
Traceback (most recent call last):
  File stdin, line 1, in ?
  File C:\Python24\Lib\site-packages\MySQLdb\cursors.py, line 181, in
execu
any
self.errorhandler(self, TypeError, msg)
  File C:\Python24\Lib\site-packages\MySQLdb\connections.py, line 33,
in de
lterrorhandler
raise errorclass, errorvalue
TypeError: float argument required

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


Re: newbie question: convert a list to one string

2005-08-25 Thread Maciej Dziardziel
[EMAIL PROTECTED] wrote:

 H!
 
 I'm searching for the fastest way to convert a list to one big string.
 
 For example:
 test = ['test','test2','test3']

'-'.join(test)

-- 
Maciej Fiedzia Dziardziel (fiedzia (at) fiedzia (dot) prv (dot) pl)
www.fiedzia.prv.pl

Stewardesses is the longest word that is typed with only the left hand.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: newbie question: convert a list to one string

2005-08-25 Thread Sion Arrowsmith
 [EMAIL PROTECTED] wrote:
I'm searching for the fastest way to convert a list to one big string.

The join() method of strings. The string instance in question being
the separator you want, so:

 .join(test)

-- 
\S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/
  ___  |  Frankly I have no feelings towards penguins one way or the other
  \X/  |-- Arthur C. Clarke
   her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: loop in python

2005-08-25 Thread James
I am going to be a bit blunt. Don't get offended.

 Also the first thing any newbie to python asks me is abt raw speed in 
 comparison with similar languages like perl when i advocate python to perl.

Judging by your other posts, you are a newbie yourself. You are not
really in a position to 'advocate' any language over others.

 I agree that python emphasizes on readability which i didnt see in many of 
 the languages, but when the application concern is speed, does it mean that 
 python is not yet ready? even most of the googling abt python vs perl  
 convince me that perl is faster than python in most of the aspects.

One does not compare speed when they use Perl/Python/Ruby/Tcl. They are
all more or less in the same performance ball park.

Next don't make up your own benchmarks and jump to conclusions. Writing
good benchmarks is an art. If you need data, look at peer reviewed
benchmarks such as this one. http://shootout.alioth.debian.org/
As with all benchmarks, it is really hard to make general conclusions.

And you are simply looking at the wrong issue. Even if Python is 20
times slower than it's current implementation, it would still serve my
purposes. Do you believe that you need more speed? Tell us what is it
exactly that you are building and we will tell you what to do. Fetishes
with Speed and executable size are very common for young newbies. I
know because I had been there myself several years ago.

Python has been more than ready as far as speed goes. Real people, real
enterprises have been using Python in high load applications for quite
a while now and there is nothing really left to proove. People have
written entire application servers and databases in Python.

I taught myself atleast half a dozen ways to write native extensions
for Python, just in case. In the past 4 yrs or so that I have been
using Python as my main language, I did not need to speed up my Python
program even once with a custom extension. And I process multi giga
byte data sets. Why? Because, if your program is slow, chances really
are that your algorithm is slow, not the language. And most of the
Python modules that are available that need speed (GUIs, image
processing etc), are already written in C so that you, as a user, don't
have to worry.

Just get over your imaginary need for speed and learn to use Python for
what it is intended. Once again, post your actual application need, not
vague requirements with artificial conditions (I don't want C modules).

You said, elsewhere that you are writing a web application. People have
been using CGI, which has a terrible performace record for decades on
very slow machines compared to modern PCs. My point is, web
applications, generally aren't exactly the kind of applications that
have a lot of computational overhead, atleast not from the logic that
runs your site and is likely to be written in Python.

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


Re: pipes like perl

2005-08-25 Thread Piet van Oostrum
 infidel [EMAIL PROTECTED] (i) wrote:

i .readlines() won't return until it hits end-of-file, but the man
i command waits for user input to scroll the content, like the more or
i less commands let you view pages of information on a terminal.

man shouldn't wait for user input if its output is a pipe. Try man man|cat.
-- 
Piet van Oostrum [EMAIL PROTECTED]
URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4]
Private email: [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Should I move to Amsterdam?

2005-08-25 Thread Sybren Stuvel
Martin P. Hellwig enlightened us with:
 Personal transportation sucks in the Netherlands, if you live in the
 Randstad (the area of the above mentioned cities) and you have to
 travel across the Randstad, you go with the bike and/or
 bus/tram/metro/train because that is the fastest way of
 transportation.

And a bike isn't personal transportation?

 By the way, the big cities are notorious for losing your bike fast.

True. Unless you have two proper locks. In that case your bike will
last a very long time.

 That doesn't mean that public transportation is good, no actual
 since the public transportation is commercialized it sucks too.

It's quite good actually. The Dutch Railways (Nationale Spoorwegen, NS
for short) have a reputation of being late, but it isn't that bad.
Trains run frequently, and if you have a serious delay, you even get
part of your money back.

My GF and I just got back from a holiday in Croatia. There, there is
only a train every four hours, and then you're lucky. The track is so
bad, going by bus is just as fast, except you can buy a ticket on the
bus instead of having to buy a ticket + reservation in advance.

On the way back, we used the ICE (intercity express) through Germany.
It got delayed, so we missed our train to Amsterdam by 15 minutes. The
delay was in Köln, because the pope paid a visit - well known to the
Deutsche Bahn, but still they didn't do anything about it. We had to
use another train which left two hours later. And we didn't get any
compensation for this - not even for the reservation for the train we
missed.

We had a delay of two hours. In The Netherlands you would at least get
a significant percentage of your money back. Not in Germany.

After all, I think with the frequent trains (compared to Croatia) and
reasonable refunds (compared to Germany), the NS isn't that bad after
all.

 Just don't plan to get anywhere special with public transportation
 after 2300h.

There are night trains between the big cities in the Randstad. At
least in Amsterdam busses go through the city all the night, every
night. I don't know about other cities - I live in Amsterdam.

 Well politics, in the Netherlands is like politics in the rest of
 Western-Europe North-Atlantic-coast countries, excluding UK 
 Ireland.

Still, we were the first ones to legalize properly executed eutanasia.
We were also the first to have official single-sex marriages. I don't
know about other countries, but here prostitution is a regular job, so
you have to pay taxes as a prostitute, and there is even a union.

 Most of the time these politicians are social caring about everybody
 in the country including non-voters, non-payers and
 fanatic-believers of-whatever-you-can-imagine.

That's very true. I'm not too happy about that. Too many people refuse
to vote, for just that reason.

 Most people in here are non-believers or so lightly believers that
 you won't know the difference between them and the non-believers.
 The biggest part of the remaining believers are realistic and value
 life, moral and norms without compromising public safety, of course
 fanatics are every where in the world including the Netherlands.

Here in Amsterdam, things are getting more nasty. A
writer/critic/actor was killed in the name of Allah, just because he
excercised his freedom of speech.

Another man was seriously messed up while standing in his own front
door opening, just because he's homosexual. In his street, sometimes
people are shouting Go away you homo, you're not welcome here. This
is a Macoccan street!. I'm not discriminating, but Maroccans telling
Dutch people they aren't welcome in their own captial? I wish _those_
people would just go back to Marocco.

 The only serious downsize is that in the Randstad the house prices
 are too high

Very true. My girlfriend and I are renting a house in the northern
part of Amsterdam, just above Central Station. We had to search quite
hard to find that, though!

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: Should I move to Amsterdam?

2005-08-25 Thread Sybren Stuvel
Adriaan Renting enlightened us with:
 A lot of my foreign collegues commplain about how rude the dutch can
 be.  Countries like sweden or japan seem to have much better
 manners.

I also think the Dutch aren't all that communicative. I was queueing
in a store when they announced to have the new CD from an already
deceased artist. I turned around to tell the man behind me I wonder
how they did that. The reaction was just yeah, and he looked away
from me. Just coming back from Croatia, where everybody likes to talk
to each other, it was indeed a bit of a shock.

Another reason the Dutch are sometimes found to be a bit rude, is
because usually we just say what we think. For some cultures, this is
indeed considered to be rude. I just think it's honest.

 I do think however that New york should have it's name reverted to
 New Amsterdam ;-)

Definitely ;-)

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: loop in python

2005-08-25 Thread Sybren Stuvel
James enlightened us with:
 One does not compare speed when they use Perl/Python/Ruby/Tcl. They
 are all more or less in the same performance ball park.

I don't want to offend you or anything, but doesn't the second
sentence mean that someone DID do a speed comparison?

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: Should I move to Amsterdam?

2005-08-25 Thread Piet van Oostrum
 Martin P. Hellwig [EMAIL PROTECTED] (MPH) wrote:

MPH Of course this is all done with public transport and/or bike, not without
MPH reason.
MPH Personal transportation sucks in the Netherlands, if you live in the
MPH Randstad (the area of the above mentioned cities) and you have to travel
MPH across the Randstad, you go with the bike and/or bus/tram/metro/train
MPH because that is the fastest way of transportation.

That depends very much on where you live and where you have to go (mostly
on the number of changes of transport vehicle). I, for example live in a
small village, 11 km from my work in Utrecht. By bus it is 45-60 minutes,
by bike 40 min. and by car (rush hour) usually 20-25 min. Only when
something serious happens it can be 45 min. by car. This happens about
once a year. Most of the time I take the bike, but not for the speed. It is
actually a pleasant ride, mainly through woods and meadows.

My daughter worked some years ago in Nieuwegein, adjacent to Utrecht. By
car 20 min., by public transport 60-90 min. And this is not in some remote
area, but just in the center of the country, one of the most densely
populated areas.
-- 
Piet van Oostrum [EMAIL PROTECTED]
URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4]
Private email: [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


RE Despair - help required

2005-08-25 Thread Yoav
I am trying the following:

re.search(r'\\[^\\]+(?=(?$))', c:\ret_files)

and I get a return of NoneType, and I have no idea why. I know that I 
missing something here, but I really can't figure out why (I bet it's 
something obvious). I also tried this RE on KODOS and it works fine 
there, so I am really puzzled.

Any ideas?


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


Re: Should I move to Amsterdam?

2005-08-25 Thread dimitri pater
The problem with the world is stupidity. Not saying there should be acapital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself?
Frank Zappa
Geef mij wat vloerbedekking onder deze vette zwevende sofa

sorry, very off-topic, couldn't resist
dimitri

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

Re: Command Line arguments

2005-08-25 Thread michael
On Thu, 25 Aug 2005 00:46:41 -0700, Tim Roberts wrote:

 michael [EMAIL PROTECTED] wrote:
 
I have a question about Windows based python (2.4 and later).

For example, if I make a script called test.py like so:

import sys
print sys.argv

then run it:

python test.py this is a test

I see a list with 

['test.py', 'this', 'is', 'a', 'test']


All is good!

BUT...

If i make .py extensions be run as exes (by setting the .py extension to
be executable with PATHEXT setting in environment variables, the Python
program will run, but NO arguments are passed!

For example, after setting .py extension to be executable, i get this:

test this is a test

I get ['test.py]. NO arguments are passed. 

NOTE: This can NOT be blamed on Windows in my mind because Python2.2 and
earlier works FINE.
 
 It is a configuration problem.  Bring up a Command Shell and run the assoc
 and ftype commands like this:
 
   C:\Tmpassoc .py
   .py=Python.File
 
   C:\Tmpftype Python.File
   Python.File=C:\Apps\Python24\python.exe %1 %*
 
   C:\Tmp
 
 The KEY part of that is the %* at the end of the Python.File defintion.
 That tells the system to insert the rest of the command line parameters at
 that point.  If you have ONLY the %1, the command will run but no
 parameters will be forwarded.  If so, you can fix this by typing:
 
   C:\Tmpftype Python.File=C:\Apps\Python24\python.exe %1 %*
 
 Substituting your own path, of course.


Tim,

I can confirm you were right! Thank you very much.

This will get us through the issue. I wonder why this was needed? One way
or the other, you taught me something and I thank you.

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


Re: RE Despair - help required

2005-08-25 Thread Robert Kern
Yoav wrote:
 I am trying the following:
 
 re.search(r'\\[^\\]+(?=(?$))', c:\ret_files)
 
 and I get a return of NoneType, and I have no idea why. I know that I 
 missing something here, but I really can't figure out why (I bet it's 
 something obvious). I also tried this RE on KODOS and it works fine 
 there, so I am really puzzled.
 
 Any ideas?

Look at the second string. It has \r in the middle of it where you
really want \\r (or alternatively rc:\ret_files).

-- 
Robert Kern
[EMAIL PROTECTED]

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

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


Re: RE Despair - help required

2005-08-25 Thread Sybren Stuvel
Yoav enlightened us with:
 I am trying the following:

 re.search(r'\\[^\\]+(?=(?$))', c:\ret_files)

 and I get a return of NoneType, and I have no idea why.

Because you don't match a carriage return \r.

 I know that I missing something here, but I really can't figure out
 why (I bet it's something obvious).

Use forward slashes instead of backward slashes. And go nag at
Microsoft for using the most widely used escape character as a path
separator...

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: Command Line arguments

2005-08-25 Thread michael
On Thu, 25 Aug 2005 00:46:41 -0700, Tim Roberts wrote:

 michael [EMAIL PROTECTED] wrote:
 
I have a question about Windows based python (2.4 and later).

For example, if I make a script called test.py like so:

import sys
print sys.argv

then run it:

python test.py this is a test

I see a list with 

['test.py', 'this', 'is', 'a', 'test']


All is good!

BUT...

If i make .py extensions be run as exes (by setting the .py extension to
be executable with PATHEXT setting in environment variables, the Python
program will run, but NO arguments are passed!

For example, after setting .py extension to be executable, i get this:

test this is a test

I get ['test.py]. NO arguments are passed. 

NOTE: This can NOT be blamed on Windows in my mind because Python2.2 and
earlier works FINE.
 
 It is a configuration problem.  Bring up a Command Shell and run the assoc
 and ftype commands like this:
 
   C:\Tmpassoc .py
   .py=Python.File
 
   C:\Tmpftype Python.File
   Python.File=C:\Apps\Python24\python.exe %1 %*
 
   C:\Tmp
 
 The KEY part of that is the %* at the end of the Python.File defintion.
 That tells the system to insert the rest of the command line parameters at
 that point.  If you have ONLY the %1, the command will run but no
 parameters will be forwarded.  If so, you can fix this by typing:
 
   C:\Tmpftype Python.File=C:\Apps\Python24\python.exe %1 %*
 
 Substituting your own path, of course.



SOLVED! Thank you.

I wonder why this was needed for 2.4 and not 2.2? I don't think it was
lingering things from old installs because it happened on a persons
computer that had never had any python installed before 2.4.

Anyway, THANKS!

Michael 

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


Re: Doubt C and Python

2005-08-25 Thread michael
On Tue, 23 Aug 2005 06:15:03 +0100, praba kar wrote:

 Dear All,
I want to know the link between c and python.
Some people with C background use Python instead   
 of  programming in C.why?
 
 
  
 regards
 Prabahar
 
 
   
 
   
   
Just my $.02

I am a long time c/c++ programmer (by profession). I fell in love with
python about 2 years ago. I use python for many things now, and I always
have said, When it is too slow, I will write it in c++.

I have not hit that point yet. For some reasons that are hard to explain,
even though python should be slower and maybe even is sometimes, it
never is an issue. 

One reason is that python has so much better data structures built in, and
THEY are written in C, I end up with faster code. For example, if I am
doing a bunch of string compares in C, I would use a dictionary in python.
Python ends up faster because I can get to a better algorithm FASTER.

The other reason is that so many times, a hardware I/O device is really
the limiting factor (such as a hard disc, or a serial/network connection,
or waiting for the user). 

I have found that GUI programs written in python/wxpython to be every bit
as fast as pure C++. I guess you could say that because the LIBRARIES of
python are in C, and because you are never very far from a library call,
you end up running C code a large percentage of the time, even when you
are writing in Python.

My advice is to just TRY python and resolve the slow speed if you ever
hit it. I never have and I write a lot of code, even hardcore math and
image processing (See PIL - python Imaging Library).

Michael


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


Re: MySQLdb module, method executemany with anything other than strings?

2005-08-25 Thread Steve Holden
[EMAIL PROTECTED] wrote:
 The method cursor.executemany is there in order to avoid multiple calls
 to cursor.execute().
 
 I have tried, with success, to do like every single example (that I
 have found on the www) on the subject shows, to use a insert statement
 on the form:
 statement = INSERT INTO table (colA,colB,colC) values (%s,%s,%s)
 
 and pass in a list containing tuples
 list = [('bla','bla','bla'),('bla','bla','bla'),('bla','bla','bla')]
 
 on the form
 
 cursor.executemany(statement,list)
 
 This works fine for all strings, but I have never been able to insert a
 single integer or a float using this method. I get an error message
 reporting that float (or an int) is required.
 
 Statement is then of course changed to something like
 statement = INSERT INTO table (colA,colB,colC) values (%s,%i,%f)
 list = [('bla',1,0.65),('bla',3,3.7),('bla',3,0.9)]
 
 Havee anybody experienced similar problems?
 Am I doing something wrong?
 Any feedback is greatly appreciated.
 
 
 Here is som real output from the interpreter:
 
statement = 'insert into testtable3 (url,probability) values (%s,%f)'
  ^^
That's your problem, right there.
l
 
 [('url1', 0.98999), ('url2', 0.89001)]
 
cursor.executemany(statement,l)
 
 Traceback (most recent call last):
   File stdin, line 1, in ?
   File C:\Python24\Lib\site-packages\MySQLdb\cursors.py, line 181, in
 execu
 any
 self.errorhandler(self, TypeError, msg)
   File C:\Python24\Lib\site-packages\MySQLdb\connections.py, line 33,
 in de
 lterrorhandler
 raise errorclass, errorvalue
 TypeError: float argument required
 
It's just that you should use %s for *all* parameters, no matter what 
their type:

  conn = db.connect()
  curs = conn.cursor()
  curs.execute(
... create table thingy(
...f1 char(10) primary key,
...f2 float))
0L
  l = [('url1', 0.98999), ('url2', 0.89001)]
  curs.executemany(
... insert into thingy (f1, f2) values (%s, %s), l)
2L
 

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

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


Re: Should I move to Amsterdam?

2005-08-25 Thread Steve Holden
Sybren Stuvel wrote:
 Martin P. Hellwig enlightened us with:
 
[...]
 
 On the way back, we used the ICE (intercity express) through Germany.
 It got delayed, so we missed our train to Amsterdam by 15 minutes. The
 delay was in Köln, because the pope paid a visit - well known to the
 Deutsche Bahn, but still they didn't do anything about it. We had to
 use another train which left two hours later. And we didn't get any
 compensation for this - not even for the reservation for the train we
 missed.
 
 We had a delay of two hours. In The Netherlands you would at least get
 a significant percentage of your money back. Not in Germany.
 
[...]
Hitler must be turnng in his grave.

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

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


Re: Doubt C and Python

2005-08-25 Thread Uwe Schmitt
 
 On Tue, 23 Aug 2005 06:15:03 +0100, praba kar wrote:
 
  Dear All,
 I want to know the link between c and python.
 Some people with C background use Python instead   
  of  programming in C.why?
  
  
   
  regards
  Prabahar
  
  
  
  
 Just my $.02
 
 I am a long time c/c++ programmer (by profession). I fell in love with
 python about 2 years ago. I use python for many things now, 
 and I always
 have said, When it is too slow, I will write it in c++.
 
 I have not hit that point yet. For some reasons that are hard 
 to explain,
 even though python should be slower and maybe even is sometimes, it
 never is an issue. 

I made the same experience. The only reason I have for using C++
is number crunching. And I love boost python for building the bridge.

Greetings, Uwe.


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


Re: while c = f.read(1)

2005-08-25 Thread Steve Holden
Antoon Pardon wrote:
 Op 2005-08-24, Magnus Lycka schreef [EMAIL PROTECTED]:
 
Antoon Pardon wrote:

I think he did, because both expression are not equivallent
unless some implicite constraints make them so. Values where
both expressions differ are:

  start1=67, stop1=9, start2=10, stop2=29

This is just too fatuous to ignore, sorry.

Ouch! That didn't occur to me. How sloppy to just assume that
time periods can't end before they start.
 
 
 I have no trouble that you assume a time period starts before
 it ends.
 
 But two pieces of code that only give the same result under
 particular assumptions are not equivallent. For all I know
 his code might work without this assumption and thus be
 usefull in circumstances where yours is not.
 
 Maybe someone uses a convention where time intervals that
 stop before they start can have some meaning.
 
 Equivallent code IMO always gives the same results, not
 only under the particular constraints you are working with.
 
 
I'll shut up now. You win,
I'm obviously the idiot here, and Python's must be
redesigned from ground up. Pyrdon maybe?
 
 
 If I ever design a language it'll be called: 'Queny'
 
...and you will regard it as perfect and be completely unable to 
understand why nobody likes it.

Could we possibly reduce the number of arguments about ridiculous 
postulates such as , and try to remember that most people on this list 
are dealing with real life?

Magnus gave you a perfectly reasonable example of some code that could 
be simplified. You say the two pieces of code aren't equivalent. While 
you may be (strictly) correct, your assertion signally fails to add 
enlightenment to the discussion.

I continue to look forward to the first post in which you actually 
accept someone else's point of view without wriggling and squirming to 
justify your increasingly tenuous attempts to justify every opinion 
you've ever uttered on this group :-)

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

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


Re: MySQLdb module, method executemany with anything other than strings?

2005-08-25 Thread olekristianvillabo
I just realised that myself about two minutes ago, but thanks anyway!

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


Re: HTML/text formatting question

2005-08-25 Thread Edvard Majakari
Dr. Who [EMAIL PROTECTED] writes:

 This seems clunky and my next step was going to be to define generic
 functions which would generate the surrounding html tags only when
 passed the proper argument.  I was wondering if there was a better way
 to do this with a standard Python library.  It looked like formatter
 might but that it also might be too low-level.

You could use something like this:

class HTMLFormatter:

def __init__(self, tag, contents=None, **kwargs):

self.tag = tag
self._content = contents
self.attrs = dict()

self._set_attrs(kwargs)

def _set_attrs(self, attrs):

self.attrs = attrs

if '_class' in self.attrs:
self.attrs['class'] = self.attrs['_class']
del self.attrs['_class']

def set_content(self, contents, **kwargs):

Set content of HTML element to contents.

 f = HTMLFormatter('a')
 f.set_content('cat', href='http://www.cat.org')
 str(f)
'a href=http://www.cat.org;cat/a'
 str(HTMLFormatter('td', 'cat'))
'tdcat/td'
 str(HTMLFormatter('p', 'kitty kit', _class='cat'))
'p class=catkitty kit/p'
 str(HTMLFormatter('br'))
'br/'


self._content = contents

if kwargs:
self._set_attrs(kwargs)

def set_attribute(self, attr, val):
Set/update attribute 'attr' to 'val'.

self.attrs[attr] = val

def add_content(self, contents):
Add content to element.

 p = HTMLFormatter('p', 'name of the cat is ')
 p.add_content('meow')
 str(p)
'pname of the cat is meow/p'
 p = HTMLFormatter('td')
 p.add_content('cat')
 str(p)
'tdcat/td'


if self._content is None:
self._content = ''

self._content = %s%s % (self._content, str(contents))

def contents(self):
Get contents of object.

 p = HTMLFormatter('p', 'nice doggy dog')
 p.contents()
'nice doggy dog'
 p.add_content(HTMLFormatter('em', 'called wuff'))
 p.contents()
'nice doggy dogemcalled wuff/em'



return self._content

def __str__(self):
open_tag = '%s' % self.tag
if self.attrs:
attrs = self.attrs.items()
attrs.sort()
attrs_str = ' '.join(['%s=%s' % (k, v) \
  for k,v in attrs])
open_tag = '%s %s' % (self.tag, attrs_str)

if self._content is not None:
return '%s%s/%s' % (open_tag, self._content, self.tag)
else:
return '%s/' % open_tag


Doctest strings show examples how to use it. For serious HTML building stuff
it needs fiddling with, but should be handy for tiny projects.

--
# Edvard Majakari   Software Engineer
# PGP PUBLIC KEY available  Soli Deo Gloria!

$_ = '456476617264204d616a616b6172692c20612043687269737469616e20'; print
join('',map{chr hex}(split/(\w{2})/)),uc substr(crypt(60281449,'es'),2,4),\n;
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.1 Bible Source

2005-08-25 Thread Colin Gillespie
SuppressedPen wrote:
 Hi Everyone!
 
 Just started with Python 2 weeks ago and I can't put it down it's to easy
 and to powerful, I'm sure the goons will be after us for having it soon, Hi
 Hi.
 
 Was wondering if anyone might know where I can find the source code for
 PYTHON 2.1 BIBLE book.  Apparently it was online until the publisher sold
 the company.  I also understand it has been sold a second time since the
 book was published.  Maybe someone has a copy?  Thanks. DOUG.

you can access the web-site through the web.archive.org, e.g.

http://web.archive.org/web/*/http://www.pythonapocrypha.com/

The site runs fairly slowly, but all the pages seem to be there. I even 
downloaded the source code to the book from 
http://web.archive.org/web/20040610022324/http://www.pythonapocrypha.com/PySource.tgz

HTH

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


Re: Getting rid of close failed: [Errno 0] No Error on Win32

2005-08-25 Thread Yoav
Ok , I tried:

try:
os.popen3(...)
except:


as someone suggested here. And on FreeBSD I don't get the error message, 
and it works great. However, on Win32 I do get the annoying message. Any 
idea why? And How I can make it go away?

thanks.

Yoav wrote:
 I am using os.popen3 to call a console process and get its output and 
 stderr. However on Win32 (and not OS X) I also get the Errno message. 
 It's printed to the screen, which I wish to keep clean. How can disable 
 this notification?
 
 Thanks.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: same menu point is activated

2005-08-25 Thread Greg Krohn
OllieZ wrote:
 Hi all
 
 Im trying to learn wxpython by some samples and Ive come across this.
 After change EVT_MENU lines from
 EVT_MENU(self, ID_OPEN, self.OnOpen) to
 self.Bind(wx.EVT_MENU, self.OnOpen)

It should be:

self.Bind(wx.EVT_MENU, self.OnOpen, id=ID_OPEN)
 ^^

etc.


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


Re: variable hell

2005-08-25 Thread Diez B. Roggisch

Nx wrote:
  I am unpacking a list into variables, for some reason they need to be
  unpacked into variable names like a0,a1,a2upto aN whatever is
  in the list.

Explain this some reason. This smells, and the way to go would be to
use a dict mapping a_n to whatever is in the list - not creating
variables. How do you want to access generated variables anyway -
especially when you don't have the faintest idea how many of them there
are? Obviously there can't be code written based on that.

Regards,

Diez

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


Re: variable hell

2005-08-25 Thread Robert Kern
Nx wrote:
 Hi
 
  I am unpacking a list into variables, for some reason they need to be
  unpacked into variable names like a0,a1,a2upto aN whatever is 
  in the list.

Really? Why?

-- 
Robert Kern
[EMAIL PROTECTED]

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

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


Re: variable hell

2005-08-25 Thread Fredrik Lundh
Nx [EMAIL PROTECTED] wrote:

 I am unpacking a list into variables, for some reason they need to be
 unpacked into variable names like a0,a1,a2upto aN whatever is
 in the list.

why?

/F 



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


Re: variable hell

2005-08-25 Thread Sybren Stuvel
Nx enlightened us with:
 I am unpacking a list into variables, for some reason they need to
 be unpacked into variable names like a0,a1,a2upto aN whatever is
 in the list.

You're probably doing things the wrong way. What is your ultimate goal
with this? There is probably a better way of doing it.

In the mean time, look at eval().

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: variable hell

2005-08-25 Thread Peter Maas
Nx schrieb:
 Hi
 
  I am unpacking a list into variables, for some reason they need to be
  unpacked into variable names like a0,a1,a2upto aN whatever is 
  in the list.
 
  How to create the variables dynamically ?
 
  I am looking for something like 
  pseudo code line follows :
 
  a%s = str(value)

  suffix = 'var'
  vars()['a%s' % suffix] = 45
  avar
45

-- 
---
Peter Maas,  M+R Infosysteme,  D-52070 Aachen,  Tel +49-241-93878-0
E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64')
---
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: RE Despair - help required

2005-08-25 Thread Fredrik Lundh
Yoav wrote:
I am trying the following:

 re.search(r'\\[^\\]+(?=(?$))', c:\ret_files)

 and I get a return of NoneType, and I have no idea why. I know that I
 missing something here, but I really can't figure out why

instead of struggling with weird REs, why not use Python's standard
filename manipulation library instead?

http://docs.python.org/lib/module-os.path.html

/F 



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


variable hell

2005-08-25 Thread Nx

Hi

 I am unpacking a list into variables, for some reason they need to be
 unpacked into variable names like a0,a1,a2upto aN whatever is 
 in the list.

 How to create the variables dynamically ?

 I am looking for something like 
 pseudo code line follows :

 a%s = str(value)


 here below is a snippet from the mylist unpack code

 #next lines cut the end of line character from each line in the list
   mylist = [line[:-1] for line in mylist]
  
   for index,value in enumerate(mylist):
  if index == 0 :
a0 = str(value)
print a0 : ,a0
  elif index == 1 :
a1 = str(value)
print a1 : ,a1

   

Thanks
Nx

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


Re: RE Despair - help required

2005-08-25 Thread Yoav
Thanks guys. Issue solved.
I am also going to give Microsoft a call about it. Any other issues you 
want me to raise while I am talking to them?


Cheers.

Robert Kern wrote:
 Yoav wrote:
 
I am trying the following:

re.search(r'\\[^\\]+(?=(?$))', c:\ret_files)

and I get a return of NoneType, and I have no idea why. I know that I 
missing something here, but I really can't figure out why (I bet it's 
something obvious). I also tried this RE on KODOS and it works fine 
there, so I am really puzzled.

Any ideas?
 
 
 Look at the second string. It has \r in the middle of it where you
 really want \\r (or alternatively rc:\ret_files).
 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: RE Despair - help required

2005-08-25 Thread Yoav
Don't think it will do much good. I need to get them from  a file and 
extract the last folder in the path. For example:
if I get c:\dos\util
I want to extract the string \util



Fredrik Lundh wrote:
 Yoav wrote:
 
I am trying the following:

re.search(r'\\[^\\]+(?=(?$))', c:\ret_files)

and I get a return of NoneType, and I have no idea why. I know that I
missing something here, but I really can't figure out why
 
 
 instead of struggling with weird REs, why not use Python's standard
 filename manipulation library instead?
 
 http://docs.python.org/lib/module-os.path.html
 
 /F 
 
 
 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: overload builtin operator

2005-08-25 Thread Reinhold Birkenfeld
Shaun wrote:
 Hi,
 
 I'm trying to overload the divide operator in python for basic arithmetic.
 eg. 10/2 ... no classes involved.
 
 I am attempting to redefine operator.__div__ as follows:
 
  # my divide function
  def safediv(a,b):
  return ...
 
  # reassign buildin __div__
  import operator
  operator.__div__ = safediv
 
 The operator.__dict__ seems to be updated OK but the '/' operator still  
 calls buildin __div__

It won't work that way. You cannot globally modify the behaviour of an operator,
but you can customize how an operator works for your type.

Consider:

class safeint(int):
def __div__(self, other):
return safediv(self, other)

safeint(10)/2

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


Re: Doubt C and Python

2005-08-25 Thread Grant Edwards
On 2005-08-25, Ben Sizer [EMAIL PROTECTED] wrote:
 Grant Edwards wrote:
 On 2005-08-23, praba kar [EMAIL PROTECTED] wrote:
  What why it is more efficient.  Kindly let me
  know with some details.

 Have you read _any_ of the thread?  A number of people have
 already explained in detail why programming in Pything is more
 efficient.   Please read the responses you've already gotten.

 Grant,

 Going by the Google Groups timestamps that I see, there's a good chance
 that none of the other responses were visible to the OP when the above
 followup was posted.

You're probably right.  

Google groups may be The End of Usenet as We Know It.

-- 
Grant Edwards   grante Yow!  Are we on STRIKE yet?
  at   
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie question: Sub-interpreters for CAD program

2005-08-25 Thread Peter Hansen
Terry Hancock wrote:
 On Wednesday 24 August 2005 09:12 pm, Peter Hansen wrote:
Or even http://www.pythoncad.org/ which, although probably for 
mechanical CAD work (I haven't looked at it, don't really know), is 
surely a good place to get ideas of what Python can do in this area.
 
 No, I doubt it.  PythonCAD is a 2D mechanical CAD drawing system.
 I don't think it would be anywhere near what this guy wants.  They're
 just different applications. He's looking for an electronic CAD system or
 EDA, I'm pretty sure (or looking to write one, rather).

As an engineer who's worked extensively in both kinds of systems 
(primarily designing microcontroller-based circuit boards), and a 
programmer who's stolen useful ideas from endless amounts of other 
people's code, I'll say only that I disagree with your implication that 
looking at PythonCAD will give him no useful ideas whatsoever about how 
certain aspects of CAD programs could be handled.  PCB layout programs 
do, after all, have to do the basic work of displaying circuits (which 
as you know are generally shown as 2D drawings).

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


Re: RE Despair - help required

2005-08-25 Thread rafi
Yoav wrote:
 Don't think it will do much good. I need to get them from  a file and 
 extract the last folder in the path. For example:
 if I get c:\dos\util
 I want to extract the string \util

like frederik says (I use '/' as I am using Unix):

  import os
  os.path.split ('c:/foo/bar')
('c:/foo', 'bar')
  os.path.splitext ('c:/foo/bar')
('c:/foo/bar', '')
  os.path.splitext ('c:/foo/bar.txt')
('c:/foo/bar', '.txt')

or if you are really reluctant:

  'c:\\foo\\bar'.split ('\\')
['c:', 'foo', 'bar']
  'c:\\foo\\bar'.split ('\\') [-1]
'bar'


 Fredrik Lundh wrote:

 instead of struggling with weird REs, why not use Python's standard
 filename manipulation library instead?

 http://docs.python.org/lib/module-os.path.html

 /F




-- 
rafi

Imagination is more important than knowledge.
(Albert Einstein)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: RE Despair - help required

2005-08-25 Thread Reinhold Birkenfeld
Yoav wrote:
 Don't think it will do much good. I need to get them from  a file and 
 extract the last folder in the path. For example:
 if I get c:\dos\util
 I want to extract the string \util

Then os.path.basename should be for you.

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


RE: RE Despair - help required

2005-08-25 Thread Marc Boeren

Hi, 

 Don't think it will do much good. I need to get them from  a file and 
 extract the last folder in the path. For example:
 if I get c:\dos\util
 I want to extract the string \util

Still, os.path is your friend:

 import os
 filepath = r'C:\dos\util'
 base, last = os.path.split(filepath)
 print base # 'C:\dos'
 print last # 'util'
 print os.sep+last # '\util'

Don't forget to read 

  http://docs.python.org/lib/module-os.path.html

for some more info!

Regards, Mc!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: loop in python

2005-08-25 Thread Peter Hansen
Sybren Stuvel wrote:
 James enlightened us with:
 
One does not compare speed when they use Perl/Python/Ruby/Tcl. They
are all more or less in the same performance ball park.
 
 
 I don't want to offend you or anything, but doesn't the second
 sentence mean that someone DID do a speed comparison?

Yes, and has shown that they are in the same ballpark, and therefore one 
does not _need_ to compare speed any more.  At least, that's how I read 
what James posted.

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


Re: variable hell

2005-08-25 Thread Benji York
Peter Maas wrote:
   suffix = 'var'
   vars()['a%s' % suffix] = 45
   avar
 45

Quoting from http://docs.python.org/lib/built-in-funcs.html#l2h-76 about 
the vars built in:

The returned dictionary should not be modified: the effects on the 
corresponding symbol table are undefined.
--
Benji York

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


Re: RE Despair - help required

2005-08-25 Thread Robert Kern
Yoav wrote:
 Don't think it will do much good. I need to get them from  a file and 
 extract the last folder in the path. For example:
 if I get c:\dos\util
 I want to extract the string \util

You mean like this:

import os
os.path.sep + os.path.split(rc:\dos\util)[-1]

-- 
Robert Kern
[EMAIL PROTECTED]

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

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


New Arrival to Python

2005-08-25 Thread Norm Goertzen
Hi Everyone,

I'm totally captivated by Python so far.  I want to develop 
professional-looking Win32 applications with the least effort.

I have many years experience with PowerBuilder, PowerBuilder Foundation 
Class, and SQL Anywhere.  I would really like to leverage as many of 
these skills as possible.

Recently I've been learning C#.NET but am concerned with the anticipated 
longer development times.

If it matters, the IDE I choose should also allow for simpler web 
development.

thanks in advance, Norm


QUESTIONS:

1. What IDE should I use?

2. If Wing IDE is really good, which version Professional or Personal?

3. Can Sybase's SQL Anywhere Studio be fully integrated with Python?

4. How about versions that integrate with MicroSoft's Visual Studio. 
Are they generally considered a smart idea?

5. How does Python compare to PowerBuilder's DATAWINDOW technology?

6. What books are worthwhile?

My O'Reilly's Safari network has these books:

-Core Python Programming; Wesley J. Chun
-Python Developer's Handbook; André Dos Santos  Lessa
-Python Essential Reference, Second Edition; David M Beazley
-Perl To Python Migration; Martin C. Brown
-Programming Python, 2nd Edition; Mark Lutz
-Python Standard Library; Fredrik Lundh
-Python  XML; Fred L. Drake, Jr., Christopher A. Jones
-Python Cookbook; Alex Martelli, David Ascher
-Python Pocket Reference, 2nd Edition; Mark Lutz
-Learning Python; David Ascher, Mark Lutz
-Python Pocket Reference; Mark Lutz
-Python Programming on Win32; Mark Hammond, Andy Robinson
-Python: Visual QuickStart Guide; Chris Fehily
-Python Programming with the Java™ Class Libraries: A Tutorial for 
Building Web and Enterprise Applications with Jython; Richard Hightower
-Python in a Nutshell; Alex Martelli
-Text Processing in Python; David Mertz
-Learning Python, 2nd Edition; David Ascher, Mark Lutz
-Game Programming with Python, Lua, and Ruby; Tom Gutschmidt
-Python Programming for the absolute beginner; MICHAEL DAWSON
-Python Cookbook, 2nd Edition; David Ascher, Alex Martelli, Anna Ravenscroft
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Jargons of Info Tech industry

2005-08-25 Thread Denis Kasak
CBFalconer wrote:
 Mike Schilling wrote:
 Mike Meyer [EMAIL PROTECTED] wrote in message
 Mike Schilling [EMAIL PROTECTED] writes:
 l v [EMAIL PROTECTED] wrote in message
 Xah Lee wrote:

 (circa 1996), and email should be text only (anti-MIME, circa 1995),

 I think e-mail should be text only.  I have both my email and
 news readers set to display in plain text only.  It prevents
 the marketeers and spammers from obtaining feedback that my
 email address is valid.  A surprising amount of information
 can be obtained from your computer by allowing HTML and all
 of it's baggage when executing on your computer. Phishing
 comes to my mind first and it works because people click the
 link without looking to see where the link really takes them.

 A formatting-only subset of HTML would be useful for both e-mail
 and Usenet posts.

 Used to be people who wanted to send formatted text via email
 would use rich text. It never really caught on. But given that
 most of the people sending around formatted text are using
 point-n-click GUIs to create the stuff, the main advantage of
 HTML - that it's easy to write by hand - isn't needed.
 
 But the other advantage, that it's an existing and popular
 standard, remains.
 
 However, for both e-mail and news, it is totally useless.  It also
 interferes with the use of AsciiArt, while opening the recipient to
 the dangers above.

And HTML has the tendency to make e-mail and Usenet posts unnecessarily 
bigger, which will continue to be a bugger until broadband links become 
common enough.

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


Re: Fighting Spam with Python

2005-08-25 Thread Larry Bates
Before you do too much work you should probably check out:

http://spambayes.sourceforge.net/

There has already been a lot of work done on this project.

FYI, Larry

David MacQuigg wrote:
 Are you as mad about spam as I am?  Are you frustrated with the
 pessimism and lack of progress these last two years?  Do you have
 faith that an open-source project can do better than the big companies
 competing for a lock-in solution?  If so, you might be interested in
 the Open-Mail project.
 
 I'm writing some scripts to check incoming mail against a registry of
 reputable senders, using the new authentication methods.  Python is
 ideal for this because it will give mail-system admins the ability to
 experiment with the different methods, and provide some real-world
 feedback sorely needed by the advocates of each method.  So far, we
 have SPF and CSV.  See http://purl.net/macquigg/email/python for the
 latest project status.
 
 I welcome anyone who is interested in helping, expecially if you have
 some experience with mail transfer programs, like Sendmail or Postfix,
 or spam filtering programs, like SpamAssassin.  My Python may not be
 the best, so I welcome suggestions there also.  We need to make these
 scripts a model of clarity.
 
 --
 Dave
 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Limited XML tidy

2005-08-25 Thread Magnus Lie Hetland
In article [EMAIL PROTECTED], Toby White wrote:

[snip]

I do similar stuff in the new (upcoming) version of Atox
(atox.sf.net), which works with potentially ill-formed, partial XML
(in the form of PYX events) internally, and can take partial,
ill-formed XML as input.

The problem is that when the sax handler raises an exception,
I can't see how to find out why. What I want to do is for
DodgyErrorHandler to do something different depending on 
where we are in the course of parsing. Is there anyway
to get that information back from xml.sax (or indeed from
any other sax handler?)

What I ended up doing was using an SGML parser (sgmlop) instead. It's
highly forgiving (even of illegal entities and the like) but gives me
the information I need. Might be worth a look in your app too?

Toby

-- 
Magnus Lie Hetland
http://hetland.org
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: variable hell

2005-08-25 Thread Nx
Thanks for the many replies

 here is an example for what it will be used for , in this case
 fixed at 31 fieldvalues:

 
inputvalues=(s0,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15,s16,s17,s18,s19,s20,s21,s22,s23,s24,s25,
s26,s27,s28,s29,s30,s31)
   MYINSERTSELECT = INSERT INTO
ADDRESS(ALIAS,COMPANY,ADDRESSLI1,ADDRESSLI2,ADDRESSCO,TOWN,ZIP,COUNTRY,TEL1,TEL2,FAX,EMAIL,INTERNET,PERSON1,TITLE1,RES1,PERSON2,TITLE2,RES2,PERSON3,TITLE3,RES3,PERSON4,TITLE4,RES4,PERSON5,TITLE5,RES5,PRODALIAS,PAGER,TLX,ADDMEMO)
   VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
   
   con1.commit() 
   cur = con1.cursor()
   try :
cur.execute(MYINSERTSELECT,inputvalues)
con1.commit()
print 'Inserted 1 record'
   except IOError, (errno, strerror):
 print I/O error(%s): %s % (errno, strerror)
   except ValueError:
 print Could not convert data to an integer.
   except:
print Unexpected error:, sys.exc_info()[0]
raise


I am sure there is an easier way, but I have not found it yet.

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


Re: Fighting Spam with Python

2005-08-25 Thread Peter Hansen
David MacQuigg wrote:
 Are you as mad about spam as I am?  Are you frustrated with the
 pessimism and lack of progress these last two years?  Do you have
 faith that an open-source project can do better than the big companies
 competing for a lock-in solution?  If so, you might be interested in
 the Open-Mail project.
 
 I'm writing some scripts to check incoming mail against a registry of
 reputable senders, using the new authentication methods.  Python is
 ideal for this because it will give mail-system admins the ability to
 experiment with the different methods, and provide some real-world
 feedback sorely needed by the advocates of each method.  So far, we
 have SPF and CSV.  See http://purl.net/macquigg/email/python for the
 latest project status.

You might find www.spambayes.org of interest, in several ways.

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


Re: variable hell

2005-08-25 Thread bruno modulix
Nx wrote:
 Thanks for the many replies
 
  here is an example for what it will be used for , in this case
  fixed at 31 fieldvalues:
 
  
 inputvalues=(s0,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15,s16,s17,s18,s19,s20,s21,s22,s23,s24,s25,
 s26,s27,s28,s29,s30,s31)
MYINSERTSELECT = INSERT INTO
 ADDRESS(ALIAS,COMPANY,ADDRESSLI1,ADDRESSLI2,ADDRESSCO,TOWN,ZIP,COUNTRY,TEL1,TEL2,FAX,EMAIL,INTERNET,PERSON1,TITLE1,RES1,PERSON2,TITLE2,RES2,PERSON3,TITLE3,RES3,PERSON4,TITLE4,RES4,PERSON5,TITLE5,RES5,PRODALIAS,PAGER,TLX,ADDMEMO)
VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)

con1.commit() 
cur = con1.cursor()
try :
 cur.execute(MYINSERTSELECT,inputvalues)

If I refer to your original post, there's someting I dont understand:

I am unpacking a list into variables, for some reason they need to be
 unpacked into variable names like a0,a1,a2upto aN whatever is
 in the list.


Why unpack inputvalues if your next step is to pack'em back again ? Or
what did I miss ?


-- 
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: variable hell

2005-08-25 Thread Carsten Haese
On Thu, 2005-08-25 at 10:43, Nx wrote:
 Thanks for the many replies
 
  here is an example for what it will be used for , in this case
  fixed at 31 fieldvalues:
 
  
 inputvalues=(s0,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15,s16,s17,s18,s19,s20,s21,s22,s23,s24,s25,
 s26,s27,s28,s29,s30,s31)

inputvalues = tuple(mylist)

Hope this helps,

Carsten.


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


Re: variable hell

2005-08-25 Thread Adriaan Renting
You might be able to do something along the lines of

for count in range(0,maxcount):
  value = values[count]
  exec(eval('a%s=%s' % (count, value)))
 
But I am also wonder: why? 

Peter Maas wrote: 
 suffix = 'var' 
 vars()['a%s' % suffix] = 45 
 avar 
45 
 

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


Re: New Arrival to Python

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

I can just answer about books:

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

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

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

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

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

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

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

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

HTH

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


Re: variable hell

2005-08-25 Thread Carsten Haese
On Thu, 2005-08-25 at 11:04, I hastily wrote:
 On Thu, 2005-08-25 at 10:43, Nx wrote:
  Thanks for the many replies
  
   here is an example for what it will be used for , in this case
   fixed at 31 fieldvalues:
  
   
  inputvalues=(s0,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15,s16,s17,s18,s19,s20,s21,s22,s23,s24,s25,
  s26,s27,s28,s29,s30,s31)
 
 inputvalues = tuple(mylist)

And actually, you probably don't have to do that, because the execute
method should be able to handle a list just as well as a tuple.

-Carsten.


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


Re: RE Despair - help required

2005-08-25 Thread Sion Arrowsmith
In article [EMAIL PROTECTED], Yoav  [EMAIL PROTECTED] wrote:
Fredrik Lundh wrote:
 Yoav wrote:
I am trying the following:

re.search(r'\\[^\\]+(?=(?$))', c:\ret_files)
 instead of struggling with weird REs, why not use Python's standard
 filename manipulation library instead?
 
 http://docs.python.org/lib/module-os.path.html
Don't think it will do much good. I need to get them from  a file and 
extract the last folder in the path. For example:
if I get c:\dos\util
I want to extract the string \util

Did you actually look at the docs Fredrik pointed you at? Did you,
in particular, notice os.path.basename, which does (almost) exactly
what you want?

-- 
\S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/
  ___  |  Frankly I have no feelings towards penguins one way or the other
  \X/  |-- Arthur C. Clarke
   her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: variable hell

2005-08-25 Thread Nx

 
 
 Why unpack inputvalues if your next step is to pack'em back again ? Or
 what did I miss ?
 
The original values in this case are being read from a text file
with one value including a linefeed per line and the original idea was,
that having them read into a list was the best way to massage them into the
form required to be used as input values for the insert statement. 



Nx

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


Re: RE Despair - help required

2005-08-25 Thread Yoav
Thank you all guys. It seems like the simpler the solution, the more I 
am happy about it. Sorry, for the simple question, I am quite new to 
this lang.

Cheers.

Robert Kern wrote:
 Yoav wrote:
 
Don't think it will do much good. I need to get them from  a file and 
extract the last folder in the path. For example:
if I get c:\dos\util
I want to extract the string \util
 
 
 You mean like this:
 
 import os
 os.path.sep + os.path.split(rc:\dos\util)[-1]
 
-- 
http://mail.python.org/mailman/listinfo/python-list


prevent callback during initialization

2005-08-25 Thread William Gill
I am creating several tkinter widgets.  In my classes they each have a
change() method that is a callback to various IntVar, and StringVar
objects.  Everything works fine, but don't really want to trigger the
callback  when I am initializing each widget/control variable.  I can
use a flag like self.initialized= true, and wrap the change() procedures
in an if self.initialized: block.  I get the impression using flags is
not the preferred approach.  Is there some other way to accomplish
this without using a flag?

Can I redefine my change() method in __init__(), or would that mess up
the callback references already established?

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


Re: variable hell

2005-08-25 Thread [EMAIL PROTECTED]
Hey, if the man wants to write it that way, let the man write it that
way. If it works for him, great... he's sure confused the heck out of
all of us, and that translates into job security for him! As you can
see, the name of the post is 'variable hell' and that is exactly what
he is creating, so Adriaan Renting, excellent response!

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


Socket Support When Compiling Python 2.3.5 On Cygwin

2005-08-25 Thread tom
I compiled Python 2.3.5 from source on my Cygwin machine (XP), and I got
the following error when I tried to initialize Zope:

Traceback (most recent call last):
  File /opt/Zope-2.7.7/lib/python/ZEO/runzeo.py, line 42, in ?
import socket
  File /opt/Python23//lib/python2.3/socket.py, line 44, in ?
import _socket
ImportError: No module named _socket

Apparently, Zope depends on the
$PY23_HOME/lib/python2.3/lib-dynload/_socket.dll, and this file doesn't
exist on my system.  What do I need to do to make sure that this file will
be created with I compile Python 2.3.5?

The really weird thing about this is that I also compiled Python 2.4 on
this system, and the socket files were created.  What's different about
2.3.5?

Thanks in advance!

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


Re: loop in python

2005-08-25 Thread Sybren Stuvel
Peter Hansen enlightened us with:
 Yes, and has shown that they are in the same ballpark, and therefore
 one does not _need_ to compare speed any more.

Ok. I'd worded it as there have been tests already, so there is no
need to do your own, instead of one does not test.

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: Jargons of Info Tech industry

2005-08-25 Thread Mike Schilling

CBFalconer [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Mike Schilling wrote:
 Mike Meyer [EMAIL PROTECTED] wrote in message
 Mike Schilling [EMAIL PROTECTED] writes:
 l v [EMAIL PROTECTED] wrote in message
 Xah Lee wrote:

 (circa 1996), and email should be text only (anti-MIME, circa 1995),

 I think e-mail should be text only.  I have both my email and
 news readers set to display in plain text only.  It prevents
 the marketeers and spammers from obtaining feedback that my
 email address is valid.  A surprising amount of information
 can be obtained from your computer by allowing HTML and all
 of it's baggage when executing on your computer. Phishing
 comes to my mind first and it works because people click the
 link without looking to see where the link really takes them.

 A formatting-only subset of HTML would be useful for both e-mail
 and Usenet posts.

 Used to be people who wanted to send formatted text via email
 would use rich text. It never really caught on. But given that
 most of the people sending around formatted text are using
 point-n-click GUIs to create the stuff, the main advantage of
 HTML - that it's easy to write by hand - isn't needed.

 But the other advantage, that it's an existing and popular
 standard, remains.

 However, for both e-mail and news, it is totally useless.

Useless except in that it can describe formatting, which is what it would be 
used for?  (

 It also
 interferes with the use of AsciiArt,

Except that it can specify the use of a fixed-width font, which makes Ascii 
Art work.  It can also distinguish between text that can be reformatted for 
flow and text than can not.

So I think you meant to say that it *enables* Ascii Art.

 while opening the recipient to
 the dangers above.

Which is why a formatting-only subset, which doesn't cause any such dangers, 
is required.  As I said above.

Another advantage is that evewry internet-enabled computer today already 
comes with an HTML renderer (AKA browser), so that a message saved to a file 
can be read very easily. 


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


Experience regarding Python tutorials?

2005-08-25 Thread Shoeshine


Cheers everyone, I aim to learn a programming language and haven't yet
decided on what's going to be. Here I'd like to hear some voices on where I
should start, and pls don't hit me google. I have been doing some research,
but I'd like to hear about some real life expiriencies on subject.
Is Python maybe a to small target for newcomers? Make it compared to Perl...

TIA



--- 
-Linux-

-Becouse PC is a terible thing to waste...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: a question about tkinter StringVars()

2005-08-25 Thread William Gill


Eric Brunel wrote:
 On Wed, 24 Aug 2005 15:07:27 GMT, William Gill [EMAIL PROTECTED] wrote:
 
 Working with tkinter, I have a createWidgets() method in a class.
 Within createWidgets() I create several StringVars() and
 assign them to the textvariable option of several widgets.
 Effectively my code structure is:

 def createWidgets(self):
  ...
  var = StringVar()
  Entry(master,textvariable=var)
  ...
  ...

 Though 'var' would normally go out of scope when createWidgets
 completes, since the Entry and its reference do not go out of scope,
 only the name 'var' goes out of scope, not the StringVar object, Right?
 
 
 Well, apparently not:
 
 
 from Tkinter import *
 
 class MyStringVar(StringVar):
   def __del__(self):
 print I'm dying!
 
 root = Tk()
 
 def cw():
   var = MyStringVar()
   Entry(root, textvariable=var).pack()
 
 cw()
 
 root.mainloop()
 
 
 Running this script actually prints I'm dying!, so there is obviously 
 no reference from the Entry widget to the variable object. The reference 
 is actually kept at tcl level between an entry and the *tcl* variable, 
 which knows nothing about the *Python* variable.
 
 BTW, the whole purpose of StringVar's is to be kept so that the text for 
 the entry can be retrieved or modified by another part of the program. 
 So what can be the purpose of creating variables in a function or method 
 and not keeping them anywhere else than a local variable?

I posted that changing back to a non-local variable works now, and that 
my problem was probably name conflict.  I haven't been able to verify 
that, but I have to assume that was the original problem.

My band-aid may have 'worked' because tcl maintained the control 
variable and callback even though the Python variable was gone.

As far as ... the purpose of creating variables ... and not keeping 
them anywhere else  I actually was keeping them in a non-local 
list.  I was creating a local variable, appending it to the list, then 
reusing the local name for the next new control variable:
...
   var= IntVar()
   self.variables.append(var)
...
This was 'copied' from a snippet I was using as a template.

I now use:
...
   self.variables.append(IntVar())
...

Please let me know if I'm on thin ice here.

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


Re: Fighting Spam with Python

2005-08-25 Thread David MacQuigg
On Thu, 25 Aug 2005 10:18:37 -0400, Peter Hansen [EMAIL PROTECTED]
wrote:

David MacQuigg wrote:
 Are you as mad about spam as I am?  Are you frustrated with the
 pessimism and lack of progress these last two years?  Do you have
 faith that an open-source project can do better than the big companies
 competing for a lock-in solution?  If so, you might be interested in
 the Open-Mail project.
 
 I'm writing some scripts to check incoming mail against a registry of
 reputable senders, using the new authentication methods.  Python is
 ideal for this because it will give mail-system admins the ability to
 experiment with the different methods, and provide some real-world
 feedback sorely needed by the advocates of each method.  So far, we
 have SPF and CSV.  See http://purl.net/macquigg/email/python for the
 latest project status.

You might find www.spambayes.org of interest, in several ways.

Integration of a good spam filter is one of our top priorities.
Spambayes looks like a good candidate.  The key new features needed in
a spam filter are the ability to extract the sender's identity (not
that of the latest forwarder), and to factor into the spam score the
reputation of that identity.  We could use some help on this
integration.

I guess I should have said a little more about the Open-Mail project.
We are not focused on developing new authentication or filtering
methods, but rather, providing a platform that will bring these pieces
together and allow the mail admin to chose which methods are used and
in what order.  Interoperability has been the main barrier to
widescale use of authentication.  Python is superb at gluing these
pieces together.

In the flow we envision, the spam filter is the final process, used
only on the 5% that is hard to classify.  80% will get an immediate
reject.  15% will get an immediate accept without filtering, because
the sender is authenticated and has a good reputation.  Eventually,
all reputable senders will join the 15%, and the 5% will shrink to
where we can ignore it.

--
Dave


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


Re: Experience regarding Python tutorials?

2005-08-25 Thread Peter Beattie
Shoeshine wrote on 25/08/2005 17:43:
 Cheers everyone, I aim to learn a programming language and haven't yet 
 decided on what's going to be. Here I'd like to hear some voices on
 where I should start, and pls don't hit me google. I have been doing
 some research, but I'd like to hear about some real life expiriencies on
 subject. Is Python maybe a to small target for newcomers? Make it
 compared to Perl...

Try [http://www.python.org/doc/Intros.html]. There are lots of
different-level introductions and tutorials available that should give you
an idea of what to expect of Python.

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


Re: variable hell

2005-08-25 Thread rafi
Adriaan Renting wrote:
 You might be able to do something along the lines of
 
 for count in range(0,maxcount):
   value = values[count]
   exec(eval('a%s=%s' % (count, value)))

why using the eval?

exec ('a%s=%s' % (count, value))

should be fine

-- 
rafi

Imagination is more important than knowledge.
(Albert Einstein)
-- 
http://mail.python.org/mailman/listinfo/python-list


Filetypes in email attachments.

2005-08-25 Thread justin . vanwinkle
Hello everyone,

I'm writing a simple spam filter as a project, partly to learn python.
I want to filter by filetype, however, the mime content type I get
using .get_content_type gives limited and possibly bogus information,
especially when trying to detect viruses or spam.

I would like to use the magic file to detect the filetype, if this is
possible.  I have the attachement stored and (generally) decoded in a
variable.

Justin

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


Re: Experience regarding Python tutorials?

2005-08-25 Thread SamFeltus
Python is a very good place to start.

However,Perl isn't a bad place to start either.  Perl has a gazillion
ways to express yourself.  Perl is overly complicated (yet easy to get
started with), so you are exposed to numerous ways to think.  Perl
gives you 8 million different sized and colored ropes to hang yourself
with (google TMTOWTDI), so Perl will teach you to BE CAREFUL.  The
O'Reilly Perl books are excellent.

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


Re: variable hell

2005-08-25 Thread Ron Garret
In article [EMAIL PROTECTED],
 Benji York [EMAIL PROTECTED] wrote:

 Peter Maas wrote:
suffix = 'var'
vars()['a%s' % suffix] = 45
avar
  45
 
 Quoting from http://docs.python.org/lib/built-in-funcs.html#l2h-76 about 
 the vars built in:
 
 The returned dictionary should not be modified: the effects on the 
 corresponding symbol table are undefined.

If you really want to make something like this work you can define a 
class that would work like this:

vars = funkyclass()
varname = 'x'
vars[varname] = value
vars.x

But this is clearly a design mistake.  Either you know the names of the 
variables when you write the code or you do not.  If you know them you 
can simply assign them directly.  If you do not know them then you can't 
put them in the code to read their values anyway, and what you need is 
just a regular dictionary.

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


Re: Protected message

2005-08-25 Thread webmaster
Your file is attached.-- 
http://mail.python.org/mailman/listinfo/python-list

Re: variable hell

2005-08-25 Thread Robert Kern
Ron Garret wrote:

 If you really want to make something like this work you can define a 
 class that would work like this:
 
 vars = funkyclass()
 varname = 'x'
 vars[varname] = value
 vars.x
 
 But this is clearly a design mistake.  Either you know the names of the 
 variables when you write the code or you do not.  If you know them you 
 can simply assign them directly.  If you do not know them then you can't 
 put them in the code to read their values anyway, and what you need is 
 just a regular dictionary.

In fact, I do this all of the time.

  class Bunch(dict):
def __init__(self, *args, **kwds):
  dict.__init__(self, *args, **kwds)
  self.__dict__ = self

It's a lifesaver when you're working at the interactive prompt. In the
bowels of my modules, I may not know what the contents are at code-time,
but at the prompt I probably do. Bunch assists both usages.

-- 
Robert Kern
[EMAIL PROTECTED]

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

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


Just a thank... (ignore)

2005-08-25 Thread Shoeshine
Thanx for sharing... -it was of use.




--- 
-Linux-

-Becouse PC is a terible thing to waste...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Jargons of Info Tech industry

2005-08-25 Thread Rich Teer
On Thu, 25 Aug 2005, Mike Schilling wrote:

 Another advantage is that evewry internet-enabled computer today already
 comes with an HTML renderer (AKA browser), so that a message saved to a file
 can be read very easily.

I think you're missing the point: email and Usenet are, historically have
been, and should always be, plain text mediums.  If I wanted to look at
prettily formatted HTML, I'd use a web browser to look at the web.

-- 
Rich Teer, SCNA, SCSA, OpenSolaris CAB member

President,
Rite Online Inc.

Voice: +1 (250) 979-1638
URL: http://www.rite-group.com/rich
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   3   >