Re: how to overload sqrt in a module?

2006-03-05 Thread Kent Johnson
ls().update(custom_math.__dict__) This will cause interesting trouble if custom_math doesn't implement all the functions you use from math. Kent -- http://mail.python.org/mailman/listinfo/python-list

Python version of XMLUnit?

2006-03-05 Thread Kent Johnson
tters). Thanks, Kent http://xmlunit.sourceforge.net/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Package organization: where to put 'common' modules?

2006-03-05 Thread Kent Johnson
o.baz() C:\WUTemp\A>python B\bar.py ['C:\\WUTemp\\A\\B', 'C:\\Python24\\python24.zip', 'C:\\WUTemp\\A', ] foo.baz() here Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Package organization: where to put 'common' modules?

2006-03-05 Thread Kent Johnson
at the start of site.py (which does most of the setup of sys.path), one element of the path is an empty string. This is expanded by main() -> removeduppaths() -> makepath() -> os.path.abspath() to the current working dir. This is Python 2.4.2 on Win2K. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Python version of XMLUnit?

2006-03-06 Thread Kent Johnson
ly the error including XPath expressions to the node containing the error! In Jython I use unittest, not JUnit, so instead of subclassing XMLTestCase I call the static methods of XLMAssert from my test cases. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Suggesting the use of StandardError as base of error Exceptions.

2006-03-06 Thread Kent Johnson
#x27;s PEP 352, it's already done. This will be in Python 2.5. It's good to see that the time machine is stil working ;) http://www.python.org/peps/pep-0352.html Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Mixin class error

2006-03-06 Thread Kent Johnson
: http://docs.python.org/api/type-structs.html#l2h-968 So it looks like kinterbasdb.Cursor is a C extension class that may not be subclassed because Py_TPFLAGS_BASETYPE is not set. Whether this is by design or accident would be a question for the kinterbasdb developers. One workaround might be to use delegation instead of subclassing... Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Python and Java

2006-03-06 Thread Kent Johnson
ertain future. Jython 2.1 works great and there is (slow) progress being made in modernizing it. I recommend it. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Does '#hash' mean anything in IDLE?

2006-03-06 Thread Kent Johnson
alues())) The index will always disambiguate and words will never be compared. > > In general that DSU pattern doesn't even always work: you might want > the max of objects which don't directly support any comparison methods > that the cmp builtin understands. Using the index as above prevents the objects from ever being compared. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Is this not infinite?

2006-03-06 Thread Kent Johnson
r(Derived, self).__init__(etc...) > Obviously I'm missing a piece of information that would help me to see > why the call gets passed back up to Base... It's a typo in the book. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Mixin class error

2006-03-06 Thread Kent Johnson
Ed Leafe wrote: > On Mar 6, 2006, at 8:08 PM, Kent Johnson wrote: >> One workaround might be to use delegation instead of subclassing... > > Yeah, but that would involve a lot more work at this point. The > mixin approach has been working quite well up until this p

Re: compare two voices

2005-05-01 Thread Kent Johnson
is very difficult to create a meaningful score. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Using wildcards...

2005-05-02 Thread Kent Johnson
>>> import re >>> s = '{1:1} Random text here. {1:2} More text here. and so on.' >>> re.split(r'\{[^}]+\}', s) ['', ' Random text here. ', ' More text here. and so on.'] If you want to be a little stricter in what you a

Re: Inspect Python Classes for instance data information

2005-05-03 Thread Kent Johnson
Tim Henderson wrote: > Hello > > I want to creat a program that can inspect a set of classes that i have > made and spit out a savable version of these classes. To do this I need > to be able to inspect each class and get all of its instance data as > well as information about a particular meathod

Re: xmlrpclib and decoding entity references

2005-05-03 Thread Kent Johnson
2 l';glise Saint Andr; della Valle' sur le cadre craie noire, > plume et encre brune, lavis brun rehauss; de blanc sur papier brun > 190 x 228 mm. (7 1/2 x 9 in.) > > Can anyone give me a lead on how to convert the entity references into > something that will make it thr

Re: xml.parsers.expat and utf-8

2005-05-03 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > I have this code: > > import xml.parsers.expat > parser = xml.parsers.expat.ParserCreate(encoding="UTF-8") > text = unicode("þórður",'UTF-8') I think you want text = u"þórður".encode('UTF-8') so

Re: Regular Expression tools?

2005-05-04 Thread Kent Johnson
down the search for me. All I seem to be finding are other > platforms and/or not standalone. Maybe you are looking for RegexPlor: http://python.net/~gherman/RegexPlor.html Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: min max of a list

2005-05-06 Thread Kent Johnson
e = value # Get the last group if any if i > startIx: groups.append( [startIx, i] ) return groups values = [ 0, 72, 2, 4, 9, 2, 0, 0, 42, 26, 0, 282, 23, 0, 101, 0, 0, 0, 0, 0] print findPeaks(values) ## prints: [[0, 2], [2, 7], [7, 10], [10

Re: min max of a list

2005-05-06 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > Hi Kent, > Thanks for that. But We are considering [..., 0, 101, 0, 0, 0, 0, 0] -> > [13,18] .In fact if you look at the list, the histogram ends at 15 that > is [0,101,0] --> [13,15]. Dont you think so. > Well you consider ..., 0, 4, 9, 2

Re: searching substrings with interpositions

2005-05-24 Thread Kent Johnson
oor with long strings: >>> import re >>> re.search('0.*1.*0.*1', '0100') <_sre.SRE_Match object at 0x008D9BF0> >>> _.span() (0, 10) Put the chars of the search string in groups if you need to know where they were found. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Access from one class to methode of other class

2005-05-26 Thread Kent Johnson
text = self.ent.get() # get text form entry in this window > d.entry.insert(0, text)# must insert in other window > > d = First() #First window The problem is that First.__init__() never returns so the instance of First is never bound to d. Take the line self.root.mainloop() out of First.__init__() and and the line d.root.mainloop() at the end of the program and it will work as you expect. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: using timeit for a function in a class

2005-05-26 Thread Kent Johnson
t Timer.timeit() calls the function being timed 100 times. That's a lot of "hello time test" =:-) Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Help with choice of suitable Architecture

2005-05-28 Thread Kent Johnson
or a preview of the issues this raises. http://groups-beta.google.com/group/comp.lang.python/browse_frm/thread/475d065fa7871e63/c2fc42fefe114d38?hl=en#c2fc42fefe114d38 Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: write html-headers (utf-8)

2005-05-30 Thread Kent Johnson
trict.dtd";> > > > If you are using CGI you can set the Content-Type header directly. Before you output your HTML do print "Content-Type: text/html; charset=UTF-8" print # blank line, end of headers Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Is pyunit still usable?

2005-05-30 Thread Kent Johnson
hive.html If you mean the practice, Google is your friend. Countless books and articles have been written about unit testing. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: how to prepend string to a string?

2005-05-30 Thread Kent Johnson
ormally you get the desired result: dirList = ['depth1','depth2','depth3'] string = """position""" for x in dirList: string += '>> %s'% x Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: scripting browsers from Python

2005-05-31 Thread Kent Johnson
> Windows, IE can be automated via COM - see > <http://www.mayukhbose.com/python/IEC/> for example Also http://pamie.sourceforge.net/ Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: regular expression problem

2005-05-31 Thread Kent Johnson
ocks() [(0, 0, 2), (4, 2, 1), (13, 3, 1), (14, 4, 0)] You should test for len(sm.get_matching_blocks()) == 4 (the last element is a dummy) Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie Here

2005-06-01 Thread Kent Johnson
k through 2,400 folders to see if they contained two specific files in a nested subfolder. This is easy to do in Python; below is my script. Kent ''' Look in the warehouse for courses that are missing \output\html\saveres.htm and/or \output\html\readres.htm path module f

Re: optparse.py: FutureWarning error

2005-06-03 Thread Kent Johnson
ed! Where should it go in the docs? In the Language Reference or the Tutorial or...? Kent -- http://mail.python.org/mailman/listinfo/python-list

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

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

2005-06-04 Thread Kent Johnson
valuating EXPR must have __enter__() and __exit__() methods. *x* can be a tuple. Kent -- http://mail.python.org/mailman/listinfo/python-list

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

2005-06-04 Thread Kent Johnson
except: print "entered except" raise return wrapper class C(object): @in_try def func_a(self): print "func_a" @in_try def func_b(self): print "func_b" raise Exception You could probably creat

Re: Newbie Python & XML

2005-06-04 Thread Kent Johnson
MS Windows > environment. I have Python 2.4 with win32 extensions. > > 1. What else do I need I recommend ElementTree for XML processing in Python http://effbot.org/zone/element-index.htm and the Python-tutor mailing list for getting started with Python: http://mail.python.org

Re: csv and iterator protocol

2005-06-04 Thread Kent Johnson
ts. For your needs, a list of strings will work, or a cStringIO initialized from your data. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Iterate through a list calling functions

2005-06-05 Thread Kent Johnson
'isBar' ] just change it to validators = [ isDecimal, isFoo, isBar ] and your loop above will work. Python makes data-driven programming easy :-) Kent > > Many thanks > David > > My current situation below: > > # A large list of validators > def isDecimal

Re: Iterate through a list calling functions

2005-06-05 Thread Kent Johnson
results = {} > for validate in validators: > result = validate(name,value) > if result is not None: > results[name] = result > # XXX: if more than one validators succeed, > # all but the last result will be overwritten > return results No change needed in the loop above... > > # test > validators = [DecimalValidator(), ZipCodeValidator()] validators = [ isDecimal, isZipCode ] Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Iterate through a list calling functions

2005-06-05 Thread Kent Johnson
David Pratt wrote: > Hi Kent. Thank you for your reply. I gave this a go but get the > following traceback: > ... > result = validator(name, value) > TypeError: 'str' object is not callable > > Have put validators in list and iterate over it as in fol

Re: the python way?

2005-06-06 Thread Kent Johnson
() return ret def reinterpolate(word): """ main function """ wlist = shuffled(word) vlist = 'aeiouy' # ok, y isn't really a vowel, but... vees = [ x for x in wlist if x in vlist ] cons = [ x for x in wlist if x not in vlist ]

Re: help with sending mail in Program

2005-06-07 Thread Kent Johnson
: #!/usr/local/bin/python ''' Send mail to me ''' from smtplib import SMTP def sendToMe(subject, body): me = '"Kent Johnson" <[EMAIL PROTECTED]>' send(me, me, subject, body) def send(frm, to, subject, body): s = SMT

Re: xmlrpclib - methodHelp doesn't work

2005-06-07 Thread Kent Johnson
27;, 'meerkat.getItems', 'system.listMethods', 'system.methodHelp', 'system.methodSignature'] >>> print meerkatsvr.system.methodSignature('meerkat.getChannels') [['array']] >>> print meerkatsvr.system.methodHelp('meerkat.getItems') Returns an array of structs of RSS items given a recipe struct. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Trouble Encoding

2005-06-07 Thread Kent Johnson
ing is usually > ASCII-7. Why it's trying to use Latin-1 in this case is somewhat > of a mystery. Actually I believe it will use sys.stdout.encoding for this, which is presumably latin-1 on fingermark's machine. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Help! File objects and scoping

2005-06-07 Thread Kent Johnson
of scope and the actual file is closed. Try returning both somefile and mmapped or some other way of keeping a reference to someefile. Kent > > On the other hand, > doeswork.py > --- > import mmap > import os > > name="/the/exact/same/file" >

Re: Binary numbers

2005-06-07 Thread Kent Johnson
ivestate.com/ASPN/Cookbook/Python/Recipe/219300 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/111286 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65212 Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Knowing the signature of a function

2005-06-08 Thread Kent Johnson
al number of arguments including *args and **kwds args. inspect.getargspec() might also be helpful. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Changing entities

2005-06-08 Thread Kent Johnson
YTE)' >>> byter.sub(r'SIZE(\1)', s) 'SIZE(1)' >>> s = 'SIZE (1024 BYTE)' >>> byter.sub(r'SIZE(\1)', s) 'SIZE(1024)' Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: optparse.py: FutureWarning error

2005-06-08 Thread Kent Johnson
Kent Johnson wrote: > Terry Reedy wrote: > >> "Kent Johnson" <[EMAIL PROTECTED]> wrote in message >> news:[EMAIL PROTECTED] >> >>> Terry Reedy wrote: >>> >>>> "kosuke" <[EMAIL PROTECTED]> wrote in message >&

Re: help with sending mail in Program

2005-06-09 Thread Kent Johnson
Tim Roberts wrote: > Kent Johnson <[EMAIL PROTECTED]> wrote: > >>Ivan Shevanski wrote: >> >>>Could someone send me a good tutorial for sending mail then? The one I >>>found is not what I'm looking for. Also please dont send me the stmp >>&g

Re: help with sending mail in Program

2005-06-09 Thread Kent Johnson
Kent Johnson wrote: > Tim Roberts wrote: >> Not exactly like this, you didn't. The list of destination addresses in >> SMTP.sendmail must be a sequence, not a string: > > Yes, exactly like that. This is a working module, the only thing I > changed to post it was t

Re: splitting strings with python

2005-06-09 Thread Kent Johnson
his might be a good job for PyParsing. Kent > > sometimes the (1) and (2) are not included - they are included only if > the word has two different meanings > > > "..." means that there are sometimes more then two definitions per > meaning. > > > im t

Re: Changing entities

2005-06-09 Thread Kent Johnson
want to get rid of everything after 'space', this will do it: >>> import re >>> a = "I'm going send to out of space, find another race" >>> re.sub('space.*', 'space', a) "I'm going send to out of space" You s

Re: Generating HTML from python

2005-06-09 Thread Kent Johnson
just have to find a package whose style you like and whose features fit your needs. HTH, Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Is pyton for me?

2005-06-10 Thread Kent Johnson
port subprocess >>> subprocess.check_call Traceback (most recent call last): File "", line 1, in ? AttributeError: 'module' object has no attribute 'check_call' with Python 2.4.1. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Changing entities

2005-06-10 Thread Kent Johnson
Daniel wrote: > Hi Kent > > This isn't work with the following line: > FieldGraphic56::= GraphicString EBCDIC BC= " " SIZE (56 > BYTES) > > >>>>byter = re.compile(r'SIZE \((\d+) BYTE\)') Because the string doesn't match t

Re: try: except: ValueError

2005-06-10 Thread Kent Johnson
user input as a string. Then you can do whatever validation you wish, e.g. menuChoice = int(raw_input("1 = write | 2 = view | 0 = quit")) which will raise an exception if the input is not a valid integer. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Controlling a generator the pythonic way

2005-06-12 Thread Kent Johnson
while whatever: yield token def seek(self, newPosition): # change state here Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: collect data using threads

2005-06-14 Thread Kent Johnson
nd to the same list as x. At least if the execution sequence is x = self.data self.data.append(a_piece_of_data) self.data = [] ISTM it should work. I'm not arguing in favor of the original code, I'm just trying to understand your specific failure mode. Thanks, Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: collect data using threads

2005-06-14 Thread Kent Johnson
processing the returned list* before the on_received() thread runs again and actually appends to the list. The appended value will never be processed. If you want to avoid the overhead of a Queue.get() for each data element you could just put your own mutex into on_received() and get_data(). Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: how to use pyparsing for identifiers that start with a constant string

2005-06-14 Thread Kent Johnson
4er'] >>> ident = Combine(Literal('atod') + Word('_' + alphanums)) >>> for t in tests: ... try: ... print ident.parseString(t) ... except: ... print 'No match', t ... ['atodkj45k'] ['atod_asdfaw'] No match atgdkasdjfhlksj No match atod asdf4er >>> Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: dynamic

2005-06-15 Thread Kent Johnson
iffer from Foo('a').speak() Why does Final need to subclass Foo? Can you use either of these syntaxes? Either one can be specialized in a subclass: Foo()('a').speak() # use Foo.__call__() as factory Foo.make('a') # Use classmethod as factory Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: how to use pyparsing for identifiers that start with a constant string

2005-06-15 Thread Kent Johnson
Paul McGuire wrote: > Be careful, Kent. You may get tagged as "the new pyparsing guy." :) Yeah, I was a little surprised I beat you to that one :-) Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: pyunit: remove a test case on the fly

2005-06-16 Thread Kent Johnson
n(testLoader=FilteringTestLoader()) You could do something similar with a FilteringTestSuite if that fits your harness better. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: access properties of parent widget in Tkinter

2005-06-16 Thread Kent Johnson
ce using nametowidget(). > > self.nametowidget(event.widget.winfo_parent()).hasChanged= True Personally I think it is bad design for a widget to assume anything about its enclosing environment. What about passing a StringVar or IntVar to the child widget and letting it work with that? Kent -- http://mail.

Re: access properties of parent widget in Tkinter

2005-06-16 Thread Kent Johnson
William Gill wrote: > Kent Johnson wrote: > > If I change the area code in one record only the phonenumber table needs > to be updated, but since areaCode is a child of phones, > phones.hasChanged needs to be set to True by the areaCode entry widget. One possibility is for the ph

Re: Overcoming herpetophobia (or what's up w/ Python scopes)?

2005-06-17 Thread Kent Johnson
ver scopes that > Perl provides. Python has supported nested (lexical) scopes and closures since version 2.1, maybe this gives you enough control; see http://www.amk.ca/python/2.1/index.html#SECTION00030 Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Shortcut to initialize variables

2005-06-17 Thread Kent Johnson
y to do this sort of thing, and where the resulting variables are easily used? Thanks, Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: add new modules?

2005-06-17 Thread Kent Johnson
you say from mystuff.mymodule import MyClass where in both cases MyClass is defined in mymodule.py. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Announcing: ACM SIGAPL apl 2007 -- Arrays and Objects

2007-05-31 Thread Mike Kent
The APL2007 URL was given incorrectly should be http://www.sigapl.org/apl2007.html -- http://mail.python.org/mailman/listinfo/python-list

Announcing: ACM SIGAPL apl 2007 -- Arrays and Objects

2007-05-27 Thread Mike Kent
de Congres, Montreal, Quebec, CANADA Conference hotel: Hyatt Regency Montreal Committee General Chair Guy Laroque [EMAIL PROTECTED] Program Chair Lynne C. Shaw[EMAIL PROTECTED] Treasurer Steven H. Rogers [EMAIL PROTECTED] Publici

(Re)announcing APL 2007

2007-08-05 Thread Mike Kent
APL 2007 conference on Array Programming co-located with OOPSLA 2007 Sponsor: ACM SIGAPL Where:Montreal When: October 21 (tutorials) October 22/23 (main conference program) Keynote Guy Steele speaker:

What's on at APL 2007, Montreal, October 21, (Tutorials) 22, 23 (Program)

2007-08-30 Thread Mike Kent
( Details and abstracts coming to the APL 2007 web page http://www.sigapl.org/apl2007.html shortly. In the meantime ... ) Tutorials and workshops Introduction to APL (Ray Polivka) OO for APLers, APL for OOers (Dan Baronet) ... others in the works Presentations

APL2007 reminder: early (cheaper) registration ends Thursday 9/13

2007-09-08 Thread Mike Kent
On-line registration is through the OOPSLA registrar http://www.regmaster.com/conf/oopsla2007.html APL 2007 home page http://www.sigapl.org/apl2007.html -- http://mail.python.org/mailman/listinfo/python-list

Re: doxygen

2007-03-04 Thread Mike Kent
On Mar 4, 1:15 pm, Jan Danielsson <[EMAIL PROTECTED]> wrote: >When I run doxygen on my python files, it does document classes, but > not "standalone" functions. Look in the doxygen config file for your python project, named 'Doxyfile', for the config setting 'EXTRACT_ALL', and read the commen

Re: Pickle Problem

2007-03-15 Thread Mike Kent
On Mar 15, 11:13 am, "tonyr1988" <[EMAIL PROTECTED]> wrote: > if __name__=='__main__': > x = DemoClass > x.WriteToFile > You meant to create a DemoClass instance object, but instead, you obtained a reference to the class object. You want 'x = DemoClass()' instead. You meant to ca

Re: Join strings - very simple Q.

2007-03-23 Thread Mike Kent
On Mar 23, 2:37 pm, Paulo da Silva <[EMAIL PROTECTED]> wrote: > Hi! > > I was told in this NG that string is obsolet. I should use > str methods. > > So, how do I join a list of strings delimited by a given > char, let's say ','? > > Old way: > > l=['a','b','c'] > jl=string.join(l,',') > > New way?

ACM SIGAPL / APL2007 Conference / Montreal / one week away

2007-10-15 Thread Mike Kent
Conference page // with links to program details // (updated Friday 10/12) http://www.sigapl.org/apl2007.html Co-located with OOPSLA 2007 http://www.oopsla.org/oopsla2007 On-line registration (through Wednesday 10/17) http://www.regmaster.com/c

Re: Learning Python book, new edition?

2007-01-11 Thread Kent Johnson
2.4 are in it, too. No, it is one version back from that. From the Preface to the second edition: "This edition has been thoroughly updated to reflect Python 2.2...in addition, discussion of anticipated changes in the upcoming 2.3 release have been incorporated." Kent -- http://mail.python.org/mailman/listinfo/python-list

Problems with ElementTree and ProcessingInstruction

2007-01-28 Thread Kent Tenney
Howdy, I want to generate the following file; stuff How should I be doing this? As far as I can tell, ElementTree() requires everything to be inside the root element (leo_file) Thanks, Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Problems with ElementTree and ProcessingInstruction

2007-01-28 Thread Kent Tenney
On Jan 28, 7:46 pm, Gabriel Genellina <[EMAIL PROTECTED]> wrote: > At Sunday 28/1/2007 11:28, Kent Tenney wrote: > > >I want to generate the following file; > > > > > > >stuff > > >How should I be doing this?open("filename","w"

Re: Can I undecorate a function?

2007-01-29 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > Matt> In some instances I want to access just the function f, though, > Matt> and catch the values before they've been decorated. > > def f(x): > return x * x > > @as_string > def fs(x): > return f(x) or just fs =

Re: in place-ness of list.append

2007-02-05 Thread Kent Johnson
- Use + : In [1]: a=[1,2] In [2]: b=a+[3] In [3]: a Out[3]: [1, 2] In [4]: b Out[4]: [1, 2, 3] Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Unicode formatting for Strings

2007-02-05 Thread Kent Johnson
quot;Ataris Aqußticos #2.py", line 1 > SyntaxError: Non-ASCII character '\xff' in file Ataris Aqußticos #2.py > on line 1 It looks like you are saving the file in Unicode format (not utf-8) and Python is choking on the Byte Order Mark that Notepad puts at the beginning of the d

Re: Array delete

2007-02-08 Thread Kent Johnson
# print the new list where duplicates are removed For longer lists the set() method will probably be faster as this one searches temp for each item. Kent > > def main(): > list, temp = [1, 1, 2, 4, 8, 8, 8, 8, 8, 8, 10], [] > for i in range(len(list)): >

Re: multiple inheritance of a dynamic list of classes?

2007-02-12 Thread Kent Johnson
s: == help that this (Cmd) that That In your code you could use introspection to locate the plugin commands, something like PLUGIN_MODULES = map(__import__, PLUGIN_NAMES) for module in PLUGIN_MODULES: for name in dir(module): if name.startswith('do_')

Re: Is there any way to automatically create a transcript of an interactive Python session?

2007-02-18 Thread Kent Johnson
Jonathan Mark wrote: > Some languages, such as Scheme, permit you to make a transcript of an > interactive console session. Is there a way to do that in Python? > Maybe IPython's logging feature is what you want? http://ipython.scipy.org/doc/manual/node6.html#SECTION00066000

Re: python question!!

2007-11-22 Thread Mike Kent
On Nov 22, 8:23 pm, "bruce" <[EMAIL PROTECTED]> wrote: > is there a function/feature/etc.. that i can run on "foo.py" that would walk > through the entire list of files that make up foo.py, so i could see the > list of *.py files that are required to run "foo.py". There's this: http://www.tarind.

Need some help with 'with'

2007-11-27 Thread Mike Kent
I recently found myself needing to do this a lot: lock a record in a file read the record into a buffer alter the buffer write the buffer back to the record unlock the record I'd love to be able to create a context for this to use with the 'with' statement, something like: from __future__ import

Re: scanning through page and replacing all instances of 00:00:00.00

2006-04-18 Thread Kent Johnson
tatement, or when you're building the page ? >> >> > because in my sql database, the date is only 'date' (as in -mm-dd), > only when i extract it with my python-cgi does the date turn into > (-mm-dd 00:00:00.00), thus i figured the best way to fix th

Re: Missing interfaces in Python...

2006-04-18 Thread Kent Johnson
I V wrote: > To use interfaces in python, just what you would do in Java, except > don't use interfaces. +1 QOTW -- http://mail.python.org/mailman/listinfo/python-list

Re: A 'Box' Function

2006-04-18 Thread Kent Johnson
> > Does anyone have any ideas on how it could be modified? Am I > approaching it the right way? Thanks a bunch! Rather than rewriting wrap(), I would suggest wrapping it with a new function, wrap_box(), that adds the header, line endings and trailer to the lines returned from wrap(). Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Writing backwards compatible code - when?

2006-04-19 Thread Kent Johnson
ilt-in often documents the version when any change was made. You can also read through the What's New documents for each release to see what changed in that release. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: http request with cookie sending

2006-04-19 Thread Kent Johnson
Jar() cookie = cookielib.Cookie(...your cookie data here...) cj.set_cookie(cookie) opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) urllib2.install_opener(opener) data = urllib2.urlopen(...).read() Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: extracting a substring

2006-04-19 Thread Kent Johnson
l the other characters are always fixed. In that case a fixed slice will do what you want: In [1]: s='a53bc_531.txt' In [2]: s[6:-4] Out[2]: '531' Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Confused by Python and nested scoping (2.4.3)

2006-04-20 Thread Kent Johnson
Kelvie Wong wrote: > There are only two scopes in Python -- global scope and function scope. No, Python has local, nested, global and built-in scope. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Method Call in Exception

2006-04-20 Thread Kent Johnson
s: > > if hasattr(record,"name"): > name = record.name > else: > name = "Freddy" or maybe name = getattr(record, 'name', 'Freddy') Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: how to transfer a python object to other computer?

2006-04-20 Thread Kent Johnson
ne could do me a favor to give me some idea? Use pickle.dumps() and pickle.loads() to serialize to/from a string. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: send cookie on request with urllib2

2006-04-20 Thread Kent Johnson
"Tom", 80,False, "itay", False, False, > "d:\\asddd",False, False,time.time()+1000,False,None,None,None) path is the server path to which the cookie applies. Try '/'. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Thanks from the Java Developer

2006-04-21 Thread Kent Johnson
be mostly used for QA around here. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: list of functions question

2006-04-27 Thread Kent Johnson
nts that are expressions, encapsulate them in functions event_list = [f1, f2, etc] # Call each one: for ev in event_list: if ev(t): # do something Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: can this be done without eval/exec?

2006-04-27 Thread Kent Johnson
Out[3]: 0 In [4]: lst[5]() Out[4]: 5 A list comp makes this IMO cleaner: In [5]: lst = [ lambda i=i: i for i in range(10) ] In [6]: lst[0]() Out[6]: 0 In [7]: lst[5]() Out[7]: 5 Kent -- http://mail.python.org/mailman/listinfo/python-list

<    1   2   3   4   5   6   7   8   >