Re: PEP 304 - is anyone really interested?

2005-06-22 Thread Patrick Maupin
Skip Montanaro wrote: > I wrote PEP 304, "Controlling Generation of Bytecode Files": ... > If someone out there is interested in this functionality > and would benefit more from its incorporation into the > core, I'd be happy to hand it off to you. I am quite interested in this PEP. What, exactl

Re: PEP 304 - is anyone really interested?

2005-06-23 Thread Patrick Maupin
Thomas Heller wrote: > Although I was not interested originally, I think that's > a use case I also have. Optional config files, which > should not be compiled to .pyc or .pyo. Only removing > the .py file doesn't have the expected effect > if a .pyc and/or .pyo if is left. I also think that i

Re: PEP 304 - is anyone really interested?

2005-06-24 Thread Patrick Maupin
John Roth wrote: > I'd like to suggest a different mechanism, at least for packages > (top level scripts don't generate .pyc files anyway.) Put a system > variable in the __init__.py file. Something like __obj__ = path > would do nicely. Then when Python created the __init__.pyc file, > it woul

Re: formatted xml output from ElementTree inconsistency

2005-06-24 Thread Patrick Maupin
Jarek Zgoda wrote: > Why want you to read an XML document "by hand"? It's a "machine related" > data chunk. > I see this attitude all the time, and frankly I don't understand it. Please explain why XML is in ASCII/unicode instead of binary. Is it because it is easier for a machine to parse? No,

Re: formatted xml output from ElementTree inconsistency

2005-06-24 Thread Patrick Maupin
Dennis Bieber wrote: > Off hand, I'd consider the non-binary nature to be because the > internet protocols are mostly designed for text, not binary. A document at http://www.w3.org/TR/REC-xml/ lists "the design goals for XML". One of the listed goals is "XML documents should be human-legible and

Re: $6 into $1000ands this actually works!

2005-07-01 Thread Patrick Maupin
Thomas wrote: > TURN $6 INTO $15,000 IN ONLY 30 DAYS...HERES HOW! > $ REMEMBER, IT IS 100% LEGAL! DON'T PASS THIS UP! and I thought this was about some new currency/decimal module implementation which remembers units and does the conversion correctly... -- http://mail.python.org/mailman/li

Re: Possible improvement to slice opperations.

2005-09-04 Thread Patrick Maupin
> After considering several alternatives and trying out a few ideas with a > modified list object Bengt Richter posted, (Thank You), I think I've > found a way to make slice operation (especially far end indexing) > symmetrical and more consistent. I don't know that it makes it more consistent.

Re: Possible improvement to slice opperations.

2005-09-05 Thread Patrick Maupin
> No one has yet explained the reasoning (vs the mechanics) of the > returned value of the following. > > L = range(10) > L[3::-1] > > So far every attempt to explain it has either quoted the documents which > don't address that particular case, or assumed I'm misunderstanding > something,

Re: Possible improvement to slice opperations.

2005-09-05 Thread Patrick Maupin
I previously wrote (in response to a query from Ron Adam): > In any case, you asked for a rationale. I'll give you mine: > > >>> L = range(10) > >>> L[3:len(L):-1] == [L[i] for i in range(3,len(L),-1)] > True > >>> After eating supper, I just realized that I could probably make my point a bit c

Re: Possible improvement to slice opperations.

2005-09-06 Thread Patrick Maupin
Ron Adam wrote: >> This should never fail with an assertion error. You will note that it >> shows that, for non-negative start and end values, slicing behavior is >> _exactly_ like extended range behavior. > Yes, and it passes for negative start and end values as well. Umm, no: .>> for stride

Re: Proposal: add sys to __builtins__

2005-09-06 Thread Patrick Maupin
Sybren Stuvel wrote: > A programming language should not be ambiguous. The choice > between importing a module and calling a function should not > depend on the availability of a (local) variable. Yeah, this behavior would be as ambiguous as if we had a system-defined search-path for modules, whe

Re: global variables shared across modules

2005-09-09 Thread Patrick Maupin
MackS wrote: > print "inside fun(): " + global_var ... > How can I get the changed value to "persist" in such a way that it > isn't reset when control leaves fun()? Why is it even reset in the > first place? After all, the module has already been imported (and the > initialization of global_va

Assigning generator expressions to ctype arrays

2011-10-27 Thread Patrick Maupin
Bug or misunderstanding? Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53) [GCC 4.5.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> x = 32 * [0] >>> x[:] = (x for x in xrange(32)) >>> from ctypes import c_uint >>> x = (32 * c_uint)() >>> x[:] = xrange(32) >>

Re: Assigning generator expressions to ctype arrays

2011-10-27 Thread Patrick Maupin
On Oct 27, 5:31 pm, Steven D'Aprano wrote: > From the outside, you can't tell how big a generator expression is. It has no > length: I understand that. > Since the array object has no way of telling whether the generator will have > the correct size, it refuses to guess. It doesn't have to gu

Re: __dict__ attribute for built-in types

2011-10-27 Thread Patrick Maupin
On Oct 27, 9:46 pm, candide wrote: > Le 28/10/2011 02:02, MRAB a crit : > > > > > No, built-in classes written in C have certain limitations, but why > > would you want to do that anyway? > > Mainly for learning purpose and Python better understanding. > > Actually, I have a class of mine for draw

Re: Assigning generator expressions to ctype arrays

2011-10-28 Thread Patrick Maupin
On Oct 27, 10:23 pm, Terry Reedy wrote: > I do not think everyone else should suffer substantial increase in space > and run time to avoid surprising you. What substantial increase? There's already a check that winds up raising an exception. Just make it empty an iterator instead. > > It vio

Re: Assigning generator expressions to ctype arrays

2011-10-28 Thread Patrick Maupin
On Oct 28, 3:19 am, Terry Reedy wrote: > On 10/28/2011 3:21 AM, Steven D'Aprano wrote: > > > If the slice has too few elements, you've just blown away the entire > > iterator for no good reason. > > If the slice is the right length, but the iterator doesn't next raise > > StopIteration, you've jus

Re: Assigning generator expressions to ctype arrays

2011-10-28 Thread Patrick Maupin
On Oct 28, 4:51 pm, Patrick Maupin wrote: > On Oct 28, 3:19 am, Terry Reedy wrote: > > > On 10/28/2011 3:21 AM, Steven D'Aprano wrote: > > > > If the slice has too few elements, you've just blown away the entire > > > iterator for no good reason. >

Re: Assigning generator expressions to ctype arrays

2011-10-28 Thread Patrick Maupin
On Oct 28, 8:01 pm, Steven D'Aprano > > ALREADY LOSES DATA if the iterator isn't the right size and it raises an > > exception. > > Yes. What's your point? This fact doesn't support your proposal in the > slightest. You earlier made the argument that "If the slice has too few elements, you've just

Re: Assigning generator expressions to ctype arrays

2011-10-29 Thread Patrick Maupin
On Oct 28, 3:24 pm, Terry Reedy wrote: > On 10/28/2011 2:05 PM, Patrick Maupin wrote: > > > On Oct 27, 10:23 pm, Terry Reedy  wrote: > >> I do not think everyone else should suffer substantial increase in space > >> and run time to avoid surprising you. > >

Re: Efficient, built-in way to determine if string has non-ASCII chars outside ASCII 32-127, CRLF, Tab?

2011-10-31 Thread Patrick Maupin
On Mon, Oct 31, 2011 at 4:08 PM, Dave Angel wrote: Yes. Actually, you don't even need the split() -- you can pass an optional deletechars parameter to translate(). On Oct 31, 5:52 pm, Ian Kelly wrote: > That sounds overly complicated and error-prone. Not really. > For instance, split() wil

Re: Efficient, built-in way to determine if string has non-ASCII chars outside ASCII 32-127, CRLF, Tab?

2011-10-31 Thread Patrick Maupin
On Oct 31, 9:12 pm, Dave Angel wrote: > I would claim that a well-written (in C) translate function, without > using the delete option, should be much quicker than any python loop, > even if it does copy the data. Are you arguing with me? I was agreeing with you, I thought, that translate would

Re: Question about metaclass

2011-11-01 Thread Patrick Maupin
On Nov 1, 11:02 pm, Makoto Kuwata wrote: > Hi, > > I want to define a special class which groups functions, like: > >     class Greepting(FuncGroup): >         def hello():          # no self, no @staticmethod! >             print("Hello!") >         def goodbye():        # no self, no @staticmeth

Re: match, concatenate based on filename

2011-11-03 Thread Patrick Maupin
On Nov 3, 9:55 pm, Matt wrote: > Hi All, > > I am trying to concatenate several hundred files based on their filename..   > Filenames are like this: > > Q1.HOMOblast.fasta > Q1.mus.blast.fasta > Q1.query.fasta > Q2.HOMOblast.fasta > Q2.mus.blast.fasta > Q2.query.fasta > ... > Q1223.HOMOblast.fasta

Re: Problem overriding sys.excepthook

2006-01-01 Thread Patrick Maupin
Lunchtimemama wrote: > Yo all, I'm getting into Python for the first time and I'm really > having a blast. I've hit a bit of a snag and was wondering if someone > could lend some insight. Here be the code: > > import sys > def myexcepthook(type, value, tb): > import traceback > rawreport = tra

Re: Problem overriding sys.excepthook

2006-01-01 Thread Patrick Maupin
Lunchtimemama wrote: > Forgive my ignorance, but I'm not quite sure what you mean. I tried > importing the traceback module at the beginning of the script, but that > didn't make a difference. Could you provide example code to illustrate > your comment? Thanks. Assume your main module has your ex

Re: Problem overriding sys.excepthook

2006-01-02 Thread Patrick Maupin
Lunchtimemama wrote: > What is the superior method of exception handling: ... For a start, note that the exception hook does not _really_ have to be in the main module, just imported before any "protected" code is to be executed. Having said that, what I personally typically do for exception trap

Re: Translate this to python?

2006-01-03 Thread Patrick Maupin
> for (i = nPoints-1, j = 0; j < nPoints; i = j, j++) A simple translation of this would be: i = npoints-1 for j in range(npoints): ... (your code here) i = j HTH, Pat -- http://mail.python.org/mailman/listinfo/python-list

Re: Translate this to python?

2006-01-03 Thread Patrick Maupin
> for (i = nPoints-1, j = 0; j < nPoints; i = j, j++) Alternatively, if you don't like the initial setup of i and would prefer your setup code at the top of the loop: for j in range(npoints): i = (j-1) % npoints ... (your code here) Finally, you could always do something like this: poin

Re: Calling GPL code from a Python application

2006-01-03 Thread Patrick Maupin
Mike Meyer wrote: .> Note that I'm *not* interpreting the GPL. I'm interpreting what the > FSF says about the GPL. If the goal is to avoid a lawsuit, the latter > is what you have to pay attention to, as they're telling you what > actions you can take without getting sued. The text comes into play

Re: Calling GPL code from a Python application

2006-01-03 Thread Patrick Maupin
Mike Meyer wrote: .> Note that I'm *not* interpreting the GPL. I'm interpreting what the > FSF says about the GPL. If the goal is to avoid a lawsuit, the latter > is what you have to pay attention to, as they're telling you what > actions you can take without getting sued. The text comes into play

Re: Calling GPL code from a Python application

2006-01-03 Thread Patrick Maupin
Mike Meyer wrote: .> Note that I'm *not* interpreting the GPL. I'm interpreting what the > FSF says about the GPL. If the goal is to avoid a lawsuit, the latter > is what you have to pay attention to, as they're telling you what > actions you can take without getting sued. The text comes into play

Re: Translate this to python?

2006-01-03 Thread Patrick Maupin
Peter Hansen wrote: > Though, without knowing what the body does, one can't be sure > that's going to be a faithful translation. The for loop in Python > always iterates over the entire set of items given to it, unless > it's told to break early. But if "j" or "nPoints" is modified in the > body

Re: Occasional OSError: [Errno 13] Permission denied on Windows

2006-01-05 Thread Patrick Maupin
Alec Wysoker wrote: > Using Python 2.3.5 on Windows XP, I occasionally get OSError: > [Errno 13] Permission denied when calling os.remove(). This can > occur with a file that is not used by any other process on the > machine, and is created by the python.exe invocation that is > trying to delete

Re: Occasional OSError: [Errno 13] Permission denied on Windows

2006-01-05 Thread Patrick Maupin
Tim Peters wrote: > In that case, anything that burns some time and tries again > will work better. Replacing gc.collect() with time.sleep() is > an easy way to test that hypothesis; because gc.collect() > does an all-generations collection, it can consume measurable time. An slight enhancemen

Re: Apology Re: Is 'everything' a refrence or isn't it?

2006-01-09 Thread Patrick Maupin
Mike Meyer wrote: > This is where we disagree. I think their understanding of references > is dead on. What's broken is their understanding of what variables are > and what assignments mean. Once you fix that, the rest falls into > place. > > (Steven D'Aprano wrote:) > > The fact that call by objec

Re: Apology Re: Is 'everything' a refrence or isn't it?

2006-01-09 Thread Patrick Maupin
Mike Meyer wrote: > This is where we disagree. I think their understanding of references > is dead on. What's broken is their understanding of what variables are > and what assignments mean. Once you fix that, the rest falls into > place. > > (Steven D'Aprano wrote:) > > The fact that call by objec

Re: Apology Re: Is 'everything' a refrence or isn't it?

2006-01-09 Thread Patrick Maupin
Mike Meyer wrote: > This is where we disagree. I think their understanding of references > is dead on. What's broken is their understanding of what variables are > and what assignments mean. Once you fix that, the rest falls into > place. > > (Steven D'Aprano wrote:) > > The fact that call by objec

Re: Apology Re: Is 'everything' a refrence or isn't it?

2006-01-09 Thread Patrick Maupin
Mike Meyer wrote: > This is where we disagree. I think their understanding of references > is dead on. What's broken is their understanding of what variables are > and what assignments mean. Once you fix that, the rest falls into > place. > > (Steven D'Aprano wrote:) > > The fact that call by objec

Re: Coding style

2006-07-17 Thread Patrick Maupin
PTY wrote: > It looks like there are two crowds, terse and verbose. I thought terse > is perl style and verbose is python style. BTW, lst = [] was not what > I was interested in :-) I was asking whether it was better style to > use len() or not. It's not canonical Python to use len() in this c

Re: Coding style

2006-07-18 Thread Patrick Maupin
Carl Banks wrote: > Here's another reason not to use "if lst". Say you have a function > that looks like this: > > def process_values(lst): > if not lst: > return > do_expensive_initialization_step() > for item in lst: > do_something_with(item)

Re: Coding style

2006-07-18 Thread Patrick Maupin
Daniel Dittmar wrote: > > Premature generalization: the new 'premature optimization'. Premature specialization: the new 'static typing'. -- Pat -- http://mail.python.org/mailman/listinfo/python-list

Re: Coding style

2006-07-19 Thread Patrick Maupin
Christophe wrote: > > The perverse wish, expressed in the specific example, that SOME piece > > of code SOMEWHERE should PLEASE throw an exception because some idiot > > passed a generator expression rather than a list into a function, is > > not apt to be well received by an audience which strive

Re: Coding style

2006-07-19 Thread Patrick Maupin
Terry Reedy wrote: > > > Carl Banks wrote: > >> def process_values(lst): > >> if not lst: > >> return > >> do_expensive_initialization_step() > >> for item in lst: > >> do_something_with(item) > >> do_expensive_finalization_step() > > Give

Re: using names before they're defined

2006-07-22 Thread Patrick Maupin
[EMAIL PROTECTED] wrote: > I have a problem. I'm writing a simulation program with a number of > mechanical components represented as objects. When I create instances > of objects, I need to reference (link) each object to the objects > upstream and downstream of it, i.e. > > supply = supply() > c

Re: is it possible to dividing up a class in multiple files?

2006-08-07 Thread Patrick Maupin
Diez B. Roggisch wrote: > Martin Höfling wrote: > > > is it possible to put the methods of a class in different files? I just > > want to order them and try to keep the files small. > > No, its not possible. What you can do is to create several classes and one > that inherits from all of them. > >

Re: Import module with non-standard file name

2006-08-07 Thread Patrick Maupin
Ben Finney wrote: > Howdy all, > > Question: I have Python modules named without '.py' as the extension, > and I'd like to be able to import them. How can I do that? This is a piece of cake in Python. >>> from types import ModuleType >>> x = ModuleType('myModName') >>> data = open('myfilename').

Re: Question on try/except

2006-08-07 Thread Patrick Maupin
Kirk McDonald wrote: > Dan wrote: > > Is there some particular use in catching an exception and immediately > > re-raising it? Why catch it at all? > > All I can think of is that it changes the traceback to point to the > re-raise and not the original raise. I've used this technique before. It

Re: no longer can set breakpoint on 'pass' statement?

2006-08-16 Thread Patrick Maupin
I don't know for sure if this is the issue, but Python _used_ to include line number information in the actual codestream (via instructions), and now I think it's a separate table for speed reasons. So perhaps the previous ability to set breakpoints on pass instructions was merely an artifact of c

Re: It is __del__ calling twice for some instances?

2006-08-18 Thread Patrick Maupin
Duncan Booth wrote: > Duncan Booth wrote: > > > As to why it happens, there is a mechanism in Python to stop unlimited > > stack being used when objects are freed: when the stack gets too deep > > then instead of being released, the Py_DECREF call puts the object > > into a trashcan list and the o

Re: how do you get the name of a dictionary?

2006-08-21 Thread Patrick Maupin
jojoba wrote: > hello > > im quite surprised at the arrogance laid out by some of the above > posters: > > However, does it not seem reasonable to ask python: > > Given a dicitionary, Banana = {} > return one or more strings, > where each string is the name(s) of the reference(s) to Banana. > > wh

Re: Don't use __slots__ (was Re: performance of dictionary lookup vs. object attributes)

2006-08-26 Thread Patrick Maupin
[EMAIL PROTECTED] wrote: > Aahz> Taking a look at __slots__ is fine as long as you don't actually > Aahz> use them. > > Gabriel> Why? > http://groups.google.com/group/comp.lang.python/browse_thread/thread/451ad25f9c648404/f4ac2dfde32b16fd?lnk=st&q=Python+__slots__+aahz&rnum=2#f4ac2dfde32b16

Re: Don't use __slots__ (was Re: performance of dictionary lookup vs. object attributes)

2006-08-26 Thread Patrick Maupin
[EMAIL PROTECTED] wrote: > Aahz> Taking a look at __slots__ is fine as long as you don't actually > Aahz> use them. > > Gabriel> Why? > > Skip> > http://groups.google.com/group/comp.lang.python/browse_thread/thread/451ad25f9c648404/f4ac2dfde32b16fd?lnk=st&q=Python+__slots__+aahz&rnum=

Re: Don't use __slots__ (was Re: performance of dictionary lookup vs. object attributes)

2006-08-26 Thread Patrick Maupin
Jarek Zgoda wrote: > Having that said, should we hope __slots__ would disappear in (some) > future (tomorrow?!, in next 10 microseconds?!)? Please, don't left us > hopeless. > Are you saying you _do_ hope that __slots__ disappear? Why? Regards, Pat -- http://mail.python.org/mailman/listinfo/p

Re: Don't use __slots__ (was Re: performance of dictionary lookup vs. object attributes)

2006-08-27 Thread Patrick Maupin
Jacob Hallen wrote: > Patrick Maupin <[EMAIL PROTECTED]> wrote: > >Also, as I noted, I _do_ use them on occasion, so if there really _are_ > >potential pitfalls there, I would like to understand exactly what they > >are, so my ears perk up whenever I notice a __slots__

Re: Don't use __slots__ (was Re: performance of dictionary lookup vs. object attributes)

2006-08-28 Thread Patrick Maupin
Dieter Maurer wrote: > "Patrick Maupin" <[EMAIL PROTECTED]> writes on 26 Aug 2006 12:51:44 -0700: > > ... > > The only > > problem I personally know of is that the __slots__ aren't inherited, > > "__slots__" *ARE* inherited, although t

Re: list comprehention

2006-01-23 Thread Patrick Maupin
Duncan Booth showed how to solve a problem posed by Mathijs. This is very similar to Duncan's solution, except I (ab)use setdefault on a regular basis... >>> def occurrences(t): ... res = {} ... for item in t: ... res.setdefault(item,[0])[0] += 1 ... return res ... >>> ref = [

Re: list comprehension

2006-01-24 Thread Patrick Maupin
Duncan Booth wrote: > I prefer writing an 'if' statement here, Bryan prefers 'get', that's just a > choice of style. But 'setdefault' here, that has no style. Well, I'm often told I have no style, and I _did_ admit that it's an abuse of setdefault. However, I often use setdefault to populate nes

Re: Imports visibility in imported modules problem

2008-08-23 Thread Patrick Maupin
On Aug 23, 7:27 pm, "Mohamed Yousef" <[EMAIL PROTECTED]> wrote: > The problem I'm asking about is how can imported modules be aware of > other imported modules so they don't have to re-import them (avoiding > importing problems and Consicing code and imports ) You could import sys and look at sys

Re: Python String Immutability Broken!

2008-08-24 Thread Patrick Maupin
On Aug 24, 8:49 pm, "Hendrik van Rooyen" <[EMAIL PROTECTED]> wrote: > (a lot of stuff related to using a string with a C library via ctypes) Very entertaining. But let me get this straight: Are you just complaining that if you pass a string to an arbitrary C function using ctypes, that that arb

Re: Python String Immutability Broken!

2008-08-25 Thread Patrick Maupin
On Aug 25, 3:31 pm, "Hendrik van Rooyen" <[EMAIL PROTECTED]> wrote: > Actually, I am not complaining - I am asking for advice on the side > effects of what I am doing, which is replacing a bunch of bits > in what is essentially an output bit field with the corresponding > input bits at the same add

Re: exactly same as [1,2,3,] ?

2008-08-28 Thread Patrick Maupin
On Aug 28, 6:35 pm, "James Mills" <[EMAIL PROTECTED]> wrote: > I must point out though that although they contain > the same elements/data, they are not the same > object/instance. > > {{{ > #!python > > >>> x = [1, 2, 3] > >>> y = [1, 2, 3] > >>> id(x) > 3083095148L > >>> id(y) > 3082953324L > >>>

Re: subclassing complex

2008-08-29 Thread Patrick Maupin
On Aug 29, 12:17 am, BiDi <[EMAIL PROTECTED]> wrote: > I have been trying to subclass complex, but I am not able to get the > right-hand arithmetic operators working. > > As shown below, if an object of my subclass 'xcomplex' is added on the > right of a 'comlex' object, the type returned is 'compl

Re: subclassing complex

2008-08-29 Thread Patrick Maupin
On Aug 29, 4:24 am, Peter Otten <[EMAIL PROTECTED]> wrote: > A minimal example is > > >>> class Complex(complex): > > ... def __radd__(self, other): print "radd" > ...>>> 1j + Complex() > > 1j > > versus > > >>> class Int(int): > > ... def __radd__(self, other): print "radd" > ...>>> 1 + In

Re: Numeric literal syntax (was: Py 2.6 changes)

2008-09-02 Thread Patrick Maupin
On Sep 2, 6:35 am, Nick Craig-Wood <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > >  It's not just my familiarity, Ada language too uses underscore for > >  that purpose, I think, so there's a precedent, and Ada is a language > >  designed to always minimize programmin

__builtins__ magic behavior

2008-09-07 Thread Patrick Maupin
__builtins__ in 2.5.2 doesn't seem to behave like I remember it did the last time I did some custom stuff with it, a very long time ago. This isn't surprising, because of ongoing optimization, but it's hard to google for '__builtins__' so I didn't really find any documentation on the current CPyth

Re: max(), sum(), next()

2008-09-07 Thread Patrick Maupin
On Sep 7, 12:30 pm, Mensanator <[EMAIL PROTECTED]> wrote: > On Sep 6, 11:05 pm, Steven D'Aprano <[EMAIL PROTECTED] > > Sheesh. That's not a problem, because Python is not trying to be a > > dialect of SQL. > > And yet, they added a Sqlite3 module. Does that mean that, because there is an 'os' modu

Re: __builtins__ magic behavior

2008-09-07 Thread Patrick Maupin
On Sep 7, 2:50 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > Inside PyFrame_New, there is a shortcut: if the new frame and > the previous one share the same globals, then the previous > builtins are copied into the new frame. Only if the globals > differ the builtins are searched in globals.

Re: Read and write binary data

2008-09-07 Thread Patrick Maupin
On Sep 7, 5:41 pm, Mars creature <[EMAIL PROTECTED]> wrote: > Hi guys, >   I am new to Python, and thinking about migrating to it from matlab > as it is a really cool language. Right now, I am trying to figure out > how to control read and write binary data, like > 'formatted','stream','big-endian'

ANN: pdfrw pure-Python PDF file reading and writing

2009-11-27 Thread Patrick Maupin
the code and a few working examples at pdfrw.googlecode.com Feedback and/or code contributors always welcome! Best regards, Patrick Maupin -- http://mail.python.org/mailman/listinfo/python-list

Re: ANN: pdfrw pure-Python PDF file reading and writing

2009-11-27 Thread Patrick Maupin
On Nov 27, 2:35 am, Patrick Maupin wrote: > pdfrw is a basic PDF file manipulation library, developed and tested > on Python 2.5 and 2.6. > > pdfrw can read and write PDF files, and can also be used to read in > PDFs which can then be used inside reportlab (as source material

Re: ANN: pdfrw pure-Python PDF file reading and writing

2009-11-28 Thread Patrick Maupin
On Nov 27, 2:35 am, Patrick Maupin wrote: > pdfrw is a basic PDF file manipulation library, developed and tested > on Python 2.5 and 2.6. > > pdfrw can read and write PDF files, and can also be used to read in > PDFs which can then be used inside reportlab (as source material

Re: python bijection

2009-11-28 Thread Patrick Maupin
On Nov 19, 8:36 pm, Ben Finney wrote: > Carl Banks writes: > > On Nov 19, 3:24 pm, Joshua Bronson wrote: > > Apart from the GPL, it seems perfectly fine to release, and looks like > > an interesting strategy. I've wanted one of those once in a while, > > never enough to bother looking for one or

Draft PEP on RSON configuration file format

2010-02-28 Thread Patrick Maupin
All: Finding .ini configuration files too limiting, JSON and XML to hard to manually edit, and YAML too complex to parse quickly, I have started work on a new configuration file parser. I call the new format RSON (for "Readable Serial Object Notation"), and it is designed to be a superset of JSON

Re: Draft PEP on RSON configuration file format

2010-03-01 Thread Patrick Maupin
On Feb 28, 9:18 pm, Steven D'Aprano > Wait a minute... if JSON is too hard to edit, and RSON is a *superset* of > JSON, that means by definition every JSON file is also a valid RSON file. > Since JSON is too hard to manually edit, so is RSON. Well, Python is essentially a superset of JSON, with st

Re: Draft PEP on RSON configuration file format

2010-03-01 Thread Patrick Maupin
On Mar 1, 12:39 am, John Nagle wrote: > Patrick Maupin wrote: > > All: > > > Finding .ini configuration files too limiting, JSON and XML to hard to > > manually edit, and YAML too complex to parse quickly, I have started > > work on a new configuration file parser.

Re: Draft PEP on RSON configuration file format

2010-03-01 Thread Patrick Maupin
On Mar 1, 11:13 am, Robert Kern wrote: > Ignore it. That comment really doesn't apply to this case. That's for things > that only make sense in the language or standard library, like context > managers. > For libraries like this, Steven's summary is correct. It needs to have a > useful > life as

Re: Draft PEP on RSON configuration file format

2010-03-01 Thread Patrick Maupin
On Mar 1, 12:03 pm, Paul Rubin wrote: > But you are working on a solution in search of a problem.  The really > smart thing to do would be pick something more useful to work on.  We > don't need another configuration language.  I can't even say "yet > another" because there's already a "yet anoth

Re: Draft PEP on RSON configuration file format

2010-03-01 Thread Patrick Maupin
> > Certainly. The PEP format is a useful one. I've used it myself for some numpy > design documents. But can you see why people might get confused about your > intentions when you call it a draft PEP and post it to python-dev? If you stop > calling it a PEP and stop talking about putting it in the

Re: Draft PEP on RSON configuration file format

2010-03-01 Thread Patrick Maupin
On Mar 1, 12:40 pm, Daniel Fetchinson wrote: > > But you are working on a solution in search of a problem.  The really > > smart thing to do would be pick something more useful to work on.  We > > don't need another configuration language.  I can't even say "yet > > another" because there's alread

Re: Draft PEP on RSON configuration file format

2010-03-01 Thread Patrick Maupin
On Mar 1, 1:37 pm, Paul Rubin wrote: > There are in fact quite a few--json, yaml, .ini, xml, Python literals > (http://code.activestate.com/recipes/364469-safe-eval/), s-expressions, > actual Python code that the application can import, and so forth. Yes, I know about those. > The problem isn't

Re: Draft PEP on RSON configuration file format

2010-03-01 Thread Patrick Maupin
On Mar 1, 2:08 pm, Paul Rubin wrote: > Yaml sucks, but seems to have gotten some traction regardless. Yes, that's actually one of the reasons I want to do this. I've heard that some of the YAML people want that in the standard library, and IMHO that would be a huge mistake. > Therefore the Pyt

Re: Draft PEP on RSON configuration file format

2010-03-01 Thread Patrick Maupin
On Mar 1, 2:42 pm, Paul Rubin wrote: > Patrick Maupin writes: > > But for my use-case, YAML is irretrievably broken.  Sure, it looks > > reasonably nice, but it increases regression runtime unacceptably. > > How big are the files that you want to parse with it?  Sheesh. Ti

Re: Draft PEP on RSON configuration file format

2010-03-01 Thread Patrick Maupin
On Mar 1, 5:33 pm, Erik Max Francis wrote: > Psst.  That you're allowed to present the idea that you think is good > doesn't mean that other people aren't allowed to respond and point out > that in their opinion it's not such a good idea.  You don't own this or > any other thread. Absolutely, but

Re: Draft PEP on RSON configuration file format

2010-03-01 Thread Patrick Maupin
On Mar 1, 5:57 pm, Erik Max Francis wrote: > Patrick Maupin wrote: > This not only seriously stretching the meaning of the term "superset" > (as Python is most definitely not even remotely a superset of JSON), but Well, you are entitled to that opinion, but seriously, i

Re: Draft PEP on RSON configuration file format

2010-03-01 Thread Patrick Maupin
separate PDF files. Best regards, Pat On Mon, Mar 1, 2010 at 8:02 PM, Kirill Simonov wrote: > Patrick Maupin wrote: >> >> All: >> >> Finding .ini configuration files too limiting, JSON and XML to hard to >> manually edit, and YAML too complex to parse quickly

Re: Draft PEP on RSON configuration file format

2010-03-01 Thread Patrick Maupin
On Mon, Mar 1, 2010 at 8:02 PM, Kirill Simonov wrote: BTW, congratulations on slogging through the YAML grammar to generate such a good working C library! That must have been a tremendous effort. Regards, Pat -- http://mail.python.org/mailman/listinfo/python-list

Re: Draft PEP on RSON configuration file format

2010-03-02 Thread Patrick Maupin
On Mar 2, 11:59 am, Terry Reedy wrote: > To me, comparing object notation with programming language is not > helpful to the OP's purpose. Yes, I agree, it was a distraction. I fell into the trap of responding to the ludicrous claim that "if X is a superset of Y, then X cannot possibly look bett

Re: Draft PEP on RSON configuration file format

2010-03-02 Thread Patrick Maupin
On Mar 2, 5:36 pm, Steven D'Aprano wrote: > You seem to be taking the position that if you start with a config file > config.json, it is "too hard to edit", but then by renaming it to > config.rson it magically becomes easier to edit. That *is* ludicrous. No, but that seems to be the position you

Re: Draft PEP on RSON configuration file format

2010-03-02 Thread Patrick Maupin
On Mar 2, 9:20 pm, Erik Max Francis wrote: > Patrick Maupin wrote: > > On Mar 2, 5:36 pm, Steven D'Aprano > cybersource.com.au> wrote: > >> You seem to be taking the position that if you start with a config file > >> config.json, it is "to

Initial RSON prototype parser in subversion

2010-03-05 Thread Patrick Maupin
I have not yet added indentation sensitivity to the parser (although the tokenizer saves the indentation information for the parser), but the initial prototype parses all of JSON plus a lot of syntax enhancements (comments, hex/binary/octal numbers, relaxed quoting requirements for strings, trailin

ANNOUNCE: RSON v 0.02 available

2010-03-11 Thread Patrick Maupin
RSON (Readable Serial Object Notation) is a superset of JSON that is suitable for files that humans have to edit and diff. The current release is decoder-only, but the decoder will read files encoded by JSON encoders such as json or simplejson. The current release consists of a single Python modu

Re: building a dict

2010-03-13 Thread Patrick Maupin
On Mar 13, 9:05 am, vsoler wrote: > Say that "m" is a tuple of 2-tuples > > m=(('as',3), ('ab',5), (None, 1), ('as',None), ('as',6)) > > and I need to build a "d" dict where each key has an associated list > whose first element is the count, and the second is the sum. If a 2- > tuple contains a No

Re: Decorator to inject function into __call__ of a class

2010-03-13 Thread Patrick Maupin
On Mar 13, 10:19 am, Jon Clements wrote: > What I'd like to achieve is something similar to: > > @inject(B): >  def some_function(a, b): >      pass # something useful So, just typing at the keyboard here, you mean something like: class InjectClass(object): def __init__(self, func, *args, *

Re: Decorator to inject function into __call__ of a class

2010-03-13 Thread Patrick Maupin
On Mar 13, 10:38 am, Jon Clements wrote: > On 13 Mar, 16:26, Patrick Maupin wrote: > > > > > On Mar 13, 10:19 am, Jon Clements wrote: > > > > What I'd like to achieve is something similar to: > > > > @inject(B): > > >  def some_function(

Re: class inheritance

2010-03-13 Thread Patrick Maupin
On Mar 13, 11:03 am, JLundell wrote: > I've got a subclass of fractions.Fraction called Value; it's a mostly > trivial class, except that it overrides __eq__ to mean 'nearly equal'. > However, since Fraction's operations result in a Fraction, not a > Value, I end up with stuff like this: > > x = V

Re: class inheritance

2010-03-13 Thread Patrick Maupin
On Mar 13, 11:37 am, Jack Diederich wrote: > If Fraction.__add__ returns a new object but the subclass Value is > compatible (as I would except since it is a sublcass) then just change > all references in Franction.__add__ to be more generic, ex/ > > class Franction(): >   def __add__(self, other)

Re: iterator/generator

2010-03-14 Thread Patrick Maupin
First of all, as Steve Holden mentioned, do look at xlrd. It's awesome. Second, for your (a) question, if you want an iterator, that's quite easy: matriz = iter(matriz) matriz.next() # Discard the first one for i in matriz: This technique works really well, especially if you have sub-loops. Th

Re: highlight words by regex in pdf files using python

2010-03-16 Thread Patrick Maupin
On Mar 4, 6:57 pm, Peng Yu wrote: > I don't find a general pdf library in python that can do any > operations on pdfs. > > I want to automatically highlight certain words (using regex) in a > pdf. Could somebody let me know if there is a tool to do so in python? The problem with PDFs is that they

Re: to pass self or not to pass self

2010-03-16 Thread Patrick Maupin
On Mar 16, 1:59 pm, Jason Tackaberry wrote: > Why not create the bound methods at instantiation time, rather than > using the descriptor protocol which has the overhead of creating a new > bound method each time the method attribute is accessed? Well, for one thing, Python classes are open. They

  1   2   3   4   >