how to arrange classes in .py files?

2009-03-26 Thread Kent
not sure about the right code structure of python oop. Can anyone give some hint on it? would be great with reason. Thanks in advance. regards, Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: modifying a list element from a function

2009-03-27 Thread Kent
> * to do the same modification on the list "a" within a function > * not to hardcode in this function the position of the string in each >>> a = [ [4, "toto"], [5, "cou"] ] >>> def assign(element,pos,newValue): ... element[pos]=newValue ... >>> assign(a[0],1,'xxx') >>> print a [[4, 'xxx'],

Re: how to arrange classes in .py files?

2009-03-27 Thread Kent
On Mar 27, 3:01 pm, "David L. Jones" wrote: > On Mar 26, 8:51 pm, Kent wrote: > > > ... Is > > there any convention how to manage python classes into .py files? > > > ... > > In above packages, each .py file contains one python class. And > > C

question about wxpython CtrlList event binder: wx.EVT_LIST_ITEM_RIGHT_CLICK

2009-04-21 Thread Kent
uot;empty area" of the lc, nothing happened, no popup menu. I tested under WINXP, the function was not triggered at all when I right-clicked on the "empty area". I tried to bind wx.EVT_RIGHT_DOWN(UP) to the lc, but the function cannot be triggered under Linux. any suggestion? Thanks re

Re: question about wxpython CtrlList event binder: wx.EVT_LIST_ITEM_RIGHT_CLICK

2009-04-21 Thread Kent
#this is the function def onTagMgmt(self,event): tagId = event.GetData() # following codes are omitted. just some business logic stuff. checking the tagId, making decision of showing popup menu items... Kent On Apr 21, 11:24 pm, Mike Driscoll wrote: > On Apr 21, 3:35 pm,

WINXP vs. LINUX in threading.Thread

2009-04-22 Thread Kent
hello all, i want to add a "new update notification" feature to my wxPython appl. The codes below do the job. The logic is simple enough, I don't think it needs to be explained. since sometimes, under windows, proxy setting was a script. and was set in IE. In this case, connecting to the HTML wil

Re: WINXP vs. LINUX in threading.Thread

2009-04-23 Thread Kent
Thanx you guys. Now my program is working. I used the Thread subclass. and at the end of the run method, i call wx.CallAfter(mainFrame.somefunction, para) to show the dialog or change some text. I tested in winxp&linux. both worked. Kent On Apr 23, 6:16 am, Carl Banks wrote: > On Ap

Re: Generators and propagation of exceptions

2011-04-09 Thread Kent Johnson
le Error object which implements the required methods at each level to just return self. I don't know if this really works when you start nesting but perhaps it is worth a try. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: optparse eats $

2011-04-19 Thread Michael Kent
Try this on your *nix command line: echo ">$100" On a *nix command line, the '$1' part of ">$100" will be seen as 'give me the value of the shell variable "1"', and since it has no value, will result in an empty string. So it's not optparse, or Python, because the literal string you intend to

Re: skipping one unittest assertion?

2011-05-01 Thread Michael Kent
I agree that each test should test only one 'thing', but it's also true that testing one 'thing' sometimes/often involves multiple assertions. But in the OP's case, it does sound like the assertion he wants to skip should be broken out into its own test. -- http://mail.python.org/mailman/listi

Re: portable multiprocessing code

2011-05-17 Thread Michael Kent
You could also install Python 2.7 on that RedHat machine. It can be done without interfering with the 2.5 that RedHat depends on. -- http://mail.python.org/mailman/listinfo/python-list

Re: Obtaining a full path name from file

2011-05-24 Thread Michael Kent
If a filename does not contain a path component, os.path.abspath will prepend the current directory path onto it. -- http://mail.python.org/mailman/listinfo/python-list

free python course materials for high school students available

2016-08-09 Thread Kent Tong
Hi, I've taught a python course with some positive results to high school students with zero experience in programming. Now I am making these course materials (slides in English and lecture videos in Cantonese) freely available as a contribution back to the community (http://www.istudycenter.o

training materials and learning environment for teaching kids python available

2018-08-31 Thread Kent Tong
Hi all, This is a set of training materials I used to successfully teach Python to kids as little as 10 years old. It was a success because the kids didn't just finish the course, they independently completed most of the coding challenges by applying the knowledge they had learned. The first f

can't add variables to instances of built-in classes

2016-07-17 Thread Kent Tong
Hi, I can add new variables to user-defined classes like: >>> class Test: ... pass ... >>> a=Test() >>> a.x=100 but it doesn't work if the instances belong to a built-in class such as str or list: >>> a='abc' >>> a.x=100 Traceback (most recent call last): File "", line 1, in Attribu

Re: can't add variables to instances of built-in classes

2016-07-17 Thread Kent Tong
Hi Peter, Thanks a lot for your excellent explanation! -- https://mail.python.org/mailman/listinfo/python-list

Why not allow empty code blocks?

2016-07-22 Thread Kent Tong
Hi I'm aware that we can use 'pass' as an empty code block. But why doesn't python allow a code block to be empty and thus eliminate the need for this null statement? thanks in advance -- https://mail.python.org/mailman/listinfo/python-list

Re: Why not allow empty code blocks?

2016-07-22 Thread Kent Tong
On Saturday, July 23, 2016 at 9:49:51 AM UTC+8, Steven D'Aprano wrote: > Because it cannot tell the difference between an empty code block and > failing to indent the code block: > > for x in sequence: > print('loop') Thanks for the excellent answer! -- https://mail.python.org/mailman/listinfo/

Interactively online Python learning environment freely available

2020-01-28 Thread Kent Tong
Hi, I've made an online python learning environment available at https://p4kweb.appspot.com Please take a look and let me know what you think :-) -- https://mail.python.org/mailman/listinfo/python-list

My Python programming book for kids is free for 48 hours

2020-02-02 Thread Kent Tong
Hi, If you're interested, please get it for free at: https://www.amazon.com/Yes-Kids-can-learn-Python-ebook/dp/B084CY2L43/ref=sr_1_3 This is a set of training materials I used to successfully teach Python to kids as little as 10 years old. The online learning environment are freely available at

Re: unittest setup

2005-09-30 Thread Kent Johnson
#x27;__main__': unittest.TextTestRunner().run(suite()) This runs under Jython (Python 2.1); in more recent Python I think you can override TestSuite.run() instead of __call__(). Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Not defined

2005-10-01 Thread Kent Johnson
? > NameError: name 'Sphere' is not defined Which version of cgkit are you using? Kent -- http://mail.python.org/mailman/listinfo/python-list

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

2005-10-03 Thread Kent Johnson
vate { public static void main(String[] argv) throws Exception { HasPrivate hp = new HasPrivate(); Field notSoPrivate = hp.getClass().getDeclaredField("myPrivate"); notSoPrivate.setAccessible(true); System.out.println("myPrivate = " + notSoPrivate.getInt(hp)); } } Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Nicer way of strip and replace?

2005-10-11 Thread Kent Johnson
ule: euro=euro + float(rechnung[element][10].strip('"').replace(',' , '.')) Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: are there internal functions for these ?

2005-10-11 Thread Kent Johnson
See the os, os.path and shutil modules for many file operations including copy and move. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Python adodb

2005-10-12 Thread Kent Johnson
EDB.1; User ID=user; Password=passwd;Initial Catalog=Northwind;Data Source=(local)" HTH Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Looking for a Python mentor

2005-10-13 Thread Kent Johnson
rovement, in style, logic, easier > ways of doing things etc. I second gene's recommendation of the python-tutor mailing list - we do all of the above as well as cheerfully answer all questions, give suggestions on how to do things, etc. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem splitting a string

2005-10-15 Thread Kent Johnson
r x in y] [1, 2, 3, 4] The outer loop comes first. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem splitting a string

2005-10-15 Thread Kent Johnson
it(' ')] > Traceback (most recent call last): > File "", line 1, in ? > NameError: name 'y' is not defined The order of the 'for' clauses is backwards: >>> [x for y in mystr.split(' ') for x in y.split('_')] ['this', 'NP', 'is', 'VL', 'funny', 'JJ'] Kent -- http://mail.python.org/mailman/listinfo/python-list

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
is better than the obvious triangle=3 square=4 color=red drawshapes(polygon(triangle, color), polygon(square, color) ) or even drawshapes(polygon(3, red), polygon(4, red) ) which is concise and readable IMO...? Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: unittest of file-reading function

2005-10-18 Thread Kent Johnson
looks like this: def openFileAndProcessContents(filename): data = open(filename).read() processContents(data) then you can write your tests against processContents() and just pass it a string with the test data. I usually have a set of test files as part of my project that I can pass to funct

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

2005-10-19 Thread Kent Johnson
ced, the docs are often helpful: pprint( object[, stream[, indent[, width[, depth]]]]) Changed in version 2.4: The parameters indent, width and depth were added. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: parser question

2005-10-19 Thread Kent Johnson
; (which I've had a pleasant experience > with in the past) or any of the other parsers listed on the PLY site's > "Other Python Parsing Tools". A more complete list is here: http://www.nedbatchelder.com/text/python-parsers.html I have found pyparsing easy to work with. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Python variables are bound to types when used?

2005-10-19 Thread Kent Johnson
;, this will call a special method of the object bound to l2, passing "hello" as a parameter. The result will be evaluated as True or False. The actual method called on l2 may be __cmp__ or __eq__. http://docs.python.org/ref/customization.html Kent > > and what if I never used it in the definition body? > > Elucidate please. > -- http://mail.python.org/mailman/listinfo/python-list

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
good reason for update :) or learn about decorate-sort-undecorate: lst = [ ...whatever ] lst = [ x[3], i, x for i, x in enumerate(lst) ] lst.sort() lst = [ x for _, _, x in lst ] Kent > > Thanks, > Michele -- http://mail.python.org/mailman/listinfo/python-list

Re: Question on re.IGNORECASE

2005-10-20 Thread Kent Johnson
>>> re.IGNORECASE 2 >>> pattern = re.compile('.*HTTP/(\d\.\d) *(\d*) *(.*)$', re.IGNORECASE) >>> pattern.search("GGHTTP/1.1 200 OK\r\n") <_sre.SRE_Match object at 0x00965980> >>> pattern.search("GHTTP/1.1 200 OK\r\n") <

Re: ANN: Beginning Python (Practical Python 2.0)

2005-10-21 Thread Kent Johnson
k before October 30. See for example http://www.bookpool.com/sm/159059519X Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Binding a variable?

2005-10-21 Thread Kent Johnson
gt; > would show > > list = [ 6 ] You have to put a mutable object into the list - something whose state you can change. For example this works, because temp and lst[0] are references to the same mutable (changeable) list: >>> temp = [6] >>> lst = [temp] >>> lst [[6]] >>> temp[0] = 5 >>> lst [[5]] Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: need some advice on x y plot

2005-10-21 Thread Kent Johnson
d it shows up ( no x value found) > > how should i proceed? Convert one of the values to a float? What are your time and value numbers? Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Redirect os.system output

2005-10-21 Thread Kent Johnson
a3a3c287e8e2a3?hl=en&; Kent > > ..this is windows by the way. > > For example: > tmp = os.popen("hostname").read() > > ...works as expected. > > however, > > tmp = os.popen("cmd").read() > ...i would like to have access to the cmd proc

Re: Python vs Ruby

2005-10-21 Thread Kent Johnson
have seen (on small bits of code) is 3:1. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: coloring a complex number

2005-10-21 Thread Kent Johnson
ws.get('color', 'BLUE') In general when you subclass an immutable type you have to override __new__ rather than __init__. There is some explanation and example here: http://www.python.org/2.2.3/descrintro.html#__new__ Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Python vs Ruby

2005-10-21 Thread Kent Johnson
Ugh. The code generated by jythonc is *nothing like* the code you would write by hand to do the same thing. This is a meaningless comparison. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Module Importing Question

2005-10-22 Thread Kent Johnson
mething: import oneMod as theMod else: import orTheOtherMod as theMod helper.theMod = theMod import aModule # in aModule import helper.theMod as theMod theMod.someFunction() Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Question about inheritance...

2005-10-22 Thread Kent Johnson
ender() ditto In this example it doesn't make any difference but with a deeper inheritance hierachy it does. See http://www.python.org/2.2.3/descrintro.html#cooperation Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Tricky Areas in Python

2005-10-24 Thread Kent Johnson
ow." > > Oh wait! Yes I do... the setter doesn't actually take an argument to set > the property too. Is that it, or have a missed a cunningly hidden deeper > problem? Derived.getFoo() will not override the use of Base.getFoo() to access the attribute foo. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: High Order Messages in Python

2005-10-24 Thread Kent Johnson
(from the pickaxe book): File.open("testfile") do |file| file.each_line { |line| puts line } end Kent > > Alex Martelli wrote: > >>[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >> >> >>>could someone enlighten me what is the advantage of bloc

Re: output from external commands

2005-10-24 Thread Kent Johnson
= os.listdir('.') Python has built-in support for many file manipulations, see the os, os.path and shutil modules. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Redirect os.system output

2005-10-24 Thread Kent Johnson
ies 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 tr

Re: Redirect os.system output

2005-10-24 Thread Kent Johnson
asically I was opening to send the "ipconfig" command to cmd.exe and > store the result in the "result" variable. But you can see there was > an error with result. This works for me: import subprocess as sp p = sp.Popen("ipconfig", stdout=sp.PIPE) result = p.communicate()[0] print result Kent -- http://mail.python.org/mailman/listinfo/python-list

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
n Python is driven from the command line. However, >>they > > > The "MS-DOS" command window tends to use a different character > encoding than full "Windows" widgets. You can chaneg the encoding used by the command window with the chcp command. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: extracting numbers from a file, excluding fixed words

2005-10-29 Thread Kent Johnson
(not tested): inf = open('input.txt') out = open('output.txt', 'w') skips = [ 'xxx xx x xxx', 'y yy yyy yy y yyy', ] for line in inf: for skip in skips: if skip in line: continue out.write(line) inf.close() out.close() 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

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

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: 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 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
% ('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: 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: 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: 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: 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: 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
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: 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

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

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

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

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

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

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

  1   2   3   4   5   6   7   8   >