Re: Regular Expression help

2006-04-28 Thread Kent Johnson
rs is handling malformed html. Beautiful Soup is intended to handle malformed HTML and seems to do pretty well. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: best way to determine sequence ordering?

2006-04-28 Thread Kent Johnson
I V wrote: > Incidentally, does python have a built-in to do a binary search on a > sorted list? Obviously it's not too tricky to write one, but it would be > nice if there was one implemented in C. See the bisect module. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: How do I take a directory name from a given dir?

2006-05-01 Thread Mike Kent
Python 2.4.2 (#1, Nov 29 2005, 14:04:55) [GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> d = "/home/testuser/projects" >>> os.path.basename(d) 'projects' >>> os.path.dirname(d) '/home/testuser' >>> --

Re: strip newlines and blanks

2006-05-02 Thread Kent Johnson
on of the loop. (Though you will need a separate test to terminate the loop when there are no more lines.) You can iterate an open file directly; here is a shorter version: for line in open('test.dat'): line = line.rstrip('\n') if line: print line Kent >

Re: string.find first before location

2006-05-03 Thread Kent Johnson
Gary Wessle wrote: > ps. is there a online doc or web page where one enters a method and it > returns the related docs? The index to the library reference is one place: http://docs.python.org/lib/genindex.html and of course help() in the interactive interpreter... Kent --

Re: Replace

2006-05-06 Thread Kent Johnson
d =ffgtyuf == =tyryr =u=p ff" In [3]: re.sub('=.', '=#', s) Out[3]: 'tyrtrbd =#fgtyuf =# =#yryr =#=# ff' If the replacement char is not fixed then make the second argument to re.sub() be a callable that computes the replacement. PS str is not a good name

Re: Designing Plug-in Systems in Python

2006-05-07 Thread Kent Johnson
> systems. One of these might be helpful: http://developer.berlios.de/projects/plugboard/ http://termie.pbwiki.com/SprinklesPy Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: the print statement

2006-05-07 Thread Kent Johnson
strophe character in another > character set? If so, which character set? \x92 is a right single quote in Windows cp1252. http://www.microsoft.com/globaldev/reference/sbcs/1252.mspx Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Global utility module/package

2006-05-09 Thread Kent Johnson
again which just moved the > ugliness to another position. This is fine. You don't need 'global' statements to read global variables, function1() can be simply def function1(): print debugFlag Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: regular expressions, substituting and adding in one step?

2006-05-09 Thread Kent Johnson
paragraph + '\n\n'" In [20]: re.sub(r"'' \+ (.*?) \+ '\n\n'", r"'%s\n\n' % \1", test) Out[20]: "self.source += '%s\n\n' % paragraph" Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Enumerating Regular Expressions

2006-05-09 Thread Kent Johnson
inations for hints). Filter with the regex. Halting is left as an exercise for the reader. (Halting when the length reaches a predetermined limit would be one way to do it.) Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: regular expressions, substituting and adding in one step?

2006-05-10 Thread Kent Johnson
John Salerno wrote: > Call > me crazy, but I'm interested in regular expressions right now. :) Not crazy at all. REs are a powerful and useful tool that every programmer should know how to use. They're just not the right tool for every job! Kent -- http://mail.python.org/

Re: data entry tool

2006-05-10 Thread Kent Johnson
se. > > This software tool needs to work on a variety of different computers; Win95, > Win98, WinXP, Mac, Linux. Take a look at Tkinter, it is pretty easy to get started with and good for making simple GUIs. Look at the csv module for writing the data to files. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: reusing parts of a string in RE matches?

2006-05-10 Thread Kent Johnson
art = 0 while True: m = pattern.search(string, start) if not m: break ans.append( (m.start(), m.end()) ) start = m.start() + 1 print ans # => [(0, 2), (2, 4), (4, 6), (6, 8), (8, 10), (10, 12), (12, 14)] Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Memory leak in Python

2006-05-11 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > Sure, are there any available simulators...since i am modifying some > stuff i thought of creating one of my own. But if you know some > exisiting simlators , those can be of great help to me. http://simpy.sourceforge.net/ -- http://mail.python.org/mailman/listinfo/pyth

Re: unittest: How to fail if environment does not allow execution?

2006-05-11 Thread Kent Johnson
sage explaining what is wrong. I would just use the file normally in the test. If it's not there you will get an IOError with a traceback and a helpful error message. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: glob() that traverses a folder tree

2006-05-11 Thread Kent Johnson
k a little harder: for f in path.path('.\InteropSolution').walkfiles(): if f.fnmatch('*.dll') or f.fnmatch('*.exe'): print f or maybe for f in path.path('.\InteropSolution').walkfiles(): if f.ext in ['.dll', '.exe']: print f http://www.jorendorff.com/articles/python/path/index.html Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: retain values between fun calls

2006-05-14 Thread Kent Johnson
Alternately you can use an attribute of the function to save the state: In [35]: def f(a): : f.b += a : return f.b : In [36]: f.b=1 In [37]: f(1) Out[37]: 2 In [38]: f(2) Out[38]: 4 Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: any plans to make pprint() a builtin?

2006-05-14 Thread Kent Johnson
rrent/doc/misc.html#the-py-std-hook Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: OOP and Tkinter

2006-05-15 Thread Kent Johnson
tribute, not a class attribute. You need to refer to self._listbox_1 from a CustomFront method, or change _listbox_1 to a class attribute if that is what you really want. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: List behaviour

2006-05-17 Thread Mike Kent
When you did: b = a[:] b was then a copy of a, rather than just a reference to the same a. But what does a contain? It contains two sublists -- that is, it contains references to two sublists. So b, which is now a copy of a, contains copies of the two references to the same two sublists. What y

Re: who can give me the detailed introduction of re modle?

2006-05-19 Thread Kent Johnson
softwindow wrote: > the re module is too large and difficult to study > > i need a detaild introduction. > http://www.amk.ca/python/howto/regex/ Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: grabbing portions of a file to output files

2006-05-22 Thread Kent Johnson
mething like this? out = None for line in open(...): if line.startswith('H'): if out: out.close() out = open(..., 'w') if out: out.write(line) out.close() Kent -- http://mail.python.org/mailman/listinfo/python-list

GUI viewer for profiler output?

2006-05-23 Thread Kent Johnson
Can anyone point me to a GUI program that allows viewing and browsing the output of the profiler? I know I have used one in the past but I can't seem to find it... Thanks, Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: can't figure out error: module has no attribute...

2006-05-23 Thread Kent Johnson
ting it seems to depend on from which partition I > start Python. Probably you have multiple copies of selfservicelabels.py or an old selfservicelabels.pyc that is being imported. Try import selfservicelabels print selfservicelabels.__file__ to see where the import is coming from. Kent

Re: NEWB: how to convert a string to dict (dictionary)

2006-05-24 Thread Kent Johnson
manstey wrote: > Hi, > > How do I convert a string like: > a="{'syllable': u'cv-i b.v^ y^-f', 'ketiv-qere': 'n', 'wordWTS': u'8'}" > > into a dictionary: > b={'syllable': u'cv-i b.v^ y^-f', 'ketiv-qere': 'n', 'wordWTS': u'8'} Try this recipe: http://aspn.activestate.com/ASPN/Cookbook/Python/Reci

Re: Finding Upper-case characters in regexps, unicode friendly.

2006-05-25 Thread Kent Johnson
er instead of just the typical [A-Z], > which doesn't include, for example É. Is there a way to do this, or > do I have to stick with using the isupper method of the string class? > See http://tinyurl.com/7jqgt Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Best way to handle exceptions with try/finally

2006-05-25 Thread Kent Johnson
Zameer wrote: > I wonder where the "else" goes in try..except..finally... > try / except / else / finally See the PEP: http://www.python.org/dev/peps/pep-0341/ Kent -- http://mail.python.org/mailman/listinfo/python-list

Anyone compiling Python 2.3 on an SCO OpenServer 5 box?

2006-05-25 Thread Mike Kent
If anyone is successfully compiling Pyton 2.3 on an SCO OpenServer 5 box, I'd appreciate hearing from you on how you managed to do it. So far, I'm unable to get a python that doesn't coredump. -- http://mail.python.org/mailman/listinfo/python-list

Re: Anyone compiling Python 2.3 on an SCO OpenServer 5 box?

2006-05-25 Thread Mike Kent
I need to compile Python on OpenServer 5 because I need to 'freeze' our Python app, and running 'freeze' requires a working, compilable source installation of Python. -- http://mail.python.org/mailman/listinfo/python-list

Re: Speed up this code?

2006-05-26 Thread Kent Johnson
for membership in a set is much faster than searching a large list. - Find a better algorithm ;) Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Parsing python dictionary in Java using JPython

2006-05-26 Thread Kent Johnson
existing dictionaries only using JPython libraries. How do you access the dictionary files from Python? The same thing may work in Jython. For example importing the file, if it is Python syntax, should work in Jython; also I think format 0 (text) and format 1 pickles are compatible with Jython. Kent

Re: Prioritization function needed (recursive help!)

2008-01-21 Thread Kent Johnson
these. You need a topological sort. http://en.wikipedia.org/wiki/Topological_sort Two Python implementations: http://pypi.python.org/pypi/topsort/0.9 http://www.bitformation.com/art/python_toposort.html Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: How avoid both a newline and a space between 2 print commands?

2008-01-23 Thread Mike Kent
On Jan 23, 9:03 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > print "foo" > print "bar" > > has a newline in between "foo" and "bar" > > print "foo", > print "bar" > > has a space in between "foo" and "bar" > > How prevent ANYTHING from going in between "foo" and "bar" ?? > > (Without defini

Can someone explain this unexpected raw_input behavior?

2008-01-23 Thread Mike Kent
It's often useful for debugging to print something to stderr, and to route the error output to a file using '2>filename' on the command line. However, when I try that with a python script, all prompt output from raw_input goes to stderr. Consider the following test program: === Start test.py ===

Re: Can someone explain this unexpected raw_input behavior?

2008-01-23 Thread Mike Kent
Gabriel, thank you for clarifying the source of this behavior. Still, I'm surprised it would be hard-coded into Python. Consider an interactive program, that asks the user several questions, and displays paragraphs of information based on those questions. The paragraphs are output using print, a

Re: Can someone explain this unexpected raw_input behavior?

2008-01-24 Thread Mike Kent
> If it weren't for the documentation... > > "If the prompt argument is present, it is written to *standard output* > without a trailing newline." > > -- > mvh Björn I have reported this issue to the python-dev mailing list, and Guido agrees that this is a bug in Python. It turns out that the ke

Re: Reporting Python bugs (was: Can someone explain this unexpectedraw_input behavior?)

2008-01-24 Thread Mike Kent
On Jan 24, 5:13 pm, "Terry Reedy" <[EMAIL PROTECTED]> wrote: > "Ben Finney" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > | Mike Kent <[EMAIL PROTECTED]> writes: > | > | > A bug issue has been opened in the Python Trac

Re: raw_input(), STRANGE behaviour

2008-01-26 Thread Mike Kent
On Jan 26, 7:23 am, Dox33 <[EMAIL PROTECTED]> wrote: > I ran into a very strange behaviour of raw_input(). > I hope somebody can tell me how to fix this. ===CUT=== > *** Thirst, redirect stderr to file, STRANGE behaviour.. > From the command prompt I run: > python script.py 2> stderr_catch.txt

What should I use under *nix instead of freeze?

2008-02-01 Thread Mike Kent
In a comment Guido made on a recent bug report for the 'freeze' utility, he stated: "I think nobody really cares about freeze any more -- it isn't maintained." That being the case, what is the preferred/best replacement for freeze on a *nix platform? I'm looking for something that, like freeze,

Re: Talking to a usb device (serial terminal)

2008-03-03 Thread Mike Kent
> So my question is this - what is the easiest way to interface to this > "serial" device? > http://pyserial.sourceforge.net/ or perhaps http://pyusb.berlios.de/ -- http://mail.python.org/mailman/listinfo/python-list

Re: function scope

2009-02-02 Thread Mike Kent
On Feb 2, 6:40 pm, Baris Demir wrote: > def simpleCut(d=dict()): >        temp=d >        for i in temp.keys(): >            if    (temp[i] == ...) : >               temp[i]=new_value > return temp You have been bitten by the shared default parameter noobie trap: http://www.python.org/doc/fa

Re: FTP libs for Python?

2009-02-20 Thread Mike Kent
I use Fabric (http://www.nongnu.org/fab/) as my Python-based deployment tool, but it uses ssh/scp, not sftp. -- http://mail.python.org/mailman/listinfo/python-list

Problem building Python 2.5.2 curses module on HP/UX 11.11

2009-01-06 Thread Mike Kent
I'm having a problem building the Python 2.5.2 curses module on HP/UX 11.11 using gcc 3.3.6, and was hoping someone had a solution. Compiling Modules/_cursesmodule.c is giving several warnings, but no errors. The relevant compile/link output is below. The key output line is: *** WARNING: renamin

Re: tcl/tk version confusion with tkinter in Python 2.6, on OS X

2008-10-06 Thread Kent Johnson
It makes the build pretty much useless > for anyone needing it to run Tkinter apps, including Idle. I'd say > it's > a showstopper issue. I think so. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: utf-8 read/write file

2008-10-08 Thread Kent Johnson
> I have done script for that, but im having problem with croatian characters > >> (©,Ð,®,È,Æ). > > UnicodeDecodeError: 'utf8' codec can't decode byte 0x9e in position 0: > unexpected code byte Are you sure you have UTF-8 data? I guess your file is encoded in CP125

Possible read()/readline() bug?

2008-10-22 Thread Mike Kent
Before I file a bug report against Python 2.5.2, I want to run this by the newsgroup to make sure I'm not being stupid. I have a text file of fixed-length records I want to read in random order. That file is being changed in real-time by another process, and my process want to see the changes to

Re: Possible read()/readline() bug?

2008-10-23 Thread Mike Kent
To followup on this: Terry: Yes, I did in fact miss the 'buffer' parameter to open. Setting the buffer parameter to 0 did in fact fix the test code that I gave above, but oddly, did not fix my actual production code; it continues to get the data as first read, rather than what is currently on the

Can I use setup.py to ship and install only .pyc files?

2009-04-16 Thread Mike Kent
I'd like to ship only the .pyc files for a module. I was hoping the standard distutils setup.py could handle this, but so far, I've not figured out how. After a bit of work, I discovered that if I create a MANIFEST.in file, and put 'include mymodule/*.pyc' and 'exclude mymodule/*.py' in it, then

Re: ANN: PyGUI 2.0.4

2009-04-21 Thread Kent Johnson
, in win_message_to_event kind, button = win_message_map[msg] KeyError: 675 Adding this line to win_message_map in GUI/Win32/Events.py seems to fix it: wc.WM_MOUSELEAVE: ('mouse_leave', None), Kent -- http://mail.python.org/mailman/listinfo/python-list

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

2009-04-27 Thread Mike Kent
On Apr 27, 1:49 am, John Machin wrote: > > I am > > having a look at eval and exec > > WRONG WAY > GO BACK +1 QOTW -- http://mail.python.org/mailman/listinfo/python-list

Re: list index out of range

2008-05-13 Thread Mike Kent
On May 13, 2:39 pm, Georgy Panterov <[EMAIL PROTECTED]> wrote: > > def deal_hand(deck): > HAND=[] > for _ in range(2): > i=random.randint(0,len(deck)) #produces a random card from the deck ^ Here i can be from 0 thru (the number of cards in the deck). > HAND.appen

Re: Constructor re-initialization issue

2008-06-03 Thread Mike Kent
On Jun 3, 6:11 pm, [EMAIL PROTECTED] wrote: > Hello all, > > I have come across this issue in Python and I cannot quite understand > what is going on. > > class Param(): > def __init__(self, data={}, condition=False): > if condition: > data['class']="Advanced" > prin

Subclassing list, what special methods do this?

2008-06-13 Thread Mike Kent
For Python 2.5 and new-style classes, what special method is called for mylist[2:4] = seq and for del mylist[2:4] (given that mylist is a list, and seq is some sequence)? I'm trying to subclass list, and I'm having trouble determining what special methods I have to override in my class for the abo

Re: Subclassing list, what special methods do this?

2008-06-14 Thread Mike Kent
On Jun 13, 8:43 pm, Matimus <[EMAIL PROTECTED]> wrote: ...chop... > So, it looks like as long as you want to subclass list, you are stuck > implementing both __*slice__ and __*item__ methods. > > Matt Thanks. That was clear and concise, just what I needed. -- http://mail.python.org/mailman/listi

Re: Notify of change to list

2008-06-16 Thread Mike Kent
I recently wanted to do the same kind of thing. See this tread: http://groups.google.com/group/comp.lang.python/browse_thread/thread/f27c3b7950424e1c for details on how to do it. -- http://mail.python.org/mailman/listinfo/python-list

Re: Convert string to char array

2008-07-01 Thread Mike Kent
On Jul 1, 2:49 pm, "Brandon" <[EMAIL PROTECTED]> wrote: > How do I convert a string to a char array?  I am doing this so I can edit > the string received from an sql query so I can remove unnecessary > characters. Answering your specific question: Python 2.5.1 (r251:54863, Mar 31 2008, 11:09:52)

sending to an xterm

2008-08-08 Thread Kent Tenney
Howdy, I want to open an xterm, send it a command and have it execute it. I thought pexpect would do this, but I've been unsuccessful. term = pexpect.spawn('xterm') starts an xterm, but term.sendline('ls') doesn't seem to do anything. Suggestions? Thanks, K

Re: sending to an xterm

2008-08-08 Thread Kent Tenney
Derek Martin pizzashack.org> writes: > > On Fri, Aug 08, 2008 at 08:25:19PM +0000, Kent Tenney wrote: > > Howdy, > > > > I want to open an xterm, send it a command and have it execute it. > > You can't do that. xterm doesn't execute shell com

Re: sending to an xterm

2008-08-08 Thread Kent Tenney
Derek Martin pizzashack.org> writes: > > On Fri, Aug 08, 2008 at 08:25:19PM +0000, Kent Tenney wrote: > > Howdy, > > > > I want to open an xterm, send it a command and have it execute it. > > You can't do that. xterm doesn't execute shell com

datetime from uuid1 timestamp

2008-08-13 Thread Kent Tenney
Howdy, I have not found a routine to extract usable date/time information from the 60 bit uuid1 timestamp. Is there not a standard solution? Thanks, Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: datetime from uuid1 timestamp

2008-08-13 Thread Kent Tenney
> Howdy, > > I have not found a routine to extract usable > date/time information from the 60 bit uuid1 timestamp. > > Is there not a standard solution? I submitted an ASPN recipe to do it. http://code.activestate.com/recipes/576420/ -- http://mail.python.org/mailman/listinfo/python-list

Suggestion for improved ImportError message

2008-08-13 Thread Kent Tenney
name annotate from /usr//image.pyc Thanks, Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: datetime from uuid1 timestamp

2008-08-13 Thread Kent Tenney
creation date solely from the filename. Thanks, Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Suggestion for improved ImportError message

2008-08-13 Thread Kent Tenney
int: you have to modify import_from function from > > Python/ceval.c Am I correct in thinking that PyPy would mean low level stuff like this will be Python instead of C? That would be nice. > > > > My quick attempt: Quick indeed! Very cool. Thanks, Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Finally had to plonk google gorups.

2008-04-16 Thread Mike Kent
On Apr 16, 10:26 am, Mike Driscoll <[EMAIL PROTECTED]> wrote: > Yeah, I noticed that Google Groups has really sucked this week. I'm > using the Google Groups Killfile for Greasemonkey now and it helps a > lot. I like Google, but my loyalty only goes to far. This is a > complete lack of customer se

Re: Pythonically extract data from a list of tuples (getopt)

2008-04-23 Thread Mike Kent
You could use http://docs.python.org/lib/module-optparse.html -- http://mail.python.org/mailman/listinfo/python-list

Re: creating a list from a inconsistent text file

2008-05-02 Thread Mike Kent
On May 2, 9:47 am, Jetus <[EMAIL PROTECTED]> wrote: > Hello Marc; > Thanks for the input! I am worried about the comma in the "" data > items, how do I tell Python to look for the "" data first, then use > the comma separator? Marc has already given you the correct answer. You really should read

Re: Python multimap

2008-08-27 Thread Mike Kent
On Aug 27, 9:35 am, brad <[EMAIL PROTECTED]> wrote: > Recently had a need to us a multimap container in C++. I now need to > write equivalent Python code. How does Python handle this? > > k['1'] = 'Tom' > k['1'] = 'Bob' > k['1'] = 'Joe' > ... > > Same key, but different values. No overwrites either

Re: How to delete a last character from a string

2008-08-29 Thread Mike Kent
On Aug 29, 2:28 pm, [EMAIL PROTECTED] wrote: > Sorry : Earlier mail had a typo in Subject line which might look > in-appropriate to my friends > > Hi, > > I've a list some of whose elements with character \. > I want to delete this last character from the elements that have this > character set at

Re: Getting File Permissions

2006-03-07 Thread Kent Johnson
cuting I am getting error message as follows > > Traceback (most recent call last): > File "", line 1, in ? > NameError: name 'octal' is not defined The correct name is oct(). The docs on built-in functions are helpful here: http://docs.python.org/lib/built-in-funcs.html Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: generators shared among threads

2006-03-08 Thread Kent Johnson
ld. Python 2.5 will allow this (see PEP 342) but from the examples it seems the finally won't execute until the yield returns. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: cgi problem

2006-03-08 Thread Kent Johnson
Set the Location: header to the new URL. http://hoohoo.ncsa.uiuc.edu/cgi/out.html http://www.algonet.se/~ug/html+pycgi/redirect.html Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: advice on this little script

2006-03-09 Thread Kent Johnson
ell me where somemodule was coming from (should I need to > be reminded of that information). If you use from xx import yy, searching for yy will show you its provenance as well. From xx import * is evil because it does hide the provenance of names. It can also give unexpected results - if xx

Re: cgi problem

2006-03-09 Thread Kent Johnson
Paul Rubin wrote: > Tim Roberts <[EMAIL PROTECTED]> writes: > >>Yes, but the CGI module doesn't write anything, so the advice of writing a >>"Location:" header still applies. > > > Aha, it's coming from CGIHTTPServer.py:CGIHTTPRequestHandler.run_cgi() > where it says > > self.send_respo

Re: lighter weight options to Python's logging package?

2006-03-12 Thread Kent Johnson
the raw creation time %(created)f rather than %(asctime)s in your format. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Please, I Have A Question before I get started

2006-03-13 Thread Kent Johnson
Ravi Teja wrote: > I do not think that technology has gone backwards. Hyper card > alternatives still exist. > http://www.metacard.com/ At $995 per seat it's not likely to be used for a home project. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: trying to find repeated substrings with regular expression

2006-03-13 Thread Kent Johnson
r me just to search for FOO, and then > break up the string based on the locations of FOO. Use re.split() for this. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Love :)

2006-03-13 Thread Kent Johnson
Paul Rubin wrote: > So what's the most concise way > of turning it back into a string? ''.join(list(reversed(a_string))) ? You don't need the list(), join() can take an iterator: ''.join(reversed(a_string)) Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Is this possible in Python?

2006-03-13 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > Hello again, > I am disappointed. You are the experts, you've got to try harder ;-) > What i want is a generalisation of this tiny function: Why? Maybe we can find a better way... Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Localized month names?

2006-03-14 Thread Kent Johnson
quot;, "credits" or "license" for more information. In [1]: import locale In [2]: locale.nl_langinfo(locale.MON_1) Traceback (most recent call last): File "", line 1, in ? AttributeError: 'module' object has no attribute 'nl_langinfo' Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Little Help with Exceptions and ConfigParser

2006-03-14 Thread Kent Johnson
nt Errors and Exceptions, and have the > program deal with them gracefully. All the ConfigParser exceptions are subclasses of ConfigParser.Error so if you catch that instead of ConfigParser.ParsingError your code will catch NoSectionError as well. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Little Help with Exceptions and ConfigParser

2006-03-15 Thread Kent Johnson
clause by putting them in a tuple: except (IOError, Error), err: print "Problem opening configuration file. %s" %err HTH Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Install Universal Encoding Detector

2006-03-15 Thread Kent Johnson
Jacob wrote: > How do I install Universal Encoding Detector > (http://chardet.feedparser.org/)? The usual process: download unpack with your favorite tool - tar or WinZip, maybe cd chardet-1.0 python setup.py install Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Install Universal Encoding Detector

2006-03-16 Thread Kent Johnson
Jacob wrote: > How do I uninstall? Delete the chardet folder from site-packages (Python24\Lib\site-packages on Windows, not sure of the exact path on other OS's). Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Counting nested loop iterations

2006-03-16 Thread Kent Johnson
) yields a sequence of the lengths of the individual animals; passing this to sum() gives the total count. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Detecting arguments of a function - possible?

2006-03-17 Thread Kent Johnson
omething as simple as def foo(): pass can raise KeyboardInterrupt Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Parsing Hints

2006-03-17 Thread Kent Johnson
453 (u=3) You don't say what data you are trying to extract. If it is key:value pairs where the key is everything before the first colon, just use line.split(':', 1) to split on just the first colon. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: ANNOUNCE: xlrd 0.5.2 -- extract data from Excel spreadsheets

2006-03-18 Thread Kent Johnson
John Machin wrote: > I am pleased to announce a new general release (0.5.2) of xlrd, a Python > package for extracting data from Microsoft Excel spreadsheets. How does xlrd compare with pyexcelerator? At a glance they look pretty similar. Thanks, Kent -- http://mail.python.org/mailman/li

Re: POP3 Python Mail Download

2006-03-18 Thread Kent Johnson
for msg in messagesInfo: > msgNum = int(split(msg, " ")[0] > msgSize = int(split(msg, " ")[1] You have an inconsistent indent in the two lines above. All the lines in a block must have the same indent (except sub-blocks of course). Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: ANNOUNCE: xlrd 0.5.2 -- extract data from Excel spreadsheets

2006-03-18 Thread Kent Johnson
John Machin wrote: > On 19/03/2006 8:31 AM, Kent Johnson wrote: >>How does xlrd compare with pyexcelerator? At a glance they look pretty >>similar. >> > > I have an obvious bias, so I'll just leave you with a not-very-PC > analogy to think about: > &g

Re: POP3 Mail Download

2006-03-18 Thread Kent Johnson
e to the thing called 'stdout' and how you read from 'stdin'. raw_input() prompts to stdout and reads from stdin. print outputs to stdout: In [53]: print raw_input('What is your name? ') What is your name? Kent Kent or import sys and use sys.stdin and sys.stdout. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Can I use a conditional in a variable declaration?

2006-03-18 Thread Kent Johnson
work correctly because the 'and' will always evaluate to "" which is False so the last term will be evaluated and returned: a = (a == "yes") and "" or "stop" and IMO the extra syntax needed to fix it isn't worth the trouble; just spell out the if / else. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: ANNOUNCE: xlrd 0.5.2 -- extract data from Excel spreadsheets

2006-03-19 Thread Kent Johnson
John Machin wrote: > On 19/03/2006 2:30 PM, Kent Johnson wrote: >>That didn't shed much light. I'm interested in your biased opinion, >>certainly you must have had a reason to write a new package. > > * It's not new. First public release was on 2005-05-15.

Re: Counting number of each item in a list.

2006-03-19 Thread Kent Johnson
e count. I expect Paul Rubin's solution will be dramatically faster for large lists as it only iterates str_list once. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: ** Operator

2006-03-20 Thread Kent Johnson
anguages write x^y instead of x**y). The way to make this change happen is to submit a bug report with your suggested change. See the link at the bottom of the above page to find out how. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Installing PyExcelerator to write Excel files from Python

2006-03-21 Thread Kent Johnson
correct files into site-packages. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Use of Python with GDAL. How to speed up ?

2006-03-22 Thread Kent Johnson
openness > function ? Do I have to separate the code into smaller functions ? Yes. The profiler collects statistics for functions, not for individual lines of code. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: struct size confusion:

2006-03-22 Thread Kent Johnson
d longs sent from C into Python > through a socket. > >Suppose I know I am getting 34 bytes, and the last 6 bytes are a 2-byte > word followed by a 4-byte int, how can I be assured that it will be in that > format? > >In a test, I am sending data in this format: > PACK_FORMAT = "HHHI" > which is 34 bytes Are you sure? Not for me: In [9]: struct.calcsize('HHHI') Out[9]: 36 Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: string.upto() and string.from()

2006-03-22 Thread Kent Johnson
it("45", 1)[-1] '6789' >> >># if not found, return whole string >> >>>"hello, world !".upto("#") >> >>"hello, world !" "hello, world !".split("#", 1)[0] 'hello, world !' >> >>>u"hello, world !".from("#") >> >>u"hello, world !" "hello, world !".rsplit("#", 1)[-1] 'hello, world !' Kent -- http://mail.python.org/mailman/listinfo/python-list

<    2   3   4   5   6   7   8   >