Re: Defining classes

2006-12-15 Thread Michele Simionato
Steven Bethard wrote: > How are you doing it currently? Here's a sort of minimalist option: > > >>> class weeble(object): > ... def __metaclass__(name, bases, bodydict): > ... cls = type(name, bases, bodydict) > ... cls.wumpus = 'brinjal', cls > ...

Re: beginner, thread & else

2006-12-15 Thread Hendrik van Rooyen
"Fredrik Lundh" <[EMAIL PROTECTED]> wrote: > Gigs_ wrote: > > -- > > import thread > > the thread module should not be used directly by application programs; > use the "threading" module instead. Ooops! - I am doing this, for long running stuff. I was aware of

Re: automatically grading small programming assignments

2006-12-15 Thread Caleb Hattingh
Hi Brian You could make great use of XML-RPC here. XML-RPC is /really/ easy to use. Here is a simple example: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/81549 You put procedures on the server that will check the args against a the required result, and report back to the student w

Re: Need Simple Way To Determine If File Is Executable

2006-12-15 Thread Tim Golden
[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.stat() AND that is porta

Re: Writing and reading variables to/from flat file

2006-12-15 Thread Caleb Hattingh
Hi Kevin The other posters helped you with configParser, which is what you wanted, i.e. text file access. However, you can also get persistance really cheaply with pickling, if you don't need the saved data to be text-editable: (from memory) verboseSettings = {} verboseSettings['Detailed'] = '-

connect from windows to linux using ssh

2006-12-15 Thread puttaramakrishna
Hi Folks, How to connect from windows to linux using ssh without username/passwd. With this scenario, i need to write a program on python. Regards, Ramakrishna. -- http://mail.python.org/mailman/listinfo/python-list

Re: Validate XML against a set of XSD files, with Python

2006-12-15 Thread Sébastien Boisgérault
Stefan Behnel wrote: > RelaxNG support in libxml2 is pretty much perfect, BTW. The *potential* issue I mentioned before with Relax NG validation in libxml2 does *NOT* exist. I double-checked with Jing and my RelaxNG file was indeed incorrect ... (the "recursive reference outside elements" kind

Re: connect from windows to linux using ssh

2006-12-15 Thread Leo Kislov
[EMAIL PROTECTED] wrote: > Hi Folks, > > How to connect from windows to linux using ssh without username/passwd. > > With this scenario, i need to write a program on python. Use ssh library http://cheeseshop.python.org/pypi/paramiko -- Leo -- http://mail.python.org/mailman/listinfo/python-l

Re: merits of Lisp vs Python

2006-12-15 Thread xscottg
Ken Tilton wrote: > Andrew Reilly wrote: > > > That all looks like data. > > No, not reverse, the part you did not understand. I do not mean what the > code was doing, I meant that it was code. > Code is data is code - even in Python: skills_table = [ { "title": "Absolute Value", "annotati

Re: How do I edit a PythonWin path to import custom built modules???

2006-12-15 Thread mohan
BartlebyScrivener wrote: > Gabriel Genellina wrote: > > > > import sys > > print sys.path > > and see what's there. > > Yup. Did that before. That's what I mean. The d:\\python is there and > it doesn't come from the PythonPath in my windows registry. Maybe it > scans for any directory with python

Re: Conditional iteration

2006-12-15 Thread mystilleef
This why I prefer functional programming constructs for my list/sequence processing needs. is_true = lambda x: x > 0 map(process_list, filter(is_true, [-2, -1, 0, 1, 2, 3, 4]))

Re: How do I edit a PythonWin path to import custom built modules???

2006-12-15 Thread Gabriel Genellina
At Friday 15/12/2006 06:46, mohan wrote: To revert back to my question, I wanted to add a new path to my PythonWin IDE to access modules which are in folders other than normal python paths. Here, I need to put my modules in different folders since it is a request of the user. I tried to create

OT - Looking for DrPython project help

2006-12-15 Thread Franz Steinhaeusler
Sorry for posting that, if you are not intersted, please ignore my post. I'm looking for person(s), which are interested in testing and possibly bug fixing for DrPython (hosted on Sourceforge) in general and with a certain focus for Linux. Sometimes, texts in dialogs are not entirely visible, so

Re: merits of Lisp vs Python

2006-12-15 Thread David Steuber
Ken Tilton <[EMAIL PROTECTED]> writes: > Steven D'Aprano wrote: > > If that's the best example of what macros can be used for, frankly I'm > > unimpressed. > > We're shocked. Don't anyone tell him about LOOP. -- This post uses 100% post consumer electrons and 100% virgin photons. At 2.6 miles

Re: merits of Lisp vs Python

2006-12-15 Thread David Steuber
"Wolfram Fenske" <[EMAIL PROTECTED]> writes: > Paul Rubin writes: > > > "Wolfram Fenske" <[EMAIL PROTECTED]> writes: > >> Yes, I wrote about it in another post. It was introduced in Python > >> 2.5. And if it hadn't been I'd still have to write code like this. > > > >

Re: merits of Lisp vs Python

2006-12-15 Thread David Steuber
Steven D'Aprano <[EMAIL PROTECTED]> writes: > How am I being silly? Do you not believe that people write case blocks > with fifty tests? Okay, how about twenty? Ten? Eight? You should check out generic functions in CLOS. Rather than writing a ridiculously long case block, you can use EQL special

Re: Logging module: problem with some mapping keys

2006-12-15 Thread Tekkaman
On Dec 14, 6:41 pm, Peter Otten <[EMAIL PROTECTED]> wrote: > Tekkaman wrote: >> lib is a symlink to lib64 > So my initial diagnosis was correct. Unfortunately I can no longer recommend > that you remove the symlink... > Yes. What I really meant in my first reply was "it's not a symlink in the scr

Mail System Error - Returned Mail

2006-12-15 Thread severin
The message was not delivered due to the following reason(s): Your message could not be delivered because the destination computer was not reachable within the allowed queue period. The amount of time a message is queued before it is returned depends on local configura- tion parameters. Most like

Re: Conditional iteration

2006-12-15 Thread Gabriel Genellina
At Friday 15/12/2006 06:51, mystilleef wrote: This why I prefer functional programming constructs for my list/sequence processing needs. is_true = lambda x: x > 0 map(process_list, filter(is_true, [-2, -1, 0, 1, 2, 3, 4]))

Re: merits of Lisp vs Python

2006-12-15 Thread Robin Becker
Delaney, Timothy (Tim) wrote: > Ken Tilton wrote: > >>> But this is not a case where a function can't handle the job. >> Is, too. > > And Ken moves one step closer towards Python ... > http://www.google.com.au/search?q=monty+python+argument+sketch > > Tim Delaney is it time to mention the storm

Roundtrip SQL data especially datetime

2006-12-15 Thread dyork
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'. No problem with that

Re: Property error

2006-12-15 Thread king kikapu
>What version of Python? Most recent versions don't need the Hi, thanks for the help! I am using 2.5 version and i think i like more the @property decorator instead of the property(...) syntax. Is the code changing much using @property ?? Thanks again! -- http://mail.python.org/mailman/lis

concatenating strings

2006-12-15 Thread EHC
hello! since i am a py noob, please bear with me ; ) how is it possible to concat a string and an integer in a print-command? i've tried print "This robot is named %s. The current speed setting is %d, and %s has a lifetime of %d" % (self.name , self.speed , self.name) as well as print "This ro

Re: concatenating strings

2006-12-15 Thread Laurent Pointal
EHC a écrit : > hello! > > since i am a py noob, please bear with me ; ) > > how is it possible to concat a string and an integer in a > print-command? i've tried > > print "This robot is named %s. The current speed setting is %d, and %s > has a lifetime of %d" % (self.name , self.speed , self.n

Re: automatically grading small programming assignments

2006-12-15 Thread Brian Blais
Dan Bishop wrote: > On Dec 14, 8:36 pm, Brian Blais <[EMAIL PROTECTED]> wrote: >> [EMAIL PROTECTED] wrote: >>> [EMAIL PROTECTED] wrote: >>> Then on your PC you can run a script that loads each of such programs, and runs a good series of tests, to test their quality... >>> What happens if

Re: Property error

2006-12-15 Thread king kikapu
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 fget(self): return self._a

Re: Writing and reading variables to/from flat file

2006-12-15 Thread bearophileHUGS
Geoffrey Clements: > readfile = open('prefs').readlines() > for line in readfile: > print line > eval(line) > print Basic Instead of using eval, using a plain dict may be a better solution. Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: Logging module: problem with some mapping keys

2006-12-15 Thread Peter Otten
Tekkaman wrote: >> Putting /usr/lib64/python2.4 as the first entry into your >> >> PYTHONPATH >> >> environment variable might fix the problem (the idea is >> that /usr/lib64/python2.4 precedes /usr/lib/python2.4 in sys.path and is >> therefore used for the import of the logging package). > Thank

Re: concatenating strings

2006-12-15 Thread Erich Pul
thank you, i just plainly overlooked it ; ) now it works -- http://mail.python.org/mailman/listinfo/python-list

Re: merits of Lisp vs Python

2006-12-15 Thread greg
Gabriel Genellina wrote: > You can even make S = cT (c=ligth of speed in void space). > The choice of fundamental units is rather arbitrary, and can be reduced > further to only 1 fundamental unit and even NO fundamental units. I once heard mention of a system of units in use at one time with the

Re: merits of Lisp vs Python

2006-12-15 Thread greg
Ken Tilton wrote: > So this: > (defmethod tf-reverse (id (eql ',sub-id)) resx (drv-opnds tf drv)) > ,@reverser) > > becomes this: > > (defmethod tf-reverse ((id (eql ',sub-id)) tf drv > &aux (opnds (drv-opnds tf drv))) >(loop for resx in (results d

Re: merits of Lisp vs Python

2006-12-15 Thread greg
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 me your brain is somewhat stuck on the use of macros. You'

Re: merits of Lisp vs Python

2006-12-15 Thread greg
[EMAIL PROTECTED] wrote: > Neil Cerutti wrote: > >>On 2006-12-13, [EMAIL PROTECTED] >><[EMAIL PROTECTED]> wrote: >> >>>Expressions keep the same meaning even if you have to start >>>breaking them across lines, etc. >> >>Yes, it's the same way in Python. Of course, not everything is an >>expression

Re: merits of Lisp vs Python

2006-12-15 Thread greg
[EMAIL PROTECTED] wrote: > I wrote my first Python in a non-Python-aware editor, and somehow had > swapped tabs and spaces; when I moved it to IDLE---the indentation > *looked fine* but was invisibly weird. That can admittedly be a problem. It would help if the parser complained by default about m

Re: merits of Lisp vs Python

2006-12-15 Thread greg
[EMAIL PROTECTED] wrote: > Neil Cerutti wrote: > > > The parenthesis I added means I don't have > > to use the new-line escape character (\), either. > > Is this so unconscious that you don't recognize you are doing it, even > though you take a sentence to explain what you had to do to work aroun

Re: merits of Lisp vs Python

2006-12-15 Thread greg
Ken Tilton wrote: > What if it turns into an SQL lookup during refactoring? If the macro can produce SQL code, then whatever interprets the table can produce SQL code as well. If you're thinking of the macro taking apart the user's reverse function (rather than just wrapping it) and somehow tran

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

2006-12-15 Thread greg
Willem Broekema wrote: > I guess in part it's because there are not that many people really into > both Python and Lisp, and those who are might not find this an > interesting project because there is nothing "wow" to show, yet. Another reason (or maybe the reason for the reason) is that people a

Missing __length_hint__ in __getitem__ iterator

2006-12-15 Thread Giovanni Bajo
Hello, given the following object: >>> class A(object): ... def __getitem__(self, idx): ... if idx >= 10: raise IndexError ... return idx ... def __len__(self): ... return 10 ... I noticed that the iterator that Python constructs: >>> a = A() >>> i

Re: skip last line in loops

2006-12-15 Thread eight02645999
Fredrik Lundh wrote: > [EMAIL PROTECTED] wrote: > > > how can i skip printing the last line using loops (for /while) > > > > eg > > > > for line in open("file): > > print line. > > > > I want to skip printing last line of the file. > > do it lazily: > > last_line = None > for line i

Re: Property error

2006-12-15 Thread Peter Otten
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(): > d

Re: Missing __length_hint__ in __getitem__ iterator

2006-12-15 Thread Peter Otten
Giovanni Bajo wrote: > Hello, > > given the following object: > > >>> class A(object): > ... def __getitem__(self, idx): > ... if idx >= 10: raise IndexError > ... return idx > ... def __len__(self): > ... return 10 > ... > > I noticed that the itera

Re: Property error

2006-12-15 Thread Georg Brandl
Peter Otten wrote: > @decorator > def f(): ># ... > > is the same as > > def f(): > # ... > f = decorator(f()) ^^ Nope, f is not called here. (Think of staticmethod). Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: Property error

2006-12-15 Thread Rob Williscroft
king kikapu wrote in news:1166181267.949316.197360@ 16g2000cwy.googlegroups.com in comp.lang.python: > I am sure it is something very obvious Yes, property is *NOT* a decorator, it can only be used as a decorator in the one case that is mentioned in the docs: http://docs.python.org/lib/built-in

AI library

2006-12-15 Thread Felix Benner
I thought about an AI library for python. This is the possible structure I came up with. Are there any thoughts about it? ailib/ search.py class State: "represents an immutable state of a problem" def __str__(self): pass def __has

Re: Property error

2006-12-15 Thread Georg Brandl
king kikapu wrote: > Hi to all, > > i am trying to use properties in Python and i am sure i have made > something wrong with the below code but i just cannot see what it is. > > Can anyone please help me on this ? > > The code is : > > class Person(object): > age = 0 > > @property >

cxfrozen linux binaries run on FreeBSD?

2006-12-15 Thread robert
When i freeze a python app (simple - no strange sys calls) for x86 Linux, does this stuff run well also on x86 FreeBSD? Robert -- http://mail.python.org/mailman/listinfo/python-list

Re: skip last line in loops

2006-12-15 Thread Roberto Bonvallet
[EMAIL PROTECTED] wrote: >> do it lazily: >> >> last_line = None >> for line in open("file): >> if last_line: >> print last_line >> last_line = line >> >> or just gobble up the entire file, and slice off the last item: >> >> for line in list(open("file"

Re: need clarification with import statements

2006-12-15 Thread Tool69
Hi John, > 1. Your directory/package hierarchy is far too complicated. Flatten it. Ok. > 2. You have circular references: the others module will import from > utils, but utils wants to import from others. This is prima facie > evidence that your modules are not structured properly Yes, that's wh

Re: automatically grading small programming assignments

2006-12-15 Thread André
Brian Blais wrote: > Dan Bishop wrote: > > On Dec 14, 8:36 pm, Brian Blais <[EMAIL PROTECTED]> wrote: > >> [EMAIL PROTECTED] wrote: > >>> [EMAIL PROTECTED] wrote: > >>> Then on your PC you can > run a script that loads each of such programs, and runs a good series > of tests, to test the

Re: Property error

2006-12-15 Thread Peter Otten
Peter Otten wrote: > @decorator > def f(): > # ... > > is the same as > > def f(): > # ... > f = decorator(f()) > > What happens when your age() function is invoked? There is no explicit > return statement, so None is implicitly returned, and > > age = property(age()) > > is the same as age

Re: beginner, thread & else

2006-12-15 Thread Gigs_
Fredrik Lundh wrote: > did you write that yourself, or did you find it in some book or article? This is the example from programming python 2nd book, I use this just for learning -- http://mail.python.org/mailman/listinfo/python-list

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

2006-12-15 Thread Paul Boddie
greg wrote: > Willem Broekema wrote: > > > I guess in part it's because there are not that many people really into > > both Python and Lisp, and those who are might not find this an > > interesting project because there is nothing "wow" to show, yet. > > Another reason (or maybe the reason for the

Re: skip last line in loops

2006-12-15 Thread James Stroud
[EMAIL PROTECTED] wrote: > Fredrik Lundh wrote: >> [EMAIL PROTECTED] wrote: >> >>> how can i skip printing the last line using loops (for /while) >>> >>> eg >>> >>> for line in open("file): >>> print line. >>> >>> I want to skip printing last line of the file. >> do it lazily: >> >> last_

Re: tuple.index()

2006-12-15 Thread Christoph Zwerschke
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. And can somebody explain what is exactly meant with "homogenous

Re: Conditional iteration

2006-12-15 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Gabriel Genellina wrote: > Be aware that map, filter, and reduce may be dropped in Python 3000. > http://www.artima.com/weblogs/viewpost.jsp?thread=98196 > (and I won't miss them if gone) There are `imap` and `ifilter` in the `itertools` module. I guess/hope they will sta

Re: No latin9 in Python?

2006-12-15 Thread Christoph Zwerschke
Martin v. Löwis wrote: > While you are at it, you'll notice that the current version of the > character-sets database lists > > Name: ISO-8859-15 > MIBenum: 111 > Source: ISO > Please see: > > Alias: ISO_8859-15 > Alias: Latin-9 >

Re: Roundtrip SQL data especially datetime

2006-12-15 Thread Gabriel Genellina
On 15 dic, 07:44, "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

Re: tuple.index()

2006-12-15 Thread Tim Golden
[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 remove one item from it, it is still a "list of xs", where "xs" might be people, coordinate-pairs, n

Re: skip last line in loops

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

sEcOnD LIfe; Be wHaT eVeR u wAnt To bE!!!!

2006-12-15 Thread checoo
Second Life is a 3-D virtual world entirely built and owned by its residents. Since opening to the public in 2003, it has grown explosively and today is inhabited by a total of 2,007,546 people from around the globe. YOU LIVE IN A VIRTUAL WORLD, WHERE YOU CHOOSE HOW YOU LOOK AND WHAT YOU WANT TO

Re: tuple.index()

2006-12-15 Thread Simon Brunning
On 14 Dec 2006 06:24:38 -0800, Glenn Hutchings <[EMAIL PROTECTED]> wrote: > What I'm saying is that from the > perspective of someone not interested in design issues, it seems like > an omission for tuples to be missing the non-modifying methods that > lists have. >From the perpective of somone no

Problem comparing object graphs and trees

2006-12-15 Thread raphael . marvie
Dear all, I am trying to compare graphes of object through the use of the __cmp__ operator. Before managing the problem of recursive comparison, I have tried a simple test which result surprises me. Here is the simplest code I can write that presents my problem: $ cat cmp.py class A: def _

Re: skip last line in loops

2006-12-15 Thread Paul Rubin
[EMAIL PROTECTED] writes: > for line in open("file): > print line. > > I want to skip printing last line of the file.thanks def all_but_last(it): # yield all but last item of an iterator a = it.next() for b in it: yield a a = b for line in all_but_last(open("file

Re: AI library

2006-12-15 Thread Gabriel Genellina
On 15 dic, 08:50, Felix Benner <[EMAIL PROTECTED]> wrote: > I thought about an AI library for python. This is the possible > structure I came up with. Are there any thoughts about it? Without commenting about the library itself: None, True and False are spelled this way. None is a singleton, comp

Re: Large files uploading

2006-12-15 Thread Lad
Fredrik, Thank you for your reply I need to upload large files ( about 100MB ). HTTP protocol provides FORMs for uploading which is elegant and good solution for small files but using HTTP protocol for large files is not good ( server's timeouts, big memory consumption on server's side, etc.)

Re: Problem comparing object graphs and trees

2006-12-15 Thread Peter Otten
[EMAIL PROTECTED] wrote: > > $ cat cmp.py > > class A: > def __init__(self, b): > self.b = b > def __cmp__(self, other): > return self.b == other.b > > class B: > pass > > if __name__ == '__main__': > b = B() > a1 = A(b) > a2 = A(b) > print a1 == a2

Re: Problem comparing object graphs and trees

2006-12-15 Thread raphael . marvie
I am not drunk but should have rtfm. Sorry and Thanks. r. On Dec 15, 3:04 pm, Peter Otten <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > > > $ cat cmp.py > > > class A: > > def __init__(self, b): > > self.b = b > > def __cmp__(self, other): > > return self.b

Re: Problem comparing object graphs and trees

2006-12-15 Thread Duncan Booth
[EMAIL PROTECTED] wrote: > I swear I am not drunk, but why isn't a1 == a2 and worse why isn't a1 >== a1? Does someone have a clue and can explain to me this suprising > behavior? (python 2.4.3 on Ubuntu 6.06). Because the __cmp__ method doesn't return a boolean. It returns a value <0, 0 or >0 ac

Re: merits of Lisp vs Python

2006-12-15 Thread André Thieme
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 me your brain is somewhat stuck o

Restrictive APIs for Python

2006-12-15 Thread Will Ware
Python has no inherent provision for a restrictive API that blocks accesses to methods and variables outside an allowed set. Inexperienced Python programmers may fail to adhere to an agreed-upon API, directly accessing the private internals of a class. Adherence to defined APIs is a good thing. Thi

Re: merits of Lisp vs Python

2006-12-15 Thread Ken Tilton
greg wrote: > Ken Tilton wrote: > >> So this: >> (defmethod tf-reverse (id (eql ',sub-id)) resx (drv-opnds tf drv)) >> ,@reverser) >> >> becomes this: >> >> (defmethod tf-reverse ((id (eql ',sub-id)) tf drv >> &aux (opnds (drv-opnds tf drv))) >>(lo

Re: skip last line in loops

2006-12-15 Thread Daniel Klein
On 14 Dec 2006 22:47:23 -0800, [EMAIL PROTECTED] wrote: >hi, >how can i skip printing the last line using loops (for /while) > >eg > >for line in open("file): > print line. > >I want to skip printing last line of the file.thanks while True: line1 = myfile.readline() if not line1: brea

Re: merits of Lisp vs Python

2006-12-15 Thread Ken Tilton
greg wrote: > 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 me your brain is somewhat stuc

Re: merits of Lisp vs Python

2006-12-15 Thread Paul Rubin
André Thieme <[EMAIL PROTECTED]> writes: > def nif(num, pos, zero, neg): >if num > 0: > return pos >else: > if num == 0: >return zero > else: >return neg def nif(num, pos, zero, neg): return (neg, zero, pos)[cmp(num, 0)+1] > The messages were printed in e

Re: Missing __length_hint__ in __getitem__ iterator

2006-12-15 Thread Giovanni Bajo
Peter Otten wrote: > It's there, just not doctored into the dir() output: > class A(object): > ... def __getitem__(self, index): return index > ... def __len__(self): return 42 > ... iter(A()).__length_hint__ > iter(A()).__length_hint__() > 42 > > Peter Ah well, actually i

re pattern for matching JS/CSS

2006-12-15 Thread i80and
I'm working on a program to remove tags from a HTML document, leaving just the content, but I want to do it simply. I've finished a system to remove simple tags, but I want all CSS and JS to be removed. What re pattern could I use to do that? I've tried '' but that didn't work properly. I'm fai

Re: merits of Lisp vs Python

2006-12-15 Thread Christophe Cavalaria
Paul Rubin wrote: > André Thieme <[EMAIL PROTECTED]> writes: >> def nif(num, pos, zero, neg): >>if num > 0: >> return pos >>else: >> if num == 0: >>return zero >> else: >>return neg > > def nif(num, pos, zero, neg): >return (neg, zero, pos)[cmp(num, 0)+1

parsing a dictionary from a string

2006-12-15 Thread Benjamin Georgi
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). Example: >>> s = str(dict_list) >>> s '[{0: [2], 1: []}, {0: [], 1:

Re: tuple.index()

2006-12-15 Thread Christoph Zwerschke
Tim Golden wrote: > Christoph Zwerschke wrote: >> 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 remove one item from it, it is still a "list of xs", According to

Re: cxfrozen linux binaries run on FreeBSD?

2006-12-15 Thread i80and
I haven't personally used freeze (Kubuntu doesn't seem to install it with the python debs), but based on what I know of it, it makes make files. I'm not a make expert, but if FreeBSD has GNU tools, freeze's output _should_ be able to be compiled on FreeBSD. On Dec 15, 5:52 am, robert <[EMAIL PROT

Re: AI library

2006-12-15 Thread Roberto Bonvallet
Felix Benner wrote: [...] >def a-star(self, nodeFrom, nodeTo): >"""searches the shortest path (minimal weight) from >nodeFrom to nodeTo.""" >pass >>> def a-star(self, nodeFrom, nodeTo): File "", line 1 def a-star(self, nodeFrom, nod

Re: merits of Lisp vs Python

2006-12-15 Thread Ken Tilton
greg wrote: > Ken Tilton wrote: > >> The last example showed the macro inserting code to magically produce >> a binding inside the reverse function. > > > Are you sure? It looked to me like it was adding code *around* > the reverse function, not inside it. I posted a Python function > that ac

Re: merits of Lisp vs Python

2006-12-15 Thread Paul Rubin
Christophe Cavalaria <[EMAIL PROTECTED]> writes: > def nif(num, pos, zero, neg): >return (zero, pos, neg)[cmp(num, 0)] Owwoo!!! -- http://mail.python.org/mailman/listinfo/python-list

Re: merits of Lisp vs Python

2006-12-15 Thread Wade Humeniuk
Paul Rubin wrote: > > "nif" is even cleaner in Haskell, if I have this right: > > nif x p z n | (x < 0) = n > | (x == 0) = z > | (x > 0) = p > > All Haskell evaluation is automatically lazy, so no lambdas etc. needed. You can use that style in CL. (defun n

Re: aggdraw for 2.5 on WinXP?

2006-12-15 Thread Stéphane Muller
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 http://c.python.free.fr/aggdraw-1.2a3-20060212.win32-py2.5.exe without any express or

Re: merits of Lisp vs Python

2006-12-15 Thread André Thieme
Paul Rubin schrieb: > André Thieme <[EMAIL PROTECTED]> writes: >> def nif(num, pos, zero, neg): >>if num > 0: >> return pos >>else: >> if num == 0: >>return zero >> else: >>return neg > > def nif(num, pos, zero, neg): >return (neg, zero, pos)[cmp(num, 0)+

Re: tuple.index()

2006-12-15 Thread Simon Brunning
On 12/15/06, Christoph Zwerschke <[EMAIL PROTECTED]> 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.

Re: merits of Lisp vs Python

2006-12-15 Thread André Thieme
Christophe Cavalaria schrieb: > Paul Rubin wrote: > >> André Thieme <[EMAIL PROTECTED]> writes: >>> def nif(num, pos, zero, neg): >>>if num > 0: >>> return pos >>>else: >>> if num == 0: >>>return zero >>> else: >>>return neg >> def nif(num, pos, zero, neg): >

Re: merits of Lisp vs Python

2006-12-15 Thread Paul Rubin
Wade Humeniuk <[EMAIL PROTECTED]> writes: > > "nif" is even cleaner in Haskell, if I have this right: > > nif x p z n | (x < 0) = n > > | (x == 0) = z > > | (x > 0) = p > > All Haskell evaluation is automatically lazy, so no lambdas > > etc. needed. > > You can

Re: merits of Lisp vs Python

2006-12-15 Thread Paul Rubin
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. Anyway, token count doesn't mean much, you have to instead go by the user's cognitive effort in dealing with the pr

Re: tuple.index()

2006-12-15 Thread Simon Brunning
On 12/15/06, Christoph Zwerschke <[EMAIL PROTECTED]> wrote: > > If you have a tuple containing, say, a 2d coordinate pair, > > and remove something from it, it's no longer a coordinate pair. > > Now here comes the ambiguity. If you interpret "x" as "coordinate tuple" > it would be still one (a 1-t

Re: merits of Lisp vs Python

2006-12-15 Thread Pascal Bourguignon
Paul Rubin writes: > 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. No. Parentheses are editor commands. They don't count anymor

Re: cxfrozen linux binaries run on FreeBSD?

2006-12-15 Thread robert
i80and wrote: > I haven't personally used freeze (Kubuntu doesn't seem to install it > with the python debs), but based on what I know of it, it makes make > files. I'm not a make expert, but if FreeBSD has GNU tools, freeze's > output _should_ be able to be compiled on FreeBSD. Yet do the Linux

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: merits of Lisp vs Python

2006-12-15 Thread Ken Tilton
[EMAIL PROTECTED] wrote: > Ken Tilton wrote: > >>Andrew Reilly wrote: >> >> >>> That all looks like data. >> >>No, not reverse, the part you did not understand. I do not mean what the >>code was doing, I meant that it was code. >> > > > Code is data is code I was hoping no one would make tha

Re: Restrictive APIs for Python

2006-12-15 Thread Gabriel Genellina
On 15 dic, 11:31, "Will Ware" <[EMAIL PROTECTED]> wrote: > Python has no inherent provision for a restrictive API that blocks > accesses to methods and variables outside an allowed set. > Inexperienced Python programmers may fail to adhere to an agreed-upon > API, directly accessing the private int

Re: AI library

2006-12-15 Thread bearophileHUGS
Gabriel Genellina: > This is more stylish, but I prefer to use isxxx() or hasxxx() for > functions that return booleans. Lisp-like languages allow the ending ? or !, I think Ruby allows the ending ? too (allowing it with Python may be positive). Mathematica usually uses an ending uppercase Q, like

Re: One module per class, bad idea?

2006-12-15 Thread Jorgen Grahn
On Tue, 12 Dec 2006 09:29:17 +0100, Matias Jansson <[EMAIL PROTECTED]> wrote: > I come from a background of Java and C# where it is common practise to have > one class per file in the file/project structure. As I have understood it, > it is more common practice to have many classes in a Python mo

Re: tuple.index()

2006-12-15 Thread George Sakkis
Christoph Zwerschke wrote: > The statement "if you are looking for index() or count() for your > tuples, you're using the wrong container type" is too extreme I think. I > would agree with "it *may indicate* that you should better use lists". And also if that statement was correct, I would argue

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

2006-12-15 Thread Jorgen Grahn
On Fri, 15 Dec 2006 01:20:34 GMT, 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 > built in or if there's a good implementation out there. Something that, > lets face it, does whatever the C++ s

  1   2   3   >