Re: Python's "only one way to do it" philosophy isn't good?

2007-06-27 Thread John Nagle
Douglas Alan wrote: > "Chris Mellon" <[EMAIL PROTECTED]> writes: >>On 6/27/07, Douglas Alan <[EMAIL PROTECTED]> wrote: >>This totally misrepresents the case. The with statement and the >>context manager is a superset of the RAII functionality. > > > No, it isn't. C++ allows you to define smart

Re: nested list comprehension and if clauses

2007-06-27 Thread Jyotirmoy Bhattacharya
On Jun 28, 10:53 am, [EMAIL PROTECTED] (Alex Martelli) wrote: > Jyotirmoy Bhattacharya <[EMAIL PROTECTED]> wrote: > > print [(m,n) for m in range(5) for n in multab(m) if m>2] > > I was wondering if there is some way to write the if-clause so that it > > is 'hoisted' out of the inner loop and the m

Re: nested list comprehension and if clauses

2007-06-27 Thread Alex Martelli
Paul Rubin wrote: > [EMAIL PROTECTED] (Alex Martelli) writes: > > > print [(m,n) for m in range(5) for n in multab(m) if m>2] > > Sure, just place the if clause where it needs to apply (between the two > > for clauses) [apart from the fact that this example is best expre

Re: nested list comprehension and if clauses

2007-06-27 Thread Paul Rubin
[EMAIL PROTECTED] (Alex Martelli) writes: > > print [(m,n) for m in range(5) for n in multab(m) if m>2] > Sure, just place the if clause where it needs to apply (between the two > for clauses) [apart from the fact that this example is best expressed by > using range(3,5), as somebody already said;-

Re: Too many 'self' in python.That's a big flaw in this language.

2007-06-27 Thread Alex Martelli
Bjoern Schliessmann <[EMAIL PROTECTED]> wrote: ... > Mh, strange, I personally like to use "this.a" in C++, to make clear > I use an instance variable. That would be nice, unfortunately your C++ compiler will refuse that, and force you to use this->a instead;-). Many programming shops use nami

Re: nested list comprehension and if clauses

2007-06-27 Thread Alex Martelli
Jyotirmoy Bhattacharya <[EMAIL PROTECTED]> wrote: > I'm a newcomer to Python. I have just discovered nested list > comprehensions and I need help to understand how the if-clause > interacts with the multiple for-clauses. I have this small program: > > def multab(n): > print 'multab',n > r

Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-06-27 Thread Alex Martelli
John Nagle <[EMAIL PROTECTED]> wrote: > PEP 3107 is static typing without enforcement, which is not a good thing. Wrong: PEP3107 is a syntax for adding arbitrary metadata annotations (so that said annotations don't get squished where they don't belong, such as decorators or docstrings, as they us

Re: Portable general timestamp format, not 2038-limited

2007-06-27 Thread Paul Rubin
[EMAIL PROTECTED] writes: > Keep in mind that TAI is not legal time anywhere. It is also not > practical, for the TAI now is not available until next month. If you mean they don't announce the average of the 350 atomic clocks til a month later, well swell, but you can get sub-microsecond accuracy

Tkinter pack_forget() and destroy()

2007-06-27 Thread Rajendran Appavu
When I am done with a widget that is packed in a Frame, is it safe to call destroy() method on the widget after calling its pack_forget() or grid_forget() method? -- Thanks, Rajendran. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python's "only one way to do it" philosophy isn't good?

2007-06-27 Thread Douglas Alan
Dennis Lee Bieber <[EMAIL PROTECTED]> writes: > But if these "macros" are supposed to allow one to sort of extend > Python syntax, are you really going to code things like > > macrolib1.keyword > everywhere? No -- I would expect that macros (if done the way that I would like them to b

Re: Python's "only one way to do it" philosophy isn't good?

2007-06-27 Thread Graham Breed
Dennis Lee Bieber wote: > But if these "macros" are supposed to allow one to sort of extend > Python syntax, are you really going to code things like > > macrolib1.keyword > > everywhere? I don't see why that *shouldn't* work. Or "from macrolib1 import keyword as foo". And to be tru

Changing default output object for

2007-06-27 Thread Graham Dumpleton
I am sure someone has probably thought of this and there are good reasons why it is a bad idea or not possible, but, is there any technical reason why one couldn't somehow replace PRINT_ITEM byte code, with combination of byte codes which inserted in a reference to a file like object and then invok

Re: nested list comprehension and if clauses

2007-06-27 Thread Paul Rubin
Jyotirmoy Bhattacharya <[EMAIL PROTECTED]> writes: > print [(m,n) for m in range(5) for n in multab(m) if m>2] > I was wondering if there is some way to write the if-clause so that it > is 'hoisted' out of the inner loop and the multab function is not > called at all for m=0,1,2. That would seem t

nested list comprehension and if clauses

2007-06-27 Thread Jyotirmoy Bhattacharya
I'm a newcomer to Python. I have just discovered nested list comprehensions and I need help to understand how the if-clause interacts with the multiple for-clauses. I have this small program: def multab(n): print 'multab',n return [n*i for i in range(5)] print [(m,n) for m in range(5) for

Re: 16bit hash

2007-06-27 Thread Paul Rubin
"Martin v. Löwis" <[EMAIL PROTECTED]> writes: > So: what are your input data, and what is the > distribution among them? With good enough hash functions one shouldn't need to care about the input distribution. Basically functions like SHA can be used as extractors: http://en.wikipedia.org/wik

Re: glob.glob standardization

2007-06-27 Thread Martin v. Löwis
> Don't you think it would be more convenient for glob.glob to return > file names only in any case, like os.listdir do? No. Use glob.glob1 if you want a list of files. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list

Re: 16bit hash

2007-06-27 Thread Martin v. Löwis
> Is the any way to get an efficient 16bit hash in python? Unfortunately, that problem is underspecified. The simplest and most efficient 16-bit hash I can come up with is def super_efficient_hash(o): return 0 Now, you say: this gives collisions. So yes, it does - but you didn't ask for it to

Re: Python's "only one way to do it" philosophy isn't good?

2007-06-27 Thread Douglas Alan
Douglas Woodrow <[EMAIL PROTECTED]> writes: > On Wed, 27 Jun 2007 01:45:44, Douglas Alan <[EMAIL PROTECTED]> wrote >>A chaque son gout > I apologise for this irrelevant interruption to the conversation, but > this isn't the first time you've written that. > The word "chaque" is not a pronoun.

Re: Python's "only one way to do it" philosophy isn't good?

2007-06-27 Thread Douglas Alan
"Chris Mellon" <[EMAIL PROTECTED]> writes: > On 6/27/07, Douglas Alan <[EMAIL PROTECTED]> wrote: >> The C++ folks feel so strongly about this, that they refuse to provide >> "finally", and insist instead that you use destructors and RAII to do >> resource deallocation. Personally, I think that's

Re: eggs considered harmful

2007-06-27 Thread zooko
Harry: For some Free Software Python packages that I publish [1, 2, 3], I've been trying to gain the benefits of eggs while also making the resulting packages transparently useful to folks like you. (You can follow along here: [4].) One thing I've accomplished is figuring out how to install a Py

Re: 16bit hash

2007-06-27 Thread Paul Rubin
Robin Becker <[EMAIL PROTECTED]> writes: > >> Is the any way to get an efficient 16bit hash in python? > > hash(obj)&65535 > > - Josiah > yes I thought of that, but cannot figure out if the internal hash > really distributes the bits evenly. Particularly since it seems to > treat integers etc as

Re: Reversing a string

2007-06-27 Thread ptn
> mylist = [] > > That's bad. If you need to use a list in the rev function, you > should bind a new list to a local variable inside rev. > He's right. If you want to use a list to temporarily store the reversed version of your string, it should exist only in the local namespace of your funct

Re: Reversing a string

2007-06-27 Thread ptn
> > or one letter per line: > > >>> print "\n".join("spam"[::-1]) > > m > a > p > s > One liners rock ;) -- http://mail.python.org/mailman/listinfo/python-list

Re: equality & comparison by default (was Re: Too many 'self' in python.That's a big flaw in this language.)

2007-06-27 Thread Erik Max Francis
Aahz wrote: > In article <[EMAIL PROTECTED]>, > Alex Martelli <[EMAIL PROTECTED]> wrote: >> In Python 3000, ordering comparisons will not exist by default (sigh, a >> modest loss of practicality on the altar of purity -- ah well, saw it >> coming, ever since complex numbers lost ordering compariso

Re: 16bit hash

2007-06-27 Thread Dan Bishop
On Jun 27, 12:11 pm, Robin Becker <[EMAIL PROTECTED]> wrote: > Josiah Carlson wrote: > > Robin Becker wrote: > >> Is the any way to get an efficient 16bit hash in python? > > > hash(obj)&65535 > > > - Josiah > > yes I thought of that, but cannot figure out if the internal hash really > distribute

Re: Python's "only one way to do it" philosophy isn't good?

2007-06-27 Thread Lenard Lindstrom
Douglas Alan wrote: > > Lispers have long since understood how to write mapping function to > iterator converters using stack groups or continuations, but Common > Lisp never mandated stack groups or continuations for conforming > implementations. Scheme, of course, has continuations, and there a

Re: How can I 'compound' streams?

2007-06-27 Thread Dan Bishop
On Jun 27, 7:40 pm, XiaQ <[EMAIL PROTECTED]> wrote: > I need to build a stream that writes to stdout and a file at the same > time. Is there already a function in the Python library to do this? class FileAndStdout(file): def write(self, data): file.write(self, data) sys.stdout

How can I 'compound' streams?

2007-06-27 Thread XiaQ
I need to build a stream that writes to stdout and a file at the same time. Is there already a function in the Python library to do this? -- http://mail.python.org/mailman/listinfo/python-list

Re: Return name of caller function?

2007-06-27 Thread Matthew Peter
> The code below doesn't do the trick for you? > > #!/usr/bin/python > import inspect > > def master(): > print "I am the master" > slave() > > def slave(): > stack = inspect.stack() > caller = stack[1][3] > print "I am the slave; my caller was %s" % caller > > def main(): >

Re: Converting Diff Output to XML?

2007-06-27 Thread Yongjian Xu
gnosis has a converter for ASCII file to xml file, its called txt2dw.py. give it a try. -- Jim On 6/26/07, Debajit Adhikary <[EMAIL PROTECTED]> wrote: What would be the best way to convert the regular (unix) diff output into XML? Are there any libraries at all which might help? -- http://mail

Re: log caller

2007-06-27 Thread attn . steven . kuo
On Jun 27, 2:42 pm, Matthew Peter <[EMAIL PROTECTED]> wrote: > Is it possible to print the function calls to a module? Like: > > test.py > import mymod > print mymod.x() > > mymod.py > # each time a function is called we print out the called function and module > print 'Func call: %s from %s' % (??

Re: Python-list Digest, Vol 45, Issue 410

2007-06-27 Thread hari sirigibathina
Hi all, Have a question which is making me unrest: -Calling a method say aMethod() from another method where i mistakenly initialised a variable with name same as the called method like aMethod = 'string'. When i run this py script triggered "Unbound Local error". can any one explain me whats g

Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-06-27 Thread Donn Cave
In article <[EMAIL PROTECTED]>, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > John Nagle a écrit : > > Bruno Desthuilliers wrote: > > > >> Indeed - static typing is for compilers, not for programmers. > > > > > > Actually, static typing is for detecting errors before the > > program is

Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-06-27 Thread Eduardo \"EdCrypt\" O. Padoan
On 6/27/07, Stephen R Laniel <[EMAIL PROTECTED]> wrote: > On Thu, Jun 28, 2007 at 09:08:16AM +0200, Bruno Desthuilliers wrote: > > You said ? > > I could link again to Mark-Jason Dominus, who writes that > people often make the following inference: > > 1) C is strongly typed. > 2) C's typing sucks.

Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-06-27 Thread Stephen R Laniel
On Thu, Jun 28, 2007 at 09:08:16AM +0200, Bruno Desthuilliers wrote: > You said ? I could link again to Mark-Jason Dominus, who writes that people often make the following inference: 1) C is strongly typed. 2) C's typing sucks. 3) Hence strong typing sucks. But I won't. It doesn't need to be a

Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-06-27 Thread Bruno Desthuilliers
John Nagle a écrit : > Bruno Desthuilliers wrote: > >> harri a écrit : > > >> Indeed - static typing is for compilers, not for programmers. > > > Actually, static typing is for detecting errors before the > program is run. [EMAIL PROTECTED] ~ $ cat toto.c #include int main(void) { cha

Re: glob.glob standardization

2007-06-27 Thread Lawrence Oluyede
billiejoex <[EMAIL PROTECTED]> wrote: > Don't you think it would be more convenient for glob.glob to return > file names only in any case, like os.listdir do? AFAIK it's a wanted behavior. The doc says: """ Notice how any leading components of the path are preserved. """ -- Lawrence, oluyede.o

Re: Python's "only one way to do it" philosophy isn't good?

2007-06-27 Thread Andy Freeman
On Jun 27, 8:09 am, "Chris Mellon" <[EMAIL PROTECTED]> wrote: > On 6/27/07, Andy Freeman <[EMAIL PROTECTED]> wrote: > > It's easy enough to get around the lack of objectness and add the > > equivalent of an iterator iterface, in either language. The fact that > > lisp folks haven't bothered sugges

Re: 16bit hash

2007-06-27 Thread Jon Ribbens
On 2007-06-27, Robin Becker <[EMAIL PROTECTED]> wrote: > Is the any way to get an efficient 16bit hash in python? int(md5.new(s).hexdigest()[:4], 16) ? -- http://mail.python.org/mailman/listinfo/python-list

Re: Too many 'self' in python.That's a big flaw in this language.

2007-06-27 Thread Andy Freeman
On Jun 27, 2:54 pm, John Nagle <[EMAIL PROTECTED]> wrote: > >> But, what about something in between like only > >> using the dot (.) for a shorter notation? > > How about "Mavis Beacon Teaches Typing"? How about no "wouldn't it be better" suggestions until at least three months after the sugg

glob.glob standardization

2007-06-27 Thread billiejoex
os.listdir(path) return a list of file names independently if the path- argument used is absolute or relative: >>> os.getcwd() '/home/user' >>> os.listdir('Desktop') ['file.py'] >>> os.listdir('/home/user/Desktop') ['file.py'] glob.glob, instead, return file names only if given path is relative:

log caller

2007-06-27 Thread Matthew Peter
Is it possible to print the function calls to a module? Like: test.py import mymod print mymod.x() mymod.py # each time a function is called we print out the called function and module print 'Func call: %s from %s' % (???, ???) def x(): return 'hello' Where would I pick up the ??? variabl

Re: Too many 'self' in python.That's a big flaw in this language.

2007-06-27 Thread John Nagle
Bruno Desthuilliers wrote: > Jorgen Bodde a écrit : > >> But, what about something in between like only >> using the dot (.) for a shorter notation? How about "Mavis Beacon Teaches Typing"? John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: listing the type of an object

2007-06-27 Thread Thomas Jollans
Stef Mientki wrote: > How can I list a type of an object instance ? > > I tried: > > class tLED (tDevice): > def some_proc(self): > print 'type(self)', type(self) > > But i gives me: > type(self) > > Moreover, I want even the type to be listed by it's ancestor, like this > > class tDe

Re: equality & comparison by default (was Re: Too many 'self' in python.That's a big flaw in this language.)

2007-06-27 Thread Aahz
In article <[EMAIL PROTECTED]>, Alex Martelli <[EMAIL PROTECTED]> wrote: > >In Python 3000, ordering comparisons will not exist by default (sigh, a >modest loss of practicality on the altar of purity -- ah well, saw it >coming, ever since complex numbers lost ordering comparisons), but >equality an

listing the type of an object

2007-06-27 Thread Stef Mientki
How can I list a type of an object instance ? I tried: class tLED (tDevice): def some_proc(self): print 'type(self)', type(self) But i gives me: type(self) Moreover, I want even the type to be listed by it's ancestor, like this class tDevice: def some_other_proc: print 'typ

Re: Too many 'self' in python.That's a big flaw in this language.

2007-06-27 Thread Bruno Desthuilliers
Jorgen Bodde a écrit : > I had the same feeling when I started, coming from a C++ background, I > forgot about self a lot, creating local copies of what should be an > assign to a class instance, or methods that could not be found because > I forgot 'self' . > > Now I am 'kinda' used to it, as eve

Re: Zip File Woes

2007-06-27 Thread Dave Kuhlman
Jerry Hill wrote: > On 6/27/07, Robert Rawlins - Think Blue > <[EMAIL PROTECTED]> wrote: >> zip = zipfile.ZipFile('Media/Media.zip', 'r') > > Shouldn't you open this file in binary mode? It shouldn't make > any difference on unix machines, but will possibly break under > windows. T

Re: ANN: PyDAO - Python Hibernate-like Object-Relational Mapper

2007-06-27 Thread Luis M . González
On Jun 27, 4:08 pm, [EMAIL PROTECTED] wrote: > PyDAO is very thin object-relational mapper similar to Hibernate (but > much simpler). It's created to speed-up application development. It's > very simple, but powerful, based on POPO (Plain Old Python Objects). > > http://aplikacja.info/PyDAO.html >

Re: Return name of caller function?

2007-06-27 Thread Matthew Peter
--- Jay Loden <[EMAIL PROTECTED]> wrote: > > Matthew Peter wrote: > > For example, how do I get this to work? > > > > def func(): > > print "This is", __?__ > > return __caller__ > > > > def echo(): > > print "This is ", __?__ > > return func() > > > > > print echo() > >

Re: Collections of non-arbitrary objects ?

2007-06-27 Thread Bruno Desthuilliers
walterbyrd a écrit : > On Jun 26, 8:23 am, Bruno Desthuilliers [EMAIL PROTECTED]> wrote: > >>walterbyrda écrit : >> >> You do program carefully, don't you ?-) >> >>>I try. But things like typos are a normal part a life. >> >>So are they in any language. I fail to see much difference here. >>

Re: Return name of caller function?

2007-06-27 Thread Stephen R Laniel
On Wed, Jun 27, 2007 at 01:25:14PM -0700, Matthew Peter wrote: > Parsing the stack's tuple to get those attributes didn't feel reliable or > pythonic. > I am likely overlooking something. Is there a brief example you could show me > in the > context of using inspect to accomplish the goal I outli

Re: Return name of caller function?

2007-06-27 Thread Matthew Peter
--- Stephen R Laniel <[EMAIL PROTECTED]> wrote: > On Mon, Jun 25, 2007 at 06:27:29PM -0700, Matthew Peter wrote: > > For example, how do I get this to work? > > > > def func(): > > print "This is", __?__ > > return __caller__ > > > > def echo(): > > print "This is ", __?__ > > r

Re: Too many 'self' in python.That's a big flaw in this language.

2007-06-27 Thread John Roth
On Jun 27, 5:02 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > HI > I'm currently using Python. I find that a instance variable must > confined with self, > for example: > class a: > def __init__(self): > self.aa=10 > def bb(self): > print self.aa # See .if in c++,

Re: Capturing stdout from a class method

2007-06-27 Thread Thomas Jollans
Falcolas wrote: > I have a rather strange situation, and I'm not sure my brief > experience of Python will let me handle it properly. > > The situation is this: I have a Java class "X" which I need to call in > a Jython script. The output of "X" is sent to stdout using the java > call System.out.

Re: Capturing and sending keys {Esperanto}

2007-06-27 Thread Thomas Jollans
AJK wrote: > Hello there! > > I've been googleing yet, and suppose it's hopeless to try, but better > ask it... > > I want to write a program which turns Cx to Ĉ, cx to ĉ et al WHILE > TYPING. (i.e. converting Esperanto x-system to real hats, for those > who know about this.) Therefore I though w

Re: The Modernization of Emacs: terminology buffer and keybinding

2007-06-27 Thread [EMAIL PROTECTED]
In article <[EMAIL PROTECTED]>, Gian Uberto Lauri <[EMAIL PROTECTED]> wrote: > > "n" == nebulous99 <[EMAIL PROTECTED]> writes: > > n> On Jun 22, 6:32 pm, Cor Gest <[EMAIL PROTECTED]> wrote: > >> > HOW IN THE BLOODY HELL IS IT SUPPOSED TO OCCUR TO SOMEONE TO > >> ENTER > THEM, GIVEN THAT THEY

Re: Zip File Woes

2007-06-27 Thread Jerry Hill
On 6/27/07, Robert Rawlins - Think Blue <[EMAIL PROTECTED]> wrote: > zip = zipfile.ZipFile('Media/Media.zip', 'r') Shouldn't you open this file in binary mode? It shouldn't make any difference on unix machines, but will possibly break under windows. That may also explain why it work

ANN: PyDAO - Python Hibernate-like Object-Relational Mapper

2007-06-27 Thread cieslak . dariusz
PyDAO is very thin object-relational mapper similar to Hibernate (but much simpler). It's created to speed-up application development. It's very simple, but powerful, based on POPO (Plain Old Python Objects). http://aplikacja.info/PyDAO.html Main features: - can use any database that has DB-A

Capturing stdout from a class method

2007-06-27 Thread Falcolas
I have a rather strange situation, and I'm not sure my brief experience of Python will let me handle it properly. The situation is this: I have a Java class "X" which I need to call in a Jython script. The output of "X" is sent to stdout using the java call System.out. I need to capture this outp

Re: The Modernization of Emacs: terminology buffer and keybinding

2007-06-27 Thread [EMAIL PROTECTED]
In article <[EMAIL PROTECTED]>, Twisted <[EMAIL PROTECTED]> wrote: [ snip ] > I'm wondering if getting your head around unix arcana is also > dependent on an iffy "knack" where you "get it" and somehow know where > to look for documentation and problem fixes, despite everything having > its own

Re: Getting importError: No module named _md5

2007-06-27 Thread jeffself
On Jun 27, 11:54 am, [EMAIL PROTECTED] wrote: > On Jun 27, 7:04 am, jeffself <[EMAIL PROTECTED]> wrote: > > > I'm running Python 2.5.1 which I'm getting from the MacPort package > > system. I just installed Django and tried to start up the Django > > server and I got the following error: > > > Imp

Re: The Modernization of Emacs: terminology buffer and keybinding

2007-06-27 Thread [EMAIL PROTECTED]
In article <[EMAIL PROTECTED]>, Twisted <[EMAIL PROTECTED]> wrote: > On Jun 25, 5:32 pm, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > To me it's similar to "memorizing" a phone number by dialing > > it enough times that it makes its way into memory without > > conscious effort. I suspect that

Re: Reversing a string

2007-06-27 Thread Neil Cerutti
On 2007-06-27, Scott <[EMAIL PROTECTED]> wrote: > Yeah I know strings == immutable, but question 1 in section > 7.14 of "How to think like a computer Scientist" has me trying > to reverse one. No, it just wants to to print the characters in reverse, one per line. > I've come up with two things, o

Re: Tabbed windows Support in Python

2007-06-27 Thread Peter Decker
On 6/27/07, senthil arasu <[EMAIL PROTECTED]> wrote: > Hi, > Currently iam implementing GUI Framework for supporting Tabbed windows to > render different HTML Pages. > A row of tabs facilitated for navigation of pages. > > Iam expecting some classes like "QTabWidget" whick provided by Qt Libarary

Re: 16bit hash

2007-06-27 Thread Thomas Heller
Robin Becker schrieb: > Josiah Carlson wrote: >> Robin Becker wrote: >>> Is the any way to get an efficient 16bit hash in python? >> >> hash(obj)&65535 >> >> - Josiah > yes I thought of that, but cannot figure out if the internal hash really > distributes the bits evenly. Particularly since it

Re: Tabbed windows Support in Python

2007-06-27 Thread Bill Scherer
senthil arasu wrote: > Hi, > Currently iam implementing GUI Framework for supporting Tabbed > windows to render different HTML Pages. > A row of tabs facilitated for navigation of pages. > > Iam expecting some classes like "QTabWidget" whick provided by Qt > Libarary. > After starting my implem

Re: Reversing a string

2007-06-27 Thread Terry Reedy
"Scott" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | Yeah I know strings == immutable, but question 1 in section 7.14 of "How to | think like a computer Scientist" has me trying to reverse one. >>> 'this is a test'[::-1] 'tset a si siht' -- http://mail.python.org/mailman/l

Re: Set builtin lookups

2007-06-27 Thread Steve Holden
Marc 'BlackJack' Rintsch wrote: > In <[EMAIL PROTECTED]>, Evan Klitzke > wrote: > >> I have a question about the internal representation of sets in Python. >> If I write some code like >> >> if x in some_list: >> do_something() >> >> the lookup for the in statement is O(n), where n is the numb

Tabbed windows Support in Python

2007-06-27 Thread senthil arasu
Hi, Currently iam implementing GUI Framework for supporting Tabbed windows to render different HTML Pages. A row of tabs facilitated for navigation of pages. Iam expecting some classes like "QTabWidget" whick provided by Qt Libarary. After starting my implementation i came to know Tkinter not s

Re: Python's "only one way to do it" philosophy isn't good?

2007-06-27 Thread Douglas Alan
"Chris Mellon" <[EMAIL PROTECTED]> writes: > Is this where I get to call Lispers Blub programmers, because they > can't see the clear benefit to a generic iteration interface? I think you overstate your case. Lispers understand iteration interfaces perfectly well, but tend to prefer mapping fuct

Re: Collections of non-arbitrary objects ?

2007-06-27 Thread Paul Rubin
Steve Holden <[EMAIL PROTECTED]> writes: > Think of a tuple as an ordered collection. A given element's ordinal > position indicates its semantics (meaning, significance), and > generally it won't make sense to iterate over the elements of a tuple > (though naturally that doesn't stop people, and n

Re: The Modernization of Emacs: terminology buffer and keybinding

2007-06-27 Thread Joel J. Adamson
Twisted <[EMAIL PROTECTED]> writes: > On Jun 27, 8:26 am, [EMAIL PROTECTED] (Timofei Shatrov) wrote: >> >For which you need an interpreter. Such as Ghostscript. Which is a >> >pain to install and a bigger one to configure, even on Windoze. >> >> Lie. Ghostscript works out of the box on Windows. >

Re: 16bit hash

2007-06-27 Thread Nick Craig-Wood
Robin Becker <[EMAIL PROTECTED]> wrote: > Is the any way to get an efficient 16bit hash in python? Here is a 32 bit crc of which you could use the bottom 16 bits as a 16 bit hash... >>> import binascii >>> binascii.crc32("hello world") 222957957 >>> crc = binascii.crc32("hello") >>> cr

Re: Collections of non-arbitrary objects ?

2007-06-27 Thread Steve Holden
walterbyrd wrote: > On Jun 26, 8:23 am, Bruno Desthuilliers [EMAIL PROTECTED]> wrote: >> walterbyrda écrit : >> You do program carefully, don't you ?-) >>> I try. But things like typos are a normal part a life. >> So are they in any language. I fail to see much difference here. >> > > For ex

Re: Reversing a string

2007-06-27 Thread vbr
> Původní zpráva > Od: Will Maier <[EMAIL PROTECTED]> > Předmět: Re: Reversing a string > Datum: 27.6.2007 19:08:40 > > On Wed, Jun 27, 2007 at 12:53:36PM -0400, Scott wrote: > > So how on earth would be the best way to: Write a fu

Re: 16bit hash

2007-06-27 Thread Robin Becker
Josiah Carlson wrote: > Robin Becker wrote: >> Is the any way to get an efficient 16bit hash in python? > > hash(obj)&65535 > > - Josiah yes I thought of that, but cannot figure out if the internal hash really distributes the bits evenly. Particularly since it seems to treat integers etc as s

Re: Reversing a string

2007-06-27 Thread Diez B. Roggisch
Scott wrote: > Yeah I know strings == immutable, but question 1 in section 7.14 of "How > to think like a computer Scientist" has me trying to reverse one. > > I've come up with two things, one works almost like it should except that > every traversal thru the string I've gotten it to repeat the

Re: Reversing a string

2007-06-27 Thread Stefan Behnel
Scott wrote: > So how on earth would be the best way to: Write a function that takes a > string as an argument and outputs the letters backward, one per line. Homework? Anyway, what about: for c in string[::-1]: print c Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Reversing a string

2007-06-27 Thread Will Maier
On Wed, Jun 27, 2007 at 12:53:36PM -0400, Scott wrote: > So how on earth would be the best way to: Write a function that > takes a string as an argument and outputs the letters backward, > one per line. >>> def rev(forward): ... backward = list(forward) ... backward.reverse()

Reversing a string

2007-06-27 Thread Scott
Yeah I know strings == immutable, but question 1 in section 7.14 of "How to think like a computer Scientist" has me trying to reverse one. I've come up with two things, one works almost like it should except that every traversal thru the string I've gotten it to repeat the "list" again. This is

Re: Python's "only one way to do it" philosophy isn't good?

2007-06-27 Thread joswig
On Jun 27, 10:51 am, Paul Rubin wrote: > I personally use Emacs Lisp every day and I think Hedgehog Lisp (a > tiny functional Lisp dialect intended for embedded platforms like cell > phones--the runtime is just 20 kbytes) is a very cool piece of code. > But using CL for

Re: Collections of non-arbitrary objects ?

2007-06-27 Thread walterbyrd
On Jun 26, 8:23 am, Bruno Desthuilliers wrote: > walterbyrda écrit : > > >> You do program carefully, don't you ?-) > > > I try. But things like typos are a normal part a life. > > So are they in any language. I fail to see much difference here. > For example: if I mis-type a variable name in C,

Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-06-27 Thread John Nagle
Stephen R Laniel wrote: > People on here have been ... ahhh ... *generous* about > explaining that Python is dynamic, and hence that static > typing doesn't make sense. I've got it. That's not really the issue. There are languages with no static typing, like Python, and there are languages

Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-06-27 Thread John Nagle
Bruno Desthuilliers wrote: > harri a écrit : > Indeed - static typing is for compilers, not for programmers. Actually, static typing is for detecting errors before the program is run. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: 16bit hash

2007-06-27 Thread Josiah Carlson
Robin Becker wrote: > Is the any way to get an efficient 16bit hash in python? hash(obj)&65535 - Josiah -- http://mail.python.org/mailman/listinfo/python-list

Re: The Modernization of Emacs: terminology buffer and keybinding

2007-06-27 Thread Matthias Buelow
Bjorn Borud wrote: > I was told by a lot of people I consider to be intelligent that this > book would change how I think about writing software. it didn't. I > didn't really know what to expect, but after reading it I did feel > that its importance was greatly exaggerated. I think it's basical

Re: Getting importError: No module named _md5

2007-06-27 Thread half . italian
On Jun 27, 7:04 am, jeffself <[EMAIL PROTECTED]> wrote: > I'm running Python 2.5.1 which I'm getting from the MacPort package > system. I just installed Django and tried to start up the Django > server and I got the following error: > > ImportError: No module named _md5 > > I'm pretty sure this is

equality & comparison by default (was Re: Too many 'self' in python.That's a big flaw in this language.)

2007-06-27 Thread Alex Martelli
A.T.Hofkamp <[EMAIL PROTECTED]> wrote: > I think that again now with the default implementation of the > object.__eq__ and object.__hash__ methods. I believe these methods should > not exist until the programmer explicitly defines them with a suitable > notion of equivalence. > > Anybody ha

Re: import data.py using massive amounts of memory

2007-06-27 Thread GHUM
> Note that once it has made the .pyc file the subsequent runs take even > less memory than the cpickle import. Could that be the compiler compiling? Without knowing to much details about that process, but from 2.4 to 2.5 the compiler was totally exchanged, to AST. That would explain the drop f

Re: Python's "only one way to do it" philosophy isn't good?

2007-06-27 Thread Chris Mellon
On 6/27/07, Douglas Alan <[EMAIL PROTECTED]> wrote: > Paul Rubin writes: > > Gee, that's back to the future with 1975 Lisp technology. Destructors > are a much better model for dealing with such things (see not *all* > good ideas come from Lisp -- a few come from C++) a

Re: Too many 'self' in python.That's a big flaw in this language.

2007-06-27 Thread Bjoern Schliessmann
[EMAIL PROTECTED] wrote: > I'm currently using Python. How long have you been using Python? > I find that a instance variable > must confined with self, for example: > class a: > def __init__(self): > self.aa=10 > def bb(self): > print self.aa # > See .if in c++,I coul

16bit hash

2007-06-27 Thread Robin Becker
Is the any way to get an efficient 16bit hash in python? -- Robin Becker -- http://mail.python.org/mailman/listinfo/python-list

Re: simplifying algebraic expressions

2007-06-27 Thread Alex Martelli
DavidM <[EMAIL PROTECTED]> wrote: ... > Seems that I have to allow a 'punishment free' threshold of complexity, > otherwise the population stagnates. Sounds like you've hit on a good simulation of life: to get innovation, you must be very tolerant of errors!-) Alex -- http://mail.python.org/

Re: Python's "only one way to do it" philosophy isn't good?

2007-06-27 Thread Chris Mellon
On 6/27/07, Andy Freeman <[EMAIL PROTECTED]> wrote: > On Jun 26, 10:03 am, Paul Rubin wrote: > > > Map doesn't work on generators or iterators because they're not part > > > of the common lisp spec, but if someone implemented them as a library, > > > said library could ea

Re: Python's "only one way to do it" philosophy isn't good?

2007-06-27 Thread Andy Freeman
On Jun 26, 10:03 am, Paul Rubin wrote: > > Map doesn't work on generators or iterators because they're not part > > of the common lisp spec, but if someone implemented them as a library, > > said library could easily include a map that handled them as well. > > Right, mor

Re: The Modernization of Emacs: terminology buffer and keybinding

2007-06-27 Thread Twisted
On Jun 27, 8:26 am, [EMAIL PROTECTED] (Timofei Shatrov) wrote: > >For which you need an interpreter. Such as Ghostscript. Which is a > >pain to install and a bigger one to configure, even on Windoze. > > Lie. Ghostscript works out of the box on Windows. You're joking. First of all I am not a liar,

Re: Too many 'self' in python.That's a big flaw in this language.

2007-06-27 Thread A.T.Hofkamp
On 2007-06-27, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > HI > I'm currently using Python. I find that a instance variable must > confined with self, > for example: > class a: > def __init__(self): > self.aa=10 > def bb(self): > print self.aa # See .if in c++,I could

Re: Python's "only one way to do it" philosophy isn't good?

2007-06-27 Thread Andy Freeman
On Jun 27, 1:15 am, Paul Rubin wrote: > Dennis Lee Bieber <[EMAIL PROTECTED]> writes: > > >What happens when two individuals release "libraries" using these > > proposed macros -- and have implement conflicting macros using the same > > identifiers -- and you try to u

Re: urllib interpretation of URL with ".."

2007-06-27 Thread sergio
Gabriel Genellina wrote: > En Tue, 26 Jun 2007 17:26:06 -0300, sergio <[EMAIL PROTECTED]> > escribió: > >> John Nagle wrote: >> >>> In Python, of course, "urlparse.urlparse", which is >>> the main function used to disassemble a URL, has no idea whether it's >>> being used by a client or a server

  1   2   >