Re: Pythonic style involves lots of lightweight classes (for me)

2006-12-14 Thread bayerj
Hi, I think that tuples are the best and simplest approach for small structures. >>> songs = [("Paranoid", "http://...";), ("Christian Woman", "http://...";)] >>> for title, url in songs: ... print "%s: %s" % (title, url) ... Paranoid: http://... Christian Woman: http://... I think that python'

Re: Removing from a List in Place

2006-09-05 Thread bayerj
> I'm going to assume that it's supposed to work like this, but could > someone tell me the reasoning behind it? I.E. why is 3 skipped? Because: >>> alist[2] 3 You are removing the third item, not the second. -- http://mail.python.org/mailman/listinfo/python-list

Re: threading support in python

2006-09-04 Thread bayerj
Hi, You might want to split your calculation onto different worker-processes. Then you can use POSH [1] to share data and objects. You might even want to go a step further and share the data via Sockets/XML-RPC or something like that. That makes it easy to throw aditional boxes at a specific calc

Re: threading support in python

2006-09-04 Thread bayerj
Hi, GIL won't go. You might want to read http://blog.ianbicking.org/gil-of-doom.html . Regards, -Justin -- http://mail.python.org/mailman/listinfo/python-list

Re: function v. method

2006-07-17 Thread bayerj
I guess the python devs are not interested in implementing something that would require new syntax and does not give something entirely new to the language. The good thing about python is, that the devs are only implementing ideas that are very cool. There are a lot of cool (!= very cool) ideas in

Registry of Methods via Decorators

2006-06-22 Thread bayerj
I want to make a registry of methods of a class during creation. My attempt was this """ classdecorators.py Author: Justin Bayer Creation Date: 2006-06-22 Copyright (c) 2006 Chess Pattern Soft, All rights reserved. """ class decorated(object): methods = [] @classmethod def collect

Re: How to generate all permutations of a string?

2006-06-22 Thread bayerj
Mind, that Lawrence's solution may contain doubles: >>> [ i for i in permute("aa") ] [('a', 'a'), ('a', 'a')] If you don't want this, use sets. -- http://mail.python.org/mailman/listinfo/python-list

Re: learning python idioms

2006-06-11 Thread bayerj
> yup, you could spend weeks reading the Language Wars: Actually, that link is not about language wars. It's about making the switch from java to python. Nothing more, nothing less. -- http://mail.python.org/mailman/listinfo/python-list

Re: learning python idioms

2006-06-11 Thread bayerj
Hi, If you switched from java to python the best point to start is http://dirtsimple.org/2004/12/python-is-not-java.html. Greets, -Justin -- http://mail.python.org/mailman/listinfo/python-list

Re: Argument Decorators Enhancement?

2006-05-16 Thread bayerj
Hi, -1 because I find it extremly hard to read and not necessary in that scale. Actually, there are a lot of recipes in the Cookbook [1] on how to use decorators for type-checking. On example is: @require(int, int) def add(x,y): return x + y Which I find much more readable, easier to implement

Re: Property In Python

2006-04-21 Thread bayerj
>>> print property.__doc__ property(fget=None, fset=None, fdel=None, doc=None) -> property attribute fget is a function to be used for getting an attribute value, and likewise fset is a function for setting, and fdel a function for del'ing, an attribute. Typical use is to define a managed attribu

Re: How do you guys print out a binary tree?

2006-04-19 Thread bayerj
The problem is that you cannot represent a matrix as a tree, due to the fact that there are more than one tree for a matrix. First you have to decide, how you will turn the matrix into a tree. -- http://mail.python.org/mailman/listinfo/python-list

Re: How do you guys print out a binary tree?

2006-04-18 Thread bayerj
A half-empty matrix will of course have (n+1)* n * 1/2 elements. -- http://mail.python.org/mailman/listinfo/python-list

Re: How do you guys print out a binary tree?

2006-04-18 Thread bayerj
Hi, > 1 2 3 4 5 > 0 7 8 9 10 > 0 0 13 14 15 > 0 0 0 19 20 > 0 0 0 0 25 > Look at the triangle represented by the non-zero > integers. This triangle is a binary tree if we take 5 > as the root and walk down on both sides. Are you sure? Is 9 a child of 4 or 10

Re: print() in Python 3000 return value?

2006-04-03 Thread bayerj
> Sorry? 2+2 here returns 4, and certainly should with your Python. Err. Never mind. I was thinking about assignments, like >>> x += 2 which returns None. -- http://mail.python.org/mailman/listinfo/python-list

Re: print() in Python 3000 return value?

2006-04-02 Thread bayerj
Expressions like >>> 2 + 2 return None, too. I am not certain, but as far as I know this has some major design reasons. Thus I am certain, that print() will return None also. -- http://mail.python.org/mailman/listinfo/python-list

Re: How to search HUGE XML with DOM?

2006-03-31 Thread bayerj
Mind, that XML documents are not more flexible than RDBMS. You can represent any XML document in a RDBMS. You cannot represent any RDBMS in an XML document. RDBMS are (strictly spoken) relations and XML documents are trees. Relations are superior to trees, at least mathematically speaking. Once y