Re: Quickie - Regexp for a string not at the beginning of the line

2012-10-26 Thread Asen Bozhilov
Rivka Miller wrote: I am looking for a regexp for a string not at the beginning of the line. For example, I want to find $hello$ that does not occur at the beginning of the string, ie all $hello$ that exclude ^$hello$. The begging of the string is zero width character. So you could use

Re: Best way to structure data for efficient searching

2012-04-02 Thread Asen Bozhilov
Larry.Mart wrote: Since there are duplicates, I can't use a dict. And if I have any extraneous data in the keys (i.e. something to make them unique) then I still have to walk through the entire dict to find the matches. You can use slightly different approach. With double mapping you could

Re: Dictionaries and incrementing keys

2011-06-14 Thread Asen Bozhilov
Steve Crook wrote: Whilst certainly more compact, I'd be interested in views on how pythonesque this method is. Instead of calling function you could use: d = {} d[key] = (key in d and d[key]) + 1 Regards. -- http://mail.python.org/mailman/listinfo/python-list

Re: Rant on web browsers

2011-06-14 Thread Asen Bozhilov
Chris Angelico wrote: I've just spent a day coding in Javascript, and wishing browsers supported Python instead (or as well). All I needed to do was take two dates (as strings), figure out the difference in days, add that many days to both dates, and put the results back into DOM Input

Square bracket and dot notations?

2011-06-11 Thread Asen Bozhilov
Hi all, I am beginner in Python. What is interesting for me is that Python interpreter treats in different way dot and square bracket notations. I am coming from JavaScript where both notations lead prototype chain lookup. In Python it seems square bracket and dot notations lead lookup in

Re: Square bracket and dot notations?

2011-06-11 Thread Asen Bozhilov
Francesco Bochicchio wrote: User classes - that is the ones you define with the class statement - can implement support for the squared bracket and dot notations: -  the expression myinstance[index] is sort of translated into  of myinstance.__getitem__(index) -   the expression

Re: Square bracket and dot notations?

2011-06-11 Thread Asen Bozhilov
Terry Reedy wrote: Right. d.items is a dict method. d['items'] is whatever you assign. Named tuples in the collections modules, which allow access to fields through .name as well as [index], have the name class problem. All the methods are therefore given leading underscore names to avoid

Re: Function declarations ?

2011-06-10 Thread Asen Bozhilov
Andre Majorel wrote: Is there a way to keep the definitions of the high-level functions at the top of the source ? I don't see a way to declare a function in Python. I am not a Python developer, but Pythonic way of definition not declaration is definitely interesting. Languages with variable