Re: BASIC vs Python

2004-12-19 Thread Alan Gauld
OK, I'll play... > > Productive in? C, C++, Pascal (inc OP/Delphi/Kylix), Python, PL/Sql, 80x86 assembler > > Familiar enough to at least produce code in? awk, perl, Java, ksh, Lisp, Logo, VBScript, Javascript, Tcl, DOS batch, SDL > You forgot an important category here. Can debug, if

Re: How about "pure virtual methods"?

2004-12-19 Thread John Machin
Alex Martelli wrote: > class Meta_for_NR(type): > def __init__(cls, cn, cb, cd): > super(Meta_for_NR, cls).__init__(cn, cb, cd) > abstract_methods = [] > for n, v in inspect.getmembers(cls, inspect.ismethod): > if v is notimplemented: abstract_methods.append

symbol not found involving dynlink/dlopen/embedding Python

2004-12-19 Thread Christopher Armstrong
With the following situation, Numarray can't find Python's symbols. problematic-Python:: Main dlopens Two Two dynlinks Python Python dlopens Numarray Numarray dynlinks Python I have another pure-C example that tries to mirror this, with:: minimal-C:: Main dlopen Two Two dynlink Middl

Re: Use macros in Excel via win32com

2004-12-19 Thread Harald Massa
chris, > I'm creating an excel document dynamically from scratch using Python > and the win32com module. All is well, but now I need to add a macro to > the spreadsheet and run it (to enable some sorting features in the > spreadsheet). I recommend to create the excel document not from scratch

Re: symbol not found involving dynlink/dlopen/embedding Python [platform information]

2004-12-19 Thread Christopher Armstrong
Sorry, I forgot to put information about my platform. Debian unstable on linux kernel 2.4.20, Debian's package of Python2.3. gcc version 3.3.3 libc version 2.3.2 libc.so.6 output follows::: [EMAIL PROTECTED] ~% /lib/libc.so.6 GNU C Library stable release version 2.3.2, by Roland McGrath et al.

dot products

2004-12-19 Thread Rahul
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=ans+a[i]*b[i] But is there any other way which is faster than any of the abov

Re: How about "pure virtual methods"?

2004-12-19 Thread Nick Coghlan
John Machin wrote: 6. Alex's magnum opus appears to operate on problem a, and maybe on b (it's over my head). It involves a fair chunk of mucking about -- for what? Early warning, a few microseconds ahead of the invocation of a method which will cause the stub in the base class to raise an exceptio

Re: How do I define the search path for personal library

2004-12-19 Thread richardshea
If i understand correctly what you're after I think another option is import sys sys.path.append('http://mail.python.org/mailman/listinfo/python-list

Re: dot products

2004-12-19 Thread Andrey Tatarinov
Rahul wrote: 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))) btw, imho the most "Pythonic" would be: sum(i*j for (i,j) in zip(a,b)) -- http://mail.python.org/mailman/listinfo/python-list

Re: dot products

2004-12-19 Thread Nick Coghlan
Rahul 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=ans+a[i]*b[i] But is there any other way which is faster than any o

Re: dot products

2004-12-19 Thread Peter Otten
Rahul wrote: > 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 wh

newbie question

2004-12-19 Thread David Wurmfeld
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 this overkill? There is

Re: newbie question

2004-12-19 Thread Miki Tebeka
Hello David, > Is there a standard approach to enumerated types? I could create a > dictionary with a linear set of keys, but isn't this overkill? There is > afterall a "True" and "False" enumeration for Boolean. Google for Python + enum. (A good one is: http://www.norvig.com/python-iaq.html)

Re: lies about OOP

2004-12-19 Thread not [quite] more i squared
Martijn Faassen wrote: Imagine, for instance, what if he wants to egosurf, google for his own name and finds nothing because everybody was saying Djikstra all the time? That'd be terrible! Fortunately, not in our time stream : Dijkstra - 892 000 hits Djikstra - 5 500 hits "Edsger Dijkstra" - 25

Re: A rational proposal

2004-12-19 Thread Raymond L. Buvel
Alex Martelli wrote: Raymond L. Buvel <[EMAIL PROTECTED]> wrote: Mike Meyer wrote: PEP: XXX Title: A rational number module for Python I think it is a good idea to have rationals as part of the standard distribution but why not base this on the gmpy module (https://sourceforge.net/projects/gmpy

Re: A rational proposal

2004-12-19 Thread Fredrik Lundh
Raymond L. Buvel wrote: >> gmpy wraps GMP, which is covered by LGPL; therefore, gmpy itself is >> LGPL, and thus, sadly, cannot be included with python (otherwise, >> speaking as gmpy's author, I'd be glad to fix its design to meet your >> objections). > Since the LGPL was designed to allow propr

Re: newbie question

2004-12-19 Thread Nick Coghlan
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) Your questions are esoteric enough that, even though the relevant information *is* in the FM, RTFM would be a really s

Re: odbc script

2004-12-19 Thread Benji York
Chris wrote: what ever is the last loop through doesn't seem to update the database? Try a conn.commit() after your loop. -- Benji York -- http://mail.python.org/mailman/listinfo/python-list

Re: Replace single item in tkinter ListBox

2004-12-19 Thread Zhang Le
Thanks for the hint. But I did not try such *advance* techniques so far. Both Delete-then-insert and Insert-then-delete work for me. Interestingly, I found Delete-then-insert can cause some flicking when replacing items near bottom, while Insert-then-delete always works fine. Zhang Le -- http://

[ANNOUNCE] Python Thread Validator software tool

2004-12-19 Thread Stephen Kellett
Python Thread Validator. A thread analysis, lock analysis and deadlock detection tool for Python. Tool is now in beta. http://www.softwareverify.com/pythonThreadValidator/index.html Stephen -- Stephen Kellett Object Media Limitedhttp://www.objmedia.demon.co.uk RSI Information:http://www

Re: newbie question

2004-12-19 Thread Dan Bishop
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) http://www.python.org/doc/ > Is there a standard approach to enumerated types? I could create a > dictionary with

python & nurbs

2004-12-19 Thread Jelle Feringa // EZCT / Paris
Is anyone aware of a python nurbs module? So far I found Runar Tenfjord's effort, which is quite interesting: http://runten.tripod.com/NURBS/ But in the end doesn't really meet my needs. Any suggestions? Cheers, Jelle. -- http://mail.python.org/mailman/listinfo/python-list

Re: python & nurbs

2004-12-19 Thread Peter Hansen
Jelle Feringa // EZCT / Paris wrote: Is anyone aware of a python nurbs module? So far I found Runar Tenfjord's effort, which is quite interesting: http://runten.tripod.com/NURBS/ But in the end doesn't really meet my needs. Any suggestions? Yes: _describe_ your needs; don't just hint at how someth

Re: How about "pure virtual methods"?

2004-12-19 Thread Alex Martelli
John Machin <[EMAIL PROTECTED]> wrote: ... > 6. Alex's magnum opus appears to operate on problem a, and maybe on b > (it's over my head). It involves a fair chunk of mucking about -- for A dozen lines of code to write *ONCE* and put in your utilities module is a "magnum opus" and "a fair chunk

Data reading problem

2004-12-19 Thread Michal Szpadzik
I'm a newbie. I have some problems with bits data reading. I have binary data file where data is written as 12bits pack. I need to read it becouse there are saved values which have to processed later by my program. I was wandering about reading 3bytes=24bits and split it by bits moving. If any

Re: python & nurbs

2004-12-19 Thread Mike C. Fletcher
Jelle Feringa // EZCT / Paris wrote: Is anyone aware of a python nurbs module? So far I found Runar Tenfjord's effort, which is quite interesting: http://runten.tripod.com/NURBS/ But in the end doesn't really meet my needs. Any suggestions? Hint to get a useful answer: Define your needs. Displa

Re: Easy "here documents" ??

2004-12-19 Thread Jerry Sievers
[EMAIL PROTECTED] (Jim Hill) writes: > 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 > formatted arglist via (%s,%s,%s,ad

Language fluency (was Re: BASIC vs Python)

2004-12-19 Thread Aahz
In article <[EMAIL PROTECTED]>, Adam DePrince <[EMAIL PROTECTED]> wrote: > >I'd like to ask everybody a simple question. How many computer >languages are you completely and utterly fluent in? The reason I ask is >I'd like for everyone who has participated in this discussion to >introspect and as

RE: python & nurbs

2004-12-19 Thread Jelle Feringa // EZCT / Paris
> Hint to get a useful answer: Define your needs. Display in 3D (want to > use them to define and display geometry)? Numeric analysis (writing > some sort of CAD or automation system)? Modeling system (want some way > to interactively define them)? I wish I could give you a well defined answer

Re: Easy "here documents" ??

2004-12-19 Thread Fredrik Lundh
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 dicts as one.If there's > built in functionality in Python for this, I haven't discovered

Re: newbie question

2004-12-19 Thread Diez B. Roggisch
> It works as if you had written: > > for _i in xrange(len(myList)): > x = myList(_i) No, as this implies that the variable has to support random access using indices. But all that's required is the iterable-interface beeing supported - by calling __iter__ and .next() on the resulting object. --

Re: Data reading problem

2004-12-19 Thread Fredrik Lundh
Michal Szpadzik wrote: > I have some problems with bits data reading. I have binary data file where > data is written as > 12bits pack. I need to read it becouse there are saved values which have to > processed later by my > program. I was wandering about reading 3bytes=24bits and split it by

Re: How about "pure virtual methods"?

2004-12-19 Thread Fredrik Lundh
Alex Martelli: >> what? Early warning, a few microseconds ahead of the invocation of a >> method which will cause the stub in the base class to raise an >> exception? > > Exactly. Microseconds don't count, but stack levels do -- getting the > traceback end as close as possible to the real CAUSE o

Re: How about "pure virtual methods"?

2004-12-19 Thread Jp Calderone
On Sun, 19 Dec 2004 17:13:30 +0100, Fredrik Lundh <[EMAIL PROTECTED]> wrote: >Alex Martelli: > > >> what? Early warning, a few microseconds ahead of the invocation of a > >> method which will cause the stub in the base class to raise an > >> exception? > > > > Exactly. Microseconds don't count,

Re: python & nurbs

2004-12-19 Thread Lucas Raab
Jelle Feringa // EZCT / Paris wrote: Hint to get a useful answer: Define your needs. Display in 3D (want to use them to define and display geometry)? Numeric analysis (writing some sort of CAD or automation system)? Modeling system (want some way to interactively define them)? I wish I could gi

Re: decorator peculiarity

2004-12-19 Thread Fredrik Lundh
Diez B. Roggisch wrote: > However I've encountered one peculiarity that strikes me odd: > > When one writes a decorated function like this: > > @decorate > def foo(): >pass > > the function decorate usually looks like this: > > def decorate(func): >def _d(*args, **kwargs): >do_some

Re: How about "pure virtual methods"?

2004-12-19 Thread Fredrik Lundh
Jp Calderone wrote: > If the line immediately before "someobj.bar()" is "someobj = FooType()", > this will surely be easy. If someobj is instantiated further away, then > more digging is required. well, I guess I was assuming that you're debugging your own code, and that you don't generally wri

RE: python & nurbs

2004-12-19 Thread Jelle Feringa // EZCT / Paris
> Have you looked at Blender (http://www.blender3d.com)?? Blender seems very promising, its python support is exactly what I'm looking for, but it lacks the cad/parametric capabilities I'm looking for. -- http://mail.python.org/mailman/listinfo/python-list

Re: How about "pure virtual methods"?

2004-12-19 Thread Alex Martelli
Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Alex Martelli: > > >> what? Early warning, a few microseconds ahead of the invocation of a > >> method which will cause the stub in the base class to raise an > >> exception? > > > > Exactly. Microseconds don't count, but stack levels do -- getting the

Re: Easy "here documents" ??

2004-12-19 Thread Nick Craig-Wood
Jim Hill <[EMAIL PROTECTED]> wrote: > 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 > formatted arglist via (%s,%s,%s,

Re: How do I define the search path for personal library

2004-12-19 Thread les_ander
Yes, this is exactly what I wanted--just like in perl I can add search path to @inc. thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: Language fluency (was Re: BASIC vs Python)

2004-12-19 Thread Keith Dart
Hello, Aahz, Aahz wrote: myself to have "complete and utter" fluency. In fact, in some ways my fluency has degenerated now that I'm focusing on writing code for production. I'm curious about that last statement. Are you saying that if you write, full time, code for "production", that fluency will

Re: example code sought

2004-12-19 Thread Gary Richardson
"Sean McIlroy" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > There's something quite simple I'd like to do, but I'm hampered by > lack of knowledge regarding Tkinter. If someone could help me out with > a snippet of maximally-simple code showing, in general terms, how to > do this,

Re: How about "pure virtual methods"?

2004-12-19 Thread Fredrik Lundh
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 >> raise NotImplementedError("must implement abstract method bar") >

Re: Easy "here documents" ??

2004-12-19 Thread Keith Dart
Jim Hill wrote: 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 formatted arglist via (%s,%s,%s,ad infinitum) if there is. So m

Re: How about "pure virtual methods"?

2004-12-19 Thread Steve Holden
Noam Raphael wrote: Hello, I thought about a new Python feature. Please tell me what you think about it. Say you want to write a base class with some unimplemented methods, that subclasses must implement (or maybe even just declare an interface, with no methods implemented). Right now, you don'

Re: dot products

2004-12-19 Thread Steven Bethard
Rahul wrote: I want to compute dot product of two vectors stored as lists a and b.a and b are of the same length. . >>> import numarray as na . >>> a, b = na.arange(5), na.arange(5, 10) . >>> na.dot(a, b) . 80 Steve -- http://mail.python.org/mailman/listinfo/python-list

Re: Easy "here documents" ??

2004-12-19 Thread Steve Holden
Fredrik Lundh 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 dicts as one.If there's built in functionality in Python for this, I haven

Re: Easy "here documents" ??

2004-12-19 Thread Fredrik Lundh
Steve Holden wrote: >> here's a rather horrid piece of code that turns a list of dictionaries >> into a single object [that] automatically searches the dictionary chain >> when you ask for attributes (use getattr for non-standard keys). >> >> def flatten_dicts(*dicts): >> root = None >> fo

Re: How about "pure virtual methods"?

2004-12-19 Thread Mike Meyer
Noam Raphael <[EMAIL PROTECTED]> writes: > What I suggest is a new class, called notimplemented (you may suggest > a better name). It would get a function in its constructor, and would > just save a reference to it. The trick is that when a new type (a > subclass of the default type object) is cre

RE: Is this a good use for lambda

2004-12-19 Thread Walter S. Leipold
Steven Bethard wrote: > Charlie Taylor wrote: >>I have tried using named functions instead of using lambda functions, >>however, I always end up with a convoluted, hard to follow mess. > ... > Well, I think the jury could still be out on which version is more > readable, but I don't understand the

Re: How about "pure virtual methods"?

2004-12-19 Thread Doug Holton
Noam Raphael wrote: even in the best solution that I know of, there's now way to check if a subclass has implemented all the required methods without running it and testing if it works. I think there are some solutions like PyProtocols, see section 2.2 on this page: http://www.python.org/cgi-b

Re: How about "pure virtual methods"?

2004-12-19 Thread Fredrik Lundh
... From: Doug ... (I think you could create some kind of drinking game based on the number of non-quoted lines between the "From"-line and the first line containing the word "boo" in Doug's posts on comp.lang.python. A little like the game based on the number of minutes between someone mentionin

Re: BASIC vs Python

2004-12-19 Thread Mike Meyer
Scott Robinson <[EMAIL PROTECTED]> writes: > On Fri, 17 Dec 2004 20:41:11 -0600, Mike Meyer <[EMAIL PROTECTED]> wrote: > >>Scott Robinson <[EMAIL PROTECTED]> writes: >> >>> Forth seems better than basic, but is *weird* (I tried it for a >>> while). I'm not sure going from Forth to C (or Python) w

Re: Is this a good use for lambda

2004-12-19 Thread Fredrik Lundh
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 to be used in one place. Ahem. If you name the fun

Re: BASIC vs Python

2004-12-19 Thread Mike Meyer
Dennis Lee Bieber <[EMAIL PROTECTED]> writes: > After all, AREXX was the "VBA" of the Amiga... My first real > Python program worked with an AREXX script to handle outgoing email That's funny. My mail reader on the Amiga was an Arexx script driving the Thinker hypertext engine. It slurped u

Re: Is this a good use for lambda

2004-12-19 Thread Steven Bethard
Walter S. Leipold wrote: I've used lambda from time to time, but only socially, and I can quit any time I want... +1 QOTW Steve -- http://mail.python.org/mailman/listinfo/python-list

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

2004-12-19 Thread Mike Meyer
Nick Craig-Wood <[EMAIL PROTECTED]> writes: > It would be nice if setdefault didn't evaluate the second argument > unless it needed it. However I guess it would have to be a language > feature to do that. Personally, I'd love a language feature that let you create a function that didn't evaluate

Web forum (made by python)

2004-12-19 Thread Gezer Punta
hi all I am looking for a forum which was produced by python link pls -- http://mail.python.org/mailman/listinfo/python-list

Re: A completely silly question

2004-12-19 Thread Mike Meyer
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 eit

Re: BASIC vs Python

2004-12-19 Thread Jan Dries
Andrew Dalke wrote: [snip] It looks like FMOD/PySonic is the closest to what I'm thinking of, and Snack coming in second. I didn't look too deeply. Most of them only play sound clips (mp3, wav, etc.) and don't have a way to specify what notes to play. If you just want to play notes, you could loo

Re: BASIC vs Python

2004-12-19 Thread Fredrik Lundh
Andrew Dalke wrote: > That is, I'm looking for something that would have let me > (were I 20 years younger and just starting to program) > do one of the "songs" I made in the early 1980s where I > generated notes at random. It was something like: > > randomize > for i=1 to 1000 do >call sou

late evaluation of function arguments (WAS: expression form of one-to-many dict?)

2004-12-19 Thread Steven Bethard
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. You can fake it with generator expresions: . >>> class C(objec

Re: python & nurbs

2004-12-19 Thread M.E.Farmer
Be sure to check the Blender forums before you give up, I recall someone working on that very thing maybe a year or so ago, but maybe my memory fuse is blown ;) M.E.Farmer Jelle Feringa // EZCT / Paris wrote: > > Have you looked at Blender (http://www.blender3d.com)?? > > Blender seems very promi

Re: Language fluency (was Re: BASIC vs Python)

2004-12-19 Thread Aahz
In article <[EMAIL PROTECTED]>, Keith Dart <[EMAIL PROTECTED]> wrote: >Aahz wrote: >> >> In fact, in some ways my fluency has degenerated now that I'm >> focusing on writing code for production. > >I'm curious about that last statement. Are you saying that if you >write, full time, code for "produ

Re: How about "pure virtual methods"?

2004-12-19 Thread John Machin
Alex Martelli wrote: > John Machin <[EMAIL PROTECTED]> wrote: >... > > 6. Alex's magnum opus appears to operate on problem a, and maybe on b > > (it's over my head). It involves a fair chunk of mucking about -- for > > A dozen lines of code to write *ONCE* and put in your utilities module > is

Re: BASIC vs Python

2004-12-19 Thread Andrew Dalke
Dennis Lee Bieber wrote: >for the A above middle-C... The other A's would be: 55, > 110, 220, (440), 880, 1760... And for a while I had the first few digits of the 12th root of 2 memorized. > Granted... But it seemed the starting complaint was that Python > -- a language that tries

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

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

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

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

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

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

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

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

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

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

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

  1   2   >