Re: Detect character encoding

2005-12-05 Thread Kent Johnson
Martin P. Hellwig wrote: I read or heard (can't remember the origin) that MS IE has a quite good implementation of guessing the language en character encoding of web pages when there not or falsely specified. Yes, I think that's right. In my experience MS Word does a very good job of

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

2005-12-05 Thread Kent Johnson
Nic Bar wrote: The problem with Jython is that I can only live inside the aplet virtual machine, Only if you are writing an applet. I need a full features application with access to the local computer resources. You can do this with Jython and JWS. Write your app in Jython, deploy with

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

2005-12-05 Thread Kent Johnson
Renato wrote: What use is Java WebStart, exactly? It's a way to deploy a Java app from a web site. Assuming the user has Java installed, the app can be launched just by clicking a link on a web page. The jar files are cached locally so they are only downloaded once, the user can make desktop

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: Documentation suggestions

2005-12-07 Thread Kent Johnson
Steve Holden wrote: BartlebyScrivener wrote: Now you are on a page with promising-looking links that all start with BeginnersGuide, but the first three are not warm welcomes, they are housekeeping matters about where you can take courses or how to download Python for people who don't know

Re: Mutability of function arguments?

2005-12-08 Thread Kent Johnson
Mike Meyer wrote: ex_ottoyuhr [EMAIL PROTECTED] writes: I'm trying to create a function that can take arguments, say, foo and bar, and modify the original copies of foo and bar as well as its local versions -- the equivalent of C++ funct(foo, bar). C++'s '' causes an argument to be passed

Re: Encoding of file names

2005-12-08 Thread Kent Johnson
utabintarbo wrote: Here is my situation: I am trying to programatically access files created on an IBM AIX system, stored on a Sun OS 5.8 fileserver, through a samba-mapped drive on a Win32 system. Not confused? OK, let's move on... ;-) When I ask for an os.listdir() of a relevant

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 it. Here are some immediate suggestions: Good

Re: Another newbie question

2005-12-08 Thread Kent Johnson
Steven D'Aprano wrote: On Wed, 07 Dec 2005 23:58:02 -0500, Mike Meyer wrote: 1) The stmt board.Blist[10].DrawQueen(board.Blist[10].b1) seems awkward. Is there another way (cleaner, more intuitive) to get the same thing done? Yes. Reaching through objects to do things is usually a bad idea.

Re: How to detect the presence of a html file

2005-12-09 Thread Kent Johnson
Phoe6 wrote: Operating System: Windows Python version: 2.4 I have bookmarks.html and wumpus.c under my c: When I tried to check the presence of the bookmarks.html, I fail. os.path.isfile('c:\bookmarks.html') False os.path.isfile('c:\wumpus.c') True The problem is that \ is

Re: Catching error text like that shown in console?

2005-12-09 Thread Kent Johnson
Peter A. Schott wrote: I know there's got to be an easy way to do this - I want a way to catch the error text that would normally be shown in an interactive session and put that value into a string I can use later. I've tried just using a catch statement and trying to convert the output to

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 to use forward slashes instead: os.path.isfile('c:/bookmarks.html

Re: Proposal: Inline Import

2005-12-09 Thread Kent Johnson
Shane Hathaway wrote: Mike Meyer wrote: Shane Hathaway [EMAIL PROTECTED] writes: That syntax is verbose and avoided by most coders because of the speed penalty. What speed penalty? import re is a cheap operation, every time but the first one in a program. I'm talking about using

Re: newby question: Splitting a string - separator

2005-12-09 Thread Kent Johnson
James Stroud wrote: The one I like best goes like this: py data = Guido van Rossum Tim Peters Thomas Liesner py names = [n for n in data.split() if n] py names ['Guido', 'van', 'Rossum', 'Tim', 'Peters', 'Thomas', 'Liesner'] I think it is theoretically faster (and more pythonic)

Re: Managing import statements

2005-12-10 Thread Kent Johnson
Jean-Paul Calderone wrote: On Sat, 10 Dec 2005 02:21:39 -0700, Shane Hathaway [EMAIL PROTECTED] wrote: How about PyLint / PyChecker? Can I configure one of them to tell me only about missing / extra imports? Last time I used one of those tools, it spewed excessively pedantic warnings.

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* Python 2.1, though you will have to run

Re: First practical Python code, comments appreciated

2005-12-14 Thread Kent Johnson
planetthoughtful wrote: Hi All, I've written my first piece of practical Python code (included below), and would appreciate some comments. My situation was that I had a directory with a number of subdirectories that contained one or more zip files in each. Many of the zipfiles had the same

Re: Worthwhile to reverse a dictionary

2005-12-15 Thread Kent Johnson
[EMAIL PROTECTED] wrote: What is the difference between d1 = {'A' : '1', 'B' : '2', 'C' : '3'} and d1 = dict(A = 1, B = 2, C = 3) ? All of the dictionary examples I saw (python.org, aspn.activestate.com, Learning Python by Lutz, among others) use d={'x' : 'y'}. The second

Re: Python newbie needs help

2005-12-15 Thread Kent Johnson
Ron Hudson wrote: I am trying to create something like a MUD, It will eventually evolve to a multi player MUD over the network game, but for now it's just a platform for authoring and playing text adventures that works like a single user MUD. You might Google python text adventure game

Re: ?: in Python

2005-12-15 Thread Kent Johnson
Andy Leszczynski wrote: How can do elegantly in Python: if condition: a=1 else: a=2 like in C: a=condition?1:2 a = condition and A or B is concise but will fail if A can evaluate as false, e.g. a = condition and None or 2 # won't do what you want I tend to use 'condition and

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

2005-12-16 Thread Kent Johnson
[EMAIL PROTECTED] wrote: This was my point though: I found the *description* - but no wordon WHICH implementation to get WHERE ? Hmm. - Browse to http://www.python.org - click Documentation - click Database API - click Database Modules (Database modules that implement the DB-API

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

2005-12-16 Thread Kent Johnson
[EMAIL PROTECTED] wrote: OK, point taken - maybe what threw me off was the simple fact that there CAN be NO ONE standard/default SQL package. As a newbie in sql I was hoping to find something like e.g. the socket module (one size fits all) So: Maybe this could be explained on the Database

Re: How to use pydoc?

2005-12-16 Thread Kent Johnson
[EMAIL PROTECTED] wrote: Thanks for replying Peter, but none of your suggestions are working. S:\projects\C2PC\srcpython -m Unknown option: -m usage: python [option] ... [-c cmd | file | -] [arg] ... The -m option was added in Python 2.4, you must have an older version (though your OP

Re: What is unique about Python?

2005-12-19 Thread Kent Johnson
gsteff wrote: I'm a computer science student, and have recently been trying to convince the professor who teaches the programming language design course to consider mentioning scripting languages in the future. Along those lines, I've been trying to think of features of Python, and scripting

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

2005-12-20 Thread Kent Johnson
Luis M. Gonzalez wrote: The only problem with KARRIGELL, I guess, is that its creator is very humble and doesn't like to advertise his creature. He is not very fond of marketing ... From my point of view the biggest problem with Karrigell is that it is released under the GPL. Most of my

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

2005-12-20 Thread Kent Johnson
Luis M. Gonzalez wrote: I don't think Pierre (Karrigell's creator) is awared of licenses and legal issues. Perhaps you can tell us what's the problem with GPL and, if possible, propose an alternative... OK I'll try. First let me say I have no interest in a licensing flame war, there are

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 needed to keep proprietary, I did make

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 section 2.b) reads, You must cause any work that you distribute

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

2005-12-21 Thread Kent Johnson
Steve Holden wrote: Paul Rubin wrote: I'm trying to avoid flame wars too, but my take on this is that Kent's reading is a little too restrictive and the GPL isn't really a problem in this situation unless he's actually modifying Karrigell itself, rather than writing applications that run

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

2005-12-21 Thread Kent Johnson
Steven D'Aprano wrote: On Wed, 21 Dec 2005 03:37:27 -0800, Neuruss wrote: x = '15' if x.isdigit(): print int(x)*3 15 is not a digit. 1 is a digit. 5 is a digit. Putting them together to make 15 is not a digit. Maybe so, but '15'.isdigit() == True: isdigit(...) S.isdigit() -

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 is compiled with Karrigell. Karrigell is a library

Re: Easiest way to calculate number of character in string

2005-12-21 Thread Kent Johnson
P. Schmidt-Volkmar wrote: Hi there, I have a string in which I want to calculate how often the character ';' occurs. If the character does not occur 42 times, the ; should be added so the 42 are reached. My solution is slow and wrong: How can this be achieved easily? Is this

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 to consider using Karrigell in my work. I recently needed a Kent stand-alone web server

Re: pyUnit and dynamic test functions

2005-12-21 Thread Kent Johnson
Sakcee wrote: Hi I am trying to use pyUnit to create a framework for testing functions I am reading function name, expected output, from a text file. Can you show a sample of what the text file might look like, and what tests you want to generate from it? and in python generating

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 GPL on a library instead

Re: Guido at Google

2005-12-22 Thread Kent Johnson
Cameron Laird wrote: While I don't understand the question, it might be pertinent to observe that, among open-source development projects, Python is unusual for the *large* number of forks or alternative imple- mentations it has supported through the years URL:

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

2005-12-22 Thread Kent Johnson
A.M. Kuchling wrote: On 20 Dec 2005 15:05:15 -0800, Michael Tobis [EMAIL PROTECTED] wrote: Python people don't really think that way. As a community we really seem to inherit the open source dysfunction of trying harder to impress each other than to reach out to the rest of the world.

Re: jython: True and False boolean literals?

2005-12-22 Thread Kent Johnson
[EMAIL PROTECTED] wrote: Aren't there boolean literals for True and False in Python (jython)? I can't get true, True, false, or False to work. I ended up having to use (1==1) and (1==0). No, there are not. Jython implements Python 2.1 which did not have boolean literals. You can just use 1

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

2005-12-22 Thread Kent Johnson
planetthoughtful wrote: I think that would be a great solution if the value being 'edited' was relatively short, or numeric, etc. But the values I want to 'edit' can be several hundred characters long (ie they're text fields containing todo notes), and using your method, I'd either accept the

Re: A simple list question.

2005-12-22 Thread Kent Johnson
KraftDiner wrote: I am trying to implement a two dimensional array. mylist = [[a,b,c],[d,e,f,c],[g,h,i]] So the array is of length 3 here... So how do I initialize this array and then set each object? At some point in my code I know there will be 3 lists in the list. So how do I initialize

Re: serialize object in jython, read into python

2005-12-22 Thread Kent Johnson
py wrote: I want to serialize an object in jython and then be able to read it in using python, and vice versa. Any suggestions on how to do this? pickle doesnt work, nor does using ObjectOutputStream (from jython). I prefer to do it file based ...something like pickle.dump(someObj,

Re: File object question

2005-12-22 Thread Kent Johnson
S. D. Rose wrote: Hello all. If I read a binary file: file = open('c:\\logo.gif', 'rw'') # Read from FS as one way to get the object, d/l from website another... file.read() is there anyway I can determine the 'size' of the object file? (Without going to the filesystem and reading the

Re: GUI and graph

2005-12-22 Thread Kent Johnson
questions? wrote: I have a graph with different parameters along different parts of the graph. I want to have a program that can display the graph with coloring for different part of the graph. Is this possible in Python? What should I read? pydot is pretty amazing in its abilitity to make

Re: The Varieties of Pythonic Experience

2005-12-22 Thread Kent Johnson
Robert Hicks wrote: You mean Jython is still going? ; ) Yes, I see the smiley but there are too many is Jython dead? posts on the Jython lists for me to leave this alone... Jython is going strong. Thanks to Brian Zimmer and a grant from PSF it is under active development again and working

Re: sorting with expensive compares?

2005-12-23 Thread Kent Johnson
[EMAIL PROTECTED] wrote: Dan Stromberg wrote: Python appears to have a good sort method, but when sorting array elements that are very large, and hence have very expensive compares, is there some sort of already-available sort function that will merge like elements into a chain, so that they

Re: Humane programmer interfaces

2005-12-23 Thread Kent Johnson
Dave Benjamin wrote: There's been a lot of discussion lately regarding Ruby and the notion of a humane interface to objects like arrays and maps, as opposed to minimalist ones. I believe the article that started the debates was this one by Martin Fowler:

Re: Detect File System changes

2005-12-23 Thread Kent Johnson
Lukas Meyer wrote: Hello, I'm trying to detect changes in a directory. E.g if someone crates a file, i'll execute another function on this file. I tried to solve this by creating a loop that permanently checks the contents of this directory with os.listdir() and compares it with the one

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

2005-12-23 Thread Kent Johnson
Wolfgang Grafen wrote: Everybody is using the cheeseshop now: http://cheeseshop.python.org/pypi?%3Aaction=browse Everybody excluding me. Looks like a huge pile of cheese thrown above a table. Sorry, I don't find what I am looking for. Can somebody explain the improvement over

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

2005-12-24 Thread Kent Johnson
planetthoughtful wrote: My intention is to build a GUI for this app, yes, but given that I'm about a week old in my learning of Python, I thought a command-line app was a better place to start. I had thought to build GUIs in wxPython - is Tkinter any easier to learn? Tkinter is quite easy

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

2005-12-28 Thread Kent Johnson
[EMAIL PROTECTED] wrote: sorry guys, here is the code for incident in bs('a', {'class' : 'price'}): price = for oText in incident.fetchText( oRE): price += oText.strip() + ',' for incident in bs('div', {'class' : 'store'}): store =

Re: urllib http status codes

2005-12-28 Thread Kent Johnson
Alvin A. Delagon wrote: Greetings! Is there any way I can obtain the HTTP status codes when using the urllib module? As of now I can only think of doing a regex on the result of the read(). Thanks in advance! ^_^ If you connect with httplib you get the status code directly from the

Re: Passing cgi parameters to script...

2005-12-30 Thread Kent Johnson
Diez B. Roggisch wrote: sophie_newbie wrote: Is there any way that I can pass cgi parameters to my script locally, before i upload it to the webserver, so that i can debug it. You might think of using CGIHttpServer to test your scripts in a server-environment - while still being local.

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

2005-12-30 Thread Kent Johnson
[EMAIL PROTECTED] wrote: hey mike-the sample code was very useful. have 2 questions when i use what you wrote which is listed below i get told unboundlocalerror: local variable 'product' referenced before assignment. You would get this error if you have a tr that doesn't have an hr

Re: how to scrape url out of href

2006-01-02 Thread Kent Johnson
[EMAIL PROTECTED] wrote: mike's code worked like a charm. i have one more question. i have an href which looks like this: td class=all a class=btn name=D1 href=http://www.cnn.com; /a i thought i would use this code to get the href out but it fails, gives me a keyerror:

Re: About zipfile on WinXP

2006-01-02 Thread Kent Johnson
rzed wrote: I create a zip file on my WinXP system, using this function: fn import zipfile import os import os.path def zipdir(dirname, zfname): zf = zipfile.ZipFile(zfname, 'w', zipfile.ZIP_DEFLATED) for root, dirs, files in os.walk(dirname): for f in files:

Re: regular expression or parser ?

2006-01-03 Thread Kent Johnson
Forced_Ambitions wrote: Hi, I m a novice to python..I m stuck in a problem and need some help. i m trying to extract data between the line start operation and the line stop operation from a txt file. and then to fill it under different columns of an excel sheet. A simple stateful

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 use IMO. Kent --

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

2006-01-06 Thread Kent Johnson
livin wrote: my log... INFO urllib.urlopen('http://192.168.1.11/hact/kitchen.asp', urllib.urlencode({'Action': 'hs.ExecX10ByName+Kitchen+Lights%2C+On %2C+100x=4y=6'})) INFO INFO File Q:\python\python23.zlib\urllib.py, line 78, in urlopen INFO File Q:\python\python23.zlib\urllib.py,

Re: question about mutex.py

2006-01-07 Thread Kent Johnson
Jean-Paul Calderone wrote: Did you read the module docstring? Of course, no multi-threading is implied -- hence the funny interface for lock, where a function is called once the lock is aquired. If you are looking for a mutex suitable for multithreaded use, see the threading

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

2006-01-07 Thread Kent Johnson
. 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: my log... INFO urllib.urlopen('http://192.168.1.11/hact/kitchen.asp', urllib.urlencode({'Action

Re: Newbie with some doubts.

2006-01-07 Thread Kent Johnson
Edgar A. Rodriguez wrote: Hi everybody, Im newbie to Python (I found it three weeks ago) , in fact Im newbie to programming. I'm being reading and training with the language, but I still wondering about what Classes are used to. Could you please give me some examples?? This essay gives

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

2006-01-13 Thread Kent Johnson
[EMAIL PROTECTED] wrote: Thanks to everyone who posted comments or put some thought into this problem. I should have been more specific with what I want to do, from your comments the general case of this problem, while I hate to say impossible, is way more trouble than it's worth. By

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! Kent --

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 have more details (a reference to a page

Re: Escaping certain characters

2005-09-10 Thread Kent Johnson
Jan Danielsson wrote: Robert Kern wrote: [---] Hmm... On second thought, I need to escape more characters. Is there no other way to escape characters in strings? Which characters? I need to escape '\n', '', '[' and ']'. I finally went with a few of these: string.replace('\n',

Re: help in simplification of code [string manipulation]

2005-09-13 Thread Kent Johnson
John wrote: How could I simplify the code to get libs out of LDFLAGS or vice versa automatically in the following python/scons code? if sys.platform[:5] == 'linux': env.Append (CPPFLAGS = '-D__LINUX') env.Append (LDFLAGS = '-lglut -lGLU -lGL -lm')

Re: Python Search Engine app

2005-09-14 Thread Kent Johnson
gene tani wrote: Yes, there's a bunch. Google for query parser + python, porter stemming stopwords text indexer. Maybe lucene has some python bindings, hmm? At least two Python versions of Lucene: http://pylucene.osafoundation.org/ http://divmod.org/projects/lupy Kent Harlin Seritt

Re: optimizing out getattr

2005-09-15 Thread Kent Johnson
Peter Otten wrote: Daishi Harada wrote: I'd like to get the 'get2' function below to perform like the 'get1' function (I've included timeit.py results). labels = ('a', 'b') def get1(x): return (x.a, x.b) def mkget(attrs): def getter(x): return tuple(getattr(x, label)

Re: Classes derived from dict and eval

2005-09-21 Thread Kent Johnson
Jeremy Sanders wrote: Hi - I'm trying to subclass a dict which is used as the globals environment of an eval expression. For instance: class Foo(dict): def __init__(self): self.update(globals()) self['val'] = 42 def __getitem__(self, item):

Re: unittest setup

2005-09-30 Thread Kent Johnson
paul kölle wrote: hi all, I noticed that setUp() and tearDown() is run before and after *earch* test* method in my TestCase subclasses. I'd like to run them *once* for each TestCase subclass. How do I do that. One way to do this is to make a TestSuite subclass that includes your startup

Re: Not defined

2005-10-01 Thread Kent Johnson
Rob wrote: When trying the basic tutorial for cgkit I always seem to get a not defined error as follows. Pythonwin GUI from cgkit import * Sphere() Traceback (most recent call last): File interactive input, line 1, in ? NameError: name 'Sphere' is not defined Which version of

Re: Will python never intend to support private, protected andpublic?

2005-10-03 Thread Kent Johnson
Mike Meyer wrote: Paul Rubin http://[EMAIL PROTECTED] writes: That's not what privilege separation means. It means that the privileged objects stay secure even when the unprivileged part of the program is completely controlled by an attacker. In which case, what's private got to do with this?

Re: Nicer way of strip and replace?

2005-10-11 Thread Kent Johnson
Markus Rosenstihl wrote: Hi, I wonder if i can make this nicer: euro=euro + float(string.replace(string.strip(rechnung[element][10], ''), ',' , '.')) You can use the str methods instead of functions from the string module: euro=euro + float(rechnung[element][10].strip('').replace(','

Re: are there internal functions for these ?

2005-10-11 Thread Kent Johnson
black wrote: hi all~ i wrote some functions for copying and moving files caz' i didnt find concret functions within the doc. but i think these operations are simple and important so there may be some internal ones i didnt know. anyone could figure me out ? See the os, os.path and shutil

Re: Python adodb

2005-10-12 Thread Kent Johnson
[EMAIL PROTECTED] wrote: In trying to use the adodb module, I have had good success. However I need to access a database with a username and password at this time. I have used a connection string like this to connect to MS SQL Server from adodb: connStrSQLServer = rProvider=SQLOLEDB.1; User

Re: Problem splitting a string

2005-10-15 Thread Kent Johnson
Alex Martelli wrote: Using sum on lists is DEFINITELY slow -- avoid it like the plague. If you have a list of lists LOL, DON'T use sum(LOL, []), but rather [x for x in y for y in LOL] Should be lol = [[1,2],[3,4]] [x for y in lol for x in y] [1, 2, 3, 4] The outer loop comes first.

Re: Problem splitting a string

2005-10-15 Thread Kent Johnson
Steven D'Aprano wrote: On Sat, 15 Oct 2005 10:51:41 +0200, Alex Martelli wrote: [ x for x in y.split('_') for y in z.split(' ') ] py mystr = 'this_NP is_VL funny_JJ' py [x for x in y.split('_') for y in mystr.split(' ')] Traceback (most recent call last): File stdin, line 1, in ?

Re: Outdated documentation

2005-10-17 Thread Kent Johnson
Laszlo Zsolt Nagy wrote: Is this the good place to post? Follow the About this document link at the bottom of any page of Python docs for information about submitting change requests. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: ordered keywords?

2005-10-17 Thread Kent Johnson
Ron Adam wrote: drawshapes( triangle=3, square=4, color=red, polygon(triangle, color), polygon(square, color) ) This comes close to the same pattern used in SVG and other formats where you have definitions before expressions. Why is this better than the obvious

Re: unittest of file-reading function

2005-10-18 Thread Kent Johnson
Helge Stenstroem wrote: Say I have a function def f(filename): result = openFileAndProcessContents(filename) return result Can that function be unit tested without having a real file as input? If you can refactor openFileAndProcessContents() so it looks like this: def

Re: [newbie]Is there a module for print object in a readable format?

2005-10-19 Thread Kent Johnson
Micah Elliott wrote: On Oct 20, Steven D'Aprano wrote: That's not what I get. What are you using? py pprint.pprint([1,2,3,4,[0,1,2], 5], width=1, indent=4) Traceback (most recent call last): File stdin, line 1, in ? TypeError: pprint() got an unexpected keyword argument 'width' I find

Re: parser question

2005-10-19 Thread Kent Johnson
Micah Elliott wrote: You might be able to tackle this easily enough with REs if your structures don't nest arbitrarily. It's hard to tell if this deserves a formal grammar based on the example. If it does, you could try PLY http://www.dabeaz.com/ply/ (which I've had a pleasant experience

Re: Python variables are bound to types when used?

2005-10-19 Thread Kent Johnson
[EMAIL PROTECTED] wrote: So I want to define a method that takes a boolean in a module, eg. def getDBName(l2): ... Now, in Python variables are bound to types when used, right? Eg. x = 10 # makes it an INT whereas x = hello # makes it a string You don't have it quite right. In each

Re: Access from one class to methode of other class

2005-05-26 Thread Kent Johnson
VK wrote: On Thu, 26 May 2005 14:33:45 +0200, VK myname@example.invalid declaimed the following in comp.lang.python: Hi, all! In my programm i have to insert a variable from class 2 to class 1 and I get error NameError: global name 'd' is not defined. How do I get access to

Re: using timeit for a function in a class

2005-05-26 Thread Kent Johnson
flupke wrote: Hi, i tried to use timeit on a function in a class but it doesn't do what i think it should do ie. time :) In stead it starts printing line after line of hello time test! What am i doing wrong in order to time the f function? Hmm, by default Timer.timeit() calls the

Re: Help with choice of suitable Architecture

2005-05-28 Thread Kent Johnson
Rob Cowie wrote: I agree with the sentiments that a single XML file is not the way to go for storing data that may be accessed concurrently. However, my hands are tied. You might like to see the thread write to the same file from multiple processes at the same time? for a preview of the

Re: write html-headers (utf-8)

2005-05-30 Thread Kent Johnson
db wrote: Hello all, I hope this is the correct newsgroup for this question. Does anybody know how I can write a html-header with python(cgi)? The problem is, I have a few html templates in which I have a header e.g: !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN

Re: Is pyunit still usable?

2005-05-30 Thread Kent Johnson
could ildg wrote: I want to know something about unittest these days, and since I'm learning python, I want to touch it through python. But when I found the newest pyunit is even so old, I wonder if it is still usable for current python version 2.4. Will you please tell me? Thank you.

Re: how to prepend string to a string?

2005-05-30 Thread Kent Johnson
flamesrock wrote: so I know you can append a string. But how do you *prepend* a string, as shown in the following code #dirList = ['depth1','depth2','depth3'] #string = position #for x in len(dirList): # string += ' %s'%dirList.pop()#() # to return position depth1

Re: scripting browsers from Python

2005-05-31 Thread Kent Johnson
Simon Brunning wrote: On 31 May 2005 00:52:33 -0700, Michele Simionato [EMAIL PROTECTED] wrote: I would like to know what is available for scripting browsers from Python. I don't know of anything cross platform, or even cross browser, but on Windows, IE can be automated via COM - see

Re: regular expression problem

2005-05-31 Thread Kent Johnson
[EMAIL PROTECTED] wrote: hi everyone there is a way, using re, to test (for es) in a=[a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14] if a list b is composed by three sublists of a separated or not by elements. if b=[a2,a3,a4,a7,a8,a12,a13] gives true because in a we have

Re: Newbie Here

2005-06-01 Thread Kent Johnson
Mark Sargent wrote: Hi All, I'm taking the plunge into Python. I'm currently following this tutorial, http://docs.python.org/tut/ I am not a programmer in general, although I've learnt a bit of bash scripting and some php/asp. I want to get into python to use it for Linux/Unix related

Re: optparse.py: FutureWarning error

2005-06-03 Thread Kent Johnson
Terry Reedy wrote: kosuke [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] man python --- COMMAND LINE OPTIONS This should REALLY be on the doc page of the Python site. Hear, hear! I never even knew this existed! Where should it go in the docs? In the Language Reference or

Re: optparse.py: FutureWarning error

2005-06-03 Thread Kent Johnson
Terry Reedy wrote: Kent Johnson [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Terry Reedy wrote: kosuke [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] man python --- COMMAND LINE OPTIONS This should REALLY be on the doc page of the Python site. Hear, hear! I

Re: For review: PEP 343: Anonymous Block Redux and Generator Enhancements

2005-06-04 Thread Kent Johnson
Robin Becker wrote: Ilpo Nyyssönen wrote: with locking(mutex), opening(readfile) as input: ... with EXPR as x: BLOCK EXPR can be a tuple so the above would be ambiguous. I don't think EXPR can be a tuple; the result of evaluating EXPR must have __enter__() and __exit__()

Re: how to get name of function from within function?

2005-06-04 Thread Kent Johnson
Christopher J. Bottaro wrote: Steven Bethard wrote: [...snip...] Yes, has's suggestion is probably the right way to go here. I'm still uncertain as to your exact setup here. Are the functions you need to wrap in a list you have? Are they imported from another module? A short clip of your

Re: Newbie Python XML

2005-06-04 Thread Kent Johnson
LenS wrote: I have a situation at work. Will be receiving XML file which contains quote information for car insurance. I need to translate this file into a flat comma delimited file which will be imported into a software package. Each XML file I receive will contain information on one quote

Re: csv and iterator protocol

2005-06-04 Thread Kent Johnson
Philippe C. Martin wrote: Can I initialize csv with input data stored in RAM (ex: a string) ? - so far I cannot get that to work. Or to rephrase the question, what Python RAM structure supports the iterator protocol ? Many, including strings, lists and dicts. For your needs, a list of strings

Re: Iterate through a list calling functions

2005-06-05 Thread Kent Johnson
David Pratt wrote: Hi. I am creating methods for form validation. Each validator has its own method and there quite a number of these. For each field, I want to evaluate errors using one or more validators so I want to execute the appropriate validator methods from those available. I am

Re: Iterate through a list calling functions

2005-06-05 Thread Kent Johnson
George Sakkis wrote: That's a typical case for using an OO approach; just make a class for each validator and have a single polymorphic validate method (I would make validators __call__able instead of naming the method 'validate'): # Abstract Validator class; not strictly necessary but good

<    1   2   3   4   5   6   7   >