Re: Need Simple Way To Determine If File Is Executable

2006-12-15 Thread Tim Roberts
Tim Daneliuk <[EMAIL PROTECTED]> wrote: > >This seems to work, at least approximately: > > os.stat(selected)[ST_MODE] & (S_IXUSR|S_IXGRP|S_IXOTH > >It probably does not catch every single instance of something >that could be considered "executable" because this is a sort >of fluid thing in Window

Re: Over my head with descriptors

2006-12-15 Thread Tim Roberts
"Sarcastic Zombie" <[EMAIL PROTECTED]> wrote: > >Code included below. > >Basically, I've created a series of "question" descriptors, which each >hold a managed value. This is so I can implement validation, and render >each field into html automatically for forms. > >My problem is this: every instan

Re: merits of Lisp vs Python

2006-12-15 Thread greg
André Thieme wrote: > The <=> is called cmp in Python. > In Lisp it is called signum. The Lisp function has in general the > advantage that it keeps type information. > While Pythons cmp returns either -1, 0 or 1 the Lisp version can > also return -1.0 and 1.0 and also complex numbers: > (signum #

Re: merits of Lisp vs Python

2006-12-15 Thread greg
[EMAIL PROTECTED] wrote: > Then bring in more statement and you either have to > remember precedence rules (I can never remember those) or add some > parenthesis (oops!). Probably you've been burned by C, which has a ridiculously large number of precedence levels -- I don't know *anyone* who can r

Re: merits of Lisp vs Python

2006-12-15 Thread greg
André Thieme wrote: > So instead of > cmp(foo(a, b, c), bar(x, y, z)) you would prefer > foo(a, b, c) cmp bar(x, y, z) ? Incidentally, someone once came up with an fiendishly clever hack that lets you write things in Python like foo(a, b, c) |kmp| bar(x, y, z) i.e. effectively define your ow

Re: merits of Lisp vs Python

2006-12-15 Thread greg
André Thieme wrote: > The thing with most (if not all) programming languages other than Lisp > is: these abstractions are leaky. > They have a low level knowledge leak. Users of aif need to know how to > pass in arguments. As you see he had do embed the code that needs execution > into a block (an

Re: merits of Lisp vs Python

2006-12-15 Thread greg
André Thieme wrote: > (aif (timeConsumingCalculation) > (use it)) I think the answer is that you just wouldn't do that in Python at all. Having magic variables spring into existence in your local namespace as a side effect of calling something is just not Pythonic. (It is very Perlish, on th

Re: merits of Lisp vs Python

2006-12-15 Thread greg
Ken Tilton wrote: > I think your brain is stuck on flaming. Sorry, I didn't mean to come across as flaming, far from it. I'll take a deep breath before posting from now on, I promise. :-) > I did explain the last little fun bit (where reverse code miraculously > got a case-specific "signed-valu

Re: merits of Lisp vs Python

2006-12-15 Thread Ken Tilton
greg wrote: > Ken Tilton wrote: > >> McCarthy: "Is code also data in Python?" >> Norvig: "No." > > > I don't think that was the right answer. Norvig is a smart guy. He was talking to John McCarthy. He gave the right answer. :) > He should have > said "Yes", and then shown McCarthy eval() an

Re: tuple.index()

2006-12-15 Thread Hendrik van Rooyen
"Christoph Zwerschke" <[EMAIL PROTECTED]> wrote: > I don't think it's a problem of false logic but the problem that > "homogenous data" is not defined. > > We probably agree that it usually makes perfect sense to use tuples for > coordinates. But in certain mathematical algorithms it also makes s

Re: Roundtrip SQL data especially datetime

2006-12-15 Thread Leo Kislov
John Nagle wrote: > Routinely converting MySQL DATETIME objects to Python "datetime" > objects isn't really appropriate, because the MySQL objects have a > year range from 1000 to , while Python only has the UNIX range > of 1970 to 2038. You're mistaken. Python datetime module excepts year

Re: Roundtrip SQL data especially datetime

2006-12-15 Thread John Nagle
dyork wrote: > "John Machin" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > I was looking for a constructor that was the complement of str(). Most/many > languages would provide that. Sometimes it's called parse(). > > >>The constructor is datetime.datetime(year, ., second)

SINGAPORE PRIVATE CONDO / APT FOR SALE / Singapore New Upcoming Residential Projects

2006-12-15 Thread Spytips
SINGAPORE PRIVATE CONDO / APT FOR SALE / Singapore New Upcoming Residential Projects CONDO BUY , SELL , RENT , INVEST YOUR PROPERTY . CALL MINDY ( +65 ) 91002985 [EMAIL PROTECTED] www.mindyyong.com www.hotvictory.com www.hotvictory.com/singaporeproperty.htm Singapore New Upcoming Residential P

Re: convert from date string to epoch

2006-12-15 Thread Amit Khemka
On 12/16/06, Stefan Antonelli <[EMAIL PROTECTED]> wrote: > Hi, > > i have to convert several timestamps. The given format, eg "-mm-dd > hh:mm:ss" > has to be converted to an epoch string. Is there any proper way to do this? > > If not, i have to split the given string and resolve this by a cal

Re: Roundtrip SQL data especially datetime

2006-12-15 Thread Frank Millman
dyork wrote: > When getting data from a database using the dbapi and an SQL query, how do > you in general round trip the data? Especially date-time? > This is what I do. I am posting this partly because I hope it helps, partly because it is a bit clunky and I would appreciate suggestions for imp

Re: merits of Lisp vs Python

2006-12-15 Thread greg
Ken Tilton wrote: > McCarthy: "Is code also data in Python?" > Norvig: "No." I don't think that was the right answer. He should have said "Yes", and then shown McCarthy eval() and exec. Code isn't quite as *convenient* to work with as data in Python as it is in Lisp, but that doesn't mean it can

Re: Serial port failure

2006-12-15 Thread Leo Kislov
Rob wrote: > try: > response = p.readline() > except SerialException: > print ">Timed out<" > try: > port.writelines(msg) > except OSError: > print "Serial port failure. Power cycle units" > port.close()

Re: convert from date string to epoch

2006-12-15 Thread Paul Watson
Stefan Antonelli wrote: > Hi, > > i have to convert several timestamps. The given format, eg "-mm-dd > hh:mm:ss" > has to be converted to an epoch string. Is there any proper way to do this? > > If not, i have to split the given string and resolve this by a calculation? > > Thanks for help.

Re: Roundtrip SQL data especially datetime

2006-12-15 Thread Carsten Haese
On Sat, 2006-12-16 at 04:27 +, dyork wrote: > "John Machin" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > I suppose it all depends on your definition of obvious :-) > I was looking for a constructor that was the complement of str(). Most/many > languages would provide that

Re: Serial port failure

2006-12-15 Thread Rob
Leo, I like your tuple idea. I will implement it. The ack and nak both have the same format, namely: "Id Ack" or "Id Nak" rob On Dec 15, 4:34 pm, "Leo Kislov" <[EMAIL PROTECTED]> wrote: > Rob wrote: > > Hi all, > > > I am fairly new to python, but not programming and embedded. I am > > having

Re: tuple.index()

2006-12-15 Thread James Stroud
Christoph Zwerschke wrote: > Maybe there would be less dispute if this dogma/convention(?) "Tuples > are for heterogeneous data, list are for homogeneous data" would be > written down somewhere in the tutorial, reference or in PEP8, so people > would be aware of it. This is a good idea. It has

Re: Roundtrip SQL data especially datetime

2006-12-15 Thread dyork
"John Machin" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I suppose it all depends on your definition of obvious :-) I was looking for a constructor that was the complement of str(). Most/many languages would provide that. Sometimes it's called parse(). > The constructor is da

Re: merits of Lisp vs Python

2006-12-15 Thread Paul Rubin
Kirk Sluder <[EMAIL PROTECTED]> writes: > Personally, I've always preferred use the imperative to describe > basic math rather than the passive. This would seem to map better to > RPN than infix. For writing down complicated, nested expressions too? That's very unusual. E.g. n! = (n/e)**n

Re: Roundtrip SQL data especially datetime

2006-12-15 Thread dyork
Thanks Gabriel, but when I said "round trip" I really did mean: convert all the way to string and all the way back again, so your kind advice is not all that helpful. I need string to get to a non-Python object or a Web page. DY "Gabriel Genellina" <[EMAIL PROTECTED]> wrote in message news:[EM

Re: tuple.index()

2006-12-15 Thread James Stroud
Simon Brunning wrote: > So, you can infer no semantic meaning from an items position in the list. [...] > The fact that an item is the nth item is a tuple *means* something. Wouldn't it be nice, then, to find out where something is in a tuple so that one could infer semantic meaning from its po

Re: merits of Lisp vs Python

2006-12-15 Thread Kirk Sluder
In article <[EMAIL PROTECTED]>, Paul Rubin wrote: > Don't be silly. Some operators are more natural as infix and others > as functions. It's just like in natural language. People have an > innate ability to make such distinctions and it's fine for a > programming lang

Re: automatically grading small programming assignments

2006-12-15 Thread Andrew Sackville-West
On Fri, Dec 15, 2006 at 06:44:37AM +, Dennis Lee Bieber wrote: > On Thu, 14 Dec 2006 12:27:07 -0500, Brian Blais <[EMAIL PROTECTED]> > declaimed the following in gmane.comp.python.general: > > > > I envision a number of possible solutions. In one solution, I provide a > > function > > temp

[ANN] IronPython Community Edition r5

2006-12-15 Thread Sanghyeon Seo
This is the fifth release of IronPython Community Edition (IPCE). You can download it from SourceForge. http://sourceforge.net/projects/fepy FePy project aims to provide enhancements and add-ons for IronPython. Visit the project homepage for more informations. http://fepy.sourceforge.net/ Binary

Re: Designing a cancellable function

2006-12-15 Thread Gabriel Genellina
At Friday 15/12/2006 22:20, Leo Breebaart wrote: I have written a function foo() that iterates over and processes a large number of files. The function should be available to the user as library function, via a command-line interface, and through a GUI. So, I added a 'config' object as a parame

Re: merits of Lisp vs Python

2006-12-15 Thread Paul Rubin
André Thieme <[EMAIL PROTECTED]> writes: > >> How complicated ss it to say "cmp(a, b)" compared to "a cmp b"? > > It gets worse when the expressions are nested. > > So instead of > cmp(foo(a, b, c), bar(x, y, z)) you would prefer > foo(a, b, c) cmp bar(x, y, z) ? Don't be silly. Some operators

Re: merits of Lisp vs Python

2006-12-15 Thread André Thieme
Paul Rubin schrieb: > André Thieme <[EMAIL PROTECTED]> writes: >> And I didn't count the indentation level and \n in Python code. >> Why should I? They are editor commands. > > No they're part of Python syntax. A change in indent level is > recognized by Python's lexical scanner as a token and yo

Re: merits of Lisp vs Python

2006-12-15 Thread Paul Rubin
André Thieme <[EMAIL PROTECTED]> writes: > > But there would be even more tokens, the lines going between the > > nodes > > in the trees, for example. > > These are painted by the editor. If you have to tell the editor where to put them, they are tokens. -- http://mail.python.org/mailman/listinf

Re: Designing a cancellable function

2006-12-15 Thread Michele
Hi Leo, what about one (or more) thread(s) which run the eat() method of FilesEater object with inheriths from a superclass what's needed to update the progress attribute (for example a _inc_progress() private method)? (So you can have a UrlEater class and so on, them all knowing how to update the

Re: merits of Lisp vs Python

2006-12-15 Thread André Thieme
Paul Rubin schrieb: > André Thieme <[EMAIL PROTECTED]> writes: >> Lisp has no parens. An editor could support a mode where code >> is displayed in written in trees. There wouldn't be a single paren. > > But there would be even more tokens, the lines going between the nodes > in the trees, for exam

Re: Quake 3 and the Python interpreter

2006-12-15 Thread Mathias Panzenboeck
Neil Toronto wrote: > > 2) Is there any way to restrict Python modules from accessing files > outside of a sandbox? > As far as I heard, there is no really working way. But maybe that has changed in python 2.5? Or it will in 3.0? I dunno. -- http://mail.python.org/mailman/listinfo/python-list

Re: convert from date string to epoch

2006-12-15 Thread John Machin
Stefan Antonelli wrote: > Hi, > > i have to convert several timestamps. The given format, eg "-mm-dd > hh:mm:ss" > has to be converted to an epoch string. What is an "epoch string"? > Is there any proper way to do this? > > If not, i have to split the given string and resolve this by a calc

Designing a cancellable function

2006-12-15 Thread Leo Breebaart
I have written a function foo() that iterates over and processes a large number of files. The function should be available to the user as library function, via a command-line interface, and through a GUI. So, I added a 'config' object as a parameter to foo() that can be used by the caller to expli

Re: No latin9 in Python?

2006-12-15 Thread Martin v. Löwis
Christoph Zwerschke schrieb: > Shall I proceed writing such a patch? Shall I also add latin0 and l0 > which are other inofficial aliases? Sure, go ahead. I see no need for the latin0/l0 aliases, though: they predate the formal adoption of iso-8859-15, and should be phased out by now (I'm sure that

Re: Python Interactive Interpreter Breakage

2006-12-15 Thread Simon Eves
Simon Eves wrote: I am trying to write a Python module to embed the functionality of Maya (the 3D modelling and animation application from Autodesk, formerly Alias) for doing scripted scene manipulation and rendering processes in Python. Here are both versions of the code, in case what I wrote

Re: concatenating strings

2006-12-15 Thread Caleb Hattingh
Hi Erich If you're going to be doing a lot of string substitution, you should look at the Templating support in the library: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/304005 and (a little bit fancier): http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/335308 Regards Caleb

Python Interactive Interpreter Breakage

2006-12-15 Thread Simon Eves
I am trying to write a Python module to embed the functionality of Maya (the 3D modelling and animation application from Autodesk, formerly Alias) for doing scripted scene manipulation and rendering processes in Python. I am aware of the CGKit project, which does this and a lot more, but it is ove

convert from date string to epoch

2006-12-15 Thread Stefan Antonelli
Hi, i have to convert several timestamps. The given format, eg "-mm-dd hh:mm:ss" has to be converted to an epoch string. Is there any proper way to do this? If not, i have to split the given string and resolve this by a calculation? Thanks for help. Stefan. -- http://mail.python.org/mailm

Re: Has comparison of instancemethods changed between python 2.5 and 2.4?

2006-12-15 Thread Frank Niessink
Fredrik Lundh: > Frank Niessink wrote: > > > However, the instance the two methods belong to are different, i.e. > > id(callback) returns different values for the two methods. > > are you using the *object* as the callback? otherwise, that sentence > doesn't make much sense; You are right,

Re: CLPython (was Re: merits of Lisp vs Python)

2006-12-15 Thread Paul Rubin
[EMAIL PROTECTED] writes: > > a = 'hello' > > a[0] = 'H' # attempt to change first letter to upper case > > As CLPython mirrors Python semantics, this results in a TypeError. The > internal representation of an immutable Python string is a mutable Lisp > string, but there is no way you can a

Re: merits of Lisp vs Python

2006-12-15 Thread Paul Rubin
André Thieme <[EMAIL PROTECTED]> writes: > Lisp has no parens. An editor could support a mode where code > is displayed in written in trees. There wouldn't be a single paren. But there would be even more tokens, the lines going between the nodes in the trees, for example. -- http://mail.python.

Re: merits of Lisp vs Python

2006-12-15 Thread Paul Rubin
André Thieme <[EMAIL PROTECTED]> writes: > And I didn't count the indentation level and \n in Python code. > Why should I? They are editor commands. No they're part of Python syntax. A change in indent level is recognized by Python's lexical scanner as a token and you should count it. You wouldn

Re: Serial port failure

2006-12-15 Thread Leo Kislov
Rob wrote: > Hi all, > > I am fairly new to python, but not programming and embedded. I am > having an issue which I believe is related to the hardware, triggered > by the software read I am doing in pySerial. I am sending a short > message to a group of embedded boxes daisy chained via the seri

Re: merits of Lisp vs Python

2006-12-15 Thread William James
André Thieme wrote: > [EMAIL PROTECTED] schrieb: > William James schrieb: > >>> How would you solve this in Python? > >>> You could embed it inside a lambda and must somehow make the > >>> variable "it" visible in it, because in the context of aif this > >>> "it" gets bound to the result.In Rub

Re: Metaclass uses?

2006-12-15 Thread Mike C. Fletcher
Nathan Harmston wrote: > Hi, > > Recently I posted a question about the factory pattern in python. I ve > implemented this following one of the ideas posted. After some reading > I ve seem a lot of Aspect Oriented Programming mentioned but I m not > really sure what it is. > > Can anyone help me un

Re: merits of Lisp vs Python

2006-12-15 Thread Slawomir Nowaczyk
On Fri, 15 Dec 2006 17:21:12 +0100 André Thieme <[EMAIL PROTECTED]> wrote: #> And we might go further (again with an easy Graham example). #> See this typical pattern: #> #> result = timeConsumingCalculation() #> if result: #>use(result) #> #> We need this ugly temporary variable result to r

Metaclass uses?

2006-12-15 Thread Nathan Harmston
Hi, Recently I posted a question about the factory pattern in python. I ve implemented this following one of the ideas posted. After some reading I ve seem a lot of Aspect Oriented Programming mentioned but I m not really sure what it is. Can anyone help me understand how metaclasses can improve

Re: merits of Lisp vs Python

2006-12-15 Thread André Thieme
[EMAIL PROTECTED] schrieb: William James schrieb: >>> How would you solve this in Python? >>> You could embed it inside a lambda and must somehow make the >>> variable "it" visible in it, because in the context of aif this >>> "it" gets bound to the result.In Ruby: >> def aif val >> yield v

Re: aggdraw for 2.5 on WinXP?

2006-12-15 Thread rzed
Stéphane Muller <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > rzed a écrit : >> Has anyone generated an aggdraw installer or aggdraw.pyd for >> Python 2.5 (WinXP)? If so, could it be made available for those >> of us who don't have a working compiler? >> > Hello, > > You can try > > h

Re: Serial port failure

2006-12-15 Thread Rob
I have been modifying the code today, tracing through it and trying to make it more robust and implement data hiding. That way as someone reads through my main they will see intuitively what I am doing. For that reason I went back and added a filename parameter to OpenPort. The reason I am clos

Re: Serial port failure

2006-12-15 Thread Grant Edwards
On 2006-12-15, hg <[EMAIL PROTECTED]> wrote: >> Here is OpenPort >> >> >> OpenPort procedure >> >> def OpenPort(name): >> BRate = 19200 >> Tout =

Re: Serial port failure

2006-12-15 Thread Rob
Craig, In the embedded firmware, the each box re-transmits after it finishes reading the packet. This is a very rudimentary system, and uses no flow control. The topology is that each embedded box has a master and a slave port. The master is used to receive data from the upstream box, and send

Re: Serial port failure

2006-12-15 Thread hg
Rob wrote: > Here is OpenPort > > > OpenPort procedure > > def OpenPort(name): > BRate = 19200 > Tout = 3 > > try: > # Initialize th

Re: Serial port failure

2006-12-15 Thread Rob
Here is OpenPort OpenPort procedure def OpenPort(name): BRate = 19200 Tout = 3 try: # Initialize the port p = serial.Serial(n

Re: merits of Lisp vs Python

2006-12-15 Thread William James
André Thieme wrote: > William James schrieb: > > André Thieme wrote: > >> William James schrieb: > >> > >>> def nif num, pos, zero, neg > >>> send( num>0 ? pos : (num==0 ? zero : neg) ) > >>> end > >> btw, your nif body is built out of 13 tokens, so more > >> complicated than the Python version.

Re: merits of Lisp vs Python

2006-12-15 Thread William James
André Thieme wrote: > Paul Rubin schrieb: > > André Thieme <[EMAIL PROTECTED]> writes: > >> and the Lisp version has only 9: > >> nth, 1+, truncate, signum, num, list, pos, zero, neg > > > > Oh come on, you have to count the parentheses too. > > We could define hundreds of way how to count tok

Re: skip last line in loops

2006-12-15 Thread Peter Otten
James Stroud wrote: > Fredrik Lundh wrote: >> James Stroud wrote: >> >>> See the documentation for xreadlines. >> >> why? >> >> > 5.16 xreadlines -- Efficient iteration over a file http://www.python.org/dev/peps/pep-0004/ The cheat sheet for the effbot quiz :-) Peter -- http://mail.python

Re: merits of Lisp vs Python

2006-12-15 Thread André Thieme
William James schrieb: > André Thieme wrote: >> William James schrieb: >> >>> def nif num, pos, zero, neg >>> send( num>0 ? pos : (num==0 ? zero : neg) ) >>> end >> btw, your nif body is built out of 13 tokens, so more >> complicated than the Python version. >> >> >> André >> -- > > def nif num,

distutils - rpm

2006-12-15 Thread [EMAIL PROTECTED]
When I try to create an rpm using distutils, I get an error like this: error: Installed (but unpackaged) file(s) found: /usr/share/games/pychess/sidepanel/bookPanel.pyc /usr/share/games/pychess/sidepanel/bookPanel.pyo ... I found this solution http://www.mail-archive.com/distutils-sig@pyt

Re: merits of Lisp vs Python

2006-12-15 Thread William James
André Thieme wrote: > William James schrieb: > > > def nif num, pos, zero, neg > > send( num>0 ? pos : (num==0 ? zero : neg) ) > > end > > btw, your nif body is built out of 13 tokens, so more > complicated than the Python version. > > > André > -- def nif num, *args send args[ 1 + (0 <=> num

arrayType vs. typedArrayType?

2006-12-15 Thread tobiah
I hope no one minds my trying my question again in a more concise way: Using SOAPpy call, if I return [[1,2],[3,4]] from the server, I get back: : ['1', '2', '3', '4'] typedArrayType, and it flattened out my list of lists. But if I add some other type to the array: [1,[1,2],[3,4]] I get back so

Re: skip last line in loops

2006-12-15 Thread James Stroud
Fredrik Lundh wrote: > James Stroud wrote: > >> See the documentation for xreadlines. > > why? > > > > > 5.16 xreadlines -- Efficient iteration over a file -- http://mail.python.org/mailman/listinfo/python-list

converting mysql db into sqlite3.

2006-12-15 Thread chun ping wang
hi, i have a simple problem of opening an existing mysql database with sqlite3. Is it possible? (I have an instinct that it is), however i don';t know the most easiest and straight forward approach to do so. Thanks for the help.

Re: merits of Lisp vs Python

2006-12-15 Thread André Thieme
greg schrieb: > [EMAIL PROTECTED] wrote: >> Adding parentheses ... all this is a >> burden specific to Python. > > As opposed to Lisp, where all you have to do is > use parentheses... oh, er... Lisp has no parens. An editor could support a mode where code is displayed in written in trees. There

Re: tuple.index()

2006-12-15 Thread Nick Maclaren
In article <[EMAIL PROTECTED]>, "Tim Golden" <[EMAIL PROTECTED]> writes: |> [Christoph Zwerschke] |> |> > And can somebody explain what is exactly meant with |> > "homogenous data"? |> |> This seems to have been explained a few times |> recently :) Basically, if you have a "list of xs" |> and re

Re: About alternatives to Matlab

2006-12-15 Thread sturlamolden
Jon Harrop wrote: > Can convolution be implemented efficiently in Python? numpy.convolve > Functional programming makes this easy. You just compose closures from > closures instead of arrays from arrays. Indeed. But learning yet another language is too much work. > This is what I meant by o

Re: Serial port failure

2006-12-15 Thread hg
Rob wrote: > Hi all, > > I am fairly new to python, but not programming and embedded. I am > having an issue which I believe is related to the hardware, triggered > by the software read I am doing in pySerial. I am sending a short > message to a group of embedded boxes daisy chained via the ser

Re: About alternatives to Matlab

2006-12-15 Thread sturlamolden
Jon Harrop wrote: > Yes. Non-sequential access is hugely expensive these days, and bounds > checking is virtually free. So that's one less reason to use C/C++... ;-) The lifiting scheme is sequential. -- http://mail.python.org/mailman/listinfo/python-list

Re: (newbie) class with a single instance ?!

2006-12-15 Thread Fredrik Lundh
Andrea Tomadin wrote: > I run a program which does some logging on files. I want to collect > all the filenames and handlers in the same structure. All the files > should be opened at startup, closed at exit, and easily accessed by > the rest of the script. open them at the module level, an

Re: Roundtrip SQL data especially datetime

2006-12-15 Thread John Machin
dyork wrote: > When getting data from a database using the dbapi and an SQL query, how do > you in general round trip the data? Especially date-time? > > An SQL datetime column translates nicely into a Python datetime (surprise), > which then translates into a string like '2005-08-03 07:32:48'. It

Re: (newbie) class with a single instance ?!

2006-12-15 Thread Kleine Aap
Andrea Tomadin wrote: > This works, but isn't it weird to define a class if I know from the > very beginning that there will be no more than an instance of that > class? Singleton http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52558 -- http://mail.python.org/mailman/listinfo/python-lis

Re: merits of Lisp vs Python

2006-12-15 Thread Neil Cerutti
On 2006-12-15, André Thieme <[EMAIL PROTECTED]> wrote: > In Lisp it is like an IF and represents exactly what we think. > IF in Lisp: > (if expr > (then-part) > (else-part)) > > nif in Lisp: > (nif expr > (positive-part) > (zero-part) > (negative-part)) > > It looks as i

(newbie) class with a single instance ?!

2006-12-15 Thread Andrea Tomadin
Hi, I need a suggestion on the better implementation for a very basic task. I run a program which does some logging on files. I want to collect all the filenames and handlers in the same structure. All the files should be opened at startup, closed at exit, and easily accessed by the rest of

Re: Serial port failure

2006-12-15 Thread drake
[EMAIL PROTECTED] wrote: ..snip> > In the second iteration of your loop, you appear to be opening a port > that is already open: > > for i in range(3): > port = OpenPort() > > thus the error message: "the serial port is unavailable". > > --Drake Smith Skip that -- I didn't not

Re: CLPython (was Re: merits of Lisp vs Python)

2006-12-15 Thread metawilm
Paul Rubin wrote: > I thought it was of some interest though I'm a little surprise by the > choice of CL rather than Scheme as a target. In many aspects Python is a subset of CL. In CLPython, exceptions are Lisp conditions with a custom metaclass (strictly spoken not portable CL), Python (meta)cla

Re: merits of Lisp vs Python

2006-12-15 Thread André Thieme
William James schrieb: > def nif num, pos, zero, neg > send( num>0 ? pos : (num==0 ? zero : neg) ) > end btw, your nif body is built out of 13 tokens, so more complicated than the Python version. André -- -- http://mail.python.org/mailman/listinfo/python-list

Re: Serial port failure

2006-12-15 Thread drake
Rob wrote: > Hi all, > > I am fairly new to python, but not programming and embedded. I am > having an issue which I believe is related to the hardware, triggered > by the software read I am doing in pySerial. I am sending a short > message to a group of embedded boxes daisy chained via the seria

Re: merits of Lisp vs Python

2006-12-15 Thread André Thieme
William James schrieb: I suppose that is Ruby code. So my statement was correct when I said: "In some languages it would look a bit cleaner, for example Ruby." This is because it has a minimal syntax for "lambda". > def p > puts "very positive" > "positive" > end > def z > puts "no no" >

Re: Restrictive APIs for Python

2006-12-15 Thread Gabriel Genellina
On 15 dic, 13:46, "Will Ware" <[EMAIL PROTECTED]> wrote: > Gabriel Genellina wrote: > > In Python, the usual way of saying "don't play with me" is prepending > > an underscore: _private > Thanks, I am familiar with that. So enforce it instead of going against the nature of the language. > > BTW, h

Re: I'm looking for a pythonic red-black tree...

2006-12-15 Thread emin . shopper
You could try and wrap the C/C++ code at http://web.mit.edu/~emin/www/source_code/index.html and make a python extension... On Dec 14, 8:20 pm, "Just Another Victim of the Ambient Morality" <[EMAIL PROTECTED]> wrote: > I need a red-black tree in Python and I was wondering if there was one > bu

Re: Serial port failure

2006-12-15 Thread Nick Craig-Wood
Rob <[EMAIL PROTECTED]> wrote: > I am fairly new to python, but not programming and embedded. I am > having an issue which I believe is related to the hardware, triggered > by the software read I am doing in pySerial. I am sending a short > message to a group of embedded boxes daisy chained v

Re: merits of Lisp vs Python

2006-12-15 Thread André Thieme
Neil Cerutti schrieb: > That's not a real difficulty, is it? > > CL-USER> (mapcar #'(lambda (x) >(funcall (nif x p z n))) >'(0 2.5 -8)) Didn't you forget the #' before p, z and n? >> CL-USER> (mapcar #'(lambda (x) >>(nif x (p) (z) (n))) >

Re: merits of Lisp vs Python

2006-12-15 Thread William James
André Thieme wrote: > greg schrieb: > > Ken Tilton wrote: > > > >> The reason I post macro expansions along with examples of the macro > >> being applied is so that one can see what code would have to be > >> written if I did not have the defskill macro to "write" them for me. > > > > It seems to m

Re: parsing a dictionary from a string

2006-12-15 Thread Fredrik Lundh
Benjamin Georgi wrote: > I could use some help extracting the keys/values of a list of > dictionaries from a string that is just the str() representation of the > list (the problem is related to some flat file format I'm using for file > IO). > > Example: > >>> s = str(dict_list) > >>> s > '

Re: parsing a dictionary from a string

2006-12-15 Thread Tim Williams
On 15/12/06, Benjamin Georgi <[EMAIL PROTECTED]> wrote: > Hello list, > > I could use some help extracting the keys/values of a list of > dictionaries from a string that is just the str() representation of the > list (the problem is related to some flat file format I'm using for file > IO). > > Exa

How Micro-pump will change the future of computer/ mobile chips.

2006-12-15 Thread studyandjobs
How Micro-pump will change the future of computer/ mobile chips. Engineers at Purdue University have developed a tiny "micro-pump" cooling device small enough to fit on a computer chip that circulates coolant through channels etched into the chip. . For detail http://www.studyandj

Re: Common Python Idioms

2006-12-15 Thread Kent Johnson
Fredrik Lundh wrote: > Stephen Eilert wrote: > >> I do think that, if it is faster, Python should translate >> "x.has_key(y)" to "y in x". > > http://svn.python.org/view/sandbox/trunk/2to3/fix_has_key.py?view=markup Seems to have moved to here: http://svn.python.org/view/sandbox/trunk/2to3/fixes

Re: Has comparison of instancemethods changed between python 2.5 and 2.4?

2006-12-15 Thread Fredrik Lundh
Frank Niessink wrote: > However, the instance the two methods belong to are different, i.e. > id(callback) returns different values for the two methods. are you using the *object* as the callback? otherwise, that sentence doesn't make much sense; bound methods are generated on the fly, and th

Pychecker

2006-12-15 Thread Okko Willeboordse
I execfile some script from another script like below i = 5 execfile(script) script uses i Running script standalone as well as running script through pychecker is not possible because script expects i I still need to run script through pychecker. I must do that from the calling script since

Re: Has comparison of instancemethods changed between python 2.5 and 2.4?

2006-12-15 Thread Fredrik Lundh
Thomas Heller wrote: > It seems so: > > python -c "o = object(); print o.__str__ == o.__str__" > > prints True with Python 2.5, and False with Python 2.4. that's not an instance method, though: >>> o = object() >>> type(o.__str__) using a real instance method, I get the same result under

Re: reloading modules

2006-12-15 Thread Kent Johnson
Dustan wrote: > [EMAIL PROTECTED] wrote: >> I'm using python.exe to execute my modules. I have a music.py module >> which contains my classes and a main.py module which uses these >> classes. In python.exe, I call "import main" to execute my program. The >> problem is that I have to close python an

Re: Property error

2006-12-15 Thread George Sakkis
king kikapu wrote: > Your example Dennis, work as expected. I understand the mistake i have > made. But when i try to fix the original code usihn @property now, it > gives me the same error. > So, here it is: > > class Person(object): > _age = 0 > > @property > def age(): > def

Re: Need Simple Way To Determine If File Is Executable

2006-12-15 Thread Tim Daneliuk
Tim Golden wrote: > [Tim Daneliuk] >> I have a program wherein I want one behavior when a file is >> set as executable and a different behavior if it is not. Is >> there a simple way to determine whether a given named file is >> executable that does not resort to all the lowlevel ugliness >> of os

Re: Has comparison of instancemethods changed between python 2.5 and 2.4?

2006-12-15 Thread Thomas Heller
Frank Niessink schrieb: [...] > Now, with Python 2.5 (and not with Python 2.4) I have a callback that is > not being added to the list because, apparently, it compares equal to > some of the callbacks already in the list. However, the instance the two > methods belong to are different, i.e. id(

Re: Property error

2006-12-15 Thread George Sakkis
king kikapu wrote: > Your example Dennis, work as expected. I understand the mistake i have > made. But when i try to fix the original code usihn @property now, it > gives me the same error. > So, here it is: > > class Person(object): > _age = 0 > > @property > def age(): > def

Re: Property error

2006-12-15 Thread George Sakkis
king kikapu wrote: > Your example Dennis, work as expected. I understand the mistake i have > made. But when i try to fix the original code usihn @property now, it > gives me the same error. > So, here it is: > > class Person(object): > _age = 0 > > @property > def age(): > def

  1   2   3   >