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

2005-03-31 Thread Bill Mill
*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-29 Thread Bill Mill
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 disagree that mixing data with program code is a bad

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

2005-03-29 Thread Bill Mill
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
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: String Splitter Brain Teaser

2005-03-28 Thread Bill Mill
) - 1 e = enumerate(s) for i,c in e: if i l and s[i+1] == '/': e.next() i2, c2 = e.next() yield [c, c2] else: yield [c] for g in xgen('ATT/GATA/G'): print g ... ['A'] ['T'] ['T', 'G'] ['A'] ['T'] ['A', 'G'] Peace Bill Mill

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) for i,c in e: if i l and s[i+1] == '/': e.next

Re: String Splitter Brain Teaser

2005-03-28 Thread Bill Mill
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: Version Number Comparison Function

2005-03-25 Thread Bill Mill
('.') 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. 1.1000 would be 1.999). How general do you need to be? Peace Bill Mill bill.mill at gmail.com

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

2005-03-25 Thread Bill Mill
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
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: 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 bill.mill at gmail.com

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 clearly rhymed

Re: Why tuple with one item is no tuple

2005-03-15 Thread Bill Mill
. To define a one-tuple, put a comma after the '1': type(('1',)) type 'tuple' 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

Re: Why tuple with one item is no tuple

2005-03-15 Thread Bill Mill
is particularly appealing; a lone comma creating a data structure seems counter-intuitive, but it's nice to do a, b = b, a instead of (a, b) = (b, a) . In this case, 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

Re: c.l.p.announce question

2005-03-15 Thread Bill Mill
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: pre-PEP: Print Without Intervening Space

2005-03-11 Thread Bill Mill
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 opposed to the introduction of more. Peace Bill Mill bill.mill at gmail.com -- http

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

2005-03-09 Thread Bill Mill
= bigscaryfunction() or: def sget(dict, key, func, *args): if key in dict: return key else: return func(*args) sget(d, 'x', bigscaryfunction) Both methods are untested, but should work with minor modifications. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python

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

2005-03-09 Thread Bill Mill
of: z = d.get('x', test) z function test at 0x008D66B0 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
*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: Making things more functional in Python

2005-03-04 Thread Bill Mill
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
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 is always a double anyway, here I would like only to show the vector-matrix operation). Obviously, Python

Re: How would you program this?

2005-03-02 Thread Bill Mill
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
- 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 Mill

Re: substring matching

2005-03-02 Thread Bill Mill
') 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: Regular Expressions: large amount of or's

2005-03-01 Thread Bill Mill
] found_words ['word1', 'word2'] Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list

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): ... if x i:

Re: Loop in list.

2005-02-08 Thread Bill Mill
#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 three elements but I don't see reference

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, Chad Everett [EMAIL PROTECTED

Re: string issue

2005-02-04 Thread Bill Mill
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

Re: string issue

2005-02-04 Thread Bill Mill
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

Re: string issue

2005-02-04 Thread Bill Mill
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: Java Integer.ParseInt translation to python

2005-01-31 Thread Bill Mill
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 gmail.com -- http://mail.python.org/mailman/listinfo

Dynamic class methods misunderstanding

2005-01-28 Thread Bill Mill
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: In [2]: class test: ...: def __init__(self, method

Re: Dynamic class methods misunderstanding

2005-01-28 Thread Bill Mill
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
. 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
: |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 Hans suggested. Thanks a lot. Peace Bill Mill bill.mill at gmail.com -- http

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: snip To add m as a new method to the *class*, do this: class test: ... def __init__(self, method): ... self

Re: Dynamic class methods misunderstanding

2005-01-28 Thread Bill Mill
) 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: 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 to split it up

Re: a question

2005-01-19 Thread Bill Mill
/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 gmail.com On Wed, 19 Jan 2005 16:16:32 +, Nader Emami [EMAIL PROTECTED] wrote

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 string before putting a continuation

Re: list item's position

2005-01-19 Thread Bill Mill
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 how to find an element's numeric value (0,1,2,3...) in the list. Here's an example of what I'm doing: for bar

<    1   2