Re: Python To Send Emails Via Outlook Express

2004-12-19 Thread ian
Hi Keith Thanks for your reply. I am aware of the smtplib module and it works very well! (refer script below) The problem is that I have a developed a freeware application called Kirby Alarm And Task Scheduler (see www.kirbyfooty.com). The program can pop up a note, run a program, play a sound, o

Re: Python To Send Emails Via Outlook Express

2004-12-19 Thread Fredrik Lundh
<[EMAIL PROTECTED]> wrote: > But all I want to do is use Python to instruct Outlook Express to send > an email. and you succeeded -- the error message you saw came from the mail server, not outlook itself. your problem is that the server didn't like the mail you sent; checking the server config

Re: Easy "here documents" ??

2004-12-19 Thread Keith Dart
Fredrik Lundh wrote: Jim Hill wrote: I'm trying to write a script that writes a script for a rather specialized task. I know that seems weird, but the original version was written in Korn shell and most of my team are familiar with the way it does things even though they don't read Korn. so why

Re: how to pass globals across modules (wxPython)

2004-12-19 Thread Fredrik Lundh
Martin Drautzburg wrote: > My wxPython program starts execution in mainFrame.py like this >[...] >class MainApp(wxApp): >def OnInit(self): >self.mainFrame = MainFrame(None) >self.mainFrame.Show() >

Re: Python To Send Emails Via Outlook Express

2004-12-19 Thread Max M
[EMAIL PROTECTED] wrote: Thanks Fredrik, That was my first impression too. But all I want to do is use Python to instruct Outlook Express to send an email. Which you did! From the look of the traceback. But your mailserver is configured in such a way that you cannot send mail from your machine us

Re: accessing module global vars by name

2004-12-19 Thread Steven Bethard
Martin Drautzburg wrote: IOW how can I write something like # xxx.py for varName in ("foo", "bar"): magic.varName = 1 I think you want to use the dict returned by globals(). Modifying this dict can add/remove names from the global scope.[1] >>> foo Traceback (most recent call last): Fi

Re: Python To Send Emails Via Outlook Express

2004-12-19 Thread Keith Dart
[EMAIL PROTECTED] wrote: Hi Ganesan I tried changing s.Send to s.Send(). It now comes up with an exception error.. The details are below. Looks like the COM part works, but sending mail has an error from the SMTP host. But, slightly off topic, FYI, Python can send email directly with the email an

Re: Easy "here documents" ??

2004-12-19 Thread Fredrik Lundh
Jim Hill wrote: > I'm trying to write a script that writes a script for a rather specialized > task. I know that seems weird, but the original version was written in > Korn shell and most of my team are familiar with the way it does things > even though they don't read Korn. so why didn't you te

Re: atmosphere on c.l.py (WAS: How about "pure virtual methods"?)

2004-12-19 Thread Steven Bethard
Doug Holton wrote: He was only acknowledging the problem to those 3 people who complained about it. I was making the point that others do not like being trolled either. Ahh, gotcha. Read your comment with the right intonation this time. =) Steve -- http://mail.python.org/mailman/listinfo/python

Re: Python To Send Emails Via Outlook Express

2004-12-19 Thread ian
Thanks Fredrik, That was my first impression too. But all I want to do is use Python to instruct Outlook Express to send an email. That way the user would not have to do any setting up etc of the mail server properties etc and Outlook Express will magage all the connection side of things. I have

accessing module global vars by name

2004-12-19 Thread Martin Drautzburg
Withing a module I can assign a value to a global var by assigning to it in the outermost scope. Fine. But how can I do this if the attribute name itself is kept in a variable. Once the module is loaded I can access the module's namespace no problem, but inside the module the dictionary is not yet

Re: Writev

2004-12-19 Thread Steven Bethard
Adam DePrince wrote: file.writelines( seq ) and map( file.write, seq ) are the same; the former is syntactic sugar for the later. Well, that's not exactly true. For one thing, map(file.write, seq) returns a list of Nones, while file.writelines returns only the single None that Python functions w

how to pass globals across modules (wxPython)

2004-12-19 Thread Martin Drautzburg
My wxPython program starts execution in mainFrame.py like this [...] class MainApp(wxApp): def OnInit(self): self.mainFrame = MainFrame(None) self.mainFrame.Show() self.SetTopWindow(self.mainFram

Re: Python To Send Emails Via Outlook Express

2004-12-19 Thread Fredrik Lundh
<[EMAIL PROTECTED]> wrote: > I tried changing s.Send to s.Send(). It now comes up with an exception > error.. > com_error: (-2147352567, 'Exception occurred.', (0, None, 'The server > rejected one or more recipient addresses. The server response was: 554 > <[EMAIL PROTECTED]>: Relay access denied

Re: Is this a good use for lambda

2004-12-19 Thread Fredrik Lundh
Bengt Richter wrote: >>Ahem. If you name the function, you can reuse the name (or just forget about >>it) >>as soon as you've used the function object. >> >>If you don't want to reuse the name because you might want to reuse the >>function >>object, you have to name it anyway. >> > Are you forg

Re: Easy "here documents" ??

2004-12-19 Thread Fredrik Lundh
Jim Hill wrote: >>And if you prefer not to type so much: >> >>def I(*args): return "".join(map(str, args)) >>def F(v, fmt): return ("%" + fmt) % v > > Not that I don't appreciate the suggestions from masters of the Python > universe, but the reason I'm switching to Python from Perl is for the > re

Re: No acceptable C compiler was found in $PATH

2004-12-19 Thread Fredrik Lundh
"banaticus" <[EMAIL PROTECTED]> wrote: > What does this error message mean? What can I do to fix it? it usually means what it says... (read on) > Here'e the command that I just tried running, and the messages that > I received. I just barely unpacked python. > > linux:/Python-2.4 # ./configure

Re: atmosphere on c.l.py (WAS: How about "pure virtual methods"?)

2004-12-19 Thread Doug Holton
Steven Bethard wrote: Doug Holton wrote: Fredrik Lundh wrote: well, since I'm not in the ego-stroking business, what if I promise never to reply to posts by you, robert, and alex? That's not fair to the rest of us though :) That's not even fair to the non-rest of us. =) As I noted, "his answers

Re: Writev

2004-12-19 Thread Adam DePrince
On Mon, 2004-12-20 at 00:30, Steven Bethard wrote: > Adam DePrince wrote: > > Many other programmers have faced a similar issue; cStringIO, > > ''.join([mydata]), map( file.write, [mydata]) are but some attempts at > > making this process more efficient by jamming the components to be > > written i

Re: Easy "here documents" ??

2004-12-19 Thread Jim Hill
John Roth wrote: [Here docs] >I'm not sure why you'd want to do this, though. >It seems like it would be mostly useful in a style >of programming that's quite foreign to the way >Python wants to be programmed. I'm going to try some of the suggestions that others have floated but I think you've re

Re: Easy "here documents" ??

2004-12-19 Thread Jim Hill
Keith Dart wrote: >Jim Hill wrote: >> Is there a way to produce a very long multiline string of output with >> variables' values inserted without having to resort to this wacky > >I was thinking about this. But I can't think of any reason why you would >want to do this in Python. What's wrong wit

Re: Easy "here documents" ??

2004-12-19 Thread Jim Hill
Fredrik Lundh wrote: >Scott David Daniels wrote: > >> And if you enjoy building insecure stuff, try: >> >> def fix(text, globals_=None, locals=None, quote='"'): >> d = (globals_ or locals or globals()).copy() >> source = text.split(quote) >> source[1::2] = (str(eval(expr

Re: Easy "here documents" ??

2004-12-19 Thread Jim Hill
Nick Craig-Wood wrote: >Jim Hill <[EMAIL PROTECTED]> wrote: >> Is there a way to produce a very long multiline string of output with >> variables' values inserted without having to resort to this wacky >> """v = %s"""%(variable) >I prefer this > > ... I'll have %(amount)s %(what)s > ... f

Re: Python To Send Emails Via Outlook Express

2004-12-19 Thread ian
Hi Ganesan I tried changing s.Send to s.Send(). It now comes up with an exception error.. The details are below. Ian Traceback (most recent call last): File "C:\Python23\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 307, in RunScript debugger.run(codeObject, __main__.__dict__

another layer for a DBMS?

2004-12-19 Thread [EMAIL PROTECTED]
I call it "DBITM" or database internal text messaging. For a free writing of this, send email to: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Writev

2004-12-19 Thread Adam DePrince
On Sun, 2004-12-19 at 23:43, Jp Calderone wrote: > On Sun, 19 Dec 2004 23:12:27 -0500, Adam DePrince <[EMAIL PROTECTED]> wrote: > > [snip] [snip] to free the memory, of course. > > The support of iterators is a cool idea, but I'm not sure > it is actually useful. Consider the case where not

Re: dot products

2004-12-19 Thread Bengt Richter
On 19 Dec 2004 03:04:15 -0800, "Rahul" <[EMAIL PROTECTED]> wrote: >HI. >I want to compute dot product of two vectors stored as lists a and b.a >and b are of the same length. > >one simple way is >sum(a[i]*b[i] for i in range(len(a))) > >another simple way is >ans=0.0 >for i in range(len(a)): >ans=

Re: Python To Send Emails Via Outlook Express

2004-12-19 Thread Ganesan R
> "ian" == ian <[EMAIL PROTECTED]> writes: > import win32com.client > s = win32com.client.Dispatch('CDO.Message') > s.From = "[EMAIL PROTECTED]" > s.To = "[EMAIL PROTECTED]" > s.Subject = "The subject" > s.Send > ... but nothing happens. > What am I doing wrong? Does anyone have some sampl

Re: Writev

2004-12-19 Thread Steven Bethard
Adam DePrince wrote: Many other programmers have faced a similar issue; cStringIO, ''.join([mydata]), map( file.write, [mydata]) are but some attempts at making this process more efficient by jamming the components to be written into a sequence. I'm obviously misunderstanding something because I ca

Python To Send Emails Via Outlook Express

2004-12-19 Thread ian
Hi, I'm a newbie (oh no I can here you say another one...) How can I get Python to send emails using the default windows email client (eg outlook express)? I thought I could just do the following import win32com.client s = win32com.client.Dispatch('CDO.Message') s.From = "[EMAIL PROTECTED]"

Re: atmosphere on c.l.py (WAS: How about "pure virtual methods"?)

2004-12-19 Thread Steven Bethard
Doug Holton wrote: Fredrik Lundh wrote: well, since I'm not in the ego-stroking business, what if I promise never to reply to posts by you, robert, and alex? That's not fair to the rest of us though :) That's not even fair to the non-rest of us. =) As I noted, "his answers ... are often very ins

embedding: forcing an interpreter to end

2004-12-19 Thread pdectm
I'm trying to prototype an application which runs multiple python scripts, each in its own interpreter and OS thread. I've not been able to forceable stop a script which does not respond to a request to stop. My thought was to simply call: PyThreadState_Clear(xxx); PyThreadState_Delete(xxx); //

Re: dot products

2004-12-19 Thread Rahul
Raymond Hettinger wrote: > [Rahul]. > > I want to compute dot product of two vectors stored as lists a and b.a > > and b are of the same length. > > > > one simple way is > > sum(a[i]*b[i] for i in range(len(a))) > > > > another simple way is > > ans=0.0 > > for i in range(len(a)): > > ans=ans+a[i

Re: Writev

2004-12-19 Thread Jp Calderone
On Sun, 19 Dec 2004 23:12:27 -0500, Adam DePrince <[EMAIL PROTECTED]> wrote: > [snip] > > Of course, to take advantage of this requires that writev be exposed. I > have an implementation of writev. This implementation is reasonably > smart, it "unrolls" only so as many iteration.next calls as ne

Re: Is this a good use for lambda

2004-12-19 Thread Bengt Richter
On Sun, 19 Dec 2004 20:59:43 +0100, "Fredrik Lundh" <[EMAIL PROTECTED]> wrote: >Walter S. Leipold wrote: > >> I think that Charlie's point is that, when you use "def ", you have >> polluting your namespace. The whole program becomes harder to >> understand because you can't ignore anywhere, eve

Re: Web forum (made by python)

2004-12-19 Thread bitshadow
I have to say i'm really impressed at that fledgling progject choe, the only problem i could see is that it seemed to have problems connecting to the database everytime. I think pybbs is a wonderful idea and a great think to give back to the commnity. I will keep checking on your sites for future

Re: expression form of one-to-many dict?

2004-12-19 Thread Bengt Richter
On Sun, 19 Dec 2004 21:29:27 +0100, "Fredrik Lundh" <[EMAIL PROTECTED]> wrote: >Mike Meyer wrote: > >> Personally, I'd love a language feature that let you create a function >> that didn't evaluate arguments until they were actually used - lazy >> evaluation. That lets you write the C ?: operator

Re: Easy "here documents" ??

2004-12-19 Thread John Roth
"Jim Hill" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] I've done some Googling around on this and it seems like creating a here document is a bit tricky with Python. Trivial via triple-quoted strings if there's no need for variable interpolation but requiring a long, long formatte

Writev

2004-12-19 Thread Adam DePrince
Often I've written code that generates some textual output and dumps said output to a file or socket. Of course, we are all familiar with the performance impact (multiple copies of text data and O(n**2) performance) associated with the naive approach of: string += "some other string" string +=

No acceptable C compiler was found in $PATH

2004-12-19 Thread banaticus
What does this error message mean? What can I do to fix it? Here'e the command that I just tried running, and the messages that I received. I just barely unpacked python. linux:/Python-2.4 # ./configure checking MACHDEP... linux2 checking EXTRAPLATDIR... checking for --without-gcc... n

Re: A completely silly question

2004-12-19 Thread Keith Dart
Jp Calderone wrote: On Sun, 19 Dec 2004 23:15:40 GMT, Keith Dart <[EMAIL PROTECTED]> wrote: Mike Meyer wrote: The termios gives module gives you the tools to manipulate the tty directly, without invoking stty. The tty module gives you an easier interface to those routines. However, it's missing a s

Re: input record seperator (equivalent of "$|" of perl)

2004-12-19 Thread M.E.Farmer
Yea I should have mentioned I am running python 2.2.2. Can it be ported to python 2.2.2? Till they get python 2.4 all up and runningI'll wait a bit. Thanks for the info, M.E.Farmer Scott David Daniels wrote: > M.E.Farmer wrote: > > I dont have itertools yet. That module looks like it rocks. >

ANN: Python Multimedia Computing book and software

2004-12-19 Thread Doug Holton
This book is due to be published any day now: "Introduction to computing and programming with Python: A Multimedia Approach" by Mark Guzdial, a CS professor at Georgia Tech. It uses the Jython Environment for Students (JES). It is completely free and open source. You can use it for example to

Re: Web forum (made by python)

2004-12-19 Thread Doug Holton
Peter Hansen wrote: None of which in any way invalidates Jp's point... Neither does it invalidate mine. What is up with the trollers today? They are out in force now that the holidays are here. -- http://mail.python.org/mailman/listinfo/python-list

Re: Boo who? (was Re: newbie question)

2004-12-19 Thread Doug Holton
Peter Hansen wrote: "Virtually identical" indeed. :-) As noted on the website that I've pointed out to you multiple times now, the syntax of boo is indeed virtually identical to python. The functionality however, is more like C#. -- http://mail.python.org/mailman/listinfo/python-list

Re: Easy "here documents" ??

2004-12-19 Thread Bengt Richter
On Sun, 19 Dec 2004 16:46:34 +0100, "Fredrik Lundh" <[EMAIL PROTECTED]> wrote: >Jerry Sievers wrote: > >> It gets uglier though if you want to do this from inside a function >> and have variables from more than one scope interpolated. For that >> you need something that can treat a series of dict

Re: Boo who? (was Re: newbie question)

2004-12-19 Thread Peter Hansen
Luis M. Gonzalez wrote: Why? If it's virtually identical, why would anyone bother even visiting that site? ;-) The difference is that it runs on the .NET frmework (and Mono). So instead of using the python standard libraries, you use the .NET ones. Regarding its syntax, it is very similar to Pyth

Re: Web forum (made by python)

2004-12-19 Thread Peter Hansen
Doug Holton wrote: Jp Calderone wrote: Part of fostering a friendly environment on python-list is not making comments like these. Another part is actually answering the content of a person's question like I did, instead of trolling and flaming, like Fredrik and others here are want to do. Non

Re: input record seperator (equivalent of "$|" of perl)

2004-12-19 Thread Scott David Daniels
M.E.Farmer wrote: I dont have itertools yet. That module looks like it rocks. thanks for the pointers, M.E.Farmer If you have python 2.3 or 2.4, you have itertools. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: A rational proposal

2004-12-19 Thread Dave Benjamin
Hi Mike - Thanks for taking the time to put this together. In article <[EMAIL PROTECTED]>, Mike Meyer wrote: > - max(*args): return the largest of a list of numbers and self. > - min(*args): return the smallest of a list of numbers and self. I would strongly prefer either adapting the already bui

Re: atmosphere on c.l.py (WAS: How about "pure virtual methods"?)

2004-12-19 Thread Doug Holton
Steven Bethard wrote: I don't really have a good solution; despite the unnecessarily vicious comments, I don't feel like I can set my newsreader to ignore messages from, for example, Fredrik, because his answers, when not attacks, are often very insightful. If you find a good solution to this p

Re: atmosphere on c.l.py (WAS: How about "pure virtual methods"?)

2004-12-19 Thread Fredrik Lundh
Simon Wittber wrote: > We've just had a Python 2.4 release, and poor Mr Lundh has likely had > hundreds of user's clamouring for a binary, 2.4 compatible PIL > release. many hundreds, indeed. but that's not a problem at all; I have a webserver that helps me with things like that. -- http:

Re: input record seperator (equivalent of "$|" of perl)

2004-12-19 Thread M.E.Farmer
Fredrik, Thanks didn't realize that about reading a file on a for loop. Slick! By the way the code I posted was an attempt at not building a monolithic memory eating list like you did to return the values in your second example. Kinda thought it would be nice to read them as needed instead of all a

Re: A completely silly question

2004-12-19 Thread Jp Calderone
On Sun, 19 Dec 2004 23:15:40 GMT, Keith Dart <[EMAIL PROTECTED]> wrote: >Mike Meyer wrote: > > The termios gives module gives you the tools to manipulate the tty > > directly, without invoking stty. The tty module gives you an easier > > interface to those routines. However, it's missing a setsane

Funny story about python

2004-12-19 Thread eScrewDotCom
eScrew Welcome to eScrew! eScrew is eScrew and this is eScrew story. eScrew will tell you eScrew story if you promise eScrew to consider eScrew story as joke. eScrew story is very funny. eScrew story is so funny that eScrew will have to take break from time to time because eScrew needs some rest f

Re: Web forum (made by python)

2004-12-19 Thread Jp Calderone
On Sun, 19 Dec 2004 18:45:12 -0600, Doug Holton <[EMAIL PROTECTED]> wrote: >Jp Calderone wrote: > > Part of fostering a friendly environment on python-list is not making > > comments like these. > > Another part is actually answering the content of a person's question > like I did, instead of

Re: atmosphere on c.l.py (WAS: How about "pure virtual methods"?)

2004-12-19 Thread Simon Wittber
> I do understand the feeling though; Fredrik Lundh jumped at me only a > few days ago when I said that I personally found list comprehensions > more readable than map. I certainly don't mind being advised or > corrected if I've written incorrect or even just suboptimal code, but > attacking a per

Re: Boo who? (was Re: newbie question)

2004-12-19 Thread Luis M. Gonzalez
> Why? If it's virtually identical, why would anyone bother even > visiting that site? ;-) > > But I suspect you mean that the syntax of the language is virtually > identical, while probably there are some significant differences. > Maybe in the richness of its standard library? Or the size of

Re: Web forum (made by python)

2004-12-19 Thread Choe, Cheng-Dae
try http://kldp.net/projects/pybb/ example site is http://bbs.pythonworld.net:9080/pybbs.py On Sun, 19 Dec 2004 22:09:52 +0200, Gezer Punta <[EMAIL PROTECTED]> wrote: > hi all > I am looking for a forum which was produced by python > > link pls > -- > http://mail.python.org/mailman/listinfo/pyt

RE: atmosphere on c.l.py (WAS: How about "pure virtual methods"?)

2004-12-19 Thread Robert Brewer
Fredrik Lundh wrote: > well, since I'm not in the ego-stroking business, what if I > promise never to > reply to posts by you, robert, and alex? ?? I'll take your replies anytime. You're a long way from all noise and no signal. I'm happy to learn what I can from you. Robert Brewer MIS Amor Mini

Re: Is this a good use for lambda

2004-12-19 Thread Michael Sparks
On Mon, 20 Dec 2004, Fredrik Lundh wrote: > Simo Melenius wrote: > > >> Ahem. If you name the function, you can reuse the name (or just > >> forget about it) as soon as you've used the function object. > > > > Sure, but mental pollution counts too IMO. What you write and what you > > read must go t

Re: Boo who? (was Re: newbie question)

2004-12-19 Thread Doug Holton
Peter Hansen wrote: Why? If it's virtually identical, why would anyone bother even visiting that site? ;-) But I suspect you mean that the syntax of the language is virtually identical, while probably there are some significant differences. Maybe in the richness of its standard library? Or the s

Re: Web forum (made by python)

2004-12-19 Thread Doug Holton
Jp Calderone wrote: Part of fostering a friendly environment on python-list is not making comments like these. Another part is actually answering the content of a person's question like I did, instead of trolling and flaming, like Fredrik and others here are want to do. -- http://mail.python.

Re: Web forum (made by python)

2004-12-19 Thread Jp Calderone
On Sun, 19 Dec 2004 18:30:03 -0600, Doug Holton <[EMAIL PROTECTED]> wrote: >Gezer Punta wrote: > > > hi all > > I am looking for a forum which was produced by python > > If you want Zope-based, try Plone. But probably you don't. > I am not aware of any standard python CGI-based forum software,

Boo who? (was Re: newbie question)

2004-12-19 Thread Peter Hansen
Doug Holton wrote: Boo, a programming language that is virtually identical to python, ... See http://boo.codehaus.org/ In fact, since not many seem to be aware of its existence, I encourage everyone here to check out boo as an alternative to python. Why? If it's virtually identical, why would any

Re: Web forum (made by python)

2004-12-19 Thread Doug Holton
Gezer Punta wrote: hi all I am looking for a forum which was produced by python If you want Zope-based, try Plone. But probably you don't. I am not aware of any standard python CGI-based forum software, but I am sure you could find one if you search sourceforge or google. I am surprised no one e

Re: input record seperator (equivalent of "$|" of perl)

2004-12-19 Thread Fredrik Lundh
"M.E.Farmer" wrote: > What about a generator and xreadlines for those really large files: when you loop over a file object, Python uses a generator and a xreadlines- style buffering system to read data as you go. (if you check the on-line help, you'll notice that xreadlines itself is only provid

Re: input record seperator (equivalent of "$|" of perl)

2004-12-19 Thread M.E.Farmer
What about a generator and xreadlines for those really large files: py>def recordbreaker(recordpath, seperator='#'): ... rec = open(recordpath ,'r') ... xrecord = rec.xreadlines() ... a =[] ... for line in xrecord: ... sep = line.find(seperator) ... if sep != -1: ...

Re: Driving win32 GUIs with Python

2004-12-19 Thread Andrew McLean
In article <[EMAIL PROTECTED]>, Fredrik Lundh <[EMAIL PROTECTED]> writes Andrew McLean wrote: I have a requirement to drive a Windows GUI program from a Python Script. The program was originally a DOS program written in Turbo Pascal, and was recently translated to Delphi. I don't think it expos

Re: Easy "here documents" ??

2004-12-19 Thread Doug Holton
Jim Hill wrote: Is there a way to produce a very long multiline string of output with variables' values inserted without having to resort to this wacky """v = %s"""%(variable) No, not without the god-awful hacks you've already seen. But it is possible in boo: : http://boo.codehaus.org/ See http://b

Re: atmosphere on c.l.py (WAS: How about "pure virtual methods"?)

2004-12-19 Thread Doug Holton
Fredrik Lundh wrote: If you find a good solution to this problem, please let me know. well, since I'm not in the ego-stroking business, what if I promise never to reply to posts by you, robert, and alex? That's not fair to the rest of us though :) -- http://mail.python.org/mailman/listinfo/python

Re: dot products

2004-12-19 Thread Fredrik Lundh
Raymond Hettinger wrote: > * applying itertools instead of genexps can save the eval-loop overhead > * however, genexps are usually more readable than itertools solutions I'm still waiting for you to implement itertools as a parse-tree analyzer/code generator, rather than an "bare" extension mod

Re: newbie question

2004-12-19 Thread Doug Holton
David Wurmfeld wrote: I am new to python; any insight on the following would be appreciated, even if it is the admonition to RTFM (as long as you can direct me to a relevant FM) Is there a standard approach to enumerated types? I could create a dictionary with a linear set of keys, but isn't th

Re: MySQLdb & Python 2.4 on Windows

2004-12-19 Thread Fredrik Lundh
Matthias Verniers wrote: > 2. Is it possible to use Python 2.4 & 2.3 next to each other without > conflicts? yes, assuming "next to each other" means "on the same machine". but binary extensions are bound to the Python version they were built for; you cannot use a 2.3 extension with 2.4 on wind

Re: dot products

2004-12-19 Thread Raymond Hettinger
[Rahul]. > I want to compute dot product of two vectors stored as lists a and b.a > and b are of the same length. > > one simple way is > sum(a[i]*b[i] for i in range(len(a))) > > another simple way is > ans=0.0 > for i in range(len(a)): > ans=ans+a[i]*b[i] > > But is there any other way which is f

Re: Is this a good use for lambda

2004-12-19 Thread Fredrik Lundh
Simo Melenius wrote: >> Ahem. If you name the function, you can reuse the name (or just >> forget about it) as soon as you've used the function object. > > Sure, but mental pollution counts too IMO. What you write and what you > read must go through your brain, including dummy variables. And next

Re: input record seperator (equivalent of "$|" of perl)

2004-12-19 Thread Doug Holton
[EMAIL PROTECTED] wrote: Hi, I know that i can do readline() from a file object. However, how can I read till a specific seperator? for exmple, if my files are name profession id # name2 profession3 id2 I would like to read this file as a record. I can do this in perl by defining a record seperator

MySQLdb & Python 2.4 on Windows

2004-12-19 Thread Matthias Verniers
Hello Yesterday I installed Python 2.4. Since I often work with MySQL, I need the MySQLdb module, wich worked fine under 2.3. Now, it doesn't work under 2.4, it says it needs python 2.3 when I try to install the module. Now I have some (rather nooby) questions: 1. Has anyone tried installing MySQ

RE: example code sought

2004-12-19 Thread Walter S. Leipold
Sean McIlroy wrote: > What I want to do is simply to move a shape around on > the screen using the mouse. I've looked at Tkdnd.py but > I can't seem to extract what I need from the more involved > stuff in there. Here's a simple sample that displays random rectangles that can be dragged around

Re: How about "pure virtual methods"?

2004-12-19 Thread Doug Holton
Fredrik Lundh trolled: (I think you could create some kind of drinking game based on the number of ...times the nasty trolls pounce on this list? No, I think the idea is to actually address the content of someone's question, politely and in the *holiday spirit*, not spirits. -- http://mail.python.

Re: A completely silly question

2004-12-19 Thread Keith Dart
Mike Meyer wrote: Craig Ringer <[EMAIL PROTECTED]> writes: On Sat, 2004-12-18 at 00:40, Amir Dekel wrote: This must be the silliest question ever: What about user input in Python? (like stdin) Where can I find it? I can't find any references to it in the documentation. Under UNIX, I generally eith

Re: Data reading problem

2004-12-19 Thread Fredrik Lundh
> if you need to read lots of 12-bit values, you can create a simple bitstream > generator: in private mail, Michal told me that his files were quite large, and that the bitstream approach wasn't fast enough. another way to do this is to use PIL's "bit" decoder: import Image im = Image.f

Re: Easy "here documents" ??

2004-12-19 Thread Fredrik Lundh
Scott David Daniels wrote: > And if you enjoy building insecure stuff, try: > > def fix(text, globals_=None, locals=None, quote='"'): > d = (globals_ or locals or globals()).copy() > source = text.split(quote) > source[1::2] = (str(eval(expr, d, locals or d)) > for expr

Re: atmosphere on c.l.py (WAS: How about "pure virtual methods"?)

2004-12-19 Thread Fredrik Lundh
Steven Bethard wrote: > I do understand the feeling though; Fredrik Lundh jumped at me only a few > days ago when I said > that I personally found list comprehensions more readable than map. if you think that's what you said, you're clearly didn't read the post you replied to very carefully. I

Re: Easy "here documents" ??

2004-12-19 Thread Scott David Daniels
Nick Craig-Wood wrote: I prefer this >>> amount = 1 >>> cost = 2.0 >>> what = 'potato' >>> print """\ ... I'll have %(amount)s %(what)s ... for $%(cost)s please""" % locals() I'll have 1 potato for $2.0 please >>> And if you enjoy building insecure stuff, try: def fi

RE: atmosphere on c.l.py (WAS: How about "pure virtual methods"?)

2004-12-19 Thread Robert Brewer
Steven Bethard wrote: > Alex Martelli wrote: > > Definitely not the c.l.py I recalled > [snip] > > I guess I'm not going to stay around all that long this time. > > That would be a sad loss for all of us out here who very much > appreciate your very deep knowledge of Python and your > willingness

atmosphere on c.l.py (WAS: How about "pure virtual methods"?)

2004-12-19 Thread Steven Bethard
Alex Martelli wrote: Definitely not the c.l.py I recalled [snip] I guess I'm not going to stay around all that long this time. That would be a sad loss for all of us out here who very much appreciate your very deep knowledge of Python and your willingness to share it. I do understand the feeling

Re: Is this a good use for lambda

2004-12-19 Thread Steven Bethard
Simo Melenius wrote: Now, if lambda was more than an expr, dumping "lambda" keyword would be a convenient idea -- unnecessary keywords can make the language less clear in some cases. One could do with Python's plain and simple "def", like this: filter (def (x): x*2, myseq) (Disclaimer: Without thin

Re: Driving win32 GUIs with Python

2004-12-19 Thread Fredrik Lundh
Andrew McLean wrote: >I have a requirement to drive a Windows GUI program from a Python Script. The >program was >originally a DOS program written in Turbo Pascal, and was recently translated >to Delphi. I don't >think it exposes an OLE or other automation interface. I don't have access to >t

Driving win32 GUIs with Python

2004-12-19 Thread Andrew McLean
I have a requirement to drive a Windows GUI program from a Python Script. The program was originally a DOS program written in Turbo Pascal, and was recently translated to Delphi. I don't think it exposes an OLE or other automation interface. I don't have access to the source. A bit of Googling

Re: How about "pure virtual methods"?

2004-12-19 Thread Scott David Daniels
John Machin wrote (of Alex Martelli's sketch): Thank you for the motivation. I now understand what it is attempting to do. Unfortunately it doesn't succeed. Instead of: if v is notimplemented: abstract_methods.append(n) you need: if v.im_func is notimplemented: abstract_methods.append(n) Here is an

Re: input record seperator (equivalent of "$|" of perl)

2004-12-19 Thread Keith Dart
[EMAIL PROTECTED] wrote: Hi, I know that i can do readline() from a file object. However, how can I read till a specific seperator? for exmple, if my files are name profession id # name2 profession3 id2 I would like to read this file as a record. I can do this in perl by defining a record seperator

Re: How about "pure virtual methods"?

2004-12-19 Thread Alex Martelli
John Machin <[EMAIL PROTECTED]> wrote: > Thank you for the motivation. I now understand what it is attempting to > do. Unfortunately it doesn't succeed. Instead of: > > if v is notimplemented: abstract_methods.append(n) > > you need: > if v.im_func is notimplemented: abstract_methods.append(n)

Re: newbie question

2004-12-19 Thread Keith Dart
David Wurmfeld wrote: I am new to python; any insight on the following would be appreciated, even if it is the admonition to RTFM (as long as you can direct me to a relevant FM) Is there a standard approach to enumerated types? I could create a dictionary with a linear set of keys, but isn't th

Re: How about "pure virtual methods"?

2004-12-19 Thread Alex Martelli
Fredrik Lundh <[EMAIL PROTECTED]> wrote: ... > Alex Martelli wrote: > > >> Traceback (most recent call last): > >> File "mymodule.py", line 9, in somefunction > >> someobj.bar() > >> ... zero or more lines ... > >> File "somelibrary.py", line 3, in bar > >> r

Re: input record seperator (equivalent of "$|" of perl)

2004-12-19 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > I know that i can do readline() from a file object. > However, how can I read till a specific seperator? > > for exmple, > if my files are > > name > profession > id > # > name2 > profession3 > id2 > > I would like to read this file as a record. > I can do this in perl b

Windows CD autorun program

2004-12-19 Thread M.E.Farmer
Hello all, I needed this and did a quick search around and didn't see any examples. I knew it had to be easy, and it was. So here it is a CD_Autorun program in python. It is very simple and without comments is only about 30 lines. Also included a setup.py at the end of the script so you can 'compil

Re: Is this a good use for lambda

2004-12-19 Thread Simo Melenius
"Fredrik Lundh" <[EMAIL PROTECTED]> writes: > Walter S. Leipold wrote: > > I think that Charlie's point is that, when you use "def ", > > you have polluting your namespace. The whole program > > becomes harder to understand because you can't ignore > > anywhere, even if it was only ever intended

Re: expression form of one-to-many dict?

2004-12-19 Thread Fredrik Lundh
Mike Meyer wrote: > Personally, I'd love a language feature that let you create a function > that didn't evaluate arguments until they were actually used - lazy > evaluation. That lets you write the C ?: operator as a function, for > a start. > > Hmmm. No, iterators can't be used to fake it. Oh we

input record seperator (equivalent of "$|" of perl)

2004-12-19 Thread les_ander
Hi, I know that i can do readline() from a file object. However, how can I read till a specific seperator? for exmple, if my files are name profession id # name2 profession3 id2 I would like to read this file as a record. I can do this in perl by defining a record seperator; is there an equivalen

  1   2   >