Re: pre-PEP: The create statement

2006-04-05 Thread Paddy
I wonder if the resulting code would look like Python. It seems a great way to unify how things are defined, but I would not want to mix the syntax with the current style. - Pad. -- http://mail.python.org/mailman/listinfo/python-list

Re: efficiency of range() and xrange() in for loops

2006-04-05 Thread Georg Brandl
Alan Morgan wrote: >>range is giving you a real list, while xrange is giving you an xrange object. >>Have you tried to slice an xrange object? Or using .append on it? > > No, I hadn't. I presume these could all be defined. How would xrange(100).remove(1) work? Georg -- http://mail.python.org/

Re: urllib.urlencode wrongly encoding ± character

2006-04-05 Thread sleytr
you are right. but when I capture traffic in firefox via livehttpheaders extension, it shows me that ± is encoded to %B1. Addition to that, I found lots of page about urlencoding they have a conversation tables or scripts. All of them defines ± as %B1 . realy confused? I can copy and use urlencod

Re: pre-PEP: The create statement

2006-04-05 Thread Carl Banks
Steven Bethard wrote: > This PEP proposes a generalization of the class-declaration syntax, > the ``create`` statement. The proposed syntax and semantics parallel > the syntax for class definition, and so:: > > create : > > > is translated into the assignment:: > > = ("", , ) >

Re: ``pickling'' and ``unpickling''

2006-04-05 Thread Lonnie Princehouse
Pickling is the Python term for serialization. See http://en.wikipedia.org/wiki/Serialization Suppose you want to save a Python object "x" to a file... output_file = open('my_pickle', 'wb') # open a file import pickle pickle.dump(x, output_file) # write x to the file output_file.close() ...

Re: efficiency of range() and xrange() in for loops

2006-04-05 Thread Fredrik Lundh
Steve R. Hastings wrote: > > the difference isn't very > > large, xrange is actually slower in some python versions, and you'll > > need the integer objects sooner or later anyway... > > Actually, for many uses of "for i in (range|xrange)", you only need the > value of i, and you aren't doing anyt

Re: slicing question: rawdata[j:j+1] == 'xx' #will this ever be true ??

2006-04-05 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > I am new to python language and most of my python programming has been > done with IronPython. > > I was looking at the source of markupbase.py which is included with > Python 2.4 and came across the following line of code:- > > if rawdata[j:j+1] == '--': #comment > > i

``pickling'' and ``unpickling''

2006-04-05 Thread sushant . sirsikar
Hi, I am new in Python World.I want to know what is mean by ``pickling'' and ``unpickling'' ? And how can we used it?Please Give Me some links of Picking Examples. Thanks Sushant -- http://mail.python.org/mailman/listinfo/python-list

Re: Convertion of Unicode to ASCII NIGHTMARE

2006-04-05 Thread Roger Binns
"Serge Orlov" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I have an impression that handling/production of byte order marks is > pretty clear: they are produced/consumed only by two codecs: utf-16 and > utf-8-sig. What is not clear? Are you talking about the C APIs in Python/SQL

Re: XMLRPCLIB appears to be broken?

2006-04-05 Thread Fredrik Lundh
"flamesrock" wrote: > So.. why the heck is it doing this Clearly it's pythons fault, but do you run PHP on a Python emulator ? if not, I completely fail to see how it can "clearly be Python's fault" that the XML-RPC binding you're using for PHP don't understand the XML-RPC protocol. > 1)why

Re: efficiency of range() and xrange() in for loops

2006-04-05 Thread Carl Banks
Steve R. Hastings wrote: > I wondered if the Python > compiler could, as a special case, turn: > > for i in range(n) > > into compiled code equivalent to > > for i in itr > > where "itr" is a lightweight iterator that returns the same values as > iter(range(n)). Nope, out of the question for Pytho

XMLRPCLIB appears to be broken?

2006-04-05 Thread flamesrock
Hi, I'm running xmlrpclib on python 2.4.2. The problem: When I pass arguments via xmlrpclib, it passes the args as a list to the first variable. Take this example (function should return second of two arguments, but always returns '') >>server = >>xmlrpclib.ServerProxy('http://simcitysphere.com

Re: pre-PEP: The create statement

2006-04-05 Thread Paul Rubin
I haven't looked at this enough to really understand it, but it looks interesting and promising. -- http://mail.python.org/mailman/listinfo/python-list

Re: Best way to have a for-loop index?

2006-04-05 Thread Klaas
roy spewed: > The real question is *why* do you want the index? > > If you're trying to iterate through list indicies, you're probably trying > to write C, C++, Fortran, Java, etc in Python. Could we stop the stupid continual beratement of people validly asking about enumerate()? Yes, we want to

pre-PEP: The create statement

2006-04-05 Thread Steven Bethard
The PEP below should be mostly self explanatory. I'll try to keep the most updated versions available at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt http://ucsu.colorado.edu/~bethard/py/pep_create_statement.html PEP: XXX Title: The create statement Version: $Revisi

RE: Python and microsoft outlook-using com, can I interact with msoutlook?

2006-04-05 Thread brandon.mcginty
Thanks to the 2 people who've replied; it's been a little harder than I thought to use outlook, but I'll get the hang of it, and I sincerely thank you both. THX, Brandon McGinty -- Feel free to contact me for technical support, or just to chat; I always have time to talk and help, and a

slicing question: rawdata[j:j+1] == 'xx' #will this ever be true ??

2006-04-05 Thread richard . hsu
I am new to python language and most of my python programming has been done with IronPython. I was looking at the source of markupbase.py which is included with Python 2.4 and came across the following line of code:- if rawdata[j:j+1] == '--': #comment i was confused because based on my understa

Re: Convertion of Unicode to ASCII NIGHTMARE

2006-04-05 Thread Serge Orlov
Roger Binns wrote: > "Fredrik Lundh" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > Roger Binns wrote: > > > >> SQLite only accepts Unicode so a Unicode string has to be supplied. > > > > fact or FUD? let's see: > > Note I said SQLite. For APIs that take/give strings, you can eit

Re: python on Mac

2006-04-05 Thread Robert Kern
Robert Kern wrote: > James Stroud wrote: >>The python in /usr/bin is a link (to a link). You can do this: >> >>sudo rm /usr/bin/python >>sudo ln -s \ >>/System/Library/Frameworks/Python.framework/Versions/2.4/bin/python \ >>/usr/bin/python > > No, for the love of all that is holy, don't d

Re: python on Mac

2006-04-05 Thread Robert Kern
James Stroud wrote: > Thomas Nelson wrote: > >>I just purchased a new macbook (os 10.4.6), and I'm trying to install >>python 2.4 on it. I downloaded and ran the two installers recommended >>at http://www.python.org/download/mac/. Now I have IDLE, which runs >>2.4.1, but typing "python" at a ter

Splitting a string with extra parameters

2006-04-05 Thread Chris P
Hello list, I just started using python and I must say I enjoy it very much. I do have an issue in which I hope to get some pointers to. I have a string, which I need to split based on a delimiter. This I know how to do. But what I cannot figure out is, take for example the following: "column 1

Re: python on Mac

2006-04-05 Thread pierreth
You removed /usr/bin/python! This is a really bad idea. You should never modify /usr/bin because the system is expecting it. This is why the new installation is in /usr/local/bin. Modify your /usr/local instead are change your .login file instead. It is much safer. -- http://mail.python.org/mail

Re: using range() in for loops

2006-04-05 Thread Alex Martelli
Georg Brandl <[EMAIL PROTECTED]> wrote: > Steven D'Aprano wrote: > > On Wed, 05 Apr 2006 16:15:12 +0200, Georg Brandl wrote: > > > >> [EMAIL PROTECTED] wrote: > >>> hi John, > >>> Python doesn't provide for loop like C / C++ but using Range() or > >>> Xrange() you can achive all the function

Re: how to login a newsgroup programmely and fetch its emails to read?

2006-04-05 Thread alex23
Frank Potter wrote: > how to login a newsgroup and get its informations by an account and a > password? by using the nntplib module in the library: http://docs.python.org/lib/module-nntplib.html - alex23 -- http://mail.python.org/mailman/listinfo/python-list

Re: Installing Python 2.4 on RedHat

2006-04-05 Thread Ju Hui
install new version on differente location. use ln -s to use new python. -- http://mail.python.org/mailman/listinfo/python-list

Installing Python 2.4 on RedHat

2006-04-05 Thread pierreth
Hello, I made some programming wit Python 2.4 but Red Hat comes with version 2.3 as default. So I would like to install the last version of Python on a production server but I am a bit afraid. As I know, if I install the new version, the default version will still be 2.3, right? I would like to kn

Re: A way to read shelves quickly?

2006-04-05 Thread flamesrock
Have you though about using threads? -- http://mail.python.org/mailman/listinfo/python-list

Re: urllib.urlencode wrongly encoding ± character

2006-04-05 Thread Serge Orlov
[EMAIL PROTECTED] wrote: > Hi, I'm trying to make a gui for a web service. Site using ± > character in value of some fields. But I can't encode this character > properly. > > > >>> data = {'key':'±'} > >>> urllib.urlencode(data) > 'key=%C2%B1' > > but it should be only %B1 not %C2%B1. It should b

Re: python on Mac

2006-04-05 Thread Thomas Nelson
Thanks to you both. I downloaded the dmg suggested, and trustingly typed: sudo rm /usr/bin/python sudo ln -s /usr/local/bin/python2.4 /usr/bin/python And now my command line and scripts behave the way I expect. Thanks again. THN -- http://mail.python.org/mailman/listinfo/python-list

Re: MOO meets Python

2006-04-05 Thread alex23
There's also the unfortunately named POO: http://www.strout.net/python/poo/index.html (Although that page claims it hasn't been updated since '98...) Python has already reminded me of MOO-coding in some key ways: the object model, the core libraries, the minimalism of the language. - alex23 --

Re: efficiency of range() and xrange() in for loops

2006-04-05 Thread Azolex
Steve R. Hastings wrote: > On Thu, 06 Apr 2006 02:33:16 +0200, Azolex wrote: >> Don't. It's quite funny, thanks. > > I guess I should laugh. :-/ > > > When you read my original articles, did *you* think I was proposing that > range() be changed to always return an iterator? I thought what I wr

how to login a newsgroup programmely and fetch its emails to read?

2006-04-05 Thread Frank Potter
how to login a newsgroup and get its informations by an account and a password? -- http://mail.python.org/mailman/listinfo/python-list

Re: efficiency of range() and xrange() in for loops

2006-04-05 Thread Felipe Almeida Lessa
Em Qua, 2006-04-05 às 19:15 -0700, Alex Martelli escreveu: > Steve R. Hastings <[EMAIL PROTECTED]> wrote: >... > > Actually, for many uses of "for i in (range|xrange)", you only need the > > value of i, and you aren't doing anything with the integer object. You > > Then, the speediest approac

Re: efficiency of range() and xrange() in for loops

2006-04-05 Thread Alex Martelli
Steve R. Hastings <[EMAIL PROTECTED]> wrote: ... > Actually, for many uses of "for i in (range|xrange)", you only need the > value of i, and you aren't doing anything with the integer object. You Then, the speediest approach may be completely different: import itertools for i in itertools.re

Re: python on Mac

2006-04-05 Thread Alex Martelli
Thomas Nelson <[EMAIL PROTECTED]> wrote: ... > at http://www.python.org/download/mac/. Now I have IDLE, which runs Darn, that page needs to be fixed -- it's out of date!-( Sorry... See instead and download

Re: efficiency of range() and xrange() in for loops

2006-04-05 Thread Felipe Almeida Lessa
Em Qua, 2006-04-05 às 22:24 +0200, Fredrik Lundh escreveu: > the difference isn't very > large, xrange is actually slower in some python versions, and you'll > need the integer objects sooner or later anyway... Some code is worth a thousand words: $ python2.3 Python 2.3.5 (#2, Mar 6 2006, 10:1

Re: how to convert string

2006-04-05 Thread Azolex
a couple more exotic variations print (10 * "%s ") % tuple(range(10)) print filter(lambda x : x not in "[,]",str(range(10))) -- http://mail.python.org/mailman/listinfo/python-list

urllib.urlencode wrongly encoding ± character

2006-04-05 Thread sleytr
Hi, I'm trying to make a gui for a web service. Site using ± character in value of some fields. But I can't encode this character properly. >>> data = {'key':'±'} >>> urllib.urlencode(data) 'key=%C2%B1' but it should be only %B1 not %C2%B1. where is this %C2 coming from? -- http://mail.python

Re: output formatting for user-defined types

2006-04-05 Thread Russ
Thanks, but that is not acceptable for my application. Any other ideas? I thought I might be able to overload __rmod__, but apparently python applies the % operator before __rmod__ is even invoked if the left-hand argument is a string. -- http://mail.python.org/mailman/listinfo/python-list

Re: binding - python

2006-04-05 Thread John McMonagle
Quoc, the following code, verbatim, works for me: from Tkinter import * class Pong(Frame): def createWidgets(self): self.QUIT = Button(self, text='QUIT', foreground='red', command=self.quit) self.QUIT.pack(side=LEFT, fill=BOTH) ## The playi

Re: IMPORTANT 2.5 API changes for C Extension Modules

2006-04-05 Thread David Rushby
Thank you for taking the time to pull the relevant links together and make this post, Neal. -- http://mail.python.org/mailman/listinfo/python-list

Re: kinterbas and Python

2006-04-05 Thread David Rushby
Balin wrote: > Hi all, > I have some problem with packege kinterbas for Firebird db connection > this is my code: > > import kinterbasdb > > class ConnessioneDB: > def initialize(self): > kinterbasdb.init(concurrency_level=1) > con = kinterbasdb.connect(host='192.168.1.20', > da

LINKFORSHARED problem on Mac OS 10.4

2006-04-05 Thread Andrew Trevorrow
[I sent this to pythonmac-sig but never got a reply, so hopefully there are more Mac Python gurus here.] I recently added Python scripting to our app (an open source, cross-platform Life app called Golly; see http://golly.sourceforge.net/ if you're interested). Based on what I read at http://pyth

Re: output formatting for user-defined types

2006-04-05 Thread Peter Hansen
Russ wrote: > I'd like to get output formatting for my own classes that mimics the > built-in output formatting. For example, > > x = 4.54 print "%4.2f" % x > > > 4.54 > > In other words, if I substitute a class instance for "x" above, I'd > like to make the format string apply to an e

Re: python on Mac

2006-04-05 Thread Thomas Nelson
There is no 2.4 in my Versions folder, only 2.3 and current. Should one of the installers have created this directory? Which one? THN -- http://mail.python.org/mailman/listinfo/python-list

Re: A Lambda Logo Tour

2006-04-05 Thread David Hopwood
Xah Lee wrote: > PS if you know any new lambda logo, please let me know. Thanks. ^ Oops, no, that would be an old lambda logo... -- David Hopwood <[EMAIL PROTECTED]> -- http://mail.python.org/mailman/listinfo/python-list

Re: python on Mac

2006-04-05 Thread James Stroud
Thomas Nelson wrote: > I just purchased a new macbook (os 10.4.6), and I'm trying to install > python 2.4 on it. I downloaded and ran the two installers recommended > at http://www.python.org/download/mac/. Now I have IDLE, which runs > 2.4.1, but typing "python" at a terminal still opens 2.3.5,

Re: efficiency of range() and xrange() in for loops

2006-04-05 Thread Azolex
Steve R. Hastings wrote: > On Thu, 06 Apr 2006 09:08:45 +1000, Steven D'Aprano wrote: >> Yes, the above example is a good use case for xrange. Did you think that >> anyone denied that there were good cases for it? > > I am now officially sorry for starting this thread. Don't. It's quite funny, th

Re: efficiency of range() and xrange() in for loops

2006-04-05 Thread Steve R. Hastings
On Thu, 06 Apr 2006 02:33:16 +0200, Azolex wrote: > Don't. It's quite funny, thanks. I guess I should laugh. :-/ When you read my original articles, did *you* think I was proposing that range() be changed to always return an iterator? I thought what I wrote was pretty clear... -- Steve R. Has

Re: how to convert string

2006-04-05 Thread swami426
Try this for x in range(10): sys.stdout.write(x) sys.stdout.write(" ") 0 1 2 3 4 5 6 7 8 9 [EMAIL PROTECTED] wrote: > I want to print number 0 to 9 in one line like this > 0 1 2 3 4 5 6 7 8 9 > > if I do like this, it prints in different lines > > for i in xrange(10): > pr

Re: is there any bug in this multi-thread script?

2006-04-05 Thread Ju Hui
up... -- http://mail.python.org/mailman/listinfo/python-list

python on Mac

2006-04-05 Thread Thomas Nelson
I just purchased a new macbook (os 10.4.6), and I'm trying to install python 2.4 on it. I downloaded and ran the two installers recommended at http://www.python.org/download/mac/. Now I have IDLE, which runs 2.4.1, but typing "python" at a terminal still opens 2.3.5, because it points to /usr/bin

binding - python

2006-04-05 Thread beta
Dear All, I am new with Python. I have question on binding. I have small pingpong application, I want to change color og the ball whenever mouse is clicked. I have theBall and changeColor functions. I don't know how to bind it together. Does anyone know? I am very appreciate of your help. Thanks.

Re: efficiency of range() and xrange() in for loops

2006-04-05 Thread Alan Morgan
In article <[EMAIL PROTECTED]>, Erik Max Francis <[EMAIL PROTECTED]> wrote: >Alan Morgan wrote: > >> In article <[EMAIL PROTECTED]>, >> Giovanni Bajo <[EMAIL PROTECTED]> wrote: > > >>>Because you assume that the only use-case of range() is within a for-loop. >>>range() is a builtin function that c

output formatting for user-defined types

2006-04-05 Thread Russ
I'd like to get output formatting for my own classes that mimics the built-in output formatting. For example, >>> x = 4.54 >>> print "%4.2f" % x 4.54 In other words, if I substitute a class instance for "x" above, I'd like to make the format string apply to an element or elements of the instance

Re: Counting all permutations of a substring

2006-04-05 Thread Azolex
[counting all (possibly overlapping) occurences of a substring in a string] def count_subs(s,subs,pos=0) : pos = 1+s.find(subs,pos) return pos and 1+count_subs(s,subs,pos) or equivalently def count_subs(s,subs) pos,cnt = 0,0 while True : pos = 1+s.find(subs,pos)

Re: efficiency of range() and xrange() in for loops

2006-04-05 Thread Steve R. Hastings
On Thu, 06 Apr 2006 09:08:45 +1000, Steven D'Aprano wrote: > Yes, the above example is a good use case for xrange. Did you think that > anyone denied that there were good cases for it? I am now officially sorry for starting this thread. Please let me just summarize what I wanted to say: * Ques

Re: efficiency of range() and xrange() in for loops

2006-04-05 Thread Alan Morgan
In article <[EMAIL PROTECTED]>, Georg Brandl <[EMAIL PROTECTED]> wrote: >Alan Morgan wrote: >> In article <[EMAIL PROTECTED]>, >> Giovanni Bajo <[EMAIL PROTECTED]> wrote: >>>Steve R. Hastings wrote: >>> > in Python 2.X, range is defined to return a list. if you start > returning something

Re: Mouse event - binding

2006-04-05 Thread John McMonagle
On Wed, 2006-04-05 at 16:04 -0700, beta wrote: > Hi John, > > It don't work! > I did what you told me, here is theBall function > > def theBall(self): > self.ball = self.draw.create_oval("0i", "0i", "0.20i", > "0.20i", > fill="red") > se

Re: Mouse event - binding

2006-04-05 Thread John McMonagle
On Wed, 2006-04-05 at 16:04 -0700, beta wrote: > Hi John, > > It don't work! > I did what you told me, here is theBall function > > def theBall(self): > self.ball = self.draw.create_oval("0i", "0i", "0.20i", > "0.20i", > fill="red") > se

A way to read shelves quickly?

2006-04-05 Thread zmason
I have a collection of about 5M shelves, each consisting of string->int mappings with on the order of 500 entries per shelf. I want to iterate through them rapidly and get the contents of each. But calling items() on each of them is slow - on the order of 1 or 2 seconds. Is there any way I can s

Re: how to convert string

2006-04-05 Thread Recoruds
for i in xrange(10): print i, this could be fine. -- http://mail.python.org/mailman/listinfo/python-list

Re: Mouse event - binding

2006-04-05 Thread beta
Hi John, It don't work! I did what you told me, here is theBall function def theBall(self): self.ball = self.draw.create_oval("0i", "0i", "0.20i", "0.20i", fill="red") self.draw.tag_bind(self.ball, '', changeColour) Would you review all

Re: efficiency of range() and xrange() in for loops

2006-04-05 Thread Steven D'Aprano
On Wed, 05 Apr 2006 15:02:33 -0700, Steve R. Hastings wrote: > On Wed, 05 Apr 2006 22:24:24 +0200, Fredrik Lundh wrote: >>> If Python actually allocates the list, then clearly we should all use >>> "for i in xrange". >> >> clearly we should all? speak for yourself. > > I apologize for my pithy

Re: efficiency of range() and xrange() in for loops

2006-04-05 Thread Georg Brandl
Alan Morgan wrote: > In article <[EMAIL PROTECTED]>, > Giovanni Bajo <[EMAIL PROTECTED]> wrote: >>Steve R. Hastings wrote: >> in Python 2.X, range is defined to return a list. if you start returning something else, you'll break stuff. >>> >>> Perhaps I'm mistaken here, but I don't see ho

Re: efficiency of range() and xrange() in for loops

2006-04-05 Thread Erik Max Francis
Alan Morgan wrote: > In article <[EMAIL PROTECTED]>, > Giovanni Bajo <[EMAIL PROTECTED]> wrote: > >>Because you assume that the only use-case of range() is within a for-loop. >>range() is a builtin function that can be used in any Python expression. For >>instance: >> >>RED, GREEN, BLUE, WHITE, B

Re: How to parse a name out of a web page?

2006-04-05 Thread Andrew Gwozdziewycz
On Apr 5, 2006, at 4:50 PM, Haibao Tang wrote: > with high accuracy... > > My temporary plan is to first recognized consecutive two or three > initial-capitalized words, but certainly we need to do more than that? > Anyone has suggestions? > > Thanks first. > > -- > http://mail.python.org/mailma

Re: Counting all permutations of a substring

2006-04-05 Thread Andrew Gwozdziewycz
On Apr 5, 2006, at 5:07 PM, Chris Lasher wrote: > Hi all, > How can one count all the permutations of a substring in a string? For > a more concrete example, let's say > targetstr = 'AAA' > and > probestr = 'AA' > > I want to consider how many times one can count probestr ('AA') in > targetstr ('

Re: efficiency of range() and xrange() in for loops

2006-04-05 Thread Steve R. Hastings
On Wed, 05 Apr 2006 22:09:29 +, Giovanni Bajo wrote: > [...] you assume that the only use-case of range() is within a for-loop. No, I do not assume any such thing. I have not suggested that range() should be changed to always return an iterator. I wondered if the Python compiler could, as a

Re: efficiency of range() and xrange() in for loops

2006-04-05 Thread Alan Morgan
In article <[EMAIL PROTECTED]>, Giovanni Bajo <[EMAIL PROTECTED]> wrote: >Steve R. Hastings wrote: > >>> in Python 2.X, range is defined to return a list. if you start >>> returning something else, you'll break stuff. >> >> Perhaps I'm mistaken here, but I don't see how this optimization could >>

Re: Unicode question : turn "José" into u"José"

2006-04-05 Thread Ben Finney
"Ian Sparks" <[EMAIL PROTECTED]> writes: > This is probably stupid and/or misguided but supposing I'm passed a > byte-string value that I want to be unicode, this is what I do. I'm > sure I'm missing something very important. Perhaps you need to read one of the good Python Unicode tutorials, such

Re: Mouse event - binding

2006-04-05 Thread John McMonagle
On Wed, 2006-04-05 at 09:21 -0700, beta wrote: > Dear John, > > Thanks for your help. I don't know how to bind the ball only into a > program. Would you mind help me on this? I added the changeColour > function, here is a complete program. ...SNIP code... Add the following code after you draw t

Re: small challenge : fixpoint((x+1)**0.5 for x in itially(2))

2006-04-05 Thread Azolex
Paul McGuire wrote: > Howzis? > > -- Paul > > > class Bag: > pass > data = Bag() > data.x = None > > def itially(bar): > if data.x is None: > data.x = bar > while 1: > yield data.x > > def limit(z): > eps = 1e-10 > done = False > z2 = z.next() > z1 =

Re: How to parse a name out of a web page?

2006-04-05 Thread Rune Strand
Haibao Tang wrote: > with high accuracy... > > My temporary plan is to first recognized consecutive two or three > initial-capitalized words, but certainly we need to do more than that? > Anyone has suggestions? > > Thanks first. It's not easy to say without seeing the HTML. If you the structure

Re: efficiency of range() and xrange() in for loops

2006-04-05 Thread Giovanni Bajo
Steve R. Hastings wrote: >> in Python 2.X, range is defined to return a list. if you start >> returning something else, you'll break stuff. > > Perhaps I'm mistaken here, but I don't see how this optimization could > possibly break anything. Because you assume that the only use-case of range() i

Re: efficiency of range() and xrange() in for loops

2006-04-05 Thread Steve R. Hastings
On Wed, 05 Apr 2006 22:24:24 +0200, Fredrik Lundh wrote: >> If Python actually allocates the list, then clearly we should all use >> "for i in xrange". > > clearly we should all? speak for yourself. I apologize for my pithy turn of phrase. Clearly what I should have written was: "If Python act

Re: Filters like old skool Jive, Fudd, Valspeak... Text transformation in Python

2006-04-05 Thread John Machin
> Any good "generators" written in Python? I'd like to roll me one of > these as well; e.g. execute the program and it will create a few > paragraphs of text in the jargon of a discipline, subdiscipline, > subculture, etc. Anyone know what I'm talking about? Perhaps you might be interested in this

Re: Counting all permutations of a substring

2006-04-05 Thread [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote: > Chris Lasher wrote: > > Hi all, > > How can one count all the permutations of a substring in a string? For > > a more concrete example, let's say > > targetstr = 'AAA' > > and > > probestr = 'AA' > > > > I want to consider how many times one can count probestr ('AA') in

Re: how to comment lot of lines in python

2006-04-05 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Michael Sperlle wrote: > What's wrong with using three sets of double-quotes? One can't comment out code that contains multiline strings. Especially nested comment out does not work. > I do it with kwrite and it works like a charm. Why not Ctrl+D (comment) and Ctrl+Shif

Re: Counting all permutations of a substring

2006-04-05 Thread [EMAIL PROTECTED]
Chris Lasher wrote: > Hi all, > How can one count all the permutations of a substring in a string? For > a more concrete example, let's say > targetstr = 'AAA' > and > probestr = 'AA' > > I want to consider how many times one can count probestr ('AA') in > targetstr ('AAA'). The value in this exam

Re: Unicode question : turn "José" into u"José"

2006-04-05 Thread Kent Johnson
ianaré wrote: > maybe a bit off topic, but how does one find the console's encoding > from within python? > In [1]: import sys In [3]: sys.stdout.encoding Out[3]: 'cp437' In [4]: sys.stdin.encoding Out[4]: 'cp437' Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Unicode question : turn "José" into u"José"

2006-04-05 Thread John Machin
The most important thing that you are missing is that you need to know the encoding used for the 8-bit-character string. Let's guess that it's Latin1. Then all you have to do is use the unicode() builtin function, or the string decode method. # >>> s = 'Jos\xe9' # >>> s # 'Jos\xe9' # >>> u = unico

Re: how to convert string

2006-04-05 Thread Ben C
On 2006-04-05, Scott David Daniels <[EMAIL PROTECTED]> wrote: > Ben C wrote: >> ... But this puts an extra space on the end (so did the print i, >> version above). > Actually, no (the trailing-comma prints do a funny dance). > Check it out: [...] You're right, I tried it! Thanks for that. Useful,

Re: Unicode question : turn "José" into u"José"

2006-04-05 Thread ianaré
maybe a bit off topic, but how does one find the console's encoding from within python? -- http://mail.python.org/mailman/listinfo/python-list

wxPython problem with freeze.py

2006-04-05 Thread ianaré
I have a wxPython application that i can run no problem from source, now i want to freeze it for distribution. I tried the freeze.py script and got the following output: freezing Frame1 ... freezing UserDict ... freezing __main__ ... freezing codecs ... freezing copy ... freezing copy_reg ... fre

Re: efficiency of range() and xrange() in for loops

2006-04-05 Thread [EMAIL PROTECTED]
Todd wrote: > Steve R. Hastings wrote: > > When you compile the expression > > > > for i in range(1000): > > pass > > > > does Python make an iterator for range(), and then generate the values > > on the fly? Or does Python actually allocate the list [0, 1, 2, ..., 999] > > and then s

Re: Best way to have a for-loop index?

2006-04-05 Thread nikie
Roy Smith wrote: > In article <[EMAIL PROTECTED]>, > [EMAIL PROTECTED] wrote: > > > I write a lot of code that looks like this: > > > > for myElement, elementIndex in zip( elementList, > > range(len(elementList))): > > print "myElement ", myElement, " at index: ",elementIndex > > > > > > My q

Re: "The World's Most Maintainable Programming Language"

2006-04-05 Thread Ralf Muschall
Mirco Wahab wrote: > Perl, named after Pearl Biggar (Larry Wall’s fiancée), His wife was Gloria since at least 1979, perl was published in 1987. This seems to be an insider joke (he wanted to call the language "Gloria" first, then "pearl", then "perl"). > set a high standard for naming techni

Counting all permutations of a substring

2006-04-05 Thread Chris Lasher
Hi all, How can one count all the permutations of a substring in a string? For a more concrete example, let's say targetstr = 'AAA' and probestr = 'AA' I want to consider how many times one can count probestr ('AA') in targetstr ('AAA'). The value in this example is, obviously, 2: you can match th

Re: Filters like old skool Jive, Fudd, Valspeak... Text transformation in Python

2006-04-05 Thread John Salerno
Dave Hansen wrote: > Don't forget the famous American philosopher who contemplated the > meaning of is. Unfortunately, until he gives us a definition, we'll never really know who he is... :) -- http://mail.python.org/mailman/listinfo/python-list

Re: Unicode question : turn "José" into u"José"

2006-04-05 Thread aurora
First of all, if you run this on the console, find out your console's encoding. In my case it is English Windows XP. It uses 'cp437'. C:\>chcp Active code page: 437 Then >>> s = "José" >>> u = u"Jos\u00e9" # same thing in unicode escape >>> s.decode('cp437') == u # use encoding that

Re: efficiency of range() and xrange() in for loops

2006-04-05 Thread Todd
Steve R. Hastings wrote: > When you compile the expression > > for i in range(1000): > pass > > does Python make an iterator for range(), and then generate the values > on the fly? Or does Python actually allocate the list [0, 1, 2, ..., 999] > and then step through it? I ran an expe

Re: Filters like old skool Jive, Fudd, Valspeak... Text transformation in Python

2006-04-05 Thread Dave Hansen
On 5 Apr 2006 13:44:48 -0700 in comp.lang.python, [EMAIL PROTECTED] wrote: >bruno at modulix wrote: >> There's a Kant generator example in Dive Into Python: >> http://diveintopython.org/xml_processing/index.html > >Thanks Bruno! Perhaps I could modify it to throw in some Hume and >Wittgenstein, mi

How to parse a name out of a web page?

2006-04-05 Thread Haibao Tang
with high accuracy... My temporary plan is to first recognized consecutive two or three initial-capitalized words, but certainly we need to do more than that? Anyone has suggestions? Thanks first. -- http://mail.python.org/mailman/listinfo/python-list

Re: Filters like old skool Jive, Fudd, Valspeak... Text transformation in Python

2006-04-05 Thread dananrg
bruno at modulix wrote: > There's a Kant generator example in Dive Into Python: > http://diveintopython.org/xml_processing/index.html Thanks Bruno! Perhaps I could modify it to throw in some Hume and Wittgenstein, mix it all up in a syntactic / semantic blender and REALLY confuse people. Word Gam

topmole.com: Best of the best hardware and software lists

2006-04-05 Thread Top
Best of the best hardware lists at http://www.topmole.com Don't waste hours searching for the best graphics card or digital camera find it instantly on www.topmole.com Find the best: AMD Socket 939 Motherboards Internal Hard Drives 17 inch TFT Monitors 19 inch TFT Monitors 20 inch TFT Monitors

Re: RELEASED Python 2.5 (alpha 1)

2006-04-05 Thread Michael Ekstrand
Michele Simionato wrote: > Michael Ekstrand wrote: >> After reading AMK's survey of what's new in Python 2.5, I am suitably >> impressed. As usual, I can't wait to start using the cool new >> features... extended generators? (mind is currently swimming with the >> question of "can I implement Sche

Unicode question : turn "José" into u"José"

2006-04-05 Thread Ian Sparks
This is probably stupid and/or misguided but supposing I'm passed a byte-string value that I want to be unicode, this is what I do. I'm sure I'm missing something very important. Short version : >>> s = "José" #Start with non-unicode string >>> unicoded = eval("u'%s'" % "José") Long version :

Re: efficiency of range() and xrange() in for loops

2006-04-05 Thread Fredrik Lundh
Steve R. Hastings wrote: > If Python actually allocates the list, then clearly we should all use > "for i in xrange". clearly we should all? speak for yourself. the difference isn't very large, xrange is actually slower in some python versions, and you'll need the integer objects sooner or late

Re: efficiency of range() and xrange() in for loops

2006-04-05 Thread Georg Brandl
Steve R. Hastings wrote: > When you compile the expression > > for i in range(1000): > pass > > does Python make an iterator for range(), and then generate the values > on the fly? Or does Python actually allocate the list [0, 1, 2, ..., 999] > and then step through it? It does.

  1   2   3   >