Re: Comparison of parsers in python?

2009-09-20 Thread andrew cooke
find the end of line); (4) the community for support is small. so i would suggest asking on the pyparsing list for advice on using that with large data files (you are getting closer to the point where i would recommend lepl - but of course i am biased as i wrote it). andrew ps is there somewhere can

Re: Comparison of parsers in python?

2009-09-20 Thread andrew cooke
One word of warning - the documentation for that format says at the beginning that it is compressed in some way. I am not sure if that means within some program, or on disk. But most parsers will not be much use with a compressed file - you will need to uncompress it first. -- http://mail.pytho

Re: Comparison of parsers in python?

2009-09-20 Thread andrew cooke
On Sep 20, 8:11 am, Peng Yu wrote: > On Sun, Sep 20, 2009 at 6:50 AM, andrew cooke wrote: > > On Sep 19, 9:34 pm, Peng Yu wrote: > >> On Sep 19, 6:05 pm, Robert Kern wrote: > >> >http://nedbatchelder.com/text/python-parsers.html > > >> This is more a

Re: Comparison of parsers in python?

2009-09-20 Thread andrew cooke
better could well be more complex and slower on small texts. andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Comparison of parsers in python?

2009-09-20 Thread andrew cooke
oject you might be better interfacing to a compiled parser (lepl has memoisation, so should scale quite well, but it's not something i've looked at in detail yet). andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: explicit call to __init__(self) in subclass needed?

2009-09-18 Thread Andrew MacKeith
Bruno Desthuilliers wrote: Andrew MacKeith a écrit : I create a class like this in Python-2.6 >>> class Y(str): ... def __init__(self, s): ... pass ... >>> y = Y('giraffe') >>> y 'giraffe' >>> How does the base class (s

explicit call to __init__(self) in subclass needed?

2009-09-17 Thread Andrew MacKeith
? Is this behavior specific to the str type, or do base classes not need to be explicitly initialized? Andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: How do I begin debugging a python memory leak?

2009-09-16 Thread Andrew Svetlov
guppy-pe On Sep 16, 8:10 pm, Matthew Wilson wrote: > I have a web app based on TurboGears 1.0.  In the last few days, as > traffic and usage has picked up, I noticed that the app went from using > 4% of my total memory all the way up to 50%. > > I suspect I'm loading data from the database and som

Re: python decimals

2009-09-16 Thread Andrew Svetlov
ource. Perhaps I will start to work on it about end of next week - it's high priority task for my company. On Sep 16, 4:49 am, Mark Dickinson wrote: > On Sep 16, 1:35 am, Andrew Svetlov wrote: > > > It only reflects the fact what comp.lang.python replicated by several > > web si

Re: python decimals

2009-09-15 Thread Andrew Svetlov
It only reflects the fact what comp.lang.python replicated by several web sites. Unfortunately looks like there are no link to library implements that : ( On Sep 15, 5:17 pm, Terry Reedy wrote: > Mark Dickinson wrote: > > On Sep 15, 2:27 am, Andrew Svetlov wrote: > >> Is

python decimals

2009-09-14 Thread Andrew Svetlov
Is there some kind of python binding for decNumber library? Standard decimal.Decimal is good enough, but very slow. My current project toughly coupled with 'currency' operations and we have performance problems related to decimal calculations. >From my perspective decNumber is fast and has well wid

Re: Mapping in python? Transforming shapefile so that basemap can read them?

2009-09-12 Thread Andrew MacIntyre
ls.org/) - FWTools (http://fwtools.maptools.org/) Shapefiles, except for the coordinate system support included in ESRI's more recent products, are documented in a publicly accessible PDF which googling for "ESRI shapefile" should find. -- ----

Re: Frustrated with scopes

2009-08-12 Thread andrew cooke
join >         return Line() > > fact = _StreamFactory() > obj = fact(43, "name.txt") > print obj Ah! OK, thanks for that. I need to look at this again. I'll post again if necessary, but if it works for you then I clearly don't understand what the issue is myself. Andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Frustrated with scopes

2009-08-12 Thread andrew cooke
On Aug 12, 7:49 am, andrew cooke wrote: > On Aug 12, 1:51 am, James Stroud > wrote: > > > > > andrew cooke wrote: > > > Is there a way to make this work (currently scope and join are > > > undefined at runtime when the inner class attributes are define

Re: Frustrated with scopes

2009-08-12 Thread andrew cooke
On Aug 12, 1:51 am, James Stroud wrote: > andrew cooke wrote: > > Is there a way to make this work (currently scope and join are > > undefined at runtime when the inner class attributes are defined): > > > class _StreamFactory(object): > > >     @staticmethod &

Re: Frustrated with scopes

2009-08-11 Thread andrew cooke
correction: "source" and "join" are undefined. Sorry, Andrew -- http://mail.python.org/mailman/listinfo/python-list

Frustrated with scopes

2009-08-11 Thread andrew cooke
e = source __join = join [...] I can get something working by bouncing through global values, but it looks awful and I think it's a source of a bug due too values being redefined. Thanks, Andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Parsing Binary Structures; Is there a better way / What is your way?

2009-08-07 Thread andrew cooke
ns. disclaimer: this is quite new and i don't know of anyone that actually uses it; it is also Python3 only (because it uses bytes()). andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: If Scheme is so good why MIT drops it?

2009-07-26 Thread Andrew Reilly
easier to master. Isn't it widely accepted that the number of people who have mastered C++ is about five? All of the rest of us just struggle... [I know enough of C++ to avoid it whenever I can, and to not use it for my own projects. I'm happy with a mix of C, python and lisp(or scheme).] -- Andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: finding most common elements between thousands of multiple arrays.

2009-07-07 Thread Andrew Henshaw
"mclovin" wrote in message news:c5332c9b-2348-4194-bfa0-d70c77107...@x3g2000yqa.googlegroups.com... > Currently I need to find the most common elements in thousands of > arrays within one large array (arround 2 million instances with ~70k > unique elements) > > so I set up a dictionary to handle

Re: Suppressing Implicit Chained Exceptions (Python 3.0)

2009-07-02 Thread andrew cooke
David Bolen wrote: > "andrew cooke" writes: > >> However, when printed via format_exc(), this new exception still has the old exception attached via the mechanism described at >> http://www.python.org/dev/peps/pep-3134/ (this is Python 3.0). > > If you're

Suppressing Implicit Chained Exceptions (Python 3.0)

2009-07-01 Thread andrew cooke
uot; in the PEP described above. Thanks, Andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: itertools.intersect?

2009-06-15 Thread Andrew Henshaw
"Raymond Hettinger" wrote in message news:fb1feeeb-c430-4ca7-9e76-fea02ea3e...@v23g2000pro.googlegroups.com... > [David Wilson] >> The problem is simple: given one or more ordered sequences, return >> only the objects that appear in each sequence, without reading the >> whole set into memory. Th

Lexical scope: converting Perl to Python

2009-06-12 Thread Andrew Savige
I'd like to convert the following Perl code to Python:  use strict;  {    my %private_hash = ( A=>42, B=>69 );    sub public_fn { my $param = shift; return $private_hash{$param};    }  }  print public_fn("A");    # good:  prints 42  my $x = $private_hash{"A"};  # error: good, hash n

Re: import sqlite3

2009-06-04 Thread Andrew McNamara
On 04/06/2009, at 9:45 PM, willgun wrote: By the way ,what does 'best regards' means at the end of a mail? The correspondent is wishing you well. You'll also see things like "kind regards", "best wishes" and so on. "Regard" essentially means respect. -- http://mail.python.org/mailman/lis

Re: import sqlite3

2009-06-03 Thread Andrew McNamara
On 04/06/2009, at 4:14 PM, willgun wrote: What did you call the .py file? sqlite3.py? If so, you've just imported your own module again. 8-) After the import, try "print sqlite3.__file__", which will tell you where the module came from. Thank you all the same. I'm a student from China.It'

Re: import sqlite3

2009-06-03 Thread Andrew McNamara
On 04/06/2009, at 3:15 PM, willgun wrote: When i run the following in IDLE: IDLE 2.6.1 import sqlite3 con =sqlite3.connect (r'g:\db1') everything goes well,but when i save these to a .py file and run it: Traceback (most recent call last): File "C:\Users\hp\Desktop\SQLite3\sqlite3.py", l

Most pythonic way to truncate unicode?

2009-05-28 Thread Andrew Fong
e an orphaned byte. So truncate(u'\u4000\u4001\u4002 abc',4) == u'\u4000' ... as opposed to getting UnicodeDecodeError. I'm using Python2.6, so I have access to things like bytearray. Are there any built-in ways to do something like this already? Or do I just have to iter

Re: Building Python with icc on 64-bit Linux

2009-05-28 Thread Andrew MacIntyre
he libffi source and adjusting its configure script to properly handle the problematic case. Unless you need ctypes, this may be something you can skip over... -- ----- Andrew I MacIntyre "These

Re: Generic web parser

2009-05-18 Thread andrew cooke
http://groups.google.com/group/beautifulsoup/browse_thread/thread/d416dd19fdaa43a6 http://jjinux.blogspot.com/2008/10/python-some-notes-on-lxml.html andrew -- http://mail.python.org/mailman/listinfo/python-list

Configure options for minimal Python 2.6

2009-05-15 Thread Andrew Malcolmson
ere a list of the feature/package names of the other optional components? --- Andrew Malcolmson -- http://mail.python.org/mailman/listinfo/python-list

Re: New to python, can i ask for a little help?

2009-05-14 Thread Andrew Chung
in the past? Again, thank you to all of you who responded so quickly to my question. It helped alot. Andrew On Wed, May 13, 2009 at 1:58 PM, Chris Rebert wrote: > On Wed, May 13, 2009 at 12:22 PM, warhammer1...@gmail.com > wrote: > > On May 12, 9:27 pm, Chris Rebert wrote: > &g

Re: SQL and CSV

2009-05-08 Thread andrew cooke
o be some kind of cryptic argument against parameters. andrew Nick wrote: > On May 8, 1:49 pm, "andrew cooke" wrote: >> Lawrence D'Oliveiro wrote: >> > In message , Peter Otten wrote: >> >> >> While it may not matter here using placeholders instead

Re: SQL and CSV

2009-05-08 Thread andrew cooke
_str__ or __float__ or whatever? And you would still use the library to give safety with other values. Maybe you could give an example of the kind of problem you're thinking of? Thanks, Andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Statically linked extension and relative import

2009-05-07 Thread Andrew MacIntyre
ot in the foo package namespace (which is why "import bar" works), so should be imported as bar in foo's __init__.py. from foo import bar should then work from other code by virtue of the package namespace (instantiated by __init__.py) then having a bar symbol. -- ----

Tkinter Caesar Cipher GUI (speed errors?)

2009-05-06 Thread Andrew Free
/8adfdc83e9b5a2e9e7af1f557a97a3ee.png?direct That just makes no sense at all. Is 100 to fast for it to run? I would think it would wait for it to finish and update the GUI before it moved on. Thanks, Andrew-- http://mail.python.org/mailman/listinfo/python-list

Re: The whole story

2009-04-28 Thread andrew cooke
Paul Hemans wrote: > Hi Andrew, > The reason I am using mapped objects is that I need to abstract from the > database implementation allowing the replication to target a number of > different platforms. This will definitely slow things down. have you looked at sqlalchemy's ge

Re: Is there a maximum size to a Python program?

2009-04-27 Thread andrew cooke
t you can use sql directly when it's the best solution, and mapped objects when they are more useful). these are both kind-of obvious, but that's all i needed to handle fairly large data volumes with sqlalchemy. andrew Carbon Man wrote: > I have a program that is generated fro

Re: [OT] large db question about no joins

2009-04-17 Thread andrew cooke
on the more general point about exactly how to handle large data sets, i found this article interesting - http://highscalability.com/unorthodox-approach-database-design-coming-shard andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Automatically generating arithmetic operations for a subclass

2009-04-14 Thread andrew cooke
Arnaud Delobelle wrote: > "andrew cooke" writes: >> Arnaud Delobelle wrote: >>> class MyInt(int): >>> for op in binops: >>> exec binop_meth % (op, op) >>> for op in unops: >>> exec unop_meth % (op,

Re: Automatically generating arithmetic operations for a subclass

2009-04-14 Thread andrew cooke
self, other): > return type(self)(int.__%s__(self, other)) > """ > > unop_meth = """ > def __%s__(self): > return type(self)(int.__%s__(self)) > """ > > class MyInt(int): > for op in binops: > exec binop_meth % (op, op) > for op in unops: > exec unop_meth % (op, op) > del op what's the "del" for? curious, andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: ANN: PyGUI 2.0.1

2009-04-13 Thread Andrew MacKeith
-packages\GUI\Generic c:\python26\Lib\site-packages\GUI\Resources c:\python26\Lib\site-packages\GUI\Resources\cursors c:\python26\Lib\site-packages\GUI\Win32 Andrew MacKeith -- http://mail.python.org/mailman/listinfo/python-list

Re: Why is it that *dbm modules don't provide an iterator? (Language design question)

2009-04-09 Thread andrew cooke
http://bugs.python.org/issue662923 imply that there *was* suitable code (for 2.4)? So is this a regression? And should that issue be re-opened? Andrew > For gdbm, you can also use the firstkey/nextkey methods. > > Regards, > Martin > -- > http://mail.python.org/mailman/listi

Re: Recommendations on Pythonic tree data structure design techniques

2009-04-09 Thread andrew cooke
umeric keys. This doesn't make sense to me. It sounds like you are re-inventing lists (arrays). Andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Scrap Posts

2009-04-09 Thread andrew cooke
this discussion has happened before, here and on -dev, and people have generally acclaimed the list filtering). andrew Avi wrote: > Hey Folks, > > I love this group and all the awesome and python savvy people who post > here. However I also see some dumb posts like 'shoes' or

Re: Re: Why does Python show the whole array?

2009-04-09 Thread andrew cooke
ike myself, it's not easy to remember - i keep forgetting it! i think it's because i associate "in" with iteration, and assume everything else will be method calls or functions (and from earlier discussions here, it's clear some people are even more blinkered, and think everything

Re: Retrieving a specific object from a list?

2009-04-09 Thread andrew cooke
andrew cooke wrote: [...] > but when you need to access instances by more than one value (.bar and > .baz) then typically that's a hard problem, and there's a trade-off > somewhere. you might find writing a special container that contains two > dicts is useful. if so, you

Re: Retrieving a specific object from a list?

2009-04-09 Thread andrew cooke
inking at a high enough level about the algorithm - even though my third suggestion (deque) sounds rather obscure you may find that once you look at you algorithm more carefully it can be rewritten in that way. i think i've seen this in my own code as i improve at integrating what might be more "functional" idioms into python in a "natural" (pythonic) way. andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: nested looping

2009-04-08 Thread andrew cooke
bit late here, but if it's as simple as you say, i think it would be much more efficient (because you only scan checklist and alist once each) to do: known = set() for check in checklist: known.add(check[0:-1]) missing = filter(lambda alpha: alpha not in known, alist) andrew PK

Re: Why does Python show the whole array?

2009-04-08 Thread andrew cooke
wo strings match at the start. the problem is that the method return isn't consistent with implicit conversion to boolean; python does convert non-zero to True. andrew > print test > -- > http://mail.python.org/mailman/listinfo/python-list > > -- http://mail.python.org/mailman/listinfo/python-list

Re: Creating Linked Lists in Python

2009-04-07 Thread andrew cooke
l.TaggedFragments-class.html) hope that makes sense. it could probably be more efficient (does an O(n) scan of all intervals each time a new interval is added so is O(n^2)), but since this is used in the "compile" part of a regexp, speed may not be as important as in the "match" phase. andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: in place list modification necessary? What's a better idiom?

2009-04-07 Thread andrew cooke
MRAB wrote: > andrew cooke wrote: >> R. David Murray wrote: >>>> [...] >>>> try: >>>> dimensions.append(float(s)) >>>> except: >>>> dimensions.append(float(quantization[s])) >>> No, no, no; never use a b

PyXML and Python-2.6

2009-04-07 Thread Andrew MacKeith
Is there a guide to porting projects that depend on PyXML to Python-2.6? Andrew MacKeith -- http://mail.python.org/mailman/listinfo/python-list

Re: in place list modification necessary? What's a better idiom?

2009-04-07 Thread andrew cooke
d be better catching a specific exception. as a general rule, maybe, but in this particular case i can't see a reason - so i'm not sure if you're just pedantically following rules or if i've missed something i should know. andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: in place list modification necessary? What's a better idiom?

2009-04-07 Thread andrew cooke
convert('1,2,red') [1.0, 2.0, 0] >>> convert('1,2,blue') [1.0, 2.0, 1] >>> convert('1,2,blue,blue') [1.0, 2.0, 1, 0] andrew cooke wrote: > Carl Banks wrote: >> import collections >> import itertools >> >> def createIniti

Re: in place list modification necessary? What's a better idiom?

2009-04-07 Thread andrew cooke
ic. just return the cast value or catch the exception: [...] try: dimensions.append(float(s)) except: dimensions.append(float(quantization[s])) (not sure float() is needed there either if you're using a recent version of python - only reason i can think of is to avoid integer division in older versions). andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Returning different types based on input parameters

2009-04-06 Thread andrew cooke
andrew cooke wrote: > George Sakkis wrote: >> That's more of a general API design question but I'd like to get an >> idea if and how things are different in Python context. AFAIK it's >> generally considered bad form (or worse) for functions/methods to

Re: Returning different types based on input parameters

2009-04-06 Thread andrew cooke
(as opposed to input parameters). [...] you probably want to look up substitutability: http://www.google.cl/search?q=substitutability+principle andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Best way to start

2009-04-06 Thread andrew cooke
Avi wrote: > What is a good way to learn Python? > > Do you recommend going by a book (suggestions welcome) or learning > with tutorials? Both? how do you like to learn and how much experience do you have programming in other languages? andrew -- http://mail.python.org/mailman/lis

Re: speed of string chunks file parsing

2009-04-06 Thread andrew cooke
t try to avoid having multiple occurrences of ".*". see the timeit package for testing the speed of small chunks of code. andrew Hyunchul Kim wrote: > Hi, all > > I have a simple script. > Can you improve algorithm of following 10 line script, with a view point > of speed

Re: Spring-like IoC in python?

2009-04-05 Thread andrew cooke
you are already in a scripting language. but maybe i have missed something, given that this stuff exists (hence me trying to understand it). andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Why doesn't StopIteration get caught in the following code?

2009-04-04 Thread andrew cooke
n you define a function or a method that contains "yield". the above doesn't, so it's not rewritten and there's no magic. more exactly: http://docs.python.org/reference/datamodel.html#index-1747 andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Testing dynamic languages

2009-04-04 Thread andrew cooke
andrew cooke wrote: > if you are going to do that, stay with java. seriously - i too, am a java > developer about half the time, and you can make java pretty dynamic if you > try hard enough. look at exploiting aspects and functional programming > libraries, for example. also, of c

Re: How to free /destroy object created by PyTuple_New

2009-04-04 Thread Andrew Svetlov
To destroy every python object you need to call Py_DECREF. To call python code fron you C thread you need to use pair PyGILState_Ensure/PyGILState_Release. -- http://mail.python.org/mailman/listinfo/python-list

Re: Testing dynamic languages

2009-04-04 Thread andrew cooke
ove just my experience. i tend to use java for the server side and python for getting data into the database, so each plays to its strengths. andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: A design problem I met again and again.

2009-04-04 Thread andrew cooke
andrew cooke wrote: [...] >>> > #= >>> > def start(type, id): >>> > if(type == "XXX"): >>> > pass >>> > else if(type == "YYY"): >>> > pass >>> >

Re: A design problem I met again and again.

2009-04-04 Thread andrew cooke
ave a ', if type(x) is Foo: print 'furry foo' elif type(x) is Bar: print 'bubbly Bar; else: print 'strange beast' might be refactored as class MyPrintable(object): def my_print(self): print 'i have a ', self.describe() class Foo(MyPrintable): def describe(self): return 'furry Foo' etc etc. it's not always possible, but any type() or isinstance() in an OO program is a big red flag that the design is wrong. andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Module caching

2009-04-03 Thread andrew cooke
are you an experienced python programmer? a lot of newbies post here with problems related to unexpected results because they make "the usual" mistakes about list mutability and default function arguments. i suspect that's not the case here, but it seemed worth mentioning, just i

Re: A design problem I met again and again.

2009-04-03 Thread andrew cooke
ll the other uncertainties in software development, that i cannot see why people are even discussing it (well, i can understand, because human nature is what it is, and software development seems to attract a certain kind of pedantic, rigid mind, but even so...) andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Iteratoration question

2009-04-02 Thread andrew cooke
7;s pretty > much the definition of it. You have read the iteration protocol > after it's been mentioned so many times now, haven't you? argh. when i said "yes" i meant that something calls them - that they realy do exist behind the scenes. but rhodri is right (again), it

Re: Iteratoration question

2009-04-02 Thread andrew cooke
gt;> x = count() >>> dir(x) ['__class__', '__delattr__', '__doc__', '__getattribute__', '__hash__', '__init__', '__iter__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', 'close', 'gi_frame', 'gi_running', 'next', 'send', 'throw'] >>> i = x.__iter__() >>> i.next() 0 >>> i.next() 1 andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Iteratoration question

2009-04-02 Thread andrew cooke
7;extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort'] >>> l.__iter__ >>> i = l.__iter__() >>> dir(i) ['__class__', '__delattr__', '__doc__', '__getattribute__', '__hash__', '__init__', '__iter__', '__length_hint__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', 'next'] >>> i.next() 1 >>> i.next() 2 note that the list only has __iter__, not next. calling __iter__() returns an iterator (something that has a next method) and calling next on that gives you the same result. dir() just shows all the attributes of an object. andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Iteratoration question

2009-04-02 Thread andrew cooke
ction that returns a value. What he > needs > is an __iter__() method that returns self. Alternately, __iter__ could be yeah, sorry, i was in a rush and not thinking straight. andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Iteratoration question

2009-04-02 Thread andrew cooke
#x27;value' like in the following > >>>> for x in value: > ... print x > ... > Traceback (most recent call last): > File "", line 1, in ? > TypeError: iteration over non-sequence > > But yet, I can do... > >>>> value.next() >

Re: Iteratoration question

2009-04-02 Thread andrew cooke
new instance each time it is called. BUT while what you are doing is interesting, it is not the same as Python's iterators, which use "yield" from a function and don't require storing a value in a class. look for "yield" in the python docs. this comment may be irrelevant; i am just worried you are confusing the above (which apart from the mistake about instances is perfectly ok) and python's iterators (which use next(), yield, etc). andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: [Python-Dev] PEP 382: Namespace Packages

2009-04-02 Thread andrew cooke
andrew cooke wrote: > Chris Withers wrote: >> Martin v. Löwis wrote: >>> I propose the following PEP for inclusion to Python 3.1. >>> Please comment. >> >> Would this support the following case: >> >> I have a package called mortar, which def

Re: [Python-Dev] PEP 382: Namespace Packages

2009-04-02 Thread andrew cooke
emy, but i am sure other packages do something similar. it's described in the python docs. andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Goes Mercurial

2009-04-02 Thread andrew cooke
;m happy with svn - but i am curious about what the advantages and disadvantages might be. thanks, andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: league problem in python

2009-04-02 Thread Andrew Henshaw
"Ross" wrote in message news:d5cc0ec7-5223-4f6d-bab4-3801dee50...@r37g2000yqn.googlegroups.com... ... snip ... > I would like to create a simple program where the pro could enter in > how many people were in the league, the number of courts available, > and the number of weeks the schedule would

Re: simple iterator question

2009-04-02 Thread andrew cooke
Sion Arrowsmith wrote: > Neal Becker wrote: >>How do I interleave 2 sequences into a single sequence? >> >>How do I interleave N sequences into a single sequence? > > itertools.chain(*itertools.izip(*Nsequences)) aha! thanks. andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Class methods read-only by default?

2009-04-02 Thread andrew cooke
class, not the instance). so you may be able to delete the method from the class, but then it will affect all instances. you can't delete it from one instance because it's not in that instance. as i said, just a guess, based on vague ideas about how python works. andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: simple iterator question

2009-04-02 Thread andrew cooke
single in together: yield single seems like it should work (warning: untried). will terminate on shortest length doodah. andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: A design problem I met again and again.

2009-04-02 Thread andrew cooke
n)) access time. in contrast a single file means a linear scan, O(n). (i am talking about human use here - people reading and trying to understand code, perhaps during debugging or code review or whatever). andrew (you could argue that the file contents can be sorted in some way - you coul

Re: Alpha/For Discussion: RPMs for around 3,000 PyPI packages.

2009-04-01 Thread andrew cooke
es. neat idea. the info for each package includes information on which python versions it is compatible with. wouldn't it make sense to use that? might explain a lot of failures. andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Beazley on Generators

2009-04-01 Thread andrew cooke
ith-nice-syntax.html > > Peters implementation can be simplified but it already contains all > relevant ideas. oh that's neat. thanks for that. andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: python for loop

2009-04-01 Thread andrew cooke
he total "pile" is rather than counting (do they know the difference between two small things and one big thing, for example). that experiment doesn't seem to address this. andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: List of paths

2009-04-01 Thread andrew cooke
Nico Grubert wrote: >> May be not so much pythonic, but works >> >> for i in range(len(q)): >> for x in q[i:]: >>if x.startswith(q[i]) and x!=q[i]: >>q.remove(x) > > ...but works fine. Thanks, Eugene. > Also thanks to Andrew. Y

Re: Regex trouble

2009-04-01 Thread andrew cooke
more exactly, my guess is perl has a special case for this that avoids doing a search over all possible matchers via the pushdown stack. andrew cooke wrote: > > ".*?" is a "not greedy" match, which is significantly more difficult to > handle than a normal ".*&qu

Re: Regex trouble

2009-04-01 Thread andrew cooke
ed with a simple finite automaton. disclaimer: this is all fairly new to me as i just recently implemented a regular expression matcher myself, and i may be wrong on some of the details. andrew akshat agarwal wrote: > Hi, > > I am trying to use the following snippet of code to print a r

Re: python for loop

2009-04-01 Thread andrew cooke
andrew cooke wrote: [...] > so in a small/moderate size library of 600 lines (including blanks and 6000 > comments, but excluding tests and exploratory code) the only time i have > used range with array indices i was either unhappy with the

Re: python for loop

2009-04-01 Thread andrew cooke
/moderate size library of 600 lines (including blanks and comments, but excluding tests and exploratory code) the only time i have used range with array indices i was either unhappy with the code, or implementing a complex data structure. andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: A design problem I met again and again.

2009-04-01 Thread andrew cooke
rguments, perhaps using introspection to find method names, etc) andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: List of paths

2009-04-01 Thread andrew cooke
>>> def filter(values): ... last = None ... for value in values: ... if last is None or not value.startswith(last): ... yield value ... last = value ... >>> for x in filter(['/notebook', ]): ... print(x) ... /notebook /desktop /server/hp/pro

Re: Stripping non-numbers from a file parse without nested lists?

2009-03-31 Thread andrew cooke
the problem is, but the mention of nested lists makes me think maybe you need a generator. you can define this function: def tokens(filename): with open(filename, "r", encoding="ascii") as fh: for line in fh: for word in line.lower().split():

Re: Python Goes Mercurial

2009-03-31 Thread andrew cooke
Lawrence D'Oliveiro wrote: > In message , andrew > cooke wrote: > >> Lawrence D'Oliveiro wrote: >>> <http://arstechnica.com/open-source/news/2009/03/python-adopts-the- > mercurial-version-control-system.ars> >>> >>> So what were these &q

Re: Python Goes Mercurial

2009-03-31 Thread andrew cooke
discussion in python-dev about this (see thread titled "And the winner is..."). i haven't read the article you link to, but compared to what i've read on dev "strong antipathies" sounds a bit over-hyped. andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: python for loop

2009-03-31 Thread andrew cooke
; 5; ++i) { a[i] = 0; } were you being honest about the c background?! andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Printing Out Called Function Calls

2009-03-31 Thread andrew cooke
) > when I need it to execute the fn tableTop. What do? change server famrs? use eval() or exec()? andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Introducing Python to others

2009-03-31 Thread andrew cooke
David C. Ullrich wrote: > In article , > Scott David Daniels wrote: > >> Mensanator wrote: >> > On Mar 26, 11:42 am, "andrew cooke" wrote: >> >> ... >> >> that's cute, but if you show them 2.6 or 3 it's even cuter

Re: regex negative lookbehind assertion not working correctly?

2009-03-31 Thread andrew cooke
it is working - it's making the final "8" not be matched. don't you want lookahead rather than lookbehind? or force an end of string? andrew Gabriel Rossetti wrote: > Hello everyone, > > I am trying to write a regex pattern to match an ID in a URL only if it &

<    4   5   6   7   8   9   10   11   12   13   >