Re: how to find not the next sibling but the 2nd sibling or find sibling "a" OR sinbling "b"

2006-01-19 Thread Kent Johnson
iful Soup. The value in the attribute dictionary can be a callable; try this: def isFoodOrDrink(attr): return attr in ['food', 'drink'] b = incident.findNextSibling('div', {'class': isFoodOrDrink}) Alternately you could omit the class spec and check for it in code. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: another docs problem - imp

2006-01-13 Thread Kent Johnson
Fredrik Lundh wrote: > Kent Johnson wrote: >>Is there such a list? I have contributed many doc patches and if such >>glory is mine I would like to know it! > > unfortunately, your name don't seem to be mentioned in the Doc version > history either: > > do you

Re: another docs problem - imp

2006-01-13 Thread Kent Johnson
Steve Holden wrote: > Clearly. So get your sleeves rolled up and provide a fix. Then you too > will get your name in the Python documentation contributors' list. Is there such a list? I have contributed many doc patches and if such glory is mine I would like to know it! Ke

Re: How can I make a dictionary that marks itself when it's modified?

2006-01-13 Thread Kent Johnson
tr, value): ... print 'foo.__setattr__' ... object.__setattr__(self, attr, value) ... >>> f=foo() >>> f.x = 3 foo.__setattr__ >>> def new_setattr(attr, value): ... print 'new_setattr' ... >>> f.__setattr__ = new_setattr foo.__setattr__ >>> f.y=3 foo.__setattr__ still calls foo.__setattr__() Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie with some doubts.

2006-01-07 Thread Kent Johnson
examples?? This essay gives some simple suggestions of when and why you might want to use classes: http://www.pycs.net/users/0000323/stories/15.html Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Help Please: 'module' object has no attribute 'compile'

2006-01-07 Thread Kent Johnson
module by that name. In this case your module doesn't have a compile attribute. This would cause the error you see. Kent > > > "Kent Johnson" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >>livin wrote: >> >>>

Re: question about mutex.py

2006-01-07 Thread Kent Johnson
e the > threading module. I have always seen mutexes used in multi-threaded programs. I'm curious, what is the usefulness of a non-thread-safe mutex? I'm sure it must be good for something, I just can't figure it out. Thanks, Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Help Please: 'module' object has no attribute 'compile'

2006-01-06 Thread Kent Johnson
'compile' That line reads _typeprog = re.compile('^([^/:]+):') Do you have a module named 're' that is shadowing the library module of the same name? Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Python based Compiler tools

2006-01-06 Thread Kent Johnson
Doru-Catalin Togea wrote: > Hi! > > I have some experience with PLY. What other alternatives are there, and > which is the "best" (that is most feature rich, easiest to use, ...)? Here is a list: http://www.nedbatchelder.com/text/python-parsers.html pyparsing is easy to u

Re: Microsoft IronPython?

2006-01-04 Thread Kent Johnson
le for production use for many years. The Groovy community was still working on the *language definition* in November 2005 and has yet to deliver a stable final release. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: regular expression or parser ?

2006-01-03 Thread Kent Johnson
not needed. If you can live with CSV output instead of XLS then see the csv module for the processing part. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: About zipfile on WinXP

2006-01-02 Thread Kent Johnson
27; or '..' then you are including them in the zip. Try something like fullname = os.path.join(root, f)[len(dirname):] to get relative paths in the zip - WinZip puts empty entries for directories in the zip. Maybe WinXP requires these. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: how to scrape url out of href

2006-01-02 Thread Kent Johnson
t; > any idea what i'm doing wrong here with the syntax? thanks in advance > ISTM that is a child of , not a sibling, and findNextSibling is a method, not an indexable element. Try n = incident('a', {'class': 'btn'}) link = n['href'] + "','" Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: help with lists and writing to file in correct order

2005-12-30 Thread Kent Johnson
#x27;tr'): print row and expand from there. At each step use print statements to make sure you are finding the data you expect. Kent if i however chnage row to incident in "for incident in > bs('tr'):" i then get mytuples printed out nicely but once again get a >

Re: Passing cgi parameters to script...

2005-12-30 Thread Kent Johnson
ronment - while still being local. Which can be as simple as typing python -c "import CGIHTTPServer; CGIHTTPServer.test()" from the command line in the root dir of your site (the dir that contains the cgi-bin dir). Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: urllib http status codes

2005-12-28 Thread Kent Johnson
rectly from the response object. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: help with lists and writing to file in correct order

2005-12-28 Thread Kent Johnson
', {'id' : 'food'}): > food = "" > for oText in incident.fetchText( oRE): > food += oText.strip() + "','" > I would use a loop that finds the row for a single item with something like for item in bs('tr', {'class' : 'base'}): then inside the loop fetch the values for store, food and price for that item and write them to your output file. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Providing 'default' value with raw_input()?

2005-12-24 Thread Kent Johnson
> learn? Tkinter is quite easy to use for simple apps. Pythoncard is a layer on top of wxPython that makes it easier to use, you might want to look at that. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Vaults of Parnassus hasn't been updated for months

2005-12-23 Thread Kent Johnson
nd user interface is also much better. Where is the > search button, where can I find the latest additions? If you go to the main cheeseshop page http://cheeseshop.python.org/pypi?%3Aaction=home there is a search link, you can view by categories, and it shows the last 20 additions. There is also

Re: Detect File System changes

2005-12-23 Thread Kent Johnson
.listdir() and compares it with the > one before. But this isn't really working properly. > > Can anyone give me a hint to get this working? We just had a thread on this topic: http://groups.google.com/group/comp.lang.python/browse_frm/thread/b8808c14ecd333ab/ca7110a977

Re: Desc of packages for XML processing

2005-12-23 Thread Kent Johnson
e. > > Here we go: > > OPTIONS > = > - libxml2 > - lxml > - Pyxml > - 4Suite Also ElementTree, Amara > > lxml > - > Disadvantages > == - No Windows release to date :-( Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: "Humane" programmer interfaces

2005-12-23 Thread Kent Johnson
I think this is one of the great strengths of Python - that those who create the language have been able to discover very powerful, general concepts and apply them broadly and consistently to solve a variety of problems. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: sorting with expensive compares?

2005-12-23 Thread Kent Johnson
y what the OP is trying to avoid. If there is some function of the arrays which sorts in the same order as the natural comparison then that function can be used as a sort key. sort(arrayList, key=some_proxy_function) Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: The Varieties of Pythonic Experience

2005-12-22 Thread Kent Johnson
ent again and working towards compatibility with CPython 2.3. And of course the current 2.1 release is extremely stable and usable as is. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: GUI and graph

2005-12-22 Thread Kent Johnson
g in its abilitity to make nice, readable renderings of graph data. http://dkbza.org/pydot.html Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: File object question

2005-12-22 Thread Kent Johnson
of the object file? (Without > going to the filesystem and reading the filesize from the directory ...) Once you have read the data you can get the size of that: d = file.read() print len(d) Is that what you mean? Otherwise I don't know how you can get the size of a file without asking

Re: serialize object in jython, read into python

2005-12-22 Thread Kent Johnson
p 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import pickle >>> class Foo: ... pass ... >>> f=open('pickle.txt') >>> lst = pickle.load(f) >>> f.close() >>> lst ['hello world', (0, 1, 2, 3, 4, 5, 6, 7, 8, 9), {'a': 1, 'c': 3, 'b': 2}, <__main__.Foo instance at 0x00A51350>] >>> Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: A simple list question.

2005-12-22 Thread Kent Johnson
ist. > So how do I initialize this list such that I can access them > as elements... like > mylist[1] = [c,f,g] > in random order... If you can separate the code into a list builder and a list client, maybe the builder can just use append and the client can use indexing. Kent --

Re: Providing 'default' value with raw_input()?

2005-12-22 Thread Kent Johnson
e presented as the 'default', available for editing. For fields that long I think a GUI is more appropriate than trying to use command-line editing. You might take a look at easygui - it's textbox is readonly but it looks like it wouldn't be hard to make it editable - or

Re: jython: True and False boolean literals?

2005-12-22 Thread Kent Johnson
(1==0)". No, there are not. Jython implements Python 2.1 which did not have boolean literals. You can just use 1 and 0. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Which Python web framework is most like Ruby on Rails?

2005-12-22 Thread Kent Johnson
ut Python. The hard part for me is getting them to believe me enough to try Python for themselves. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Guido at Google

2005-12-22 Thread Kent Johnson
http://phaseit.net/claird/comp.lang.python/python_varieties.html >. If you are maintaining that page - JPython is now called Jython and has a web site at http://www.jython.org. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Which Python web framework is most like Ruby on Rails?

2005-12-21 Thread Kent Johnson
Paul Rubin wrote: > [Kent Johnson] > Where would you draw the line? Suppose I want to use a GPLed library > in my Python code, does that mean I have to distribute my code under > the GPL if I distribute them together? > > Yes, that's the point of using the G

Re: pyUnit and dynamic test functions

2005-12-21 Thread Kent Johnson
tLength= lambda : self.assertEqual( len(returnedVals) > , len(inp) ) I don't understand the above at all. What do function_call, function_returnedVals, returnedVals and inp refer to? What is the point of the lambdas and the assignment to attributes of (undefined) self? Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Which Python web framework is most like Ruby on Rails?

2005-12-21 Thread Kent Johnson
Martin Christensen wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > >>>>>>"Kent" == Kent Johnson <[EMAIL PROTECTED]> writes: > > Kent> [Karrigell is GPL'ed] Unfortunately this makes it impossible for > Kent> me

Re: Easiest way to calculate number of character in string

2005-12-21 Thread Kent Johnson
> > How can this be achieved easily? Is this homework? str.count() and string multiplication are your friends here. See http://docs.python.org/lib/string-methods.html http://docs.python.org/lib/typesseq.html Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Which Python web framework is most like Ruby on Rails?

2005-12-21 Thread Kent Johnson
Paul Rubin wrote: > Kent Johnson <[EMAIL PROTECTED]> writes: > >>You've lost me here. The server certainly would contain Karrigell >>code, it wouldn't function without it. I don't understand the analogy >>to GCC, the web site is not something that

Re: How to check if a string "is" an int?

2005-12-21 Thread Kent Johnson
make 15 is not a digit. Maybe so, but '15'.isdigit() == True: isdigit(...) S.isdigit() -> bool Return True if all characters in S are digits and there is at least one character in S, False otherwise. >>> '15'.isdigit() True though your other points ar

Re: Which Python web framework is most like Ruby on Rails?

2005-12-21 Thread Kent Johnson
se, at least. I have been avoiding GPL products at work for many years, much longer than Microsoft has been telling me to do so. > > In this case I agree there's likely to be a clear separation between > server and content that will allow Kent to distribute an unmodified > Karrig

Re: Which Python web framework is most like Ruby on Rails?

2005-12-20 Thread Kent Johnson
Paul Rubin wrote: > Kent Johnson <[EMAIL PROTECTED]> writes: >>>Remember that the GPL only applies to the code of Karrigell >>>itself, not to stuff that you write using it. >> >>IANAL but that is not my understanding of the GPL. GPL version 2 >>sect

Re: Which Python web framework is most like Ruby on Rails?

2005-12-20 Thread Kent Johnson
Paul Rubin wrote: > Kent Johnson <[EMAIL PROTECTED]> writes: > >>I chose CherryPy in part because its license allows this. I >>would have considered Karrigell if it had a different license. > > > Have you had to modify CherryPy in some substantive way that you

Re: Which Python web framework is most like Ruby on Rails?

2005-12-20 Thread Kent Johnson
ause its license allows this. I would have considered Karrigell if it had a different license. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Which Python web framework is most like Ruby on Rails?

2005-12-20 Thread Kent Johnson
under the GPL. Most of my projects at least have the potential of being distributed to customers and GPL is not an option. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: What is unique about Python?

2005-12-19 Thread Kent Johnson
useful features of prior > languages in an unusually pleasant way? IMO it is the latter. Most of the features of Python can be found in other languages. Not so many languages have them all. It is the combination of ease of use and power that makes Python stand out. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: How to use pydoc?

2005-12-16 Thread Kent Johnson
sion (though your OP shows 2.4.2...). Try python c:\python23\Lib\pydoc.py sys or whatever the correct path is to python on your system. > > I should also be able to run 'pydoc -g' to start a webserver. python c:\python23\Lib\pydoc.py -g or Start / Programs / Python 2.x / Module

Re: why does php have a standard SQL module and Python doesn't !?

2005-12-16 Thread Kent Johnson
ook, they > could be abandoned - hint: have a better homepage !!) This hint needs to go to the MySQL for Python folks, it's their home page. Kent > > Thanks, > Sebastian > -- http://mail.python.org/mailman/listinfo/python-list

Re: why does php have a standard SQL module and Python doesn't !?

2005-12-16 Thread Kent Johnson
DB-API specification.) - read list, find the database of your choice Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: ?: in Python

2005-12-15 Thread Kent Johnson
#x27;t do what you want I tend to use 'condition and A or B' if I'm sure A won't be false, otherwise just write out the if / else. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Python newbie needs help

2005-12-15 Thread Kent Johnson
uot;python text adventure game" if you want to build on others' work instead of starting from scratch. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Worthwhile to reverse a dictionary

2005-12-15 Thread Kent Johnson
examples I saw (python.org, aspn.activestate.com, > Learning Python by Lutz, among others) use d={'x' : 'y'}. > The second form is only available in Python 2.3 and newer, so any example that is older than that will use the first form. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: First practical Python code, comments appreciated

2005-12-14 Thread Kent Johnson
). Your usage will work for either, but your names are misnomers. > > filelist = listFiles(path) > for s in filelist: I would write for dirpath, dirnames, filenames in filelist: which gives names to what you call s[0] and s[2] or just for dirpath, dirnames, filenames in os.walk(path):

Re: Managing import statements

2005-12-10 Thread Kent Johnson
Jean-Paul Calderone wrote: > On Sat, 10 Dec 2005 13:40:12 -0500, Kent Johnson <[EMAIL PROTECTED]> >> Do any of these tools (PyLint, PyChecker, pyflakes) work with Jython? To >> do so they would have to work with Python 2.1, primarily... > > Pyflakes will *check* Pytho

Re: Managing import statements

2005-12-10 Thread Kent Johnson
(PyLint, PyChecker, pyflakes) work with Jython? To do so they would have to work with Python 2.1, primarily... Thanks, Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: newby question: Splitting a string - separator

2005-12-09 Thread Kent Johnson
27;Peters', 'Thomas', 'Liesner'] > > I think it is theoretically faster (and more pythonic) than using regexes. Unfortunately it gives the wrong result. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Proposal: Inline Import

2005-12-09 Thread Kent Johnson
ec per loop You need a lot of imports before 1 usec becomes "appreciable". And your proposal is doing the import anyway, just under the hood. How will you avoid the same penalty? Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: How to detect the presence of a html file

2005-12-09 Thread Kent Johnson
Peter Hansen wrote: > Kent Johnson wrote: > >> The simplest fix is to use raw strings for all your Windows path needs: >> os.path.isfile(r'c:\bookmarks.html') >> os.path.isfile(r'c:\wumpus.c') > > > Simpler still is almost always t

Re: Catching error text like that shown in console?

2005-12-09 Thread Kent Johnson
xc() If you want more control over the exception info - for example to put it in a string instead of printing it - look at the other functions in the traceback module. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: How to detect the presence of a html file

2005-12-09 Thread Kent Johnson
('\b') 1 >>> len('\w') 2 The simplest fix is to use raw strings for all your Windows path needs: os.path.isfile(r'c:\bookmarks.html') os.path.isfile(r'c:\wumpus.c') In raw strings the only \ escapes are \' and \", everything else is left alone. >>> len(r'\b') 2 >>> len(r'\w') 2 Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Another newbie question

2005-12-08 Thread Kent Johnson
>Yes. Reaching through objects to do things is usually a bad idea. > > > I don't necessarily disagree, but I don't understand why you say this. Why > it is bad? http://en.wikipedia.org/wiki/Law_of_Demeter Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Documentation suggestions

2005-12-08 Thread Kent Johnson
A.M. Kuchling wrote: > On Wed, 07 Dec 2005 12:10:18 -0500, > Kent Johnson <[EMAIL PROTECTED]> wrote: > >>OK I'll bite. That Beginners Guide page has bugged me for a long time. >>It's a wiki page but it is marked as immutable so I can't change

Re: Encoding of file names

2005-12-08 Thread Kent Johnson
o these files, but am unable, since > python (on Win32, at least) does not recognize this as a valid > filename. Just to eliminate the obvious, you are calling os.path.join() with the parent name before calling isfile(), yes? Something like for f in os.listdir(someDir): fp = os.path.jo

Re: Mutability of function arguments?

2005-12-08 Thread Kent Johnson
, from the point of view of a C++ programmer, Python passes references by value. In other words if you think of variables as pointers (references) to values, and function call as passing the reference by value, the behaviour of Python makes sense. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Documentation suggestions

2005-12-07 Thread Kent Johnson
an Gauld's tutorial is very popular on the tutor list, so is A Byte of Python (which is not listed on the NonProgrammers page). I would list them first. Or maybe take a vote on the tutor list for favorite beginner's tutorial. That should help a little, maybe we won't confuse the

Re: Is there an equivalent to Java Webstart in Python?

2005-12-06 Thread Kent Johnson
Ravi Teja wrote: > Hi Kent, > Too complicated example :-). Jythonc works just fine to create a > regular jar file that you can reference in your jnlp file. If it works for you, good. I have never been able to compile a real app with jythonc and I gave up on it long ago. Kent

Re: Is there an equivalent to Java Webstart in Python?

2005-12-05 Thread Kent Johnson
desktop and Start menu shortcuts for the app, and you can update users automatically by deploying new jars to the web server. It's pretty nice and largely trouble-free. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there an equivalent to Java Webstart in Python?

2005-12-05 Thread Kent Johnson
deploy with JWS, be happy, go home early ;) I have some notes about it here: http://personalpages.tds.net/~kent37/Python/JythonWebStart.html Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Detect character encoding

2005-12-05 Thread Kent Johnson
a very good job of guessing the encoding of text files. Kent -- http://mail.python.org/mailman/listinfo/python-list

CDDB.py binaries for Python 2.4

2005-12-04 Thread Kent Tenney
nt binaries for this package? Thanks, Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: How to list currently defined classes, methods etc

2005-12-02 Thread Kent Johnson
27;] > How do I obtain the reference to the method it is bound to. > The same problem can be extended to attributes and classes. Use getattr() to inspect classes and instances: >>> class deeper: ... def deepest(self): ... print 'goodbye' ... >>> getattr(deeper, 'deepest') >>> d=deeper() >>> getattr(d, 'deepest') > Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Looking for good beginner's tutorial

2005-11-29 Thread Kent Johnson
ripts, but has no > formal programming training. http://wiki.python.org/moin/BeginnersGuide/NonProgrammers Kent -- http://mail.python.org/mailman/listinfo/python-list

No apos in htmlentitydefs

2005-11-28 Thread Kent Johnson
: http://www.w3.org/TR/xhtml1/dtds.html#a_dtd_Special_characters and AFAIK it is commonly supported by browsers which IMO argues that it should be included. Any thoughts? Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Persist a class (not an instance)

2005-11-25 Thread Kent Johnson
Sybren Stuvel wrote: > Kent Johnson enlightened us with: > >>Is there a way to persist a class definition (not a class instance, >>the actual class) so it can be restored later? > > > From the docs: > > "Similarly, classes are pickled by named refere

Re: Python book for a non-programmer

2005-11-25 Thread Kent Johnson
://premierpressbooks.com/ptr_detail.cfm?group=Programming&isbn=1%2D59200%2D073%2D8 Python Programming: An Introduction to Computer Science http://www.fbeedle.com/99-6.html And the Introductory Books page in the wiki lists many: http://wiki.python.org/moin/IntroductoryBooks Kent -- http://mail.python

Persist a class (not an instance)

2005-11-25 Thread Kent Johnson
= self.find_class(module, name) File "C:\Python24\lib\pickle.py", line 1140, in find_class klass = getattr(mod, name) AttributeError: 'module' object has no attribute 'Foo' The idea is to persist classes that are created and modified at runtime. Thanks, Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Web-based client code execution

2005-11-21 Thread Kent Johnson
t hacking. My Jython and Web Start recipe is here: http://personalpages.tds.net/~kent37/Python/JythonWebStart.html Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Web-based client code execution

2005-11-20 Thread Kent Johnson
Paul Watson wrote: > Kent Johnson wrote: >> Stephen Kellett wrote: >>> ActiveState do a version of Python that can run in a script tag like >>> JavaScript and VBScript. This requires Windows Scripting Host. They >>> also do a similar thing for Perl, n

Re: Is there a way to create a button in either pygame or livewires?

2005-11-20 Thread Kent Johnson
Nathan Pinno wrote: > Hey all, > > Is there a way to create a button in either pygame or livewires, that is > able to be clicked and when clicked sends a command to restart the program? Maybe something here: http://www.pygame.org/wiki/gui Kent -- http://mail.python.org/mailman/lis

Re: Web-based client code execution

2005-11-20 Thread Kent Johnson
t because everything else really isn't cross platform. > > > ActiveState do a version of Python that can run in a script tag like > JavaScript and VBScript. This requires Windows Scripting Host. They also > do a similar thing for Perl, not sure about TCL. See http://gro

Re: searching for files on Windows with Python

2005-11-19 Thread Kent Johnson
Peter Hansen wrote: > Kent Johnson wrote: >> import path >> files = path.path(pathToSearch).walkfiles(filename) > > A minor enhancement (IMHO) (though I certainly agree with Kent's > recommendation here): since there is nothing else of interest in the > "

Re: searching for files on Windows with Python

2005-11-17 Thread Kent Johnson
path.path objects in pathToSearch whose names match filename (which is a glob so wildcards are recognized). path.path is a subclass of str so the results can be used wherever you want the full path. http://www.jorendorff.com/articles/python/path/index.html Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Need advice on subclassing code

2005-11-15 Thread Kent Johnson
u could have a factory like this: import C def makeC(x, y): subtype = 'C_%d_%d' % (x, y) cls = getattr(C, subtype, C.C) return cls(x, y) Then in module C just define the subtypes you need to specialize; all other values of x and y will get the base class C.C. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: generate HTML

2005-11-15 Thread Kent Johnson
% ('text',) 'text to go here: text' >>> "text to go here: %s" % ('text',) 'text to go here: text' Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Book

2005-11-13 Thread Kent Johnson
David Rasmussen wrote: > What is the best book for Python newbies (seasoned programmer in other > languages)? I like Learning Python. Python in a Nutshell is good if you want something brief. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Confusion about __call__ and attribute lookup

2005-11-13 Thread Kent Johnson
John J. Lee wrote: > Kent Johnson <[EMAIL PROTECTED]> writes: > >>Leif K-Brooks wrote: >> >>>New-style classes look up special methods on the class, not on the instance: >> >>For my future reference, is this documented somewhere in the standard doc

Re: Confusion about __call__ and attribute lookup

2005-11-10 Thread Kent Johnson
Leif K-Brooks wrote: > New-style classes look up special methods on the class, not on the instance: For my future reference, is this documented somewhere in the standard docs? Thanks, Kent -- http://mail.python.org/mailman/listinfo/python-list

Confusion about __call__ and attribute lookup

2005-11-10 Thread Kent Johnson
tax is handled internally, or do all special methods work this way, or is there something else going on? PS Is there any place in the standard Python docs where the details of attribute lookup are spelled out? Thanks, Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Regular expression question -- exclude substring

2005-11-07 Thread Kent Johnson
noise1 01 noise2 00 target 01'] >>> rgx = re.compile(r"(00.*?01) target_mark") >>> rgx.findall('00 noise1 01 noise2 00 target 01 target_mark 00 dowhat 01') ['00 noise1 01 noise2 00 target 01'] Since target_mark only occurs once in the string the greedy and non-greedy match is the same in this case. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Regular expression question -- exclude substring

2005-11-07 Thread Kent Johnson
e bit between the numbers then use everything-but-that instead of . - for example if spaces can only appear as you show them, use "(00 [^ ]* 01) target_mark" or "(00 \S* 01) target_mark" Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: need help extracting data from a text file

2005-11-07 Thread Kent Johnson
oo(bar)').group(1) 'bar' >>> fooRe.search('This is a foo bar baz blah blah (bar)').group(1) 'bar' Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Pylab and pyserial plot in real time

2005-11-06 Thread Kent Johnson
e drawn. I don't know if it will work incrementally if you call show() in the loop. Kent > > thank you in advance > > David > > > > import serial > from pylab import * > > ser = ser

Re: modifying source at runtime - jython case

2005-11-06 Thread Kent Johnson
nstances (their methods). Ok, I think my first reply completely missed the mark. IIUC what you want is hard. This recipe might help: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/160164 Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: modifying source at runtime - jython case

2005-11-05 Thread Kent Johnson
0b19b37ac48deaa/e599041de4b8feb0?rnum=22#e599041de4b8feb0 Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: re sub help

2005-11-05 Thread Kent Johnson
if text == 'enddelim': self.delimiterSeen = False return text if self.delimiterSeen: return text return '' delimRe = re.compile('\n|startdelim|enddelim') newText = delimRe.sub(subber(), a) print repr(newText) Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Calling Class' Child Methods

2005-11-05 Thread Kent Johnson
ames: for method in [ 'SomeMethod', 'SomeOtherMethod' ]: setattr(self, method, getattr(self.customwidget, method)) This gives you more control over which methods are delegated - if there are some Custom methods that you do *not* want to expose in MainClass this might be a better approach. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: How can I do this in Python?

2005-11-05 Thread Kent Johnson
Lad wrote: > Can you please explain in more details (1) choice? If you are using CGI you might be interested in the VoidSpace logintools which seems to handle much of this process. See http://www.voidspace.org.uk/python/logintools.html#no-login-no-access Kent -- http://mail.python.org/mail

Re: Learning multiple languages (question for general discussion)

2005-11-03 Thread Kent Johnson
. Never? When you move on? You can become proficient in a couple of months but that is different from "expert" which is different from "knows everything there is to know". I have been using Python for several years and I still learn from the old hands in this news group. Ken

Re: Object-Relational Mapping API for Python

2005-11-02 Thread Kent Johnson
hop", but most of them were alpha, > better, or seemed to be forsaken a long time ago. Can you recommend me > anything? > SQLObject, PyDO, Durus and Django's database API. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Flat file, Python accessible database?

2005-11-01 Thread Kent Johnson
binary has to run in order to use the > dbase. Oh, and I'm using Python under Cygwin. Depending on what you mean by "SQL-like" you might like KirbyBase http://www.netpromi.com/kirbybase.html Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: frozenset/subclassing/keyword args

2005-10-31 Thread Kent Johnson
. for information on suggesting changes." If you click the link there it will tell you how to submit a doc bug which is the best way to get this fixed. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Function returns none

2005-10-31 Thread Kent Johnson
next caller up. See example below. Kent > > I have this program: > > import sys > from xml.dom.minidom import parse > > > # search the tree for an element with a particular class > > def findelement(current, classtofind, topnode = None): > if topnode

<    1   2   3   4   5   6   7   8   >