[issue45690] Argparse exclusive group inside required exclusive group displays incorrectly

2021-11-02 Thread andrew cooke
New submission from andrew cooke : The code below, when invoked with -h, prints: (.env) [andrew@localhost py]$ python -m tests_sa.argparse_bug -h usage: argparse_bug.py [-h] (-a A | [-b B | -c C)] options: -h, --help show this help message and exit -a A -b B -c C where the final two

Basic misunderstanding on object creation

2015-05-13 Thread andrew cooke
Hi, The following code worked on Python 3.2, but no longer works in 3.4. Did something change, or have I always been doing something dumb? (I realise the code is pointless as is - it's the simplest example I can give of a problem I am seeing with more complex code). class Foo: ... def

Re: Basic misunderstanding on object creation

2015-05-13 Thread andrew cooke
But then nothing will be passed to __init__ on the subclass. Andrew class Foo: ... def __new__(cls, *args, **kargs): ... print('new', args, kargs) ... super().__new__(cls) ... class Bar(Foo): ... def __init__(self, a): ... print('init', a) ... Bar(1) new

Re: Basic misunderstanding on object creation

2015-05-13 Thread andrew cooke
On Wednesday, 13 May 2015 11:36:12 UTC-3, Thomas Rachel wrote: Am 13.05.2015 um 15:25 schrieb andrew cooke: class Foo: ... def __new__(cls, *args, **kargs): ... print('new', args, kargs) ... super().__new__(cls, *args, **kargs) new (1,) {} Traceback (most

Re: Basic misunderstanding on object creation

2015-05-13 Thread andrew cooke
On Wednesday, 13 May 2015 13:37:23 UTC-3, Terry Reedy wrote: On 5/13/2015 9:25 AM, andrew cooke wrote: The following code worked on Python 3.2, but no longer works in 3.4. Bugfixes break code that depends on buggy behavior. See https://bugs.python.org/issue1683368 Your code also fails

Re: Basic misunderstanding on object creation

2015-05-13 Thread andrew cooke
On Wednesday, 13 May 2015 11:56:21 UTC-3, Ian wrote: On Wed, May 13, 2015 at 8:45 AM, andrew cooke and...@acooke.org wrote: class Foo: ... def __new__(cls, *args, **kargs): ... print('new', args, kargs) ... super().__new__(cls) ... class Bar(Foo): ... def

[issue18422] is_package missing so can't use -m

2013-07-10 Thread andrew cooke
New submission from andrew cooke: Using python 3.3, if I try to run __main__ I see this error: Traceback (most recent call last): File /usr/local/lib/python3.3/runpy.py, line 140, in _run_module_as_main mod_name, loader, code, fname

[issue18422] is_package missing so can't use -m

2013-07-10 Thread andrew cooke
andrew cooke added the comment: can't see how to edit posts, so adding as a comment, this is what triggers the bug: PYTHONPATH=src python -m simplessl -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18422

[issue18423] Document limitations on -m

2013-07-10 Thread andrew cooke
New submission from andrew cooke: Apparently the limited support for -m is standard behaviour - see http://bugs.python.org/issue18422 - but it's not documented at http://docs.python.org/3/using/cmdline.html#cmdoption-m That should say, somewhere, that it only applies to leaf modules

[issue18422] is_package missing so can't use -m

2013-07-10 Thread andrew cooke
andrew cooke added the comment: in case anyone else ends up here through google... the problem described here is not related to the linked issue. it was just a missing `__init__.py` in the module (plus sucky error messages). the following works fine: . ├── README.md ├── src

[issue17403] Robotparser fails to parse some robots.txt

2013-03-26 Thread andrew cooke
andrew cooke added the comment: what is rietveld? and why is this marked as easy? it seems like it involves issues that aren't described well in the spec - it requires some kind of canonical way to describe urls with (and without) parameters to solve completely. -- nosy: +acooke

[issue17403] Robotparser fails to parse some robots.txt

2013-03-26 Thread andrew cooke
andrew cooke added the comment: thanks (only subscribed to this now, so no previous email). my guess is that google are assuming a dumb regexp so http://example.com/foo? in a rule does not match http://example.com/foo and also i realised that http://google.com/robots.txt doesn't

Confused about logger config from within Python (3)

2012-12-28 Thread andrew cooke
When I use a config file things seem to work (in other projects), but for my current code I hoped to configure logging from Python. I distilled my problem down to the following test, which does not print anything. Please can someone explain why? I was expecting the module's logger to

Re: Confused about logger config from within Python (3)

2012-12-28 Thread andrew cooke
similarly, if i run the following, i see only done: from logging import DEBUG, root, getLogger if __name__ == '__main__': root.setLevel(DEBUG) getLogger(__name__).debug(hello world) print('done') -- http://mail.python.org/mailman/listinfo/python-list

Re: Confused about logger config from within Python (3)

2012-12-28 Thread andrew cooke
On Friday, 28 December 2012 21:56:46 UTC-3, Peter Otten wrote: Other revolutionary ideas: read the docs http://docs.python.org/dev/howto/logging.html#logging-basic-tutorial ;) how do you think i knew about the root handler without reading the damn docs you condescending asshole? anyway,

[issue12897] Support for iterators in multiprocessing map

2012-06-11 Thread andrew cooke
andrew cooke and...@acooke.org added the comment: hi - i'm the original author (may be using a different account). as far as i remember, i raised this because it seemed relevant given the link i gave. if you've looked at the issue and think your approach would work, or that this should

[issue12029] Catching virtual subclasses in except clauses

2012-05-11 Thread andrew cooke
andrew cooke and...@acooke.org added the comment: perhaps it could just work in a simple, consistent way? in my original report i wondered whether there was a significant performance hit. but so far the objections against fixing this seem to be (1) a lawyer could be convinced the current

[issue12029] Catching virtual subclasses in except clauses

2012-05-11 Thread andrew cooke
Changes by andrew cooke and...@acooke.org: -- nosy: -acooke ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12029 ___ ___ Python-bugs-list mailing

ordering with duck typing in 3.1

2012-04-07 Thread andrew cooke
hi, please, what am i doing wrong here? the docs say http://docs.python.org/release/3.1.3/library/stdtypes.html#comparisons in general, __lt__() and __eq__() are sufficient, if you want the conventional meanings of the comparison operators but i am seeing assert 2 three E

[issue12897] Support for iterators in multiprocessing map

2011-09-05 Thread andrew cooke
New submission from andrew cooke and...@acooke.org: http://stackoverflow.com/questions/7306522/combining-itertools-and-multiprocessing/7307078 suggests (and the idea itself seems reasonable) that it would sometimes be useful for multiprocessing to operate correctly (ie lazily) with lazy input

Re: ABC-registered Exceptions are not caught as subclasses

2011-05-08 Thread andrew cooke
http://bugs.python.org/issue12029 -- http://mail.python.org/mailman/listinfo/python-list

[issue12029] ABC registration of Exceptions

2011-05-08 Thread andrew cooke
New submission from andrew cooke and...@acooke.org: Hi, In general, registering a class with an ABC is equivalent to making it a subclass (isinstance and issubclass are patched through ABCMeta). However, this does not work for exceptions (see example below, where exception is not caught

ABC-registered Exceptions are not caught as subclasses

2011-05-07 Thread andrew cooke
This isn't hugely surprising, but doesn't seem to be documented. Is it a bug, or worth raising as one, or have I misunderstood? Python 3.2 (r32:88445, Feb 27 2011, 13:00:05) [GCC 4.5.0 20100604 [gcc-4_5-branch revision 160292]] on linux2 Type help, copyright, credits or license for more

Re: My stupidity / strange inconsistency overriding class methods

2011-04-20 Thread andrew cooke
Thanks for finding that reference in the data model docs! I was about to post a bug report because in PEP 3119 it says otherwise: The primary mechanism proposed here is to allow overloading the built-in functions isinstance() and issubclass(). The overloading works as follows: The call

Re: My stupidity / strange inconsistency overriding class methods

2011-04-20 Thread andrew cooke
I didn't phrase that very well. I do see the point about this being an instance lookup on a class... -- http://mail.python.org/mailman/listinfo/python-list

Re: meteclasses 2.x/3.x compatibility

2011-04-20 Thread andrew cooke
What I do in Lepl is use two stages. The first calls the type/metaclass directly and the second subclasses that. This avoids using the sugar that changes between 2 and 3. So, for example, in http://code.google.com/p/lepl/source/browse/src/lepl/matchers/matcher.py#40 I have _Matcher =

Re: Language lib reference in man format ?

2011-04-20 Thread andrew cooke
(1) Python's docs use Sphinx, which uses restructured text as a markup. You can generate man pages from restructured text using rst2man (which is installed on my computer, probably as part of python/docutils). HOWEVER I imagine it's not going to work very well, if at all, because Sphinx uses

My stupidity / strange inconsistency overriding class methods

2011-04-19 Thread andrew cooke
Hi, I've been staring at this problem, in various forms, all day. Am I missing something obvious, or is there some strange hardwiring of isinstance? This is with Python 3.2. class A(metaclass=ABCMeta): @classmethod def __instancecheck__(cls, instance): return

Re: My stupidity / strange inconsistency overriding class methods

2011-04-19 Thread andrew cooke
Also, there's something strange about the number of arguments (they're not consistent between the two examples - the A to __instancecheck__ should not be needed). Yet it compiles and runs like that. Very confused :o( -- http://mail.python.org/mailman/listinfo/python-list

Re: My stupidity / strange inconsistency overriding class methods

2011-04-19 Thread andrew cooke
OK, sorry, I see the mistake. I'm confusing __class__ on the instance and on te class (the latter being the metaclass). Sorry again, Andrew -- http://mail.python.org/mailman/listinfo/python-list

Why is __root checked for in OrderedDict?

2011-04-07 Thread andrew cooke
If you look at the code in http://hg.python.org/cpython/file/6adbf5f3dafb/Lib/collections/__init__.py#l49 the attribute __root is checked for, and only created if missing. Why? I ask because, from what I understand, the __init__ method will only be called when the object is first being

Re: Why is __root checked for in OrderedDict?

2011-04-07 Thread andrew cooke
Is that normal? I mean, OK, it's possible (and yes I forgot it could be called directly), but is there any usual reason to do so? I guess what I'm asking is: if I'm writing library code should I be this careful? (I've written quite a lot of Python code without this ever biting me, but maybe

Confused about __prepare__

2011-04-07 Thread andrew cooke
In the code below I use __prepare__ to change the class dictionary so that a tuple is stored in __setitem__(). Since __getitem__() removes the tuple I wasn't expecting any problems, but it seems that __init__ is being retrieved via some other mechanism. Why? Is a copy of the dict being made

Re: Confused about __prepare__

2011-04-07 Thread andrew cooke
Sorry I should probably have made clear that this is Python 3.2 -- http://mail.python.org/mailman/listinfo/python-list

Re: Confused about __prepare__

2011-04-07 Thread andrew cooke
Yes, I think you're right, thanks. Makes sense from an efficiency POV. Luckily, it turns out I don't need to do that anyway :o) Cheers, Andrew -- http://mail.python.org/mailman/listinfo/python-list

Replacing *instance* dict

2011-04-07 Thread andrew cooke
== 'three' print('woop') On Thursday, April 7, 2011 7:31:16 PM UTC-3, andrew cooke wrote: class TupleDict(dict): '''Stores additional info, but removes it on __getitem__().''' def __setitem__(self, key, value): print('setting', key, value) super(TupleDict

Why is return type in getfullspec().annotations named as return?

2011-04-02 Thread andrew cooke
This conflicts with any parameter named return. Wouldn't it have been better to use - as the key? Is there any way this can be changed? Andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Why is return type in getfullspec().annotations named as return?

2011-04-02 Thread andrew cooke
Sorry, ignore that. I just realised that return will be a reserved word, so that can't happen. Andrew -- http://mail.python.org/mailman/listinfo/python-list

python3.2m installed as (additional) binary

2011-02-27 Thread andrew cooke
Hi, I just downloaded, built and altinstalled Python3.2 on Linux x64. I noticed that in /usr/local/bin I have two identical (says diff) binaries called Python3.2 and Python3.2m. Is this expected? I can find very little reference to them apart from a short discussion in python-dev where

Re: python3.2m installed as (additional) binary

2011-02-27 Thread andrew cooke
[Sorry I clicked the wrong button so I think my prev reply went only to Tom] Thanks. Yes, they're hard linked. And the bug report mentions PEP 3149 which says that m means --with-pymalloc was used http://www.python.org/dev/peps/pep-3149/ Cheers, Andrew --

Re: Another Regexp Question

2010-07-06 Thread andrew cooke
http://bugs.python.org/issue9179 On Jul 5, 9:38 pm, MRAB pyt...@mrabarnett.plus.com wrote: andrew cooke wrote: On Jul 5, 8:56 pm, MRAB pyt...@mrabarnett.plus.com wrote: andrew cooke wrote: What am I missing this time? :o( Nothing. It's a bug. :-( Sweet :o) Thanks - do you want me

[issue9179] Lookback with group references incorrect (two issues?)

2010-07-06 Thread andrew cooke
New submission from andrew cooke and...@acooke.org: from re import compile # these work as expected assert compile('(a)b(?=b)(c)').match('abc') assert not compile('(a)b(?=c)(c)').match('abc') assert compile('(a)b(?=c)(c)').match('abc') assert not compile('(a)b(?=b)(c)').match('abc

[issue9179] Lookback with group references incorrect (two issues?)

2010-07-06 Thread andrew cooke
andrew cooke and...@acooke.org added the comment: I hope the above is clear enough (you need to stare at the regexps for a time) - basically, lookback with a group conditional is not as expected (it appears to be evaluated as lookahead?). Also, some patterns compile that probably shouldn't

[issue9179] Lookback with group references incorrect (two issues?)

2010-07-06 Thread andrew cooke
andrew cooke and...@acooke.org added the comment: If it's any help, these are the equivalent tests as I think they should be (you'll need to translate engine(parse(... to compile(...) http://code.google.com/p/rxpy/source/browse/rxpy/src/rxpy/engine/backtrack/_test/engine.py?r

[issue9179] Lookback with group references incorrect (two issues?)

2010-07-06 Thread andrew cooke
andrew cooke and...@acooke.org added the comment: I thought someone was working on the re module these days? I thought there I'd seen some issues with patches etc? Anyway, short term, sorry - no patch. Medium/long term, yes it's possible, but please don't rely on it. The simplest way

[issue9179] Lookback with group references incorrect (two issues?)

2010-07-06 Thread andrew cooke
andrew cooke and...@acooke.org added the comment: Ah good point, thanks. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9179 ___ ___ Python-bugs

Another Regexp Question

2010-07-05 Thread andrew cooke
As ever, I guess it's most likely I've misunderstood something, but in Python 2.6 lookback seems to actually be lookahead. All the following tests pass: from re import compile assert compile('(a)b(?=(?(2)x|c))(c)').match('abc') assert not

Re: Another Regexp Question

2010-07-05 Thread andrew cooke
On Jul 5, 8:56 pm, MRAB pyt...@mrabarnett.plus.com wrote: andrew cooke wrote: What am I missing this time? :o( Nothing. It's a bug. :-( Sweet :o) Thanks - do you want me to raise an issue or will you? Cheers, Andrew -- http://mail.python.org/mailman/listinfo/python-list

Help with Regexp, \b

2010-05-29 Thread andrew cooke
This is a bit embarassing, but I seem to be misunderstanding how \b works in regexps. Please can someone explain why the following fails: from re import compile p = compile(r'\bword\b') m = p.match(' word ') assert m My understanding is that \b matches a space

Re: Help with Regexp, \b

2010-05-29 Thread andrew cooke
On May 29, 11:24 am, Duncan Booth duncan.bo...@invalid.invalid wrote: andrew cooke and...@acooke.org wrote: Please can someone explain why the following fails:         from re import compile         p = compile(r'\bword\b')         m = p.match(' word ')         assert m [...] You

Re: Parser

2010-05-03 Thread andrew cooke
On May 2, 3:54 pm, Andreas Löscher andreas.loesc...@s2005.tu- chemnitz.de wrote: Hi, I am looking for an easy to use parser. I am want to get an overview over parsing and want to try to get some information out of a C-Header file. Which parser would you recommend? Best, Andreas I develop

Ann: Validating Emails and HTTP URLs in Python

2010-05-03 Thread andrew cooke
Hi, The latest Lepl release includes an implementation of RFC 3696 - the RFC that describes how best to validate email addresses and HTTP URLs. For more information please see http://www.acooke.org/lepl/rfc3696.html Lepl's main page is http://www.acooke.org/lepl Because Lepl compiles to

Re: Ann: Validating Emails and HTTP URLs in Python

2010-05-03 Thread andrew cooke
FYI, Fourthought's PyXML has a module called uri.py that contains   regexes for URL validation. I've over a million URLs (harvested from   the Internet) through their code. I can't say I checked each and every   result, but I never saw anything that would lead me to believe it was  

Confused by slash/escape in regexp

2010-04-11 Thread andrew cooke
Is the third case here surprising to anyone else? It doesn't make sense to me... Python 2.6.2 (r262:71600, Oct 24 2009, 03:15:21) [GCC 4.4.1 [gcc-4_4-branch revision 150839]] on linux2 Type help, copyright, credits or license for more information. from re import compile p1 = compile('a\x62c')

Re: Confused by slash/escape in regexp

2010-04-11 Thread andrew cooke
On Apr 11, 8:12 pm, Lie Ryan lie.1...@gmail.com wrote: In the first case, *python* will unescape the string literal '\x62' into letters 'b'. In the second case, python will unescape the double backslash '\\' into a single slash '\' and *regex* will unescape the single-slash-62 into 'b'. In the

Re: Confused by slash/escape in regexp

2010-04-11 Thread andrew cooke
On Apr 11, 7:18 pm, Paul McGuire pt...@austin.rr.com wrote: [...] So I would say the surprise isn't that case 3 didn't match, but that case 2 matched. Unless I just don't get what you were testing, not being an RE wiz. Case 2 is the regexp engine interpreting escapes that appear as literal

Re: Function name unchanged in error message

2010-01-30 Thread andrew cooke
On Jan 29, 11:22 am, Peter Otten __pete...@web.de wrote: The name is looked up in the code object. As that is immutable you have to make a new one: [details snipped] thanks very much! sorry i didn't reply earlier - been travelling. (also, thanks to any other replies - i'm just reading through

Re: Function name unchanged in error message

2010-01-30 Thread andrew cooke
On Jan 29, 5:37 pm, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: The decorator module is a very fine addition to anyone's tool set -- but   in this case it is enough to use the wraps() function from the functools   standard module. ah, thanks! i thought something like this existed in the

Re: Function name unchanged in error message

2010-01-30 Thread andrew cooke
On Jan 29, 11:50 am, exar...@twistedmatrix.com wrote: new.function and new.code will let you construct new objects with different values (and copying over whichever existing attributes you want to preserve). unfortunately new is deprecated and dropped from 3. i can't see how the same

Re: Function name unchanged in error message

2010-01-30 Thread andrew cooke
On Jan 30, 7:17 pm, andrew cooke and...@acooke.org wrote: On Jan 29, 5:37 pm, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: The decorator module is a very fine addition to anyone's tool set -- but   in this case it is enough to use the wraps() function from the functools   standard

Re: Function name unchanged in error message

2010-01-30 Thread andrew cooke
On Jan 29, 1:09 pm, Michele Simionato michele.simion...@gmail.com wrote: On Jan 29, 2:30 pm, andrew cooke and...@acooke.org wrote: Is there any way to change the name of the function in an error message?  In the example below I'd like the error to refer to bar(), for example

Function name unchanged in error message

2010-01-29 Thread andrew cooke
Is there any way to change the name of the function in an error message? In the example below I'd like the error to refer to bar(), for example (the motivation is related function decorators - I'd like the wrapper function to give the same name) def foo(): ... return 7 ... foo.__name__ =

[issue7792] Errors registering non-classes with ABCs

2010-01-26 Thread andrew cooke
New submission from andrew cooke and...@acooke.org: There are two related issues here. The first is, I think, a simple bug: When I try to register a function as a subclass of an ABC I get the error: TypeError: issubclass() arg 2 must be a class or tuple of classes Looking at the code

Re: Comparison of parsers in python?

2009-09-26 Thread andrew cooke
On Sep 21, 10:59 am, Nobody nob...@nowhere.com wrote: I have a similar question. What I want: a tokeniser generator which can take a lex-style grammar (not necessarily lex syntax, but a set of token specifications defined by REs, BNF, or whatever), generate a DFA, then run the DFA on

Re: Intercepting binding?

2009-09-24 Thread andrew cooke
On Sep 24, 7:12 am, Carl Banks pavlovevide...@gmail.com wrote:     with capture_changed_bindings() as changed:         b = 5         c = 4         d = 6     print changed test() Quick and dirty, not robust at all.  But you get the idea. Carl Banks brilliant. using the with context is

Re: Intercepting binding?

2009-09-24 Thread andrew cooke
On Sep 24, 5:20 am, Steven D'Aprano ste...@remove.this.cybersource.com.au wrote: Speaking as a user (although not of Andrew's domain specific language), I'd like to say to developers PLEASE PLEASE PLEASE don't try to help me with half-baked unreliable solutions that only work sometimes.

Intercepting binding?

2009-09-23 Thread andrew cooke
This is a bit vague, I'm afraid, but is there any way for me to take code like: a = Foo() beta = Bar() and somehow attach the string a to the Foo instance and beta to the Bar instance. At some later point in the program I want to be able to look at the Bar instance and say to the user

Re: Intercepting binding?

2009-09-23 Thread andrew cooke
For example, I assume it's possible to somehow access the dictionary for the current block, but I can't see how to do this after assignment. If I do it in the Foo constructor, for example, a will not yet be bound. On Sep 23, 8:15 pm, andrew cooke and...@acooke.org wrote: This is a bit vague

Re: Intercepting binding?

2009-09-23 Thread andrew cooke
On Sep 23, 8:40 pm, Rhodri James rho...@wildebst.demon.co.uk wrote: eggs[42] = Foo() beans['spam'] = Foo() chips.spam = Foo() spam[eggs.beans['chips']] = Foo() spam.append(Foo()) these are valid points, but in practice the main use (for the restricted application i care about) is si,ple

Re: Intercepting binding?

2009-09-23 Thread andrew cooke
On Sep 23, 10:11 pm, Dave Angel da...@ieee.org wrote: This comes up periodically in this list, and the answer is always something like:  you can't get there from here. Well, I'm both flexible and desperate, so this is a possible route (perhaps near enough): import sys class Foo(object):

Re: Intercepting binding?

2009-09-23 Thread andrew cooke
for the record, googling for f_back.f_locals reveals a wide variety of similar hacks and also a cleaner way to access the current frame: inspect.currentframe() -- http://mail.python.org/mailman/listinfo/python-list

Re: Comparison of parsers in python?

2009-09-20 Thread andrew cooke
On Sep 19, 9:34 pm, Peng Yu pengyu...@gmail.com wrote: On Sep 19, 6:05 pm, Robert Kern robert.k...@gmail.com wrote: http://nedbatchelder.com/text/python-parsers.html This is more a less just a list of parsers. I would like some detailed guidelines on which one to choose for various parsing

Re: Comparison of parsers in python?

2009-09-20 Thread andrew cooke
On Sep 20, 8:11 am, Peng Yu pengyu...@gmail.com wrote: On Sun, Sep 20, 2009 at 6:50 AM, andrew cooke and...@acooke.org wrote: On Sep 19, 9:34 pm, Peng Yu pengyu...@gmail.com wrote: On Sep 19, 6:05 pm, Robert Kern robert.k...@gmail.com wrote: http://nedbatchelder.com/text/python-parsers.html

Re: Comparison of parsers in python?

2009-09-20 Thread andrew cooke
On Sep 19, 11:39 pm, TerryP bigboss1...@gmail.com wrote: [...] For flat data, simple unix style rc or dos style ini file will often suffice, and writing a parser is fairly trivial; in fact writing a [...] python already includes parsers for .ini configuration files. [...] The best way to

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. --

Re: Comparison of parsers in python?

2009-09-20 Thread andrew cooke
The file size of a wig file can be very large (GB). Most tasks on this file format does not need the parser to save all the lines read from the file in the memory to produce the parsing result. I'm wondering if pyparsing is capable of parsing large wig files by keeping only minimum required

Re: Comparison of parsers in python?

2009-09-20 Thread andrew cooke
also, parsing large files may be slow. in which case you may be better with a non-python solution (even if you call it from python). your file format is so simple that you may find a lexer is enough for what you want, and they should be stream oriented. have a look at the shlex package that is

Re: Comparison of parsers in python?

2009-09-20 Thread andrew cooke
I don't quite understand this point.  If I don't use a parser, since python can read numbers line by line, why I need a lexer package? for the lines of numbers it would make no difference; for the track definition lines it would save you some work. as you said, this is a simple format, so the

Re: Comparison of parsers in python?

2009-09-20 Thread andrew cooke
So for the track definition, using a lexer package would be better than using regex in python, right? they are similar. a lexer is really just a library that packages regular expressions in a certain way. so you could write your own code and you would really be writing a simple lexer. the

Re: Comparison of parsers in python?

2009-09-20 Thread andrew cooke
On Sep 20, 9:12 am, andrew cooke and...@acooke.org wrote: ps is there somewhere can download example files?  this would be useful for my own testing.  thanks. i replied to a lot of your questions here; any chance you could reply to this one of mine? the wig format looks like it could be a good

Re: Comparison of parsers in python?

2009-09-20 Thread andrew cooke
On Sep 20, 3:16 pm, Peng Yu pengyu...@gmail.com wrote: On Sun, Sep 20, 2009 at 1:35 PM, andrew cooke and...@acooke.org wrote: On Sep 20, 9:12 am, andrew cooke and...@acooke.org wrote: ps is there somewhere can download example files?  this would be useful for my own testing.  thanks. i

[issue3058] Let SimpleXMLRPCServer pass client_address to called functions.

2009-08-27 Thread andrew cooke
andrew cooke and...@acooke.org added the comment: Came here wondering how best to solve this myself. I already subclass the request handler to do client validation (password etc) and it stuck me that a simpler solution would be to use thread local storage. This avoids having to modify dispatch

Re: Frustrated with scopes

2009-08-12 Thread andrew cooke
On Aug 12, 8:52 am, Dave Angel da...@ieee.org wrote: Supply us with just enough source code to actually try it, give the full error message including traceback, and tell us what you expected to see.  Also tell us Python version   (sys.version) So far you've done none of these.  When I try the

Frustrated with scopes

2009-08-11 Thread andrew cooke
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 def __call__(lines, source, join=''.join): class Line(object): __source = source

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

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

2009-08-07 Thread andrew cooke
On Aug 5, 10:46 am, Martin P. Hellwig martin.hell...@dcuktec.org wrote: Hi List, On several occasions I have needed (and build) a parser that reads a binary piece of data with custom structure. For example (bogus one): BE +-+-+-+-+--++ |

Re: Suppressing Implicit Chained Exceptions (Python 3.0)

2009-07-02 Thread andrew cooke
David Bolen wrote: andrew cooke and...@acooke.org 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 in control of the format_exc

Suppressing Implicit Chained Exceptions (Python 3.0)

2009-07-01 Thread andrew cooke
I have some (library) code where an exception is caught and, since the underlying cause is rather obscure, a different exception is raised that more clearly explains the issue to the caller. However, when printed via format_exc(), this new exception still has the old exception attached via the

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

Re: SQL and CSV

2009-05-08 Thread andrew cooke
Lawrence D'Oliveiro wrote: In message gu0ofm$oj9$0...@news.t-online.com, Peter Otten wrote: While it may not matter here using placeholders instead of manually escaping user-provided values is a good habit to get into. Until you hit things it can't deal with. The post you are replying to

Re: SQL and CSV

2009-05-08 Thread andrew cooke
against parameters. andrew Nick wrote: On May 8, 1:49 pm, andrew cooke and...@acooke.org wrote: Lawrence D'Oliveiro wrote: In message gu0ofm$oj9$0...@news.t-online.com, Peter Otten wrote: While it may not matter here using placeholders instead of manually escaping user-provided values

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 generic sql support? you

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

2009-04-27 Thread andrew cooke
not sure i've read all the posts on this, and i don't fully understand the problem, but someone's mentioned sqlalchemy, so here's my experience with that and large updates using mapped objects. 1 - don't commit each object as you modify it. instead, process a whole pile in memory and then

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: I do this: binops = ['add', 'sub', 'mul', 'div', 'radd', 'rsub'] # etc unops = ['neg', 'abs', invert'] # etc binop_meth = def __%s__(self, other): return type(self)(int.__%s__(self, other)) unop_meth = def __%s__(self): return

Re: Automatically generating arithmetic operations for a subclass

2009-04-14 Thread andrew cooke
Arnaud Delobelle wrote: andrew cooke and...@acooke.org writes: Arnaud Delobelle wrote: 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? Without it, 'op' would end

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 might want to use weak

Re: Retrieving a specific object from a list?

2009-04-09 Thread andrew cooke
Jeremiah Dodds wrote: I've been looking over some of my code, and I've found something I do that has a bit of a smell to it. I've searched the group and docs, and haven't found much of anything that solves this particular problem, although I may just not be searching correctly. Anyhow, I

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

2009-04-09 Thread andrew cooke
Peter Otten wrote: John Posner wrote: Given how common string maniuplations are, I guess I'm surprised that Python hasn't yet made contains() into both a string-module function *and* a string-object method. Could you explain why you prefer 'contains(belly, beer)' or 'belly.contains(beer)'

Re: Scrap Posts

2009-04-09 Thread andrew cooke
are you on the mailing list (python-list@python.org) or reading via google groups? groups is full of junk, but the list is filtered. the (filtered) list is also available via gmane and similar. (disclaimer - i also use spamassasin so it's possible that is cleaning the mail up, but this

  1   2   3   4   >