Re: [Python-Dev] PEP 350: Codetags

2005-09-27 Thread Bill Mill
e a hard time convincing the community > at large to actually use it. You need to actually have a better mousetrap > to present before you ask people to move their cheese. :) > +1 I agree with PJE almost entirely. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Will python never intend to support private, protected and public?

2005-09-29 Thread Bill Mill
x27;] >>> >>> #here's how the crazy hackers subclassing your code can break your super ... #special private variable! ... >>> t._test__i += 6 >>> t.i got i 7 But, if your users can't figure out that they shouldn't be changing the variable called t._test__i without expecting side effects, what do you think of the users of your class? Python is for consenting adults. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Will python never intend to support private, protected and public?

2005-09-29 Thread Bill Mill
Error correction time! > >>> #here's how the crazy hackers subclassing your code can break your super > ... #special private variable! > ... That should be "using your code" not "subclassing your code". D'oh! Peace Bill Mill bill.mill at gmail

Re: A Moronicity of Guido van Rossum

2005-09-29 Thread Bill Mill
> But, this post of his shows [Guido's] haughtiness +1 IQOTW (Ironic Quote Of The Week. Thanks for the laughs, Xah) Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list

Re: grouping array

2005-09-29 Thread Bill Mill
of non zero regions..as (x1,y1,x2,y2) > [(0,0,2,1),(0,4,2,5)] which show the top left(x1,y1) and bottom > right(x2,y2) corners of each group.hope i am clear. > I don't understand. Could you give some inputs with expected outputs and some explanation? Peace Bill Mill bill.mill at gma

Re: python's performance

2005-09-29 Thread Bill Mill
? Ask something that's answerable, and we'll try to help you.) Peace Bill Mill bill.mill at gmail.com On 9/29/05, James Hu <[EMAIL PROTECTED]> wrote: > Hi, > > I used python and PIL to capture image from a digital camera, > It seems like it took more than 1 second to cap

Re: python's performance

2005-09-29 Thread Bill Mill
gt; took only .2s or less for one image with the same size. > > Don't know why python and PIL is so slow, any idea to improve the > > performance? Thanks a lot! > > > > James > > > > -- > > http://mail.python.org/mailman/listinfo/python-list > > &

Re: A Moronicity of Guido van Rossum

2005-09-29 Thread Bill Mill
+1 QOTW. > > Tim > -1 XLEGQOTW (Xah Lee Ever Getting QOTW'd) Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list

Re: python server

2005-11-07 Thread Bill Mill
et, over a corporate LAN, on the same computer, on Internet2)? Is there any framework in existance, or is this program being written from scratch? Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list

Re: PYTHON LOOSING FOR JAVA???????

2005-11-08 Thread Bill Mill
office web > > based. I sincerely enjoy the idea althoug I'd like to know what will be > > the future of this wonderful language called Python?? > > I think I know???? Although, the future is difficult to predict??? +1 QOTW Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Python obfuscation

2005-11-10 Thread Bill Mill
x27;re not used in ways you don't intend is to require the user to contact you to use it, and that's a deal with the devil. One you might need to make if security is that important to you, as Microsoft and Valve have decided it is, but it's a deal with the devil nonetheless. Peac

Re: Default method arguments

2005-11-15 Thread Bill Mill
e self.data the default argument for self.f(). (I > want to use 'A' class as following : > > myA = A(5) > myA.f() > > and get printed '5' as a result.) > class A: def __init__(self, n): self.data = n def f(self, x=None): if not x:

Re: Default method arguments

2005-11-15 Thread Bill Mill
ust tossed off an answer without thinking much, and we see the result. It could have been a good debugging lesson for him if he'd tried to pass 0; I think I'll use that as my excuse. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Zen of Python

2005-01-19 Thread Bill Mill
The example that occurs to me is that "import smtplib" is better than "import stdlib.inet.services.smtp". Peace Bill Mill bill.mill at gmail.com On Wed, 19 Jan 2005 14:13:47 -0500, Timothy Fitz <[EMAIL PROTECTED]> wrote: > While I agree that the Zen of Python is

Re: a question

2005-01-19 Thread Bill Mill
e = (1,1,1) >>> cmd = '%s/mos user wmarch, cd /fa/wm/%s/%s, mkdir %s, put %s'\ ... '%s' % (mosbin, jaar, filetype, filetype, filetype, filetype) >>> cmd '1/mos user wmarch, cd /fa/wm/1/1, mkdir 1, put 1, chmod 6441' Peace Bill Mill bill.mill at

Re: a question

2005-01-19 Thread Bill Mill
You are correct, sir. Didn't know you could do that. Neato. Peace Bill Mill bill.mill at gmail.com On Wed, 19 Jan 2005 22:10:05 +0100, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Bill Mill wrote: > > > You've got a couple problems. First, you need to end the

Re: list item's position

2005-01-19 Thread Bill Mill
)) when you can, but use it when you need to know the index of something without an additional x.index() call. Peace Bill Mill bill.mill at gmail.com On Wed, 19 Jan 2005 22:04:44 -0500, Bob Smith <[EMAIL PROTECTED]> wrote: > Hi, > > I have a Python list. I can't figure out ho

Re: Distutils: blurring the file==module borders

2005-01-24 Thread Bill Mill
read this thread, it should help you: http://mail.python.org/pipermail/tutor/2005-January/035124.html Peace Bill Mill bill.mill at gmail.com On Tue, 25 Jan 2005 02:15:58 +, Frans Englich <[EMAIL PROTECTED]> wrote: > > Hello all, > > Due to the size of my source, I want t

Dynamic class methods misunderstanding

2005-01-28 Thread Bill Mill
ot; function? Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Dynamic class methods misunderstanding

2005-01-28 Thread Bill Mill
On 28 Jan 2005 15:41:49 GMT, F. Petitjean <[EMAIL PROTECTED]> wrote: > Le Fri, 28 Jan 2005 10:20:30 -0500, Bill Mill a écrit : > > Hello all, > > > > I have a misunderstanding about dynamic class methods. I don't expect > > this behavior: > > > >

Re: Dynamic class methods misunderstanding

2005-01-28 Thread Bill Mill
le in python 2.4, that's equivalent to: self.m = type(self.__init__)(method, self, Test) I didn't know that you could call types to create another type. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Dynamic class methods misunderstanding

2005-01-28 Thread Bill Mill
ouble printing here is a typo? > >>> > > To add m as a new method to the *instance*, use new.instancemethod, as > Diez B. Roggisch already pointed out. > Thanks, you helped me understand it a lot. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Dynamic class methods misunderstanding

2005-01-28 Thread Bill Mill
ot the object, as follows: > > |class Test: > |def __init__(self): > |self.method() > | > |def m(self): > |print self > | > |setattr(Test, 'method', m) > |Test() > beautiful; so this appears to be equivalent to the __class__ method that Ha

Re: Dynamic class methods misunderstanding

2005-01-28 Thread Bill Mill
On Fri, 28 Jan 2005 11:59:50 -0500, Hans Nowak <[EMAIL PROTECTED]> wrote: > Bill Mill wrote: > > > On Fri, 28 Jan 2005 11:09:16 -0500, Hans Nowak <[EMAIL PROTECTED]> wrote: > > > > > >>To add m as a new method to the *class*, do this: > >&

Re: Dynamic class methods misunderstanding

2005-01-28 Thread Bill Mill
you do *not* know the attribute name at coding time but > will have it in a string at run time, as in > > methodname = 'method' > ..# some time later > setattr(Test, methodname, m) > > Sometime Python makes things easier than people are initially willing to > believe ;-) I felt like there had to be a simpler solution. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Java Integer.ParseInt translation to python

2005-01-31 Thread Bill Mill
ing,16); Tell me what this does, give me an example or two, and I'll translate it for you. I don't feel like going to read the java docs to figure it out. You probably want to look at the built-in int() function though. Type help(int) at the python prompt. Peace Bill Mill bill.mill at gm

Re: newbie: Syntax error

2005-02-04 Thread Bill Mill
Chad, try "elif tries == 2" or just "else:". You are not allowed to put an expression after an else statement. I recommend you read the python tutorial at http://docs.python.org/tut/tut.html . Peace Bill Mill bill.mill at gmail.com On Fri, 4 Feb 2005 12:49:51 -0600,

Re: string issue

2005-02-04 Thread Bill Mill
u're operating in-place on an array while it's being iterated over. Since the iterator is only created once, you're can't change the array while you're iterating over it. Instead, try a list comprehension: >>> ips = [ip for ip in ips if '255' not in ip] >>> ips ['128.173.120.79', '198.82.247.98', '127.0.0.1'] Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list

Re: string issue

2005-02-04 Thread Bill Mill
d, iterate over > > a copy by using: > > > > for ip in ips[:]: > > ... > > > > regards > > Steve > > Very neat. That's a trick that everyone should know about. I vote it > goes in Dr. Dobbs newsletter. Once you know it, it's neat, and I use it sometimes. However, it's a little too "magical" for my tastes; I'd rather be more explicit about what's going on. Peace Bill Mill bill.mill at gmail.com > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list

Re: string issue

2005-02-04 Thread Bill Mill
import copy >>> ips = ['255.255.255.255', '128.173.120.79', '198.82.247.98', ... '127.0.0.1', '255.0.0.0', '255', '128.173.255.34'] >>> for ip in copy(ips): ... if '255' in ip: ... ips.remove(ip) ... >>> ips ['128.173.120.79', '198.82.247.98', '127.0.0.1'] But I still think that the list comprehension is the best. Peace Bill Mill bill.mill at gmail.com > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list

Re: Possibly OT: Controlling winamp with Python

2005-02-04 Thread Bill Mill
Brent, You could write the Python program as a proxy of the internet stream. Basically, you would point your proxy at the web stream and receive the data it sends. At the same time, you would be listening for connections on some socket on the local machine. You would then point winamp towards the

Re: Folding in vim

2005-07-06 Thread Bill Mill
vely, zc and zC close it non- and recursively. zr opens all folds one level, zR opens them all recursively, zm closes them all one level, and zM closes them all recursively. It's pretty sweet. Maybe we should have a big Vim-python tip-a-thon thread? Peace Bill Mill [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Scipy - Latex Annotations in plots

2005-07-06 Thread Bill Mill
u know another one with 3D-capabilities as well? > That would be very nice, > Perhaps gnuplot.py (http://gnuplot-py.sourceforge.net/) will work for you? It is a thin wrapper around Gnuplot, which is very good at producing ps format images, and is capable of producing 3 dimensional graphs. Pe

Re: Yet Another Python Web Programming Question

2005-07-11 Thread Bill Mill
#x27;t know, but it causes a lot of errors for windows folks. I'm a frequent linux/windows switcher, and it's caused me no end of troubles - if you're getting "premature end of script headers" in your apache error logs, this may be your problem. Peace Bill Mill bill.mil

Re: question on "input"

2005-07-12 Thread Bill Mill
;) y or n?y >>> answer 'y' Check out the documentation of both functions at http://docs.python.org/lib/built-in-funcs.html for more details. Peace Bill Mill -- http://mail.python.org/mailman/listinfo/python-list

Re: String Manipulation

2005-07-13 Thread Bill Mill
string.maketrans('.,-', ' ')) #read the docs at # http://docs.python.org/lib/node109.html # for more details #End program 3 Hope this helps; you should be able to put the pieces together to do what you want to do. If you can't, feel free to

Re: Python Programming Contest

2005-07-15 Thread Bill Mill
ers, > Brian > -- > http://mail.python.org/mailman/listinfo/python-list > Questions: Will that random test generator (included in the download) be used to perform the actual testing? How many tests will be run on each program? What is the penalty for a wrong answer? Peace Bill Mill PS -

odd python/linux/cherrypy behavior

2005-07-16 Thread Bill Mill
all problem, I figure out that if I move it to my ext3 drive, it again works perfectly. Prints out the same information, says it's waiting on 8080, but this time, I can access it. Can anybody posit a guess as to why it would behave this way? Peace Bill Mill bill.mill at gmail.com -- http

Re: odd python/linux/cherrypy behavior

2005-07-16 Thread Bill Mill
On 7/16/05, Neil Hodgson <[EMAIL PROTECTED]> wrote: > Bill Mill: > > > ... a FAT partition for data as a dmz which both linux and NT can > > access ... > > Yesterday, I downloaded the new release of cherrypy, and stuck it on > > the dmz drive. ... > > Ev

Re: odd python/linux/cherrypy behavior

2005-07-16 Thread Bill Mill
On 7/16/05, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On Sat, 16 Jul 2005 19:54:31 -0400, Bill Mill <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > > > The FAT dirs are mounted with the following options: > > defaults,user,umask=000

Re: smtplib

2005-07-18 Thread Bill Mill
the last release. > > Do you know any idea about this change? check out the CVS changelog to see what's changed with it: http://cvs.sourceforge.net/viewcvs.py/python/python/dist/src/Lib/smtplib.py?rev=1.70&view=log Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list

Re: is this pythonic?

2005-07-20 Thread Bill Mill
yield (i, elt) i += 1 for i, url in my_enumerate(links): but it's not too bad as it is. Also, my function is completely untested - it's close to right though.) Peace Bill Mill -- http://mail.python.org/mailman/listinfo/python-list

Re: is this pythonic?

2005-07-20 Thread Bill Mill
On 7/20/05, Bill Mill <[EMAIL PROTECTED]> wrote: > On 7/20/05, Simon Brunning <[EMAIL PROTECTED]> wrote: > > On 7/20/05, Mage <[EMAIL PROTECTED]> wrote: > > > Or is there better way? > > > > > > for (i, url) in [(i,links[i]) for i in ran

Re: is this pythonic?

2005-07-21 Thread Bill Mill
On 7/21/05, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Wed, 20 Jul 2005 16:30:10 -0400, Bill Mill wrote: > > > On 7/20/05, Simon Brunning <[EMAIL PROTECTED]> wrote: > >> On 7/20/05, Mage <[EMAIL PROTECTED]> wrote: > >> > Or is there bet

Re: Stupid question: Making scripts python-scripts

2005-07-21 Thread Bill Mill
program? I bet there's an equivalent you could symlink to it. Unfortunately, I've never BSDed, so I can't help you find it. To get a workable subset of the normal env functionality, you could try (assuming you use bash): /home/llimllib $ echo "$@" > /usr/bin/env /home/

Re: Stupid question: Making scripts python-scripts

2005-07-21 Thread Bill Mill
On 7/21/05, Bill Mill <[EMAIL PROTECTED]> wrote: > On 7/21/05, Jan Danielsson <[EMAIL PROTECTED]> wrote: > > Hello all, > > > >How do I make a python script actually a _python_ in unix:ish > > environments? > > > > I know about adding: >

Re: [Beginner] Calling a function by its name in a string

2005-07-27 Thread Bill Mill
t; >>> def foo(): print "foobarred" ... >>> foo() foobarred >>> eval("foo()") foobarred >>> Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list

Re: [Beginner] Calling a function by its name in a string

2005-07-27 Thread Bill Mill
func_name): ... for e in lst: ... getattr(e, func_name)() ... >>> call_this_func(x, 'func1') func1 called other func1 func1 called >>> Note that the getattr raises an AttributeError if func_name doesn't exist in the object; you should probably wrap it in a try/except. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Ten Essential Development Practices

2005-07-29 Thread Bill Mill
> although, as some argue, it's > possible [GvR] thinks in base 9.5, that just doesn't seem Pythonic to me. +1 QOTW Peace Bill Mill [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: sample code for parsing html file to get contents of td fields

2005-08-04 Thread Bill Mill
e this? In [1]: x = "something something else and\nanother thing in a td and again else" In [2]: import re In [3]: r = re.compile('(.*?)', re.S) In [4]: r.findall(x) Out[4]: ['something else', 'in a td'] If not, you'll have to explain more clearly

Re: The ONLY thing that prevents me from using Python

2005-08-05 Thread Bill Mill
> I really wish Python could be more widely available on web server > machines. This is just my own experience and I would like to hear your > comments. > I would like a pony... no, wait, even better, a unicorn! Peace Bill Mill bill.mill at gmail.com PS (the gist is, why don'

Re: help in algorithm

2005-08-11 Thread Bill Mill
#x27;s using LSI for his clustering. I ask because I've done some LSI [1], and could help him out with that if he is doing it. While I'm on the subject, is there any general interest in my python LSI code? [1] http://llimllib.f2o.org/files/lsi_paper.pdf Peace Bill Mill -- http://mail.

Re: loop in python

2005-08-22 Thread Bill Mill
They come out even in the computer language shootout: http://shootout.alioth.debian.org/benchmark.php?test=all&lang=python&sort=fullcpu (tied 8-8 in execution time, although perl wins 4-12 on memory consumption) Peace Bill Mill On 8/23/05, km <[EMAIL PROTECTED]> wrote: > Hi

Re: loop in python

2005-08-22 Thread Bill Mill
> If you want a fast language, try Holden. I've just invented it. > Unfortunately it gets the answer to every problem wrong unless the > answer is 42, but boy it runs quickly. +1 QOTW (sometimes the zen master has to whack the student on the head) Peace Bill Mill bill.mill at gmai

Re: Speed quirk: redundant line gives six-fold speedup

2005-08-25 Thread Bill Mill
uot; It seems to work (>19x speedup on my machine), I'm just curious what path you followed to get there. And, finally, you should forward this to the python-dev list, if somebody hasn't already. There are more people who know a ton about python internals there. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Speed quirk: redundant line gives six-fold speedup

2005-08-25 Thread Bill Mill
es. > Unlikely; 2 people have confirmed these results already. I did find, though, that if I remove all print statements from the program, the dummy and non-dummy variable versions take indentical time. Can others reproduce this? I'm Investigating further... Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Speed quirk: redundant line gives six-fold speedup

2005-08-25 Thread Bill Mill
Bill Mill wrote: > > Pentium M 1.8 GHz Windows 2k. Here's the top of the profile results > for fast and slow on my machine (these won't look decent except in a > fixed-width font): > > > Interestingly, the test.py:36 line, which takes 45 seconds (!!) in the >

Re: Speed quirk: redundant line gives six-fold speedup

2005-08-25 Thread Bill Mill
On 8/25/05, Jack Diederich <[EMAIL PROTECTED]> wrote: > On Thu, Aug 25, 2005 at 01:35:04PM -0400, Bill Mill wrote: > > On 8/25/05, Erik Max Francis <[EMAIL PROTECTED]> wrote: > > > Mark Dickinson wrote: > > > > > > > Questions: > > > >

Re: Speed quirk: redundant line gives six-fold speedup

2005-08-25 Thread Bill Mill
On 8/25/05, Erik Max Francis <[EMAIL PROTECTED]> wrote: > Bill Mill wrote: > > > Unlikely; 2 people have confirmed these results already. > > > > I did find, though, that if I remove all print statements from the > > program, the dummy and non-dummy variable ve

Re: Speed quirk: redundant line gives six-fold speedup

2005-08-25 Thread Bill Mill
at 0x00969710>) (3, <__main__.LLentry object at 0x00969710>) (3, <__main__.LLentry object at 0x00969710>) (2, <__main__.LLentry object at 0x00969710>) Although they appear in order here, they don't always. Often, multiple objects have a value of 1, and he's going to ge

Re: C#3.0 and lambdas

2005-09-19 Thread Bill Mill
not one of the most important ones - but if I > can write > > a, (b ,c) = 1, (2,3) > > I'd like to write > > def foo(a, (b,c)): > ... > > foo(1, (2,3)) > Agreed. I discovered them when I wondered "wouldn't it be neat if functions unpacked tuples j

Re: C#3.0 and lambdas

2005-09-21 Thread Bill Mill
; > return math.sqrt((p2[0] - p1[0])**2 + (p2[1] - p1[1])**2) > > But not massively nicer than: > > def euclidian_distance(p1, p2): > (x1, y1), (x2, y2) = p1, p2 > return math.sqrt((x2 - x1)**2 + (y2 - y1)**2) > But the question is - why go to the eff

Re: How to show percentage

2005-09-22 Thread Bill Mill
You need to convert 1 or 3 to a float. How about: >>> def pct(num, den): return (float(num)/den) * 100 ... >>> pct(1, 3) 33.3333329 Peace Bill Mill bill.mill at gmail.com On 22 Sep 2005 10:51:43 -0700, Sen-Lung Chen <[EMAIL PROTECTED]> wrote: > Dear All: &

Re: Loop in list.

2005-02-08 Thread Bill Mill
node7.html#SECTION00714 . Peace Bill Mill bill.mill at gmail.com On Tue, 08 Feb 2005 06:50:08 -0800 (PST), Jim <[EMAIL PROTECTED]> wrote: > Where did this type of structure come from: > > mat = ['a' for i in range(3)]? > > This will produce a list of t

Re: check if object is number

2005-02-11 Thread Bill Mill
On Fri, 11 Feb 2005 12:11:44 -0700, Steven Bethard <[EMAIL PROTECTED]> wrote: > Is there a good way to determine if an object is a numeric type? > Generally, I avoid type-checks in favor of try/except blocks, but I'm > not sure what to do in this case: > > def f(i): > ... >

Re: Regular Expressions: large amount of or's

2005-03-01 Thread Bill Mill
Kent > > > >> > >> André > >> > > That is not exactly what I want. It should discover if some of > the predefined words appear as substrings, not only as equal > words. For instance, after matching "word2sgjoisejfisaword1yguyg", word2 > and word1 should be detected. Show some initiative, man! >>> known_words = set(["word1", "word2"]) >>> found_words = [word for word in known_words if word in "word2sgjoisejfisawo rd1yguyg"] >>> found_words ['word1', 'word2'] Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list

Re: How would you program this?

2005-03-02 Thread Bill Mill
9 - 3 3 9 7 8 3 8 7 9 5 9 8 4 7 5 9 - real0m1.255s user0m1.221s sys 0m0.030s Both solutions look correct to me; how about you? With clever enough heuristics, problems that you can expect people to solve will almost always fall to brute force algorithms, I feel. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list

Re: How would you program this?

2005-03-02 Thread Bill Mill
; 3 3 9 7 > 8 3 8 7 > 9 5 9 8 > 4 7 5 9 > - > > real0m1.255s > user0m1.221s > sys 0m0.030s > Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list

Re: passing lists

2005-03-02 Thread Bill Mill
Earl, Please post the smallest snippet of code you can which illustrates your problem. No list is an unsubscriptable object, so you seem to be passing something that is not a list to your function. As it stands, you don't give enough information to give an actual answer. Peace Bill

Re: substring matching

2005-03-02 Thread Bill Mill
e first part is actually XYZ, is there an > easy way of doing that? > data.startswith('XYZ') Please read the python tutorial at http://docs.python.org/tut/tut.html . Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list

Re: How would you program this?

2005-03-03 Thread Bill Mill
very very unlikely to happen in such a way that the row and column sums are maintained; especially as the number of rows and columns grows. Better to just do a crc or a hash of the data though. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Making things more functional in Python

2005-03-04 Thread Bill Mill
dingly obvious what your code does, which is a good thing. My list comp, on the other hand, is seven kinds of confusing for a reader. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Integer From A Float List?!?

2005-03-04 Thread Bill Mill
e archives for that (it was in february, I think). And, finally, when doing scientific stuff, I found IPython (http://ipython.scipy.org/) to be an invaluable tool. It's a much improved Python interpreter. Peace Bill Mill bill.mill at gmail.com > > (In Matlab, "integer_matrix&qu

Re: Is there a short-circuiting dictionary "get" method?

2005-03-09 Thread Bill Mill
at it means python doesn't have "delayed evaluation"). Here are two ways to do what you want: if 'x' in d: value = d['x'] else: value = bigscaryfunction() or: def sget(dict, key, func, *args): if key in dict: return key else: return func(*args) sget

Re: Is there a short-circuiting dictionary "get" method?

2005-03-09 Thread Bill Mill
t()) >>> z at 0x008D6870> So this seems to be merely an obfuscation of: >>> z = d.get('x', test) >>> z I just wanted to ask, am I missing something? Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there a short-circuiting dictionary "get" method?

2005-03-09 Thread Bill Mill
it... > def scary(): > print "scary called" > return 22 > > d = dict(x=1) > d.get('x', lambda *a : scary()) > > # print 1 > d.get('z', (lambda *a : scary())()) > scary called > 22 but: >>> d.get('x', (lambda *a: test())()) test called 1 So how is this different than d.get('x', test()) ? Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list

Re: pre-PEP: Print Without Intervening Space

2005-03-11 Thread Bill Mill
string. I agree with everything said here. Furthermore, I don't like this PEP because it introduces magic. When reading code, you just need to magically know what the double-comma does in a print statement. Yes, there are bits of magic involved in the solutions that already exist, but I am o

Re: Why tuple with one item is no tuple

2005-03-15 Thread Bill Mill
rouping, and do not unambiguously define a tuple. It's a python gotcha. To define a one-tuple, put a comma after the '1': >>>type(('1',)) > > Because I have to treat this "special" case differently in my code. you shouldn't have to; post your code if you still think you do. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Why tuple with one item is no tuple

2005-03-15 Thread Bill Mill
e, since the need to create empty tuples is vanishingly rare, I'm okay with a little inconsistency. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list

Re: c.l.p.announce question

2005-03-15 Thread Bill Mill
and people will find your blog. I know for a fact that the daily python-url editors (when not away on vacation) read planet python, and they'll send thousands of visitors to you if they link you. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Text-to-speech

2005-03-21 Thread Bill Mill
On 21 Mar 2005 12:47:07 -0800, Paul McGuire <[EMAIL PROTECTED]> wrote: > Brian, > > Having reviewed your Cease and Desist petition, I'm afraid I must > dispute some or all of your claims: > > 1. Your citation of prior art has one or more significant defects: > a. In your citation, "brace" is clea

Re: Data types

2005-03-24 Thread Bill Mill
On 24 Mar 2005 10:29:40 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > I am new to python and learning it. Can you please give me a simple > example of user defined type through class mechanism. GIYF: http://www.python.org/2.2/descrintro.html#subclassing Peace Bill Mill

Re: Version Number Comparison Function

2005-03-25 Thread Bill Mill
v1, v2): v1, v2 = v1.split('.'), v2.split('.') for x, y in zip(v1, v2): if x < y: return v1 if y > x: return v2 It assumes that v1 and v2 have the same amount of '.'s and that all of the version numbers are of the same length (i.e

Re: Grouping code by indentation - feature or ******?

2005-03-25 Thread Bill Mill
half your colons, you're spending upwards of 20 seconds per colon? If you want, I'll write a script that checks for colons at the end of lines before increased indentation, and asks you if you want to put one there - I could save you 5.8 minutes per 100 lines of code. How's that for a productivity boost? Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list

Re: breaking up is hard to do

2005-03-25 Thread Bill Mill
t sort of namespace problems? I think you need to tell us what your specific problems were, so that we can help you more. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list

Re: String Splitter Brain Teaser

2005-03-28 Thread Bill Mill
#x27;ATT/GATA/G'): print g ... ['A'] ['T'] ['T', 'G'] ['A'] ['T'] ['A', 'G'] Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list

Re: String Splitter Brain Teaser

2005-03-28 Thread Bill Mill
On Mon, 28 Mar 2005 09:18:38 -0800, Michael Spencer <[EMAIL PROTECTED]> wrote: > Bill Mill wrote: > > > for very long genomes he might want a generator: > > > > def xgen(s): > > l = len(s) - 1 > > e = enumerate(s) > >

Re: String Splitter Brain Teaser

2005-03-28 Thread Bill Mill
l of the problem. Also, item is a much clearer name than stack; I chose stack just to point out how similar the solution to objection 2 was to yours. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list

Re: PyParsing module or HTMLParser

2005-03-28 Thread Bill Mill
nother table. > Is it better and easier to use the pyparsing module or HTMLparser? > You might want to check out BeautifulSoup at: http://www.crummy.com/software/BeautifulSoup/ . Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Little Q: how to print a variable's name, not its value?

2005-03-29 Thread Bill Mill
27;. ummm, yes, of course they are. What's your point? > > Mixing data and program code, ie.. variable names as data, is not a > good idea. Down with eval! Exile exec! A pox on both their houses! (i.e. I respectfully disagree that mixing data with program code is a bad idea) Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Little Q: how to print a variable's name, not its value?

2005-03-29 Thread Bill Mill
On Tue, 29 Mar 2005 18:08:04 GMT, Cameron Laird <[EMAIL PROTECTED]> wrote: > In article <[EMAIL PROTECTED]>, > Bill Mill <[EMAIL PROTECTED]> wrote: > . > . > . > >(i.e. I respectfully

Re: Which is easier? Translating from C++ or from Java...

2005-03-29 Thread Bill Mill
;s going on so that you don't end up writing another language in python. If you do this, it doesn't matter which of the three you pick. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Little Q: how to print a variable's name, not its value?

2005-03-29 Thread Bill Mill
nt when I hit send. Naturally, I wasn't suggesting that anyone (shudder) do things like your examples of poor code. I had a much smaller point, about which I was not clear: Sometimes, it is handy to mix code and data. There *are* legitimate uses of reflection, eval, and exec. I was too glib in my response to you. I intended no disrespect, only silliness. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Little Q: how to print a variable's name, not its value?

2005-03-31 Thread Bill Mill
because a variable is simply a name binding doesn't mean Python couldn't return the name of the binding. I'm not definitely saying that I *want* an easy name() function - there's a lot of potential for abuse - but I would at least like to see it accomplished before I decide whether I like it or not. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Little Q: how to print a variable's name, not its value?

2005-03-31 Thread Bill Mill
On Thu, 31 Mar 2005 03:33:10 -0500, Bill Mill <[EMAIL PROTECTED]> wrote: > On 31 Mar 2005 08:13:30 GMT, Duncan Booth <[EMAIL PROTECTED]> wrote: > > [EMAIL PROTECTED] wrote: > > > > > But surely if you create an integer object and assign it a value, e.g. > &

Re: Pseudocode in the wikipedia

2005-04-01 Thread Bill Mill
using = are much clearer, especially since you often write many of them in a row, whereas you almost always make one assignment per line. I use := every day in PL/SQL, and it's one of the few positive syntactical features of the language. Peace Bill Mill bill.mill at gmail.com -- http://mail.pyth

Re: How to reload local namespace definitions in the python interpreter?

2005-04-04 Thread Bill Mill
port ... as ... idiom? > > e.g. import os.path as op > > > > This would, of course, require the user to qualify the names by > prefixing them with "op.". > What the OP listed above requires that too. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list

Re: change extensions

2005-04-05 Thread Bill Mill
os.rename(in_file, str(name[0]) + '.' + 'text')) > you should really use in_file.splitext - your script renames myfile.with.lots.of.dots.txt to myfile.text instead of myfile.with.lots.of.dots.text . If you *really* wanted to use split(), it oughta be ''.join(in_

Re: shebang in cross platform scripts

2005-04-06 Thread Bill Mill
> systems too. > > #!/usr/bin/env python What the others have said already is true, that it will be ignored on windows, with one caveat. The shebang is interpreted by Apache if your script is a CGI script. So, if your script is a CGI, you will need to have a windows version and a ni

Re: shebang in cross platform scripts

2005-04-06 Thread Bill Mill
ll available for > Windows. Google is your friend. > > Symbolic links also work under uwin (don't know for sure about the > others). That means you can install a link in /usr/bin to whereever > python lives, and expect #!/usr/bin/python to work just fine. This works in cygwin

  1   2   >