Re: troubles building python 2.5 on Windows XP x64 Windows Server 2003 sp1 Platform SDK

2007-04-03 Thread Steven Bethard
[EMAIL PROTECTED] wrote: On Apr 3, 2:04 pm, Steven Bethard [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: I am needing to build python 2.5 on Windows XP x64 Windows Server 2003 sp1 Platform SDK and am not finding anything documented on the process to use. Has anyone had any success

Re: troubles building python 2.5 on Windows XP x64 Windows Server 2003 sp1 Platform SDK

2007-04-03 Thread Steven Bethard
[EMAIL PROTECTED] wrote: This doc has not been updated since the 64 bit compilers came out officially. It doesn't make a whole lot of sense of what steps you should follow to build python. I saw a link on the comp.lang.python that had the steps, but that link doesn't go anywhere now. I had to

Re: how to remove multiple occurrences of a string within a list?

2007-04-03 Thread Steven Bethard
bahoo wrote: The larger problem is, I have a list of strings that I want to remove from another list of strings. If you don't care about the resulting order:: items = ['foo', 'bar', 'baz', 'bar', 'foo', 'frobble'] to_remove = ['foo', 'bar'] set(items) - set(to_remove)

Re: Sorting a multidimensional array by multiple keys

2007-04-02 Thread Steven Bethard
Thomas Krüger wrote: Alex Martelli schrieb: Thomas Krüger [EMAIL PROTECTED] wrote: def sorter(a, b): return cmp(a.id, b.id) obj_lst.sort(sorter) A MUCH better way to obtain exactly the same semantics would be: def getid(a): return a.id obj_list.sort(key=getid) Frankly

Re: getattr/setattr q.

2007-04-02 Thread Steven Bethard
Paulo da Silva wrote: In a class C, I may do setattr(C,'x',10). Is it possible to use getattr/setattr for variables not inside classes or something equivalent? I mean with the same result as exec(x=10). If you're at the module level, you can do:: globals()['x'] = 10 If you're inside

Re: I18n issue with optik

2007-04-01 Thread Steven Bethard
Thorsten Kampe wrote: * Steven Bethard (Sat, 31 Mar 2007 20:08:45 -0600) Thorsten Kampe wrote: I've written a script which uses Optik/Optparse to display the options (which works fine). The text for the help message is localised (with german umlauts) and when I execute the script

Re: I18n issue with optik

2007-04-01 Thread Steven Bethard
Thorsten Kampe wrote: I guess the culprit is this snippet from optparse.py: # used by test suite def _get_encoding(self, file): encoding = getattr(file, encoding, None) if not encoding: encoding = sys.getdefaultencoding() return encoding def print_help(self,

Re: Sorting a multidimensional array by multiple keys

2007-03-31 Thread Steven Bethard
Rehceb Rotkiv wrote: If you want a good answer you have to give me/us more details, and an example too. OK, here is some example data: reaction is BUT by the sodium , BUT it is sea , BUT it is this manner BUT the dissolved pattern , BUT it is rapid , BUT it is As each line consists

Re: I18n issue with optik

2007-03-31 Thread Steven Bethard
Thorsten Kampe wrote: I've written a script which uses Optik/Optparse to display the options (which works fine). The text for the help message is localised (with german umlauts) and when I execute the script with the localised environment variable set, I get this traceback[1]. The

Re: Modules positive surprises

2007-03-30 Thread Steven Bethard
Jan Danielsson wrote: But then there are a few modules that I just love to use, because they are so clean from interface to function. Among them I can't help mentioning optparse. plug If you like optparse, you should try argparse: http://argparse.python-hosting.com/ It has an

[ANN] argparse 0.7 - Command-line parsing library

2007-03-25 Thread Steven Bethard
Announcing argparse 0.7 --- The argparse module is an optparse-inspired command line parser that improves on optparse by supporting: * positional arguments * sub-commands * required options * options with a variable number of args * better usage messages * a much simpler

Re: Pattern for foo tool - API - shell|GUI

2007-03-25 Thread Steven Bethard
Anastasios Hatzis wrote: I'm working on a tool which is totally command-line based and consisting of multiple scripts. The user can execute a Python script in the shell, this script does some basic verification before delegating a call into my tool's package and depending on some arguments

[ANN] argparse 0.7 - Command-line parsing library

2007-03-25 Thread Steven Bethard
Announcing argparse 0.7 --- The argparse module is an optparse-inspired command line parser that improves on optparse by supporting: * positional arguments * sub-commands * required options * options with a variable number of args * better usage messages * a much simpler

Re: functions, classes, bound, unbound?

2007-03-25 Thread Steven Bethard
On Mar 25, 9:13 am, 7stud [EMAIL PROTECTED] wrote: Is there some other way to retrieve a user-defined function object from a class other than using the class name or an instance? On Mar 25, 3:00 am, [EMAIL PROTECTED] wrote: What Steven B. already said, MyClass.__dict__['someFunc'], is a

Re: Multi-line strings with formatting

2007-03-24 Thread Steven Bethard
On Fri, 2007-03-23 at 09:54 -0700, [EMAIL PROTECTED] wrote: When constructing a particularly long and complicated command to be sent to the shell, I usually do something like this, to make the command as easy as possible to follow: commands.getoutput( 'mycommand -S %d -T %d ' %

Re: functions, classes, bound, unbound?

2007-03-24 Thread Steven Bethard
7stud wrote: Here is some example code that produces an error: class Test(object): def greet(): print Hello t = Test() t.greet() TypeError: greet() takes no arguments (1 given) [snip] Test.greet() TypeError: unbound method greet() must be called with Test

Re: why brackets commas in func calls can't be ommited? (maybe it could be PEP?)

2007-03-21 Thread Steven Bethard
dmitrey wrote: I looked to the PEPs didn't find a proposition to remove brackets commas for to make Python func call syntax caml- or tcl- like: instead of result = myfun(param1, myfun2(param5, param8), param3) just make possible using result = myfun param1 (myfun2 param5 param8) param3

Re: Passing arguments to a command line from a python script

2007-03-19 Thread Steven Bethard
Luis M. González wrote: On Mar 19, 10:49 pm, zacherates [EMAIL PROTECTED] wrote: This implies that `os.system(setuppy py2exe)` should do what you want. It works! Thank you, this is just what I wanted. You'll get better error checking if instead you do:: import subprocess

Re: an enumerate question

2007-03-19 Thread Steven Bethard
[EMAIL PROTECTED] wrote: for n,l in enumerate(open(file)): print n,l # this prints current line print next line in this current iteration of the loop. Depends what you want to happen when you request next. If you want to renumber the lines, you can call .next() on the iterator::

Re: getopt or optparse options/arguments wrapping?

2007-03-18 Thread Steven Bethard
Rocky Zhou wrote: .dirs .files is just a snapshot of the current directories, which can be used to delete-outdated files when restoring. Here I used absolute path by using tar's -P parameter. When fs_rstore, it will do this: command = tar -xpz -P -f %s.tgz -T %s % (archive, self.t_files)

Re: where function

2007-03-18 Thread Steven Bethard
[EMAIL PROTECTED] wrote: Is there a function in Python analogous to the where function in IDL? x=[0,1,2,3,4,2,8,9] print where(x=2) output: [2,5] If you're doing a lot of this kind of thing, you probably want to use numpy:: import numpy x = numpy.array([0, 1, 2, 3, 4, 2,

Re: To count number of quadruplets with sum = 0

2007-03-16 Thread Steven Bethard
Marc 'BlackJack' Rintsch wrote: In [EMAIL PROTECTED], Paul Rubin wrote: n00m [EMAIL PROTECTED] writes: h = collections.defaultdict(itertools.repeat(0).next) Something wrong with h = collections.defaultdict(int) ? According to a post by Raymond Hettinger it's faster to use that

Re: getopt or optparse options/arguments wrapping?

2007-03-16 Thread Steven Bethard
Rocky Zhou wrote: I wonder is there any way to make the wrapper program can wrap options arguments for the the subprocess/command the wrapper will execute? by getopt or optparse module? [snip] I need this because I now have finished a fs_backup script written in python, it will execute tar

Re: Multiline code - trailing slash usage

2007-03-15 Thread Steven Bethard
abcd wrote: When do I need to use a trailing slash to separate code over multiple lines. For example: x = hello world, this is my multiline + \ string Yes. x = {'name' : \ 'bob'} No. You don't need trailing slashes whenever there's a pair of {}, [] or () wrapping

Re: To count number of quadruplets with sum = 0

2007-03-15 Thread Steven Bethard
n00m wrote: http://www.spoj.pl/problems/SUMFOUR/ 3 0 0 0 0 0 0 0 0 -1 -1 1 1 Answer for this input data is 33. My solution for the problem is == import time t = time.clock() q,w,e,r,sch,h = [],[],[],[],0,{} f

Re: Setting Up SOAPpy for Python v2.5 on Windows?

2007-03-13 Thread Steven Bethard
Steve wrote: What are the required version of the SOAPpy, PyXML, fpconst that are needed to run under the Python 2.5 environment on Windows? If you're not married to SOAPpy, you can use elementsoap which has just a single download and works with ElementTree from the 2.5 stdlib:

Re: class declaration shortcut

2007-03-01 Thread Steven Bethard
Arnaud Delobelle wrote: On Feb 28, 7:26 pm, Luis M. González [EMAIL PROTECTED] wrote: I've come across a code snippet inwww.rubyclr.comwhere they show how easy it is to declare a class compared to equivalent code in c#. I wonder if there is any way to emulate this in Python. The code is as

Re: class declaration shortcut

2007-03-01 Thread Steven Bethard
Arnaud Delobelle wrote: On Mar 1, 4:01 pm, Steven Bethard [EMAIL PROTECTED] wrote: Arnaud Delobelle wrote: [...] This does pretty much the same thing as the recipe I posted: Not at all. My new_struct create returns a new class which is similar to a C struct (notice the __slots__

Re: class declaration shortcut

2007-03-01 Thread Steven Bethard
Arnaud Delobelle wrote: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/502237 [snip] Although I don't see the necessity of a metaclass: you could have class Record(object): def __init__(self, *vals): for slot, val in zip(self.__slots__, vals):

Re: class declaration shortcut

2007-03-01 Thread Steven Bethard
Luis M. González wrote: This is the closest we got so far to the intended result. If there was a way to enter attributes without quotes, it would be almost identical. Ok, below is the Python code so that the following works:: class Person(Struct): name birthday children Note that * The

Re: class declaration shortcut

2007-02-28 Thread Steven Bethard
Luis M. González wrote: I've come across a code snippet in www.rubyclr.com where they show how easy it is to declare a class compared to equivalent code in c#. I wonder if there is any way to emulate this in Python. The code is as follows: Person = struct.new( :name, :birthday, :children)

Re: class declaration shortcut

2007-02-28 Thread Steven Bethard
Luis M. González wrote: On Feb 28, 6:21 pm, Steven Bethard [EMAIL PROTECTED] wrote: How about something like:: class Person(Record): __slots__ = 'name', 'birthday', 'children' You can then use the class like:: person = Person('Steve', 'April 25', []) assert

[ANN] argparse 0.6 - Command-line parsing library

2007-02-24 Thread Steven Bethard
Announcing argparse 0.6 --- argparse home: http://argparse.python-hosting.com/ argparse single module download: http://argparse.python-hosting.com/file/trunk/argparse.py?format=raw argparse bundled downloads at PyPI: http://www.python.org/pypi/argparse/ About this

[ANN] argparse 0.6 - Command-line parsing library

2007-02-24 Thread Steven Bethard
Announcing argparse 0.6 --- argparse home: http://argparse.python-hosting.com/ argparse single module download: http://argparse.python-hosting.com/file/trunk/argparse.py?format=raw argparse bundled downloads at PyPI: http://www.python.org/pypi/argparse/ About this

Re: builtin set literal

2007-02-21 Thread Steven Bethard
[EMAIL PROTECTED] wrote: Steven Bethard: take a look at the current state of tuples: 1, 2 1, () That's not a good situation. I presume the situation/syntax of tuples in Python 2.x can't be improved. But can it be improved for Py 3.0? I'm not really losing any sleep over

Re: builtin set literal

2007-02-20 Thread Steven Bethard
Steven Bethard: While Python 3.0 is not afraid to break backwards compatibility, it tries to do so only when there's a very substantial advantage. [EMAIL PROTECTED] wrote: I understand, but this means starting already to put (tiny) inconsistencies into Python 3.0... Well, there's going

Re: Python 3.0 unfit for serious work?

2007-02-20 Thread Steven Bethard
Jay Tee wrote: Yo, On Feb 16, 6:07 am, Steven Bethard [EMAIL PROTECTED] wrote: Python 3.0 is determined not to be hampered by backwards incompatibility concerns. It's not even clear yet that your average 2.6 code will work Then Python is pretty much determined to remove itself from

Re: Python 3.0 unfit for serious work?

2007-02-20 Thread Steven Bethard
Jay Tee wrote: Let's see if I can scare up something I wrote about ten years ago on a now-dead language that I really wanted to use (wound up sticking with python instead because it was supported ;-) === to figure out how to work things. The fact that there are three

Re: Python 3.0 unfit for serious work?

2007-02-20 Thread Steven Bethard
Steven Bethard wrote: So as a Python programmer, the path is clear. As soon as possible, you should make your code compatible with Python 3.0. John Nagle wrote: There's always the possiblity that Python 3 won't happen. That's not really a possibility. Unlike Perl 6, Python 3

Re: New-style classes (was Re: Checking for EOF in stream)

2007-02-19 Thread Steven Bethard
GiBo wrote: One more question - is it likely that StringIO will be turned into new-style class in the future? The reason I ask is whether I should try to deal with detection of new-/old-style classes or take the old-styleness for granted and set in stone instead. In Python 3.0, everything

Re: builtin set literal

2007-02-16 Thread Steven Bethard
Schüle Daniel wrote: {:} for empty dict and {} for empty set don't look too much atrocious to me. this looks consistent to me Yes, a lot of people liked this approach, but it was rejected due to gratuitous breakage. While Python 3.0 is not afraid to break backwards compatibility, it tries

Re: can't load a dll in python 2.5

2007-02-16 Thread Steven Bethard
[EMAIL PROTECTED] wrote: I am on WindowsXP. I have a dll that I can load in python 2.3 but when trying to load it into python 2.5 it complains that there is nothing by that name. Is there some aspect of the dll loading mechanism between python 2.3 and 2.5 that has changed preventing me from

Re: builtin set literal

2007-02-15 Thread Steven Bethard
Schüle Daniel wrote: Hello, lst = list((1,2,3)) lst = [1,2,3] t = tupel((1,2,3)) t = (1,2,3) s = set((1,2,3)) s = ... it would be nice feature to have builtin literal for set type maybe in P3 .. what about? s = 1,2,3 In Python 3.0, this looks like:: s = {1,2,3} More info

Re: builtin set literal

2007-02-15 Thread Steven Bethard
Schüle Daniel wrote: Steven Bethard schrieb: Schüle Daniel wrote: it would be nice feature to have builtin literal for set type maybe in P3 .. what about? s = 1,2,3 In Python 3.0, this looks like:: s = {1,2,3} jepp, that looks not bad .. as in a mathe book. the only disadvantage I

Re: Pep 3105: the end of print?

2007-02-15 Thread Steven Bethard
Edward K Ream wrote: The pros and cons of making 'print' a function in Python 3.x are well discussed at: http://mail.python.org/pipermail/python-dev/2005-September/056154.html Alas, it appears that the effect of this pep would be to make it impossible to use the name 'print' in a backward

Re: Pep 3105: the end of print?

2007-02-15 Thread Steven Bethard
Edward K Ream wrote: You could offer up a patch for Python 2.6 so that you can do:: from __future__ import print_function This would only work for Python 2.6. Developers might want to support Python 2.3 through 2.5 for awhile longer :-) Python 3.0 is determined not to be hampered by

Re: string.replace non-ascii characters

2007-02-11 Thread Steven Bethard
Samuel Karl Peterson wrote: Greetings Pythonistas. I have recently discovered a strange anomoly with string.replace. It seemingly, randomly does not deal with characters of ordinal value 127. I ran into this problem while downloading auction web pages from ebay and trying to replace the

Re: Retry:Question about optparse/OptionParser callback.

2007-02-10 Thread Steven Bethard
Steven W. Orr wrote: I'm writing a program that needs to process options. Due to the nature of the program with its large number of commandline options, I would like to write a callback to be set inside add_option. Something like this: parser.add_option(-b, action=callback,

Re: Array delete

2007-02-07 Thread Steven Bethard
Jerry Hill wrote: On 1/28/07, Scripter47 [EMAIL PROTECTED] wrote: Can someone plz make a function for that takes a array, and then search in it for duplicates, if it finds 2 or more items thats the same string then delete all except 1. myList = [1, 1, 2, 4, 8, 8, 8, 8, 8, 8, 10] myList

huge amounts of pure Python code broken by Python 2.5?

2007-02-06 Thread Steven Bethard
Jean-Paul Calderone [EMAIL PROTECTED] wrote: Huge amounts of my pure Python code was broken by Python 2.5. Interesting. Could you give a few illustrations of this? (I didn't run into the same problem at all, so I'm curious.) Steve -- http://mail.python.org/mailman/listinfo/python-list

Python 3.0 (Was: when will python 2.5 take in mainstream?)

2007-02-05 Thread Steven Bethard
Laurent Pointal wrote: For Python 3.0, AFAIK its a big rewrite and developers know that it will be uncompatible in large parts with existing code. Wrong on both counts. ;-) Python 3.0 is not a rewrite. It's based on the same code base as the 2.X line, but with a lot of the old deprecated

Re: when will python 2.5 take in mainstream?

2007-02-04 Thread Steven Bethard
Eric CHAO wrote: A lot of application based on python claim that python 2.3 or 2.4 is needed not 2.5, ie. mysqldb. I've been using python for months. I don't care about 2.4 or 2.5. But I like the default icons of python in 2.5. So I just use that, but some scripts can't work on that. When

[OT] main

2007-02-03 Thread Steven Bethard
[EMAIL PROTECTED] wrote: def main(argv): try: optlist, args = getopt.getopt(argv[1:], 'hvo:D:', ['help', 'verbose']) except getopt.GetoptError, msg: sys.stderr.write(preprocess: error: %s % msg) sys.stderr.write(See 'preprocess --help'.\n) return 1

Re: Checking default arguments

2007-02-02 Thread Steven Bethard
Igor V. Rafienko wrote: I was wondering whether it was possible to find out which parameter value is being used: the default argument or the user-supplied one. That is: def foo(x, y=bar): # how to figure out whether the value of y is # the default argument, or user-supplied?

Re: Sorting a list

2007-02-01 Thread Steven Bethard
Bruno Desthuilliers wrote: If you want to prevent this from happening and don't mind creating a copy of the list, you can use the sorted() function with the key and reverse arguments and operator.itemgetter: lines = [('1995', 'aaa'), ('1997', 'bbb'), ('1995', 'bbb'), ('1997', 'aaa'),

Re: Conditional expressions - PEP 308

2007-01-31 Thread Steven Bethard
Colin J. Williams wrote: It would be helpful if the rules of the game were spelled out more clearly. The conditional expression is defined as X if C else Y. We don't know the precedence of the if operator. From the little test below, it seem to have a lower precedence than or. Thus, it

Re: SyntaxError: 'return' outside function

2007-01-31 Thread Steven Bethard
Melih Onvural wrote: Has anyone seen this error before and been able to solve it? I can't seem to find anything that leads to a solution. I found this post http://zope.org/Collectors/Zope/1809, but can't really understand it. I've attached my code below to see if anything looks funny. It

Re: How to sort using hash's key?

2007-01-31 Thread Steven Bethard
JoJo wrote: I want to sort a dict via its key,but I have no idea on how to do it. d = dict(a=2, b=1) for key in sorted(d): ... print key, d[key] ... a 2 b 1 STeVe -- http://mail.python.org/mailman/listinfo/python-list

Re: How to sort using hash's key?

2007-01-31 Thread Steven Bethard
Ben Finney wrote: Steven Bethard [EMAIL PROTECTED] writes: JoJo wrote: I want to sort a dict via its key,but I have no idea on how to do it. d = dict(a=2, b=1) for key in sorted(d): ... print key, d[key] ... a 2 b 1 That's not a solution to sort the dict; that's getting

Re: Fixed length lists from .split()?

2007-01-30 Thread Steven Bethard
On Jan 26, 11:07 am, Bob Greschke [EMAIL PROTECTED] wrote: I'm reading a file that has lines like bcsn; 100; 1223 bcsn; 101; 1456 bcsn; 103 bcsn; 110; 4567 The problem is the line with only the one semi-colon. Is there a fancy way to get Parts=Line.split(;)

distutils, sdist and tests

2007-01-27 Thread Steven Bethard
How do I get distutils to include my testing module in just the sdist distribution? My current call to setup() looks like:: distutils.core.setup( ... py_modules=['argparse'], ) If change this to:: distutils.core.setup( ...

Re: distutils, sdist and tests

2007-01-27 Thread Steven Bethard
Robert Kern wrote: Steven Bethard wrote: How do I get distutils to include my testing module in just the sdist distribution? Use a MANIFEST. http://docs.python.org/dist/source-dist.html I want test_argparse.py to be available in the source distribution, but I don't think it should

Re: distutils, sdist and tests

2007-01-27 Thread Steven Bethard
Robert Kern wrote: Steven Bethard wrote: Robert Kern wrote: Steven Bethard wrote: How do I get distutils to include my testing module in just the sdist distribution? Use a MANIFEST. http://docs.python.org/dist/source-dist.html Also, I just noted this tidbit: If you don't supply

Re: distutils, sdist and tests

2007-01-27 Thread Steven Bethard
Robert Kern wrote: Steven Bethard wrote: Robert Kern wrote: Are you sure that you don't have changes left over in your setup.py when you tested that? Yep. (Though I still cleared everything out and tried it again.) Here's what I got using an unmodified setup.py and the MANIFEST.in you

Re: distutils, sdist and tests

2007-01-27 Thread Steven Bethard
Robert Kern wrote: Steven Bethard wrote: How do I get distutils to include my testing module in just the sdist distribution? Use a MANIFEST. Thanks again to Robert Kern for all the help. For the record, in the end all I did was add a MANIFEST.in file with the single line: include

Re: pyparsing Combine without merging sub-expressions

2007-01-21 Thread Steven Bethard
Dennis Lee Bieber wrote: On Sat, 20 Jan 2007 13:49:52 -0700, Steven Bethard [EMAIL PROTECTED] declaimed the following in comp.lang.python: Within a larger pyparsing grammar, I have something that looks like:: wsj/00/wsj_0003.mrg When parsing this, I'd like to keep around both

Re: pyparsing Combine without merging sub-expressions

2007-01-21 Thread Steven Bethard
Paul McGuire wrote: Steven Bethard wrote: Within a larger pyparsing grammar, I have something that looks like:: wsj/00/wsj_0003.mrg When parsing this, I'd like to keep around both the full string, and the AAA_ substring of it, so I'd like something like:: foo.parseString

pyparsing Combine without merging sub-expressions

2007-01-20 Thread Steven Bethard
Within a larger pyparsing grammar, I have something that looks like:: wsj/00/wsj_0003.mrg When parsing this, I'd like to keep around both the full string, and the AAA_ substring of it, so I'd like something like:: foo.parseString('wsj/00/wsj_0003.mrg')

Re: A note on heapq module

2007-01-18 Thread Steven Bethard
[EMAIL PROTECTED] wrote: Steven Bethard: Antoon Pardon: For me, your class has the same drawback as the heappush, heappop procedurers: no way to specify a comparision function. Agreed. I'd love to see something like ``Heap(key=my_key_func)``. It can be done, but the code becomes more

Re: A note on heapq module

2007-01-18 Thread Steven Bethard
[EMAIL PROTECTED] wrote: Steven Bethard wrote: The current code fails when using unbound methods however:: I don't like your solution, this class was already slow enough. Don't use unbound methods with this class :-) Maybe there's a (better) solution to your problem: to make Heap

[ANN] argparse 0.5 - Command-line parsing library

2007-01-17 Thread Steven Bethard
Announcing argparse 0.5 --- argparse home: http://argparse.python-hosting.com/ argparse single module download: http://argparse.python-hosting.com/file/trunk/argparse.py?format=raw argparse bundled downloads at PyPI: http://www.python.org/pypi/argparse/ About this

Re: A note on heapq module

2007-01-17 Thread Steven Bethard
Antoon Pardon wrote: For me, your class has the same drawback as the heappush, heappop procedurers: no way to specify a comparision function. Agreed. I'd love to see something like ``Heap(key=my_key_func)``. STeVe -- http://mail.python.org/mailman/listinfo/python-list

aligning ElementTrees to text

2007-01-17 Thread Steven Bethard
I'm trying to align an XML file with the original text file from which it was created. Unfortunately, the XML version of the file has added and removed some of the whitespace. For example:: plain_text = ''' ... Pacific First Financial Corp. said shareholders approved its ...

Re: A note on heapq module

2007-01-16 Thread Steven Bethard
[EMAIL PROTECTED] wrote: some time ago I have written a bug into small program that uses the functions of the heapq module, because I have added an item to the head of the heap using a normal list method, breaking the heap invariant. I know I've had similar bugs in my code before. from

[ANN] argparse 0.5 - Command-line parsing library

2007-01-16 Thread Steven Bethard
Announcing argparse 0.5 --- argparse home: http://argparse.python-hosting.com/ argparse single module download: http://argparse.python-hosting.com/file/trunk/argparse.py?format=raw argparse bundled downloads at PyPI: http://www.python.org/pypi/argparse/ About this

Re: An iterator with look-ahead

2007-01-10 Thread Steven Bethard
Neil Cerutti wrote: For use in a hand-coded parser I wrote the following simple iterator with look-ahead. There's a recipe for this: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/304373 Note that the recipe efficiently supports an arbitrary look-ahead, not just a single item.

Re: Question about using with

2007-01-09 Thread Steven Bethard
Steven W. Orr wrote: From the tutorial, they said that the following construct will automatically close a previously open file descriptor: --- #! /usr/bin/python import sys for nn in range ( 1, len(sys.argv ) ): print arg , nn, value = , sys.argv[nn] with

Re: how to find the longst element list of lists

2007-01-07 Thread Steven Bethard
Scott David Daniels wrote: Dan Sommers wrote: ... longest_list, longest_length = list_of_lists[ 0 ], len( longest_list ) for a_list in list_of_lists[ 1 : ]: a_length = len( a_list ) if a_length longest_length: longest_list, longest_length = a_list,

Re: When argparse will be in the python standard installation

2007-01-05 Thread Steven Bethard
[Thanks for looking through all these Martin!] Martin v. Löwis wrote: Steven Bethard schrieb: * alias ArgumentParser to OptionParser * alias add_argument to add_option * alias Values to Namespace * alias OptionError and OptionValueError to ArgumentError * alias add_help= keyword argument

Re: (newbie) Is there a way to prevent name redundancy in OOP ?

2007-01-05 Thread Steven Bethard
Stef Mientki wrote: Not sure I wrote the subject line correct, but the examples might explain if not clear [snip] class pin2: def __init__ (self, naam): self.Name = naam aap2 = pin2('aap2') # seems completely redundant to me. print aap2.Name You can use class statements to

Re: When argparse will be in the python standard installation

2007-01-04 Thread Steven Bethard
Martin v. Löwis wrote: Steven Bethard schrieb: If someone has an idea how to include argparse features into optparse, I'm certainly all for it. But I tried and failed to do this myself, so I don't know how to go about it. It's not necessary that the implementation is retained, only

Re: When argparse will be in the python standard installation

2007-01-04 Thread Steven Bethard
Steven Bethard schrieb: If someone has an idea how to include argparse features into optparse, I'm certainly all for it. But I tried and failed to do this myself, so I don't know how to go about it. Martin v. Löwis wrote: It's not necessary that the implementation is retained, only

[ANN] argparse 0.4 - Command-line parsing library

2007-01-04 Thread Steven Bethard
Announcing argparse 0.4 --- argparse home: http://argparse.python-hosting.com/ argparse single module download: http://argparse.python-hosting.com/file/trunk/argparse.py?format=raw argparse bundled downloads at PyPI: http://www.python.org/pypi/argparse/ New in this

Re: When argparse will be in the python standard installation

2007-01-03 Thread Steven Bethard
Martin v. Löwis wrote: [EMAIL PROTECTED] schrieb: I feel argparse has some useful things that optparse doesn't have. But I can't find it argparse in python library reference. I'm wondering when it will be available in the python standard installation. On its own, never. Somebody has to

Re: module with a threading-like api that uses processes?

2006-12-26 Thread Steven Bethard
[EMAIL PROTECTED] wrote: I could have sworn someone was working on a module recently with a threading-like API that used subprocesses under the covers, but 10 minutes or so of googling didn't yield anything. Pointers appreciated.

Re: Getting the name of an assignment

2006-12-23 Thread Steven Bethard
Adam Atlas wrote: Is it possible for an object, in its __init__ method, to find out if it is being assigned to a variable, and if so, what that variable's name is? I can think of some potentially ugly ways of finding out using sys._getframe, but if possible I'd prefer something less exotic.

Re: Getting the name of an assignment

2006-12-23 Thread Steven Bethard
Adam Atlas wrote: Isn't it a bit convoluted to use metaclasses? Yep. It's a well known fact that putting convoluted and metaclasses in the same sentence is repetitively redundant. ;-) someinstance.__class__.__name__ does the same thing. No, not really:: class C(object): ...

Re: optparser question

2006-12-22 Thread Steven Bethard
Michele Petrazzo wrote: I'm trying optparse and I see a strange (for me) behavior: def store_value(option, opt_str, value, parser): setattr(parser.values, option.dest, value) parser = optparse.OptionParser() parser.add_option(-f, --foo, action=callback,

Re: optparser question

2006-12-22 Thread Steven Bethard
Michele Petrazzo wrote: Ok, I have not understand the trickle for transform the action=callback and provide a callback to a new action. Yeah, you're not the only one. ;-) I believe, however, that the doc has to be more explicit about this strange behavior, because a not so expert dev (like

Re: Defining classes

2006-12-14 Thread Steven Bethard
Nick Maclaren wrote: I am defining a class, and I need to refer to that class when setting up its static data - don't ask - like this: Class weeble : wumpus = brinjal(weeble) Duncan Booth wrote: Alternatively you can play tricks with metaclasses for a similar effect. Nick Maclaren

Re: automatically grading small programming assignments

2006-12-14 Thread Steven Bethard
Brian Blais wrote: I have a couple of classes where I teach introductory programming using Python. What I would love to have is for the students to go through a lot of very small programs, to learn the basic programming structure. Things like, return the maximum in a list, making lists

python-dev Summary for 2006-11-16 through 2006-11-30

2006-12-13 Thread steven . bethard
is the 17th written by Steven Bethard. To contact me, please send email: - Steven Bethard (steven dot bethard at gmail dot com) Do *not* post to comp.lang.python if you wish to reach me. The `Python Software Foundation`_ is the non-profit organization that holds the intellectual property for Python

python-dev Summary for 2006-11-16 through 2006-11-30

2006-12-12 Thread steven . bethard
is the 17th written by Steven Bethard. To contact me, please send email: - Steven Bethard (steven dot bethard at gmail dot com) Do *not* post to comp.lang.python if you wish to reach me. The `Python Software Foundation`_ is the non-profit organization that holds the intellectual property for Python

Re: How can I get involved

2006-12-11 Thread Steven Bethard
Prateek wrote: Basically, I really love the language and I'm looking for ways to get involved in the community and contribute. If you're looking to help in the development of Python, the `python-dev list`_ might be a little more appropriate. You might find that just lurking on that list and

Re: How can I get involved

2006-12-11 Thread Steven Bethard
Steven Bethard wrote: .. _python-dev list: One really simple way to contribute that would be Sorry, copy-paste error. This should have been: .. _python-dev list: http://mail.python.org/mailman/listinfo/python-dev STeVe -- http://mail.python.org/mailman/listinfo/python-list

[ANN] argparse 0.3 - Command-line parsing library

2006-12-05 Thread Steven Bethard
Announcing argparse 0.3 --- argparse home: http://argparse.python-hosting.com/ argparse single module download: http://argparse.python-hosting.com/file/trunk/argparse.py?format=raw argparse bundled downloads at PyPI: http://www.python.org/pypi/argparse/ About

[ANN] argparse 0.3 - Command-line parsing library

2006-12-05 Thread Steven Bethard
Announcing argparse 0.3 --- argparse home: http://argparse.python-hosting.com/ argparse single module download: http://argparse.python-hosting.com/file/trunk/argparse.py?format=raw argparse bundled downloads at PyPI: http://www.python.org/pypi/argparse/ About

python-dev Summary for 2006-11-01 through 2006-11-15

2006-11-26 Thread steven . bethard
python-dev Summary for 2006-11-01 through 2006-11-15 .. contents:: [The HTML version of this Summary is available at http://www.python.org/dev/summary/2006-11-01_2006-11-15] = Announcements =

python-dev Summary for 2006-10-01 through 2006-10-15

2006-11-26 Thread steven . bethard
python-dev Summary for 2006-10-01 through 2006-10-15 .. contents:: [The HTML version of this Summary is available at http://www.python.org/dev/summary/2006-10-01_2006-10-15] = Announcements =

python-dev Summary for 2006-10-16 through 2006-10-31

2006-11-26 Thread steven . bethard
python-dev Summary for 2006-10-16 through 2006-10-31 .. contents:: [The HTML version of this Summary is available at http://www.python.org/dev/summary/2006-10-16_2006-10-31] = Announcements =

<    1   2   3   4   5   6   7   8   9   10   >