Re: Suggestion: str.itersplit()

2007-04-21 Thread subscriber123
On Apr 21, 8:58 am, Dustan <[EMAIL PROTECTED]> wrote: > >From my searches here, there is no equivalent to java's > > StringTokenizer in python, which seems like a real shame to me. > > However, str.split() works just as well, except for the fact that it > creates it all at one go. I suggest an iter

Re: Significance of "start" parameter to string method "endswith"

2007-04-19 Thread subscriber123
On Apr 19, 3:58 pm, Boris DuĊĦek <[EMAIL PROTECTED]> wrote: > Hello, > > what is the use-case of parameter "start" in string's "endswith" > method? Consider the following minimal example: > > a = "testing" > suffix="ing" > a.endswith(suffix, 2) > > Significance of "end" is obvious. But not so for "s

Re: working of round()

2007-04-15 Thread subscriber123
On Apr 15, 8:06 pm, [EMAIL PROTECTED] wrote: > Does round() always perfectly return the output expected or are there > some artifacts which don't allow perfect functionality > > Using python 2.5: > > >>> round(12.234, 2) > 12.23 > >>> round(12.234, 3) > 12.234 > >>> round(12.234, 1) > 12.19

Re: Python Web Servers and Page Retrievers

2007-04-11 Thread Subscriber123
that header onto the end, therefore making there two User-Agent headers, each with different values. I might add that my script IS able to retrieve search pages from Google, whereas both urllibs are FORBIDDEN with the headers that they use. On 4/8/07, Max Erickson <[EMAIL PROTECTED]> wrote:

Python Web Servers and Page Retrievers

2007-04-08 Thread Subscriber123
I wrote most of the following script, useful for retrieving pages from the web and serving web pages. Since it is so low level, it is much more customizable than simpleHTTPserver, cgiHTTPserver, urllib, or urllib2 for advanced users. For example, you can easily set your own headers when retrieving

Re: how to remove multiple occurrences of a string within a list?

2007-04-05 Thread Subscriber123
for item in listA: while item in listB: listB.remove(item) where listA is the list of things you want to remove from listB On 3 Apr 2007 11:20:33 -0700, bahoo <[EMAIL PROTECTED]> wrote: Hi, I have a list like ['0024', 'haha', '0024'] and as output I want ['haha'] If I myList.remove

Re: Prevent Modification of Script?

2007-04-05 Thread Subscriber123
If you are *really* worried about the database being attacked and edited, encrypt it by private key: require that the user set a password and use that password every time that s/he accesses the database. I am afraid that you cannot really prevent the database from being deleted completely, but you

Re: is it possible to give an instance a value?

2007-03-06 Thread Subscriber123
In answer to this part of your question, how to make this work: Person.Address 'Sydney' >>>Person.Address.type '%String' >>>Person.Address = 'Canberra' >>>print Person.Address. Person.Address.type Canberra %String try using the __getattr__ method of the class: class objWithTypeAttr(object)

Re: how to convert an integer to a float?

2007-02-27 Thread Subscriber123
How did the new division ever get approved?! That's not pythonic! What if you then need to divide two integers and find an element in a list or dict? It will give you an error! I know that at the moment it is not implemented unless imported from __future__, but I expect that it eventually might be

jsString class

2007-02-26 Thread Subscriber123
Hi all, Some of you may find this useful. It is a class I wrote that acts like the way strings do in JavaScript. It is a little buggy, and not complete, but could be useful. class jsString: def __init__(self,string): if string.__class__ is list: print "list:",string

Re: Gosper arithmetic in Python

2007-02-12 Thread Subscriber123
By the way, there are some commented out portions of code in there which you can just remove, if you want. The last two lines of the program are unnecessary, as well. On 2/12/07, Subscriber123 <[EMAIL PROTECTED]> wrote: Speaking of useful home-made modules, I wrote this primitive module

Re: Gosper arithmetic in Python

2007-02-12 Thread Subscriber123
Speaking of useful home-made modules, I wrote this primitive module which does limited math with fractions. Anyone is welcome to expand on it or use it for any purpose. If anyone would like to submit it as a PEP to be added to the Python library of reference, that would be great. If anyone wishes