Blogmaker 0.5 - blog app for Django

2007-12-12 Thread Kent Johnson
PreFab Software has released Blogmaker (tm) 0.5, a full-featured, production-quality blogging application for Django. It supports trackbacks, ping and comments with moderation and honeypot spam prevention. Blogmaker is free, open-source software licensed under a BSD license. Blogmaker powers

Re: [csv module] duplication of end of line character in output file generated

2005-01-11 Thread Kent Johnson
simon.alexandre wrote: Hi all, I use csv module included in python 2.3. I use the writer and encouter the following problem: in my output file (.csv) there is a duplication of the end of line character, so when I open the csv file in Ms-Excel a blank line is inserted between each data line. From

Re: Python unicode

2005-01-11 Thread Kent Johnson
[EMAIL PROTECTED] wrote: Kent: I don't think so. You have hacked an attribute with latin-1 characters in it, but you haven't actually created an identifier. No, I really created an identifier. For instance I can create a global name in this way: globals()[è]=1 globals()[è] 1 Maybe I'm splitting

Re: xml parsing escape characters

2005-01-20 Thread Kent Johnson
Luis P. Mendes wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 this is the xml document: ?xml version=1.0 encoding=utf-8? string xmlns=http://www..;lt;DataSetgt; ~ lt;Ordergt; ~ lt;Customergt;439lt;/Customergt; (... others ...) ~ lt;/Ordergt; lt;/DataSetgt;/string This is an

Re: xml parsing escape characters

2005-01-20 Thread Kent Johnson
Irmen de Jong wrote: Kent Johnson wrote: [...] This is an XML document containing a single tag, string, whose content is text containing entity-escaped XML. This is *not* an XML document containing tags DataSet, Order, Customer, etc. All the behaviour you are seeing is a consequence

Re: Overloading ctor doesn't work?

2005-01-20 Thread Kent Johnson
Martin Häcker wrote: Hi there, I just tried to run this code and failed miserably - though I dunno why. Could any of you please enlighten me why this doesn't work? Here is a simpler test case. I'm mystified too: from datetime import datetime class time (datetime): def __init__(self, hours=0,

Re: Overloading ctor doesn't work?

2005-01-20 Thread Kent Johnson
Paul McGuire wrote: Kent Johnson [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Martin Häcker wrote: Hi there, I just tried to run this code and failed miserably - though I dunno why. Could any of you please enlighten me why this doesn't work? Here is a simpler test case. I'm mystified

Re: Overloading ctor doesn't work?

2005-01-21 Thread Kent Johnson
Nick Craig-Wood wrote: Martin Häcker [EMAIL PROTECTED] wrote: Now I thought, just overide the ctor of datetime so that year, month and day are static and everything should work as far as I need it. That is, it could work - though I seem to be unable to overide the ctor. :( Its a bug!

Re: Help with saving and restoring program state

2005-01-25 Thread Kent Johnson
Jacob H wrote: Hello list... I'm developing an adventure game in Python (which of course is lots of fun). One of the features is the ability to save games and restore the saves later. I'm using the pickle module to implement this. Capturing current program state and neatly replacing it later is

Re: fast list lookup

2005-01-26 Thread Kent Johnson
Klaus Neuner wrote: Hello, what is the fastest way to determine whether list l (with len(l)3) contains a certain element? If you can use a set or dict instead of a list this test will be much faster. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: re.search - just skip it

2005-01-26 Thread Kent Johnson
[EMAIL PROTECTED] wrote: Input is this: SET1_S_W CHAR(1) NOT NULL, SET2_S_W CHAR(1) NOT NULL, SET3_S_W CHAR(1) NOT NULL, SET4_S_W CHAR(1) NOT NULL, ; .py says: import re, string, sys s_ora = re.compile('.*S_W.*') lines = open(y.sql).readlines() for i in range(len(lines)): try: if

Re: Help With Python

2005-01-26 Thread Kent Johnson
Thomas Guettler wrote: # No comma at the end: mylist=[] for i in range(511): mylist.append(Spam) or just mylist = [Spam] * 511 Kent print , .join(mylist) Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Startying with Python, need some pointers with manipulating strings

2005-01-27 Thread Kent Johnson
Benji99 wrote: I've managed to load the html source I want into an object called htmlsource using: import urllib sock = urllib.urlopen(URL Link) htmlSource = sock.read() sock.close() I'm assuming that htmlSource is a string with \n at the end of each line. NOTE: I've become very accustomed

Re: Possible additions to the standard library? (WAS: About standardlibrary improvement)

2005-02-04 Thread Kent Johnson
Daniel Bickett wrote: |def reverse( self ): | |Return a reversed copy of string. | |string = [ x for x in self.__str__() ] |string.reverse() |return ''.join( string ) def reverse(self): return self[::-1] Kent --

Re: changing local namespace of a function

2005-02-05 Thread Kent Johnson
Bo Peng wrote: Dear list, I have many dictionaries with the same set of keys and I would like to write a function to calculate something based on these values. For example, I have a = {'x':1, 'y':2} b = {'x':3, 'y':3} def fun(dict): dict['z'] = dict['x'] + dict['y'] fun(a) and fun(b) will set

Re: changing local namespace of a function

2005-02-05 Thread Kent Johnson
Bo Peng wrote: Yes. I thought of using exec or eval. If there are a dozen statements, def fun(d): exec 'z = x + y' in globals(), d seems to be more readable than def fun(d): d['z'] = d['x'] + d['y'] But how severe will the performance penalty be? You can precompile the string using compile(),

Re: changing local namespace of a function

2005-02-05 Thread Kent Johnson
Bo Peng wrote: Exec is slow since compiling the string and calls to globals() use a lot of time. The last one is most elegant but __getattr__ and __setattr__ are costly. The 'evil hack' solution is good since accessing x and y takes no additional time. Previous comparison was not completely

Re: changing local namespace of a function

2005-02-06 Thread Kent Johnson
Bo Peng wrote: Kent Johnson wrote: You are still including the compile overhead in fun2. If you want to see how fast the compiled code is you should take the definition of myfun out of fun2: I assumed that most of the time will be spent on N times execution of myfunc. Doh! Right. Kent -- http

Subclassing cElementTree.Element

2005-02-07 Thread Kent Johnson
Is it possible to subclass cElementTree.Element? I tried import cElementTree as et class Elt(et.Element): ... pass ... Traceback (most recent call last): File stdin, line 1, in ? TypeError: Error when calling the metaclass bases cannot create 'builtin_function_or_method' instances I

Re: Big development in the GUI realm

2005-02-08 Thread Kent Johnson
Fredrik Lundh wrote: Robert Kern wrote: Fair enough. The only time I've seen it in dead-tree print was in Heinlein's _Time Enough For Love_, unattributed to anyone else. Amazon.com search inside the book finds no hits for malice in this book.

Re: Name of type of object

2005-02-10 Thread Kent Johnson
Jive Dadson wrote: I don't think I've quite got it. The application I'm writing has some similarities to an interactive shell. Like an interactive shell, it executes arbitrary code that it receives from an input stream. When it gets an exception, it should create an informative message,

Re: Is this a bug? BOM decoded with UTF8

2005-02-11 Thread Kent Johnson
Diez B. Roggisch wrote: I know its easy (string.replace()) but why does UTF-16 do it on its own then? Is that according to Unicode standard or just Python convention? BOM is microsoft-proprietary crap. Uh, no. BOM is part of the Unicode standard. The intent is to allow consumers of Unicode text

Re: changing __call__ on demand

2005-02-13 Thread Kent Johnson
Stefan Behnel wrote: Hi! This somewhat puzzles me: Python 2.4 (#1, Feb 3 2005, 16:47:05) [GCC 3.3.4 (pre 3.3.5 20040809)] on linux2 Type help, copyright, credits or license for more information. . class test(object): ... def __init__(self): ... self.__call__ = self.__call1 ... def

Re: Second posting - Howto connect to MsSQL

2005-02-13 Thread Kent Johnson
John Fabiani wrote: Hi, Since this is (sort of) my second request it must not be an easy solution. Are there others using Python to connect MsSQL? At the moment I'd accept even a windows solution - although, I'm looking for a Linux solution. On Windows, you can use

Re: Can't subclass datetime.datetime?

2005-02-14 Thread Kent Johnson
Grant Edwards wrote: Is it true that a datetime object can convert itself into a string, but not the other way around? IOW, there's no simple way to take the output from str(d) and turn it back into d? According to this thread, a patch has been checked in that adds strptime() to datetime. So

Re: Newbie help

2005-02-14 Thread Kent Johnson
Chad Everett wrote: Nope, I am trying to learn it on my own. I am using the book by Michael Dawson. You might be interested in the Python tutor mailing list which is specifically intended for beginners. http://mail.python.org/mailman/listinfo/tutor Kent --

Re: Newbie help

2005-02-14 Thread Kent Johnson
Kent Johnson wrote: You might be interested in the Python tutor mailing list which is specifically intended for beginners. http://mail.python.org/mailman/listinfo/tutor Ah, I don't mean to imply that this list is unfriendly to beginners, or that you are not welcome here! Just pointing out

Re: more os.walk() issues... probably user error

2005-02-16 Thread Kent Johnson
rbt wrote: rbt wrote: This function is intended to remove unwanted files and dirs from os.walk(). It will return correctly *IF* I leave the 'for fs in fs_objects' statement out (basically leave out the entire purpose of the function). It's odd, when the program goes into that statment... even

Re: more os.walk() issues... probably user error

2005-02-16 Thread Kent Johnson
rbt wrote: ## for fs in fs_objects: ## ##for f in fs[2]: ##if f in file_skip_list: ##print f ##fs[2].remove(f) ## ##for d in fs[1]: ##if d in dir_skip_list: ##print d ##

Re: Alternative to standard C for

2005-02-17 Thread Kent Johnson
James Stroud wrote: It seems I need constructs like this all of the time i = 0 while i len(somelist): if oughta_pop_it(somelist[i]): somelist.pop(i) else: i += 1 There has to be a better way... somelist[:] = [ item for item in somelist if not oughta_pop_it(item) ] Kent --

Re: need some advice on x y plot

2005-10-20 Thread Kent Johnson
[EMAIL PROTECTED] wrote: how ? i have tried to use unix timestamps, and i have also tried with DateTime objects do i need to use a scale that isn't linear (default in most) ? how do i putt this off ? Here is some code that works for me. It plots multiple datasets against time. The input

Re: sort problem

2005-10-20 Thread Kent Johnson
Michele Petrazzo wrote: Lasse Vågsæther Karlsen wrote: How about: list.sort(key=lambda x: x[3]) Better to use key=operator.itemgetter(3) Yes, on my linux-test-box it work, but I my developer pc I don't have the 2.4 yet. I think that this is a good reason for update :) or learn about

Re: Question on re.IGNORECASE

2005-10-20 Thread Kent Johnson
[EMAIL PROTECTED] wrote: Hi, I'm having some problems with basic RE in python. I was wondering whether somebody could provide a hint on what's going wrong with the following script. Comments are included. TIA. -myself python2.3 Python 2.3.4 (#1, Nov 18 2004, 13:39:30) [GCC 3.2.3

Re: ANN: Beginning Python (Practical Python 2.0)

2005-10-21 Thread Kent Johnson
Magnus Lie Hetland wrote: I guess it has actually been out for a while -- I just haven't received my copies yet... Anyways: My book, Beginning Python: From Novice to Professional (Apress, 2005) is now out. Apress is offering a $10 rebate if you purchase the book before October 30. See for

Re: Binding a variable?

2005-10-21 Thread Kent Johnson
Paul Dale wrote: Hi everyone, Is it possible to bind a list member or variable to a variable such that No, Python variables don't work that way. temp = 5 The name 'temp' is now bound to the integer 5. Think of temp as a pointer to an integer object with value 5. list = [ temp ] the

Re: need some advice on x y plot

2005-10-21 Thread Kent Johnson
[EMAIL PROTECTED] wrote: i am running a query on a database and making a list of time, value pairs kinda like this plot_points = ([time, value], [time, value], [time, value]) gnuplot complains that it needs a float for one of the values. i can plot just the value, and it shows up ( no x

Re: Redirect os.system output

2005-10-21 Thread Kent Johnson
jas wrote: I would like to redirect the output from os.system to a variable, but am having trouble. I tried using os.popen(..).read() ...but that doesn't give me exactly what i want. Here is an example using subprocess:

Re: Python vs Ruby

2005-10-21 Thread Kent Johnson
Casey Hawthorne wrote: I have heard, but have not been able to verify that if a program is about 10,000 lines in C++ it is about 5,000 lines in Java and it is about 3,000 lines in Python (Ruby to?) My experience is that Java:Python is roughly 2:1, the highest I have seen (on small bits of

Re: coloring a complex number

2005-10-21 Thread Kent Johnson
Arthur wrote: Spending the morning avoiding responsibilities, and seeing what it would take to color some complex numbers. class color_complex(complex): def __init__(self,*args,**kws): complex.__init__(*args) self.color=kws.get('color', 'BLUE') In

Re: Python vs Ruby

2005-10-21 Thread Kent Johnson
Bryan wrote: i would not say sion's ratio of 5:1 is dubious. for what it's worth, i've written i pretty complex program in jython over the last year. jython compiles to java source code and the number of generated java lines to the jython lines is 4:1. Ugh. The code generated by jythonc

Re: Module Importing Question

2005-10-22 Thread Kent Johnson
James Stroud wrote: Hello All, I have two modules that I use interchangably depending on the circumstances. These modules are imported by yet another module. I want the importation of these two alternatives to be mutually exclusive and dependent on the state of the outermost module A

Re: Question about inheritance...

2005-10-22 Thread Kent Johnson
KraftDiner wrote: This is what I've got so far: class Rect(Shape): def __init__(self): super(self.__class__, self).__init__() Should be super(Rect, self).__init__() def render(self): super(self.__class__, self).render() ditto In this example it

Re: Tricky Areas in Python

2005-10-24 Thread Kent Johnson
Steven D'Aprano wrote: Alex Martelli wrote: Those two are easy. However, and this is where I show my hard-won ignorance, and admit that I don't see the problem with the property examples: class Base(object) def getFoo(self): ... def setFoo(self): ... foo =

Re: High Order Messages in Python

2005-10-24 Thread Kent Johnson
[EMAIL PROTECTED] wrote: counting that out(regardless whether it is (dis)advantage or not), what else a block can do but not a named function ? My limited understanding is that the advantage is - simpler syntax - high level of integration into the standard library (*many* methods that take

Re: output from external commands

2005-10-24 Thread Kent Johnson
darren kirby wrote: quoth the James Colannino: So, for example, in Perl I could do something like: @files = `ls`; So I guess I'm looking for something similiar to the backticks in Perl. Forgive me if I've asked something that's a bit basic for this list. Any help would be greatly appreciated :)

Re: Redirect os.system output

2005-10-24 Thread Kent Johnson
of HELP commands to cmd.exe, captures the output of the commands and saves it to a file. What did I miss? Kent Kent Johnson wrote: jas wrote: I would like to redirect the output from os.system to a variable, but am having trouble. I tried using os.popen(..).read() ...but that doesn't give

Re: Redirect os.system output

2005-10-24 Thread Kent Johnson
jas wrote: Ok, I tried this... C:\python Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. import subprocess as sp p = sp.Popen(cmd, stdout=sp.PIPE) result = p.communicate(ipconfig) 'result' is

Re: XML Tree Discovery (script, tool, __?)

2005-10-26 Thread Kent Johnson
Istvan Albert wrote: All I can add to this is: - don't use SAX unless your document is huge - don't use DOM unless someone is putting a gun to your head +1 QOTW -- http://mail.python.org/mailman/listinfo/python-list

Re: Scanning a file

2005-10-28 Thread Kent Johnson
[EMAIL PROTECTED] wrote: I want to scan a file byte for byte for occurences of the the four byte pattern 0x0100. data = sys.stdin.read() print data.count('\x00\x00\x01\x00') Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: OEM character set issue

2005-10-28 Thread Kent Johnson
Dennis Lee Bieber wrote: On Fri, 28 Oct 2005 15:55:56 +0200, Ladvánszky Károly [EMAIL PROTECTED] declaimed the following in comp.lang.python: On my hungarian Win2k, some of the accented characters of the file names appear incorrectly when Python is driven from the command line. However, they

Re: extracting numbers from a file, excluding fixed words

2005-10-29 Thread Kent Johnson
dawenliu wrote: Hi, I have a file with this content: xxx xx x xxx 1 0 0 0 1 1 0 (many more 1's and 0's to follow) y yy yyy yy y yyy The x's and y's are FIXED and known words which I will ignore, such as This is the start of the file and This is

Re: Function returns none

2005-10-31 Thread Kent Johnson
[EMAIL PROTECTED] wrote: I'm trying to write a website updating script, but when I run the script, my function to search the DOM tree returns None instead of what it should. When you call findelement() recursively you have to return the value from the recursive call to the next caller up. See

Re: frozenset/subclassing/keyword args

2005-10-31 Thread Kent Johnson
Mark E. Fenner wrote: Speaking of which, in the docs at the bottom of the description of the builtin set/frozenset, there is a link to a page describing differences between the builtin sets and the sets module sets. This link is broken locally and on the python.org docs. Locally, it reads:

Re: Flat file, Python accessible database?

2005-11-01 Thread Kent Johnson
Karlo Lozovina wrote: I've been Googling around for _small_, flat file (no server processes), SQL-like database which can be easily access from Python. Speed and perforamnce are of no issue, most important is that all data is contained within single file and no server binary has to run in

Re: Object-Relational Mapping API for Python

2005-11-02 Thread Kent Johnson
Aquarius wrote: I explored Java's Hibernate a bit and I was intrigued by how you can map entity objects to database tables, preserving all the relations and constraits. I am interested if there is something like this for Python - I noticed some APIs in the Cheeseshop, but most of them were

Re: Learning multiple languages (question for general discussion)

2005-11-03 Thread Kent Johnson
John Salerno wrote: I thought it might be interesting to get some opinions on when you know when you're done learning a language. I've been learning C# for a few months (albeit not intensively) and I feel I have a good grasp of the language in general. Never? When you move on? You can

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

Re: Calling Class' Child Methods

2005-11-05 Thread Kent Johnson
Steve Holden wrote: Andrea Gavana wrote: The class Custom has a lot of methods (functions), but the user won't call directly this class, he/she will call the MainClass class to construct the GUI app. However, all the methods that the user can call refer to the Custom class, not the

Re: re sub help

2005-11-05 Thread Kent Johnson
[EMAIL PROTECTED] wrote: hi i have a string : a = this\nis\na\nsentence[startdelim]this\nis\nanother[enddelim]this\nis\n inside the string, there are \n. I don't want to substitute the '\n' in between the [startdelim] and [enddelim] to ''. I only want to get rid of the '\n' everywhere

Re: modifying source at runtime - jython case

2005-11-05 Thread Kent Johnson
Jan Gregor wrote: Hello folks I want to apply changes in my source code without stopping jython and JVM. Preferable are modifications directly to instances of classes. My application is a desktop app using swing library. Can you be more specific? Python and Jython allow classes to be

Re: modifying source at runtime - jython case

2005-11-06 Thread Kent Johnson
Jan Gregor wrote: my typical scenario is that my swing application is running, and i see some error or chance for improvement - modify sources of app, stop and run application again. so task is to reload class defitions (from source files) and modify also existing instances (their methods).

Re: Pylab and pyserial plot in real time

2005-11-06 Thread Kent Johnson
[EMAIL PROTECTED] wrote: Hiya, I've got a PIC microcontroller reading me humidity data via rs232, this is in ASCII format. I can view this data easily using hyperterminal or pyserial and convert it to its value (relative humidty with ord(input)) But what im trying to do is plot the data

Re: need help extracting data from a text file

2005-11-07 Thread Kent Johnson
[EMAIL PROTECTED] wrote: Hey there, i have a text file with a bunch of values scattered throughout it. i am needing to pull out a value that is in parenthesis right after a certain word, like the first time the word 'foo' is found, retrieve the values in the next set of parenthesis (bar) and

Re: Regular expression question -- exclude substring

2005-11-07 Thread Kent Johnson
[EMAIL PROTECTED] wrote: Hi, I'm having trouble extracting substrings using regular expression. Here is my problem: Want to find the substring that is immediately before a given substring. For example: from 00 noise1 01 noise2 00 target 01 target_mark, want to get 00 target 01 which

Re: Regular expression question -- exclude substring

2005-11-07 Thread Kent Johnson
James Stroud wrote: On Monday 07 November 2005 16:18, [EMAIL PROTECTED] wrote: Ya, for some reason your non-greedy ? doesn't seem to be taking. This works: re.sub('(.*)(00.*?01) target_mark', r'\2', your_string) The non-greedy is actually acting as expected. This is because non-greedy

Confusion about __call__ and attribute lookup

2005-11-10 Thread Kent Johnson
I am learning about metaclasses and there is something that confuses me. I understand that if I define a __call__ method for a class, then instances of the class become callable using function syntax: class Foo(object): ... def __call__(self): ... print 'Called Foo' ... f=Foo()

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

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 docs? Maybe somewhere in here :-( http://www.python.org/doc

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: generate HTML

2005-11-15 Thread Kent Johnson
Jim wrote: Perhaps you are trying to do this: 'text to go here: %s' % ('text',) ? For that you need a double-quoted string: text to go here: %s % ('text',) Uh, no, not in Python: 'text to go here: %s' % ('text',) 'text to go here: text' text to go here: %s % ('text',) 'text to go

Re: Need advice on subclassing code

2005-11-15 Thread Kent Johnson
Rusty Shackleford wrote: Hi -- We have some code that returns an object of a different class, depending on some parameters. For example: if param x is 1 and y is 1, we make an object of class C_1_1. if param x is 1 and y is 2, we make an object of class C_1_2. C_1_1 and C_1_2 share a

Re: searching for files on Windows with Python

2005-11-17 Thread Kent Johnson
Shane wrote: I've been giving Google a good workout with no luck. I would like to be able to search a Windows filesystem for filenames, returning a list off absolute paths to the found files, something like: def findFiles(filename, pathToSearch): ... ... return

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 path module, it seems to be a fairly common idiom

Re: Web-based client code execution

2005-11-20 Thread Kent Johnson
Stephen Kellett wrote: In message [EMAIL PROTECTED], Steve [EMAIL PROTECTED] writes AJAX works because browsers can execute javascript. I don't know of a browser that can execute python. Basically your stuck with java or javascript because everything else really isn't cross platform.

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

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, not sure about TCL. See http://groups.google.com/group

Re: Web-based client code execution

2005-11-21 Thread Kent Johnson
Paul Watson wrote: My desire to have the code distributed through a web page is just to ensure that the user is running the correct version and has not hacked it in any way. I suppose I can checksum the local client application and compare it with what is on the server. Then, make a way

Persist a class (not an instance)

2005-11-25 Thread Kent Johnson
Is there a way to persist a class definition (not a class instance, the actual class) so it can be restored later? A naive approach using pickle doesn't work: import pickle class Foo(object): ... def show(self): ... print I'm a Foo ... p = pickle.dumps(Foo) p

Re: Python book for a non-programmer

2005-11-25 Thread Kent Johnson
Simon Brunning wrote: I have a non-programming friend who wants to learn Python. It's been so long since I've been in her shoes that I don't feel qualified to judge the books aimed at people in her situation. Python Programming for the absolute beginner

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 reference, so the same restrictions in the unpickling

Re: Looking for good beginner's tutorial

2005-11-29 Thread Kent Johnson
Roy Smith wrote: My wife wants to learn Python. Can anybody suggest a good tutorial for her to read? She's a PhD molecular biologist who is a pretty advanced Unix user. She mucks about with Perl scripts doing things like text processing and even some simple CGI scripts, but has no formal

Re: string slicing

2004-12-05 Thread Kent Johnson
Ishwor wrote: s = 'hello' m = s[:] m is s True I discussed the *is* operator with some of the pythoners before as well but it is somewhat different than what i intended it to do. The LP2E by Mark David says - m gets a *full top-level copy* of a sequence object- an object with the same value but

Re: string slicing

2004-12-05 Thread Kent Johnson
Ishwor wrote: On Sun, 05 Dec 2004 09:44:13 -0500, Kent Johnson [EMAIL PROTECTED] wrote: This behaviour is due to the way strings are handled. In some cases strings are 'interned' which lets the interpreter keep only a single copy of a string. If you try it with a list you get a different result

Re: Import a module without executing it?

2004-12-07 Thread Kent Johnson
Jay O'Connor wrote: The real question, I suppose, is what is a good technique to find what modules and classes implement or refer to particular names You might like to try ctags. I have had a good experience with it. It's not as automatic as I would like - you have to build a cross-reference

Re: Import a module without executing it?

2004-12-08 Thread Kent Johnson
Andy, this is a nice example. It prompted me to look at the docs for compiler.visitor. The docs are, um, pretty bad. I'm going to attempt to clean them up a little. Would you mind if I include this example? Thanks, Kent Andy Gross wrote: Here's a quick example that will pull out all functions

Re: converting html escape sequences to unicode characters

2004-12-09 Thread Kent Johnson
harrelson wrote: I have a list of about 2500 html escape sequences (decimal) that I need to convert to utf-8. Stuff like: #48708; #54665; #44592; #47196; #48372; #45244; #44144; #50640; #50836; #45236; #47732; #44552; #51060; #50620; #47560; #51648; #51104; Anyone know what the decimal is

Re: gather information from various files efficiently

2004-12-13 Thread Kent Johnson
Keith Dart wrote: try: dict[a].append(b) except KeyError: dict[a] = [b] or my favorite Python shortcut: dict.setdefault(a, []).append(b) Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: getopt: Make argument mandatory

2004-12-16 Thread Kent Johnson
Frans Englich wrote: On Wednesday 15 December 2004 14:07, Diez B. Roggisch wrote: In my use of getopt.getopt, I would like to make a certain parameter mandatory. I know how to specify such that a parameter must have a value if it's specified, but I also want to make the parameter itself

Re: Wrapper objects

2004-12-10 Thread Kent Johnson
Nick Coghlan wrote: Simon Brunning wrote: This work - http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52295? Only for old-style classes, though. If you inherit from object or another builtin, that recipe fails. Could you explain, please? I thought __getattr__ worked the same with new-

Re: How do I convert characters into integers?

2004-12-14 Thread Kent Johnson
Markus Zeindl wrote: I have got a string from the user, for example Hi!. Now I get every character with a loop: code buffer = for i in range(len(message)): ch = message[i-1:i] for ch in message: ... is simpler and more idiomatic. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Jython performance

2004-12-23 Thread Kent Johnson
Sean Blakey wrote: On Wed, 22 Dec 2004 17:03:55 -0200, Gabriel Cosentino de Barros [EMAIL PROTECTED] wrote: On the Best GUI for small-scale accounting app? tread some people mentioned jython. I went to read about it, but i was wondering if anyone has any real project done with it and can give real

Re: mathmatical expressions evaluation

2004-12-23 Thread Kent Johnson
Tonino wrote: thanks all for the info - and yes - speed is not really an issue and no - it is not an implementation of a complete financial system - but rather a small subset of a investment portfolio management system developed by another company ... What I am trying to achieve is to parse a

Re: Lambda going out of fashion

2004-12-23 Thread Kent Johnson
Robin Becker wrote: Alex Martelli wrote: . By the way, if that's very important to you, you might enjoy Mozart (http://www.mozart-oz.org/) .very interesting, but it wants to make me install emacs. :( Apparently you can also use oz with a compiler and runtime engine...see

Re: Jython IronPython Under Active Development?

2004-12-27 Thread Kent Johnson
Steve Holden wrote: Just a little further background. The Python Software Foundation recently awarded a grant to help to bring Jython into line with the current CPython release. Is information publicly available about this and other PSF grants? I don't see any announcement on the PSF web site

Re: The Industry choice

2005-01-04 Thread Kent Johnson
Alex Martelli wrote: Roy Smith [EMAIL PROTECTED] wrote: Stefan Axelsson [EMAIL PROTECTED] wrote: Yes, ignoring most of the debate about static vs. dynamic typing, I've also longed for 'use strict'. You can use __slots__ to get the effect you're after. Well, sort of; it only works for instance

Re: Tkinter: passing parameters to menu commands

2005-01-07 Thread Kent Johnson
Philippe C. Martin wrote: I have many menu items and would like them all to call the same method -However, I need the method called to react differently depending on the menu item selected. Since the menu command functions do not seem to receive any type of event style object, is there some type

Re: Tkinter: passing parameters to menu commands

2005-01-08 Thread Kent Johnson
Philippe C. Martin wrote: menu.add_cascade(label=File, menu=filemenu) filemenu.add_command(label=New, command=lambda: callback('New')) filemenu.add_command(label=Open..., command=lambda: Of course you could do this with named forwarding functions if you prefer I'm not sure what 'named forwarding

Re: Speed revisited

2005-01-09 Thread Kent Johnson
Andrea Griffini wrote: I've to admit that I also found strange that deleting the first element from a list is not O(1) in python. My wild guess was that the extra addition and normalization required to have insertion in amortized O(1) and deletion in O(1) at both ends of a random access sequence

Re: Please Contribute Python Documentation!

2005-01-09 Thread Kent Johnson
Aahz wrote: In article [EMAIL PROTECTED], Tony Meyer [EMAIL PROTECTED] wrote: I don't think I've seen such a statement before - the stuff I've seen all indicates that one should be submitting proper LaTeX docs/patches. If plain-text contributions are welcome, could this be added to the doc about

Re: How to list currently defined classes, methods etc

2005-12-02 Thread Kent Johnson
Deep wrote: I have been looking a bit and am stuck at this point. Given a string, how do i find what is the string bound to. Let me give an example. def deep(): print Hello now inspect.ismethod(deep) returns true. (As it should). But if I am trying to make a list of all bound

  1   2   3   4   5   6   7   >