Bulova Marine Star Mens Watch 96B98 Collection

2008-11-03 Thread ndata
Bulova Marine Star Mens Watch 96B98 Collection Watches Collection Site : http://www.watches-collection.com/ Bulova Marine Star Mens Watch 96B98 View Full : http://bulova.watches-collection.com/Bulova-Marine-Star-Mens-Watch-96B98.html Bulova Marine Star Mens Watch 96B98 AdditionalInfo : Brand :

Re: push-style templating - an xml-like way to process xhtml

2008-11-03 Thread has
On 2 Nov, 14:06, Tino Wildenhain <[EMAIL PROTECTED]> wrote: > > An opposite approach to this form of dynamic HTML production is called > > push-style templating, as coined by Terence Parr: > > Hm. > > "$attr.title$ > $if(attr.active)$ > $attr.submenu:menuItem()$ > $endif$" > > This looks ugly to m

Re: how to call this dll in python

2008-11-03 Thread Diez B. Roggisch
Shark schrieb: I have a windows dll1.dll with a export function: int f1(char filename,char **buf,int *bufLen) { int len; //got the length of file anyway,such as 100 len = 100;//len = getLen(filename); *buf = (char*)calloc(100); *bufLen = len; return 0; } then how can I call the f1 function with

wrapping a method function call?

2008-11-03 Thread mh
I am instantiating a class A (which I am importing from somebody else, so I can't modify it) into my class X. Is there a way I can intercept or wrape calls to methods in A? I.e., in the code below can I call x.a.p1() and get the output X.pre A.p1 X.post Many TIA! Mark class A:

Re: wrapping a method function call?

2008-11-03 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: I am instantiating a class A (which I am importing from somebody else, so I can't modify it) into my class X. Is there a way I can intercept or wrape calls to methods in A? I.e., in the code below can I call x.a.p1() and get the output X.pre A.p1 X.po

Re: Why does numpy.array(a[0],b[0]) have this meaning?

2008-11-03 Thread Marc 'BlackJack' Rintsch
On Sun, 02 Nov 2008 23:26:24 -0800, Rick Giuly wrote: > Case 1 > This generates an error, which makes sense because the argument should > be a list of numbers: > numpy.array(10,10) > > Case 2 > This does not generate an error and the result is an array with a single > element: > a = numpy.array([

Re: Simplifying anonymous inner classes?

2008-11-03 Thread Duncan Booth
Tim Chase <[EMAIL PROTECTED]> wrote: >def __init__(self, ...): > self.parser = optparse.OptionParser(...) >def __call__(self, argv): # argv is a list like sys.argv > options, args = self.parser.parse_args(argv) > # do something with options/args > > So that background provi

Re: How to make money with Python!

2008-11-03 Thread gardsted
Grant Edwards wrote: On 2008-10-31, Duncan Booth <[EMAIL PROTECTED]> wrote: If that subject line didn't trip everyone's killfiles, see http://pythonide.blogspot.com/2008/10/how-to-make-money-with-free-software.html for a fantastic story involving Python. Doh! The very clever pun went right p

Re: wrapping a method function call?

2008-11-03 Thread Steven D'Aprano
On Mon, 03 Nov 2008 08:17:02 +, mh wrote: > I am instantiating a class A (which I am importing from somebody else, > so I can't modify it) into my class X. > > Is there a way I can intercept or wrape calls to methods in A? I.e., in > the code below can I call > >x.a.p1() > > and get the

length of a tuple or a list containing only one element

2008-11-03 Thread TP
Hi everybody, I have a question about the difference of behavior of "len" when applied on tuples or on lists. I mean: $ len( ( 'foo', 'bar' ) ) 2 $ len( ( 'foo' ) ) 3 $ len( [ 'foo', 'bar' ] ) 2 $ len( [ 'foo' ] ) 1 Why this behavior for the length computation of a tuple? For my application, I p

Simple textual calendar

2008-11-03 Thread ostra pikula
Hello everyone, please, I need your help. I'm a beginner in python and this is probably elemental to you, but represents quote a goggle for me. I'm trying to write out a calendar for a year, in this form (imaginary month below): 2008, February Mon Tue Wed Thu Fri

Re: Simple textual calendar

2008-11-03 Thread Arnaud Delobelle
ostra pikula <[EMAIL PROTECTED]> writes: > Hello everyone, > > please, I need your help. I'm a beginner in python and this is > probably elemental to you, but represents quote a goggle for me. > > I'm trying to write out a calendar for a year, in this form (imaginary > month below): > 2008,

How to protect website from access without authentication?

2008-11-03 Thread Good Z
Dear All, We are developing a website and would like to password protect the whole site. If any user visit our site using ip address or using the http link, he/she will be asked for login password and then granted the access to whole site based on the correct password. Help will be appreciate

Re: Structures

2008-11-03 Thread bearophileHUGS
Paulo J. Matos: > Since Python focus > on having one way to do it and structures are something like classes > with only public methods, if I want structures that's what I should use. > Is that right? Yes, it is. On the other hand in Python 2.6 there's something that helps you build one of such cla

Re: Efficient way to remove objects from a list

2008-11-03 Thread Tino Wildenhain
一首诗 wrote: Hi all, Today I wrote some code like this: for m in self.messages: if not m.finished: continue #process the message fini = [m for m in self.messages if m.finished] for m in fini: self.messages.remove(m) As

Re: Exact match with regular expression

2008-11-03 Thread Mr . SpOOn
On Sat, Nov 1, 2008 at 1:57 AM, Lawrence D'Oliveiro <[EMAIL PROTECTED]> wrote: > In message <[EMAIL PROTECTED]>, Rob > Williscroft wrote: > >> Read (and bookmark) this: >> >> http://www.python.org/doc/2.5.2/lib/re-syntax.html > > Funny how you never get a thank-you when you tell people to RTFM. My

Re: Efficient way to remove objects from a list

2008-11-03 Thread Peter Otten
M.-A. Lemburg wrote: >> The typical way to do this is to iterate over the list in reverse >> order and then using the item index as basis for removing the >> item: >> >> for i, item in enumerate(reversed(mylist)): >> # process item >> del mylist[i] > > Sorry, the above should read: > >

Re: Simple textual calendar

2008-11-03 Thread ostra pikula
On Mon, 03 Nov 2008 14:14:00 +0100, ostra pikula <[EMAIL PROTECTED]> wrote: >Hello everyone, > >please, I need your help. I'm a beginner in python and this is >probably elemental to you, but represents quote a goggle for me. > >I'm trying to write out a calendar for a year, in this form (imaginary

Re: length of a tuple or a list containing only one element

2008-11-03 Thread Tim Chase
For making a literal tuple, parentheses are irrelevant; only the commas matter: I don't think I'd go so far as to say that the parentheses around tuples are *irrelevant*...maybe just relevant in select contexts >>> def foo(*args): ... for i, arg in enumerate(args): ... prin

Re: Efficient way to remove objects from a list

2008-11-03 Thread Peter Otten
Chris Rebert wrote: > On Mon, Nov 3, 2008 at 1:40 AM, 一首诗 <[EMAIL PROTECTED]> wrote: >> Hi all, >> >> Today I wrote some code like this: >> > > Build a new list as you go, then overwrite the old list with it. > > unfinished = [] > >>for m in self.messages: >>if not m.finishe

Re: Simple textual calendar

2008-11-03 Thread ostra pikula
On Mon, 03 Nov 2008 13:25:44 +, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > >Have your looked at the calendar module? > >http://www.python.org/doc/2.5.2/lib/module-calendar.html > >HTH Hello Arnaud, thank you for replying. Yes, I saw the calendar module, but, as I said, this isn't homework

Re: wrapping a method function call?

2008-11-03 Thread mh
Steven D'Aprano <[EMAIL PROTECTED]> wrote: > Now you can monkey patch class A if you want. It's probably not a great > idea to do this in production code, as it will effect class A everywhere. > This is perfect for me. The code in question is basically a protocol translator... it receives reque

Re: Efficient way to remove objects from a list

2008-11-03 Thread M.-A. Lemburg
On 2008-11-03 12:12, M.-A. Lemburg wrote: >> 一首诗 wrote: >>> Hi all, >>> >>> Today I wrote some code like this: >>> >>> for m in self.messages: >>> if not m.finished: >>> continue >>> >>> #process the message >>> >>> fini = [m for m in self.mes

Re: Efficient way to remove objects from a list

2008-11-03 Thread Chris Rebert
On Mon, Nov 3, 2008 at 1:40 AM, 一首诗 <[EMAIL PROTECTED]> wrote: > Hi all, > > Today I wrote some code like this: > Build a new list as you go, then overwrite the old list with it. unfinished = [] >for m in self.messages: >if not m.finished: unfinished.append(

Re: Simple textual calendar

2008-11-03 Thread skip
ostra> It is an example which I've setted myself to try to solve to see ostra> how it would go. An even simpler solution is the cal command on Unix systems: % cal 2009 2009 JanFebMar S M Tu

Re: length of a tuple or a list containing only one element

2008-11-03 Thread Steve Holden
[EMAIL PROTECTED] wrote: [...] > Where OR, AND, XOR, NOT, SHL, SHR are the bitwise operators. > Having to type (| |) often is less handy, for example this code: Which is precisely why bare parentheses are used. And remember, you often don't need to put the parentheses in. While this kind of beginn

Re: Efficient way to remove objects from a list

2008-11-03 Thread 一首诗
Thanks! That's a more clear way! On Nov 3, 9:38 pm, Peter Otten <[EMAIL PROTECTED]> wrote: > Chris Rebert wrote: > > On Mon, Nov 3, 2008 at 1:40 AM, 一首诗 <[EMAIL PROTECTED]> wrote: > >> Hi all, > > >> Today I wrote some code like this: > > > Build a new list as you go, then overwrite the old list

Re: CAD.py

2008-11-03 Thread Eric Carlson
Hello, I have pondered this notion of a 3d sketcher a bit myself. Before I go on, here is a quote from writer Neil Gaiman, author of some very good books: "Every Published writer has had it - the people who come up to you and tell you that they've Got An Idea. And boy, is it a Doozy. It's suc

Re: Efficient way to remove objects from a list

2008-11-03 Thread M.-A. Lemburg
> 一首诗 wrote: >> Hi all, >> >> Today I wrote some code like this: >> >> for m in self.messages: >> if not m.finished: >> continue >> >> #process the message >> >> fini = [m for m in self.messages if m.finished] >> for m in fini: >>

Re: How to uninstall setuptools

2008-11-03 Thread Diez B. Roggisch
Roger Erens wrote: > On my Ubuntu8.04 box I installed python-all and subsequently setuptools > for both 2.4 and 2.5 interpreters. To make a clean upgrade to 8.10 I > need to uninstall setuptools. Any hints for doing that? It sounds as if you installed it using debian package management. Then you

encoding in lxml

2008-11-03 Thread jasiu85
Hey, I have a problem with character encoding in LXML. Here's how it goes: I read an HTML document from a third-party site. It is supposed to be in UTF-8, but unfortunately from time to time it's not. I parse the document like this: html_doc = HTML(string_with_document) Then I retrieve some inf

Re: wrapping a method function call?

2008-11-03 Thread Chris Rebert
On Mon, Nov 3, 2008 at 1:57 AM, <[EMAIL PROTECTED]> wrote: > Steven D'Aprano <[EMAIL PROTECTED]> wrote: >> Now you can monkey patch class A if you want. It's probably not a great >> idea to do this in production code, as it will effect class A everywhere. >> > > This is perfect for me. The code i

Re: Structures

2008-11-03 Thread Steve Holden
Paulo J. Matos wrote: > Hi all, > > I am a Python beginner, reading through 2.6 tutorial. I am wondering > where are structures? > > On the other hand, I think I might have the answer. Since Python focus > on having one way to do it and structures are something like classes > with only public met

Re: length of a tuple or a list containing only one element

2008-11-03 Thread bearophileHUGS
Steve Holden: > While this kind of beginner > mistake is common it isn't one that's frequently repeated once the > learner understands the syntax. You may be right, but I don't have to like it. When you teach programming to people that have never done it before, and you use Python, they spot simil

Re: CAD.py

2008-11-03 Thread r
On Nov 3, 8:29 am, Eric Carlson <[EMAIL PROTECTED]> wrote: > Hello, > > I have pondered this notion of a 3d sketcher a bit myself. Before I go > on, here is a quote from writer Neil Gaiman, author of some very good books: > > "Every Published writer has had it - the people who come up to you and >

Re: Executing a hidden/background program

2008-11-03 Thread imageguy
On Nov 2, 6:32 am, [EMAIL PROTECTED] wrote: > On Nov 2, 3:59 am, "Mike Driscoll" <[EMAIL PROTECTED]> wrote: > > > You probably want to create a Windows service with Python. There are > > various ways to accomplish this. > > Was considering a Windows service too, however would like to avoid > that a

Re: Simple textual calendar

2008-11-03 Thread Tim Chase
Yes, I saw the calendar module, but, as I said, this isn't homework or something like that. It is an example which I've setted myself to try to solve to see how it would go. Calendar just gives me the solution :-( Part of the answer to a problem is knowing when not to duplicate effort that's al

Re: newbie - merging xls files using xldt and xlwt

2008-11-03 Thread J Sutar
Mr Roskam, We have interacted before on the SPSS listserve, you have helped me out fair few times! I need a helping hand again, do you have the final solution to this problem, mergin xls from a given directory? Also where do I download the relevant modules from? Cheers Jigs 2008/10/15 Albert-j

Re: How to protect website from access without authentication?

2008-11-03 Thread Shawn Milochik
This isn't really a Python question -- it's a Web development question. The easy answer is to just password protect the directory all the pages are stored in, and require a password. This can be set up using Apache or IIS. If what you really meant to ask was how to prevent anyone from accessing ce

Re: Decorator for validation - inefficient?

2008-11-03 Thread Bryan
Steven D'Aprano wrote: > On Sun, 02 Nov 2008 09:33:41 -0800, Bryan wrote: > > > I'm coming from a .Net background, and yes, one of the reasons I did not > > consider raising exceptions was to avoid the overhead of an exception > > handler clause, which in .Net land is expensive. > > Actually catchi

How to select text of text field in python‏Card‏

2008-11-03 Thread Sonia
Hi, I need to select a text of text field! Which function is used for selection of text of text field? Sonia, _ Connect to the next generation of MSN Messenger  http://imagine-msn.com/messenger/launch80/default.aspx?locale=en-us&sou

Re: length of a tuple or a list containing only one element

2008-11-03 Thread bearophileHUGS
TP: > This is actually the length of a bracketed string, not a tuple. > Tuple's are defined by the existence of a comma...try: > >>> len(('foo',)) > 1 Time ago I have suggested to change the tuple literal, to avoid the warts of the singleton and empty tuple, that may lead to bugs. But using ASCII

Re: Simplifying anonymous inner classes?

2008-11-03 Thread Tim Chase
Is there a more Pythonic way to instantiate sub-classes and provide instance-specific implementations without the overhead of an unused "anonymous" class cluttering my code/namespace? I agree with Carl Banks that what you do is already fairly Pythonic: explicit is better than implicit, and simpl

Re: How to make money with Python!

2008-11-03 Thread Kay Schluehr
On 31 Okt., 15:30, Duncan Booth <[EMAIL PROTECTED]> wrote: > If that subject line didn't trip everyone's killfiles, see >  http://pythonide.blogspot.com/2008/10/how-to-make-money-with-free-sof... > for a fantastic story involving Python. > > -- > Duncan Boothhttp://kupuguy.blogspot.com Masterpiece

How to uninstall setuptools

2008-11-03 Thread Roger Erens
On my Ubuntu8.04 box I installed python-all and subsequently setuptools for both 2.4 and 2.5 interpreters. To make a clean upgrade to 8.10 I need to uninstall setuptools. Any hints for doing that? Thanks, Roger -- http://mail.python.org/mailman/listinfo/python-list

Re: Windows DOS box redirection

2008-11-03 Thread Lie Ryan
On Fri, 31 Oct 2008 18:35:25 +0100, Stef Mientki wrote: > Bill McClain wrote: >> On 2008-10-31, Tim Golden <[EMAIL PROTECTED]> wrote: >> >>> You've got a few options. >>> >>> >> Ok, thanks! >> >> It is a small hobbyist community. I'll just document it and tell them >> "life is hard fo

Re: Unyeilding a permutation generator

2008-11-03 Thread Terry Reedy
Steve Holden wrote: [EMAIL PROTECTED] wrote: Anyway what I want to do is experiment with code similar to this (i.e. same algorithm and keep the recursion) in other languages, particularly vbscript and wondered what it would look like if it was rewritten to NOT use the yield statement - or at l

Re: Unyeilding a permutation generator

2008-11-03 Thread Michele Simionato
On Nov 2, 10:34 pm, [EMAIL PROTECTED] wrote: > Anyway what I want to do is experiment with code similar to this (i.e. > same algorithm and keep the recursion) in other languages, > particularly vbscript and wondered what it would look like if it was > rewritten to NOT use the yield statement - or a

Re: split() and string.whitespace

2008-11-03 Thread Scott David Daniels
Steven D'Aprano wrote: On Fri, 31 Oct 2008 12:18:32 -0700, Chaim Krause wrote: I have arrived here while attempting to break down a larger problem. I got to this question when attempting to split a line on any whitespace character so that I could then add several other characters like ';' and ':

Efficient way to remove objects from a list

2008-11-03 Thread 一首诗
Hi all, Today I wrote some code like this: for m in self.messages: if not m.finished: continue #process the message fini = [m for m in self.messages if m.finished] for m in fini: self.messages.remove(m) As you can, I w

Problem using urllib to download images

2008-11-03 Thread tstrogen
I am using Python 2.6 on Mac OS 10.3.9. I have been trying to use: image = urllib.URLopener() image.retrieve(url, filename) to download images from websites. I am able to do so, and end up with the appropriate file. However, when I try to open the file, I get an error message. It's something about

Structures

2008-11-03 Thread Paulo J. Matos
Hi all, I am a Python beginner, reading through 2.6 tutorial. I am wondering where are structures? On the other hand, I think I might have the answer. Since Python focus on having one way to do it and structures are something like classes with only public methods, if I want structures that's what

Re: Structures

2008-11-03 Thread Ben Finney
"Paulo J. Matos" <[EMAIL PROTECTED]> writes: > I am a Python beginner, reading through 2.6 tutorial. I am wondering > where are structures? I'm wondering a more fundamental question: What are structures? That is, what do *you* mean by that term; without knowing that, an answer isn't likely to be

Tktable on 3.0rc1

2008-11-03 Thread info
Has anyone used Tktable on python 3.0 ? -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem using urllib to download images

2008-11-03 Thread [EMAIL PROTECTED]
On Nov 3, 11:48 am, [EMAIL PROTECTED] wrote: > I am using Python 2.6 on Mac OS 10.3.9. > I have been trying to use: > image = urllib.URLopener() > image.retrieve(url, filename) > to download images from websites. I am able to do so, and end up with > the appropriate file. However, when I try to ope

Re: length of a tuple or a list containing only one element

2008-11-03 Thread Arnaud Delobelle
[EMAIL PROTECTED] writes: > Steve Holden: >> While this kind of beginner >> mistake is common it isn't one that's frequently repeated once the >> learner understands the syntax. > > You may be right, but I don't have to like it. > When you teach programming to people that have never done it before

Re: length of a tuple or a list containing only one element

2008-11-03 Thread alex23
On Nov 3, 9:08 pm, TP <[EMAIL PROTECTED]> wrote: > I have a question about the difference of behavior of "len" when applied on > tuples or on lists. I mean: > $ len( ( 'foo' ) ) > 3 This is actually the length of a bracketed string, not a tuple. Tuple's are defined by the existence of a comma...tr

Re: Why does numpy.array(a[0],b[0]) have this meaning?

2008-11-03 Thread Robert Kern
Rick Giuly wrote: Hello All, Case 1 This generates an error, which makes sense because the argument should be a list of numbers: numpy.array(10,10) Case 2 This does not generate an error and the result is an array with a single element: a = numpy.array([10]) b = numpy.array([10]) numpy.array(a[

Tiny yet useful utility

2008-11-03 Thread Mariyam Pinto
Process Manager for Windows (http:// processpriority.wiki.sourceforge.net/) It has always been a pain to use applications like Office/Outlook/Matlab/Delphi/Mozilla...Image editing s/w ...video editing s/w They take huge memory... they eat up half of your CPU and when you wanna close them, then

Replacing cmp with key for sorting

2008-11-03 Thread George Sakkis
I want to sort sequences of strings lexicographically but those with longer prefix should come earlier, e.g. for s = ['a', 'bc', 'bd', 'bcb', 'ba', 'ab'], the sorted sequence is ['ab', 'a', 'ba', 'bcb', 'bc', 'bd']. Currently I do it with: s.sort(cmp=lambda x,y: 0 if x==y else

Re: Tiny yet useful utility

2008-11-03 Thread skip
Mariyam> Process Manager for Windows Mariyam> (http://processpriority.wiki.sourceforge.net/) It has always Mariyam> been a pain to use applications like Mariyam> Office/Outlook/Matlab/Delphi/Mozilla...Image editing s/w Mariyam> ...video editing s/w What is the connection with

Re: Tiny yet useful utility

2008-11-03 Thread George Sakkis
On Nov 3, 12:55 pm, [EMAIL PROTECTED] wrote: >     Mariyam> Process Manager for Windows >     Mariyam> (http://processpriority.wiki.sourceforge.net/) It has always >     Mariyam> been a pain to use applications like >     Mariyam> Office/Outlook/Matlab/Delphi/Mozilla...Image editing s/w >     Mariy

Re: push-style templating - an xml-like way to process xhtml

2008-11-03 Thread Glenn Linderman
On approximately 11/3/2008 12:20 AM, came the following characters from the keyboard of has: On 2 Nov, 14:06, Tino Wildenhain <[EMAIL PROTECTED]> wrote: An opposite approach to this form of dynamic HTML production is called push-style templating, as coined by Terence Parr: Hm. "$att

Re: Problem using urllib to download images

2008-11-03 Thread tstrogen
Then perhaps it's a problem with my os. [TERMINAL SESSION] [18:16:33 Mon Nov 03] python Python 2.6 (trunk:66714:66715M, Oct 1 2008, 18:36:04) [GCC 4.0.1 (Apple Computer, Inc. build 5370)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import urllib >>> url = '

Re: Replacing cmp with key for sorting

2008-11-03 Thread bearophileHUGS
On Nov 3, 6:49 pm, George Sakkis <[EMAIL PROTECTED]> wrote: > I want to sort sequences of strings lexicographically but those with > longer prefix should come earlier, e.g. for s = ['a', 'bc', 'bd', > 'bcb', 'ba', 'ab'], the sorted sequence is ['ab', 'a', 'ba', 'bcb', > 'bc', 'bd']. Currently I do

Re: length of a tuple or a list containing only one element

2008-11-03 Thread bearophileHUGS
Arnaud Delobelle: >And introduces some new inconsistencies for newcomers, e.g. > s = {1, 2, 3} # A set with 3 elements > s = {1} # A set with one element > s = {} # Surely, this should be an empty set!! Are you able to list other inconsistencies? Python3 introduces one or two warts, but removes

Re: Replacing cmp with key for sorting

2008-11-03 Thread Alan G Isaac
George Sakkis wrote: s.sort(cmp=lambda x,y: 0 if x==y else -1 if x.startswith(y) else +1 if y.startswith(x) else cmp(x,y)) Probably not what you had in mind ... >>> s ['a', 'b

Re: Replacing cmp with key for sorting

2008-11-03 Thread Arnaud Delobelle
George Sakkis <[EMAIL PROTECTED]> writes: > I want to sort sequences of strings lexicographically but those with > longer prefix should come earlier, e.g. for s = ['a', 'bc', 'bd', > 'bcb', 'ba', 'ab'], the sorted sequence is ['ab', 'a', 'ba', 'bcb', > 'bc', 'bd']. Currently I do it with: > > s.so

Re: Problem using urllib to download images

2008-11-03 Thread Jerry Hill
On Mon, Nov 3, 2008 at 2:21 PM, <[EMAIL PROTECTED]> wrote: > Then perhaps it's a problem with my os. > [TERMINAL SESSION] > [18:16:33 Mon Nov 03] python > Python 2.6 (trunk:66714:66715M, Oct 1 2008, 18:36:04) > [GCC 4.0.1 (Apple Computer, Inc. build 5370)] on darwin > Type "help", "copyright", "c

Re: Replacing cmp with key for sorting

2008-11-03 Thread bearophileHUGS
Alan G Isaac: > Probably not what you had in mind ... > ... > >>> maxlen = max(len(si) for si in s) >      >>> def k(si): return si+'z'*(maxlen-len(si)) This looks a little better: assert isinstance(s, str) sorted(s, key=lambda p: p.ljust(maxlen, "\255")) If the string is an unicode that ma

Re: encoding in lxml

2008-11-03 Thread pjacobi . de
Hi Mike, > I read an HTML document from a third-party site. It is supposed to be > in UTF-8, but unfortunately from time to time it's not. There will be host of more lightweight solutions, but you can opt to sanizite incominhg HTML with HTML Tidy (python binding available). It will replace inval

Re: wrapping a method function call?

2008-11-03 Thread Aaron Brady
On Nov 3, 3:57 am, [EMAIL PROTECTED] wrote: > Steven D'Aprano <[EMAIL PROTECTED]> wrote: > > Now you can monkey patch class A if you want. It's probably not a great > > idea to do this in production code, as it will effect class A everywhere. > > This is perfect for me.  The code in question is bas

Re: Problem using urllib to download images

2008-11-03 Thread tstrogen
> That's because you downloaded some HTML and saved it in a file named > logo.gif. That's unlikely to work in any image viewing program. Try > opening the file you downloaded in a text editor and you'll see. > > -- > Jerry Aha, so the first param is the file, and second is the name you save the

Re: Replacing cmp with key for sorting

2008-11-03 Thread Arnaud Delobelle
[EMAIL PROTECTED] writes: > Arnaud Delobelle: >> Here's another idea, probably more practical: >> >>> sorted(s, key=lambda x: tuple(256-ord(l) for l in x), reverse=True) > > Nice. > A variant that probably works with unicode strings too: > > print sorted(s, key=lambda x: [-ord(l) for l in x], reve

Re: Replacing cmp with key for sorting

2008-11-03 Thread bearophileHUGS
Arnaud Delobelle: > Here's another idea, probably more practical: > >>> sorted(s, key=lambda x: tuple(256-ord(l) for l in x), reverse=True) Nice. A variant that probably works with unicode strings too: print sorted(s, key=lambda x: [-ord(l) for l in x], reverse=True) Bye, bearophile -- http://ma

Re: Finding the instance reference of an object

2008-11-03 Thread Aaron Brady
On Nov 2, 10:13 pm, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Sun, 02 Nov 2008 13:23:11 -0800, Aaron Brady wrote: > > But, doing so, an object is not the same as a reference to it, and all > > Python does is pass and copy references. > > No, that's what at least one particular implementation

Re: length of a tuple or a list containing only one element

2008-11-03 Thread Ben Finney
TP <[EMAIL PROTECTED]> writes: > Hi everybody, > > I have a question about the difference of behavior of "len" when > applied on tuples or on lists. I mean: > > $ len( ( 'foo', 'bar' ) ) > 2 > $ len( ( 'foo' ) ) > 3 > $ len( [ 'foo', 'bar' ] ) > 2 > $ len( [ 'foo' ] ) > 1 For making a literal t

redirection in a file with os.system

2008-11-03 Thread TP
Hi everybody, The following code does not redirect the output of os.system("ls") in a file: import sys, os saveout = sys.stdout fd = open( 'toto', 'w' ) sys.stdout = fd os.system( "ls" ) sys.stdout = saveout fd.close() Whereas the following works: old_stdout = os.dup( sys.stdout.fileno() ) fd =

Re: Replacing cmp with key for sorting

2008-11-03 Thread bearophileHUGS
Arnaud Delobelle: > It's funny how the obvious escapes me so often. In this case it's a well known cognitive effect: the mind of humans clings to first good/working solution, not allowing its final tuning. For that you may need to think about something else for a short time, and then look at your

Re: redirection in a file with os.system

2008-11-03 Thread Arnaud Delobelle
TP <[EMAIL PROTECTED]> writes: > Hi everybody, > > The following code does not redirect the output of os.system("ls") in a > file: > > import sys, os > saveout = sys.stdout > fd = open( 'toto', 'w' ) > sys.stdout = fd > os.system( "ls" ) > sys.stdout = saveout > fd.close() > > Whereas the followin

script that parses command line, and execfile('')

2008-11-03 Thread TP
Hello, I have a script that uses the "optparse" package to parse the command line. For example: $ script.py --help # displays help about script.py Is this possible to call such a script with execfile('') once in the Python interactive shell? >>> execfile( 'script.py' ) I get errors because the

Re: script that parses command line, and execfile('')

2008-11-03 Thread Arnaud Delobelle
TP <[EMAIL PROTECTED]> writes: > Hello, > > I have a script that uses the "optparse" package to parse the command line. > For example: > > $ script.py --help > # displays help about script.py > > Is this possible to call such a script with execfile('') once in the Python > interactive shell? > >>>

Re: 2.6, 3.0, and truly independent intepreters

2008-11-03 Thread Andy O'Meara
On Oct 30, 11:09 pm, alex23 <[EMAIL PROTECTED]> wrote: > On Oct 31, 2:05 am, "Andy O'Meara" <[EMAIL PROTECTED]> wrote: > > > I don't follow you there. If you're referring to multiprocessing, our > > concerns are: > > > - Maturity (am I willing to tell my partners and employees that I'm > > betting

Re: length of a tuple or a list containing only one element

2008-11-03 Thread Scott David Daniels
Tim Chase wrote: For making a literal tuple, parentheses are irrelevant; only the commas matter: I don't think I'd go so far as to say that the parentheses around tuples are *irrelevant*...maybe just relevant in select contexts >>> def foo(*args): ... for i, arg in enumerate(args): ..

Re: script that parses command line, and execfile('')

2008-11-03 Thread Diez B. Roggisch
TP schrieb: Hello, I have a script that uses the "optparse" package to parse the command line. For example: $ script.py --help # displays help about script.py Is this possible to call such a script with execfile('') once in the Python interactive shell? execfile( 'script.py' ) I get errors

Re: length of a tuple or a list containing only one element

2008-11-03 Thread Tim Chase
For making a literal tuple, parentheses are irrelevant; only the commas matter: I don't think I'd go so far as to say that the parentheses around tuples are *irrelevant*...maybe just relevant in select contexts >>> def foo(*args): ... for i, arg in enumerate(args): ... print

Re: encoding in lxml

2008-11-03 Thread Stefan Behnel
jasiu85 wrote: > I have a problem with character encoding in LXML. Here's how it goes: > > I read an HTML document from a third-party site. It is supposed to be > in UTF-8, but unfortunately from time to time it's not. You can instantiate your own HTML parser and pass encoding="utf-8". That way,

Re: Replacing cmp with key for sorting

2008-11-03 Thread George Sakkis
On Nov 3, 1:51 pm, [EMAIL PROTECTED] wrote: > Arnaud Delobelle: > > > Here's another idea, probably more practical: > > >>> sorted(s, key=lambda x: tuple(256-ord(l) for l in x), reverse=True) > > Nice. > A variant that probably works with unicode strings too: > > print sorted(s, key=lambda x: [-or

How do I find the memory used by a python process

2008-11-03 Thread Salim Fadhley
I'm trying to create a python unit-test which will test a complex program which includes a number of functions which have been implemented in C or C++. The unit-test needs to check that after the functions have been run a few thousand times all of the memory used by those functions has been un-all

Re: Structures

2008-11-03 Thread Paulo J. Matos
On Mon, Nov 3, 2008 at 12:32 PM, Ben Finney <[EMAIL PROTECTED]> wrote: > "Paulo J. Matos" <[EMAIL PROTECTED]> writes: > >> I am a Python beginner, reading through 2.6 tutorial. I am wondering >> where are structures? > > I'm wondering a more fundamental question: What are structures? That > is, wha

Re: How do I find the memory used by a python process

2008-11-03 Thread Martin v. Löwis
> So each test would check the amount of memory available, call the > function N times and then check the amount of memory available > afterwards. If the amount of memory before and after changes by a > certain amount then the test is failed. Please take a look at the muppy package: http://pypi.p

Re: Finding the instance reference of an object

2008-11-03 Thread Joe Strout
On Nov 3, 2008, at 12:00 PM, Aaron Brady wrote: I think we can conclude that Python passes by reference, since a function can modify objects that were passed in to it. Then please write the Python equivalent of the "Swap" methods shown at (or at

Re: Unyeilding a permutation generator

2008-11-03 Thread Jorgen Grahn
On Sun, 2 Nov 2008 14:09:01 -0800 (PST), Aaron Brady <[EMAIL PROTECTED]> wrote: > On Nov 2, 3:34 pm, [EMAIL PROTECTED] wrote: ... >> for x in  all_permx("ABCD"): >>   print x ... > I think multi-threading is the "truest" to the original. You might > develop a framework to set events when particula

Re: Simple textual calendar

2008-11-03 Thread Jorgen Grahn
On Mon, 03 Nov 2008 09:17:25 -0600, Tim Chase <[EMAIL PROTECTED]> wrote: >> Yes, I saw the calendar module, but, as I said, this isn't >> homework or something like that. It is an example which I've >> setted myself to try to solve to see how it would go. Calendar >> just gives me the solution :-(

Re: Finding the instance reference of an object

2008-11-03 Thread Aaron Brady
On Nov 3, 2:44 pm, Joe Strout <[EMAIL PROTECTED]> wrote: > On Nov 3, 2008, at 12:00 PM, Aaron Brady wrote: > > > I think we can conclude that Python passes by reference, since a > > function can modify objects that were passed in to it. > > Then please write the Python equivalent of the "Swap" meth

Re: Structures

2008-11-03 Thread Ben Finney
"Paulo J. Matos" <[EMAIL PROTECTED]> writes: > On Mon, Nov 3, 2008 at 12:32 PM, Ben Finney > <[EMAIL PROTECTED]> wrote: > > I'm wondering a more fundamental question: What are structures? > > That is, what do *you* mean by that term; without knowing that, an > > answer isn't likely to be meaningfu

Re: How do I find the memory used by a python process

2008-11-03 Thread Ben Finney
Salim Fadhley <[EMAIL PROTECTED]> writes: > The unit-test needs to check that after the functions have been run > a few thousand times all of the memory used by those functions has > been un-allocated, i.e. that there are no memory leaks. This is a great test case, thanks. I must add it to my sto

Re: Structures

2008-11-03 Thread Arnaud Delobelle
Ben Finney <[EMAIL PROTECTED]> writes: > "Paulo J. Matos" <[EMAIL PROTECTED]> writes: [...] > Okay, you're talking about ‘struct’ from the C language. That helps > answer the question. Note that structs are mutable. > In Python, the way to do that is with a dict. A class can be used, but > is of

Re: Unyeilding a permutation generator

2008-11-03 Thread Marc 'BlackJack' Rintsch
On Mon, 03 Nov 2008 21:09:58 +, Jorgen Grahn wrote: > Why multi-threading? I see no concurrency in the original algorithm. > There is, in my mind, nothing concurrent about 'yield'. No "real" concurrency but a generator can be seen as independent thread of code where the generator code is al

Re: Structures

2008-11-03 Thread Aaron Brady
On Nov 3, 3:45 pm, Ben Finney <[EMAIL PROTECTED]> wrote: > "Paulo J. Matos" <[EMAIL PROTECTED]> writes: > > > On Mon, Nov 3, 2008 at 12:32 PM, Ben Finney > > <[EMAIL PROTECTED]> wrote: > > > I'm wondering a more fundamental question: What are structures? > > > That is, what do *you* mean by that te

  1   2   >