Re: Generators and propagation of exceptions

2011-04-09 Thread Kent Johnson
On Apr 8, 3:47 pm, r wrote: > I'm already making something like this (that is, if I understand you > correctly). In the example below (an "almost" real code this time, I > made too many mistakes before) all the Expressions (including the > Error one) implement an 'eval' method that gets called by

Re: Python 2.7.1

2010-11-29 Thread Kent Johnson
On Nov 27, 11:33 pm, Benjamin Peterson wrote: > On behalf of the Python development team, I'm happy as a clam to announce the > immediate availability of Python 2.7.1. Will there be Mac binaries for 2.7.1 and 3.1.3? Currently the web site shows only source and Windows binaries. Thanks, Kent --

Re: ANN: PyGUI 2.0.4

2009-04-21 Thread Kent Johnson
On Apr 21, 8:05 am, Greg Ewing wrote: > PyGUI 2.0.4 is available: > >    http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/ > > Fixes a few more bugs and hopefully improves things > on Windows, although I can't be sure it will fix all > the Windows problems people are having, because I > have

Re: utf-8 read/write file

2008-10-08 Thread Kent Johnson
On Oct 8, 5:55 pm, gigs <[EMAIL PROTECTED]> wrote: > Benjamin wrote: > > On Oct 8, 12:49 pm, Bruno <[EMAIL PROTECTED]> wrote: > >> Hi! > > >> I have big .txt file which i want to read, process and write to another > >> .txt file. > >> I have done script for that, but im having problem with croatia

Re: tcl/tk version confusion with tkinter in Python 2.6, on OS X

2008-10-06 Thread Kent Johnson
On Oct 6, 5:58 pm, [EMAIL PROTECTED] wrote: > On Oct 6, 4:48 pm, [EMAIL PROTECTED] wrote: > > > I'm having trouble with tkinter on a new installation of Python (2.6), > > built with the framework option from source that was downloaded from > > python.org. I'm running OS 10.4 on a PowerPC G4. > > >

Re: Prioritization function needed (recursive help!)

2008-01-21 Thread Kent Johnson
rh0dium wrote: > Hi all, > > I need some help on writing a recursive priority function > > Given a list = [ A, B, C, D] > > Where the following constraints are in place: > > A depends on [B, C] > C depends on [B] > > Figure out real order that prioritizes these. You need a topological sort. h

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

Re: multiple inheritance of a dynamic list of classes?

2007-02-12 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > Hi, > > I am currently using the Cmd module for a mixed cli+gui application. I > am starting to refactor my code and it would be highly desirable if > many commands could be built as simple plugins. > > My idea was: > - Load a list of plugin names (i.e. from the config

Re: Array delete

2007-02-08 Thread Kent Johnson
azrael wrote: > if you are new to python then this will be easier to understand. if > you change this a liitle bit (depending on syntax) it should work in > any language. > just copy and paste to a .py file Yikes. If you are new to Python please ignore this un-Pythonic abomination. Check(listItem

Re: Unicode formatting for Strings

2007-02-05 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > Hi, > > I´m trying desperately to tell the interpreter to put an 'á' in my > string, so here is the code snippet: > > # -*- coding: utf-8 -*- > filename = u"Ataris Aquáticos #2.txt" > f = open(filename, 'w') > > Then I save it with Windows Notepad, in the UTF-8 format.

Re: in place-ness of list.append

2007-02-05 Thread Kent Johnson
Bart Van Loon wrote: > Hi all, > > I would like to find out of a good way to append an element to a list > without chaing that list in place, like the builtin list.append() does. > > currently, I am using the following (for a list of integers, but it > could be anything, really) > > #---

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 = as_string(f) Kent > > Call the one y

Re: Learning Python book, new edition?

2007-01-11 Thread Kent Johnson
Bjoern Schliessmann wrote: > Demel, Jeff wrote: > >> Does anyone know if there's a plan in the works for a new edition >> of Learning Python? The current edition (2nd) is a few years old >> and looks like it only covers Python 2.3. > > IIRC, differences to 2.4 are in it, too. No, it is one vers

Re: Some basic newbie questions...

2007-01-02 Thread Kent Johnson
jonathan.beckett wrote: I'm just finding it a bit weird that some of the built in functions are > static, rather than methods of objects (such as len() being used to > find the length of a list). Another explanation here: http://effbot.org/pyfaq/why-does-python-use-methods-for-some-functionality

Re: Slowdown in Jython

2006-12-29 Thread Kent Johnson
tac-tics wrote: > I have an application written in jython which has to process a number > of records. It runs fine until it gets to about 666 records (and maybe > that's a sign), and then, it's performance and responsiveness goes down > the toilet. It looks like it's running out of memory and is be

Re: One module per class, bad idea?

2006-12-25 Thread Kent Johnson
Carl Banks wrote: > Kent Johnson wrote: >> Carl Banks wrote: >>> Now, I think this is the best way to use modules, but you don't need to >>> use modules to do get higher-level organization; you could use packages >>> instead. It's a pain if you'

Re: One module per class, bad idea?

2006-12-22 Thread Kent Johnson
Carl Banks wrote: > Now, I think this is the best way to use modules, but you don't need to > use modules to do get higher-level organization; you could use packages > instead. It's a pain if you're working on two different classes in the > same system you have to keep switching files; but I guess

Re: Common Python Idioms

2006-12-15 Thread Kent Johnson
Fredrik Lundh wrote: > Stephen Eilert wrote: > >> I do think that, if it is faster, Python should translate >> "x.has_key(y)" to "y in x". > > http://svn.python.org/view/sandbox/trunk/2to3/fix_has_key.py?view=markup Seems to have moved to here: http://svn.python.org/view/sandbox/trunk/2to3/fixes

Re: reloading modules

2006-12-15 Thread Kent Johnson
Dustan wrote: > [EMAIL PROTECTED] wrote: >> I'm using python.exe to execute my modules. I have a music.py module >> which contains my classes and a main.py module which uses these >> classes. In python.exe, I call "import main" to execute my program. The >> problem is that I have to close python an

Re: Functions, callable objects, and bound/unbound methods

2006-12-01 Thread Kent Johnson
Ron Garret wrote: > The reason I want to do this is that I want to implement a trace > facility that traces only specific class methods. I want to say: > > trace(c1.m1) > > and have c1.m1 be replaced with a wrapper that prints debugging info > before actually calling the old value of m1. The

Re: Functions, callable objects, and bound/unbound methods

2006-12-01 Thread Kent Johnson
Ron Garret wrote: > The reason I want to do this is that I want to implement a trace > facility that traces only specific class methods. I want to say: > > trace(c1.m1) > > and have c1.m1 be replaced with a wrapper that prints debugging info > before actually calling the old value of m1. The

Re: a quickie: range - x

2006-11-30 Thread Kent Johnson
Steven D'Aprano wrote: > On Wed, 29 Nov 2006 19:42:16 -0800, rjtucke wrote: > >> I want an iterable from 0 to N except for element m (<=M). > x = range(m-1) + range(m+1, N) Should be range(m) + range(m+1, N) Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: multi split function taking delimiter list

2006-11-14 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > Hi, I'm looking for something like: > > multi_split( 'a:=b+c' , [':=','+'] ) > > returning: > ['a', ':=', 'b', '+', 'c'] > > whats the python way to achieve this, preferably without regexp? What do you have against regexp? re.split() does exactly what you want: In [1

Re: command text parsing and hints displaying on user input.

2006-10-17 Thread Kent Johnson
Andy wrote: > Hi guys, > > I'm writing a program with a feature of accepting user input as command > text and parsing it to correct function calls...example: > > "5 minutes later"/"5 min later"/"5 minute later"/"after 5 minutes"... > are being parsed as the same rule so the system will call a lat

Re: why should dict not be callable?

2006-10-17 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > A couple of times recently I've come across this problem: I have a > large list to sort and I need to the the "key=function" argument to > sort appropriately. But I actually have the key mapping in a big > dictionary. Now I have to make an intermediary function: > > d

Re: Book about database application development?

2006-10-17 Thread Kent Johnson
Wolfgang Keller wrote: > I know about the existence of MVC. But what I'm actually missing is a nice > textbook that teaches how to actually implement it (and other design patterns > which are useful for database applications) in a real-world application in a > way that leads to non-ridiculous be

Re: preemptive OOP?

2006-10-04 Thread Kent Johnson
Mark Elston wrote: > * Kent Johnson wrote (on 9/30/2006 2:04 PM): >> John Salerno wrote: >>> So my question in general is, is it a good idea to default to an OOP >>> design like my second example when you aren't even sure you will need >>> it? I know i

Re: preemptive OOP?

2006-09-30 Thread Kent Johnson
John Salerno wrote: > So my question in general is, is it a good idea to default to an OOP > design like my second example when you aren't even sure you will need > it? I know it won't hurt, and is probably smart to do sometimes, but > maybe it also just adds unnecessary code to the program. In

Re: windev vs python SOS

2006-09-29 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > Hi Stéphane, > > stéphane bard wrote: >> hello, my boss ask me to prefer windev to python. >> I have to argue > > First, no matter how good is Python, you should not desagree with your > boss. > Second, Windew is quite good and fun, you will love it. Yes, the boss is a

Re: efficient text file search.

2006-09-11 Thread Kent Johnson
noro wrote: > Is there a more efficient method to find a string in a text file then: > > f=file('somefile') > for line in f: > if 'string' in line: > print 'FOUND' Probably better to read the whole file at once if it isn't too big: f = file('somefile') data = f.read() if 'string' in

Re: Looking for the Perfect Editor

2006-09-11 Thread Kent Johnson
Dick Moores wrote: > At 06:30 PM 9/10/2006, Kent Johnson wrote: >> Dick Moores wrote: >>> Also, why do you use TextPad instead of IDLE? >> You're kidding, right? > > No. Tell me, please. Macros? Comparing files? What else? OK...please, no one interpret this as

Re: Looking for the Perfect Editor

2006-09-10 Thread Kent Johnson
Dick Moores wrote: > I downloaded Python (7) from > http://www.textpad.com/add-ons/synn2t.html and put the file > PythonV2.4.syn in C:\Program Files\TextPad 4\system . > > However, no syntax highlighting is showing up. so I must have done > something wrong. Do I have to do something other than

Re: Looking for the Perfect Editor

2006-09-10 Thread Kent Johnson
Dick Moores wrote: > At 01:10 PM 9/8/2006, Doug Stell wrote: >> Try www.TextPad.com. I've used it for years and love it. It >> understands many programming language constructs and can be taught to >> understand python so that things show up in color. > > Any tips on how to teach TextPad to underst

Re: Finding the name of a class

2006-08-02 Thread Kent Johnson
Kirk Strauser wrote: > Larry Bates wrote: > >> print print b.__class__.__name__ gives what you want > > That doesn't seem to do it, though. Here's the result of importing a module > from my company's internally-developed library: > from Daycos.TableCopier.copyfro import StateProcessor >>>

Python proficiency test

2006-07-21 Thread Kent Johnson
I recently helped create an on-line Python proficiency test. The publisher of the test is looking for beta testers to try the test and give feedback. If you are interested, here is an announcement from the publisher: > Brainbench is currently beta testing a new series of test questions > for

Re: Standard Yes / No Windows Dialog box creation

2006-06-21 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > I found a way to create "Open File" or "Open Folder" windows dialog > boxes, but not to create an easier Yes / No dialog box... > Maybe someone has a solution for this? Maybe you would like EasyGui http://www.ferg.org/easygui/ Kent -- http://mail.python.org/mailman/lis

Re: nested functions

2006-06-15 Thread Kent Johnson
Fredrik Lundh wrote: > George Sakkis wrote: > >> It shouldn't come as a surprise if it turns out to be slower, since the >> nested function is redefined every time the outer is called. > > except that it isn't, really: all that happens is that a new function object > is created from > prebuilt p

Re: Is there a better way of accessing functions in a module?

2006-06-13 Thread Kent Johnson
Ant wrote: > Ant wrote: > ... >> But this feels like a hack... Is there a cleaner way for accessing the >> functions of the current module similar to the __dict__ attribute of >> classes? i.e. a way to access the local symbol table? > > Sorry - posted too soon. Found the globals() built-in... You

Re: regexp questoin

2006-06-09 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > hi > > i created a script to ask user for an input that can be a pattern > right now, i use re to compile that pattern > pat = re.compile(r"%s" %(userinput) ) #userinput is passed from > command line argument > if the user key in a pattern , eg [-] , and my script will

Re: secure xmlrpc server?

2006-06-09 Thread Kent Johnson
Kent Johnson wrote: > Laszlo Nagy wrote: >> But I do not know how to create an XML RPC server in Python that uses >> HTTPS for XML transports. > > This recent recipe seems to do exactly what you want: > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496786 It w

Re: secure xmlrpc server?

2006-06-09 Thread Kent Johnson
Laszlo Nagy wrote: > But I do not know how to create an XML RPC server in Python that uses > HTTPS for XML transports. This recent recipe seems to do exactly what you want: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496786 Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Storing nothing in a dictionary and passing it to a function

2006-06-05 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > Hi, > > I'm writing a hand-written recursive decent parser for SPICE syntax > parsing. In one case I have one function that handles a bunch of > similar cases (you pass the name and the number of tokens you're > looking for). In another case I have a function that hand

Re: ANN: PQRC - Python Quick Reference Card - v 0.55

2006-06-04 Thread Kent Johnson
Laurent Pointal wrote: > And I'll maintain a fixed URL at > > http://laurent.pointal.org/python/pqrc/ Broken at the moment. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: [ANN] lxml 1.0 released

2006-06-02 Thread Kent Johnson
Stefan Behnel wrote: > Hallo everyone, > > I have the honour to announce the availability of lxml 1.0. > > http://codespeak.net/lxml/ > > It's downloadable from cheeseshop: > http://cheeseshop.python.org/pypi/lxml Are there any plans to offer a Windows installer? Thanks, Kent -- http://mail.p

Re: Python for Visual Basic or C# programmers

2006-06-01 Thread Kent Johnson
A.M wrote: > I am trying to find the equivalent functions such as vb's str or asc in > Python. Is there any resource that help me to find these kinds of functions > in Python faster? The Library Reference has a section on built-in functions: http://docs.python.org/lib/built-in-funcs.html Also

Re: An oddity in list comparison and element assignment

2006-06-01 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > Hi Alex, > With all due respect to your well-deserved standing in the Python > community, I'm not convinced that equality shouldn't imply invariance > under identical operations. > > Perhaps the most fundamental notion is mathematics is that the left and > right sides of

Re: os.walk trouble

2006-06-01 Thread Kent Johnson
The Prophet wrote: > As my first Python script, I am trying to make a program that recurses > a directory searching for files whose names match a pattern. If your patterns are simple (supported by fnmatch), the path module makes this very easy: import path for f in path.path(dirname).walkfiles('

Re: genexp performance problem?

2006-05-30 Thread Kent Johnson
Delaney, Timothy (Tim) wrote: > python -mtimeit "sum(int(L) for L in xrange(3000))" > 100 loops, best of 3: 6.76 msec per loop > > python -mtimeit -s "g = (int(L) for L in xrange(3000))" "sum(g)" > 100 loops, best of 3: 1.09 usec per loop > > The generator comprehension needs to create a new

Re: Parsing python dictionary in Java using JPython

2006-05-26 Thread Kent Johnson
sandip desale wrote: > Hi, > > We have some tools which are developed in Python and using python dictionaries. Now for some new requirments we are using Java and want to use the existing dictionaries as both the tools are executed on the same platform. So we are trying to use the existing diction

Re: Speed up this code?

2006-05-26 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > I'm creating a program to calculate all primes numbers in a range of 0 > to n, where n is whatever the user wants it to be. I've worked out the > algorithm and it works perfectly and is pretty fast, but the one thing > seriously slowing down the program is the following c

Re: Best way to handle exceptions with try/finally

2006-05-25 Thread Kent Johnson
Zameer wrote: > I wonder where the "else" goes in try..except..finally... > try / except / else / finally See the PEP: http://www.python.org/dev/peps/pep-0341/ Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding Upper-case characters in regexps, unicode friendly.

2006-05-25 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > I'm trying to make a unicode friendly regexp to grab sentences > reasonably reliably for as many unicode languages as possible, focusing > on european languages first, hence it'd be useful to be able to refer > to any uppercase unicode character instead of just the typica

Re: NEWB: how to convert a string to dict (dictionary)

2006-05-24 Thread Kent Johnson
manstey wrote: > Hi, > > How do I convert a string like: > a="{'syllable': u'cv-i b.v^ y^-f', 'ketiv-qere': 'n', 'wordWTS': u'8'}" > > into a dictionary: > b={'syllable': u'cv-i b.v^ y^-f', 'ketiv-qere': 'n', 'wordWTS': u'8'} Try this recipe: http://aspn.activestate.com/ASPN/Cookbook/Python/Reci

Re: can't figure out error: module has no attribute...

2006-05-23 Thread Kent Johnson
Chris_147 wrote: > but it seems to depend on from where I start the Python shell. > > so I've got a module selfservicelabels.py with some variables defined, > like this: > BtnSave = "link=label.save" > DeliveryAutomaat= "//[EMAIL PROTECTED]'deliveryMethod' and @value='AU']" > This

GUI viewer for profiler output?

2006-05-23 Thread Kent Johnson
Can anyone point me to a GUI program that allows viewing and browsing the output of the profiler? I know I have used one in the past but I can't seem to find it... Thanks, Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: grabbing portions of a file to output files

2006-05-22 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > hi. > I have a file with this kind of structure: > > Hxxx > . > . > . > x > Hxxx > ... > > ... > x > H > . > > and so onlines starting with '

Re: who can give me the detailed introduction of re modle?

2006-05-19 Thread Kent Johnson
softwindow wrote: > the re module is too large and difficult to study > > i need a detaild introduction. > http://www.amk.ca/python/howto/regex/ Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: OOP and Tkinter

2006-05-15 Thread Kent Johnson
Ronny Mandal wrote: > file front_ui.py: > > class Front(object): > _images = [] # Holds image refs to prevent GC > def __init__(self, root): > # Widget Initialization > self._listbox_1 = Tkinter.Listbox(root, > height = 0, > width = 0, > ... >

Re: any plans to make pprint() a builtin?

2006-05-14 Thread Kent Johnson
Duncan Booth wrote: > Personally I'd just like to see 'python' a builtin shorthand for importing > a name you aren't going to use much > e.g. > > python.pprint.pprint(x) Would you settle for import py py.std.pprint.pprint(x) ? http://codespeak.net/py/current/doc/misc.html#the-py-std-hook

Re: retain values between fun calls

2006-05-14 Thread Kent Johnson
George Sakkis wrote: > Gary Wessle wrote: >> Hi >> >> the second argument in the functions below suppose to retain its value >> between function calls, the first does, the second does not and I >> would like to know why it doesn't? and how to make it so it does? >> >> thanks >> >> # it does >> def

Re: glob() that traverses a folder tree

2006-05-11 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > # i'm guessing os.walk() is the best way to traverse folder trees. > > import os, glob > > for dir, subdir, files in os.walk('.\InteropSolution'): >for file in files: > if glob.fnmatch.fnmatch(file,"*.dll") or > glob.fnmatch.fnmatch(file,"*.exe"): > p

Re: unittest: How to fail if environment does not allow execution?

2006-05-11 Thread Kent Johnson
Kai Grossjohann wrote: > I wrote a test case that depends on a certain file existing in the > environment. So, I guess I should test that the file exists in the > setUp method. But what if it doesn't exist? How do I fail in that case? > > I would like to emit an error message explaining what is

Re: Memory leak in Python

2006-05-11 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > Sure, are there any available simulators...since i am modifying some > stuff i thought of creating one of my own. But if you know some > exisiting simlators , those can be of great help to me. http://simpy.sourceforge.net/ -- http://mail.python.org/mailman/listinfo/pyth

Re: reusing parts of a string in RE matches?

2006-05-10 Thread Kent Johnson
John Salerno wrote: > I probably should find an RE group to post to, but my news server at > work doesn't seem to have one, so I apologize. But this is in Python > anyway :) > > So my question is, how can find all occurrences of a pattern in a > string, including overlapping matches? You can

Re: data entry tool

2006-05-10 Thread Kent Johnson
Peter wrote: > This post seeks advice on whether python would be appropriate for a task, or > whether you can suggest another approach. > > The project is to transcribe historical records such as schools admissions, > ship passenger lists, birth/death/marriages, etc for genealogy studies. > What

Re: regular expressions, substituting and adding in one step?

2006-05-10 Thread Kent Johnson
John Salerno wrote: > Call > me crazy, but I'm interested in regular expressions right now. :) Not crazy at all. REs are a powerful and useful tool that every programmer should know how to use. They're just not the right tool for every job! Kent -- http://mail.python.org/mailman/listinfo/pyth

Re: Enumerating Regular Expressions

2006-05-09 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > Hi all, > > Does anybody know of a module that allows you to enumerate all the > strings a particular regular expression describes? Make a generator that yields *all* strings in your chosen alphabet (see the monthly threads about permutations and combinations for hints

Re: regular expressions, substituting and adding in one step?

2006-05-09 Thread Kent Johnson
John Salerno wrote: > Ok, this might look familiar. I'd like to use regular expressions to > change this line: > > self.source += '' + paragraph + '\n\n' > > to read: > > self.source += '%s\n\n' % paragraph > > Now, matching the middle part and replacing it with '%s' is easy, but > how would

Re: Global utility module/package

2006-05-09 Thread Kent Johnson
Christoph Haas wrote: > Evening, > > I'm currently working on a larger Python project that consists of multiple > programs and packages. As I need a few utility functions time and again I > moved them all into a Utility package and created a class there. ... > As I know that importing packages fro

Re: the print statement

2006-05-07 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > Thank you. Yes, that post answers most of the questions. I now have a > bit of an understanding of the \xhh pattern. It's still unclear to me, > however, how one can go from the \x92 pattern and arrive at the > apostrophe character. Is \x92 theh apostrophe character i

Re: Designing Plug-in Systems in Python

2006-05-07 Thread Kent Johnson
mystilleef wrote: > Hello, > > I need to design a plug-in system for a project. The goal is > to allow third party developers interact with an application > via plug-ins in a clean and robust manner. At this point I > am overwhelmed by my inexperience with designing plug-in > systems. One of thes

Re: Replace

2006-05-06 Thread Kent Johnson
Eric wrote: > I have a string... > > str = "tyrtrbd =ffgtyuf == =tyryr =u=p ff" > > I want to replace the characters after each '=', If you are replacing any char after = with # then re.sub() makes it easy: In [1]: import re In [2]: s = "tyrtrbd =ffgtyuf == =tyryr =u=p ff" In [3]: re.s

Re: string.find first before location

2006-05-03 Thread Kent Johnson
Gary Wessle wrote: > ps. is there a online doc or web page where one enters a method and it > returns the related docs? The index to the library reference is one place: http://docs.python.org/lib/genindex.html and of course help() in the interactive interpreter... Kent -- http://mail.python.org

Re: strip newlines and blanks

2006-05-02 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > hi > i have a file test.dat eg > > abcdefgh > ijklmn > <-newline > opqrs > tuvwxyz > > > I wish to print the contents of the file such that it appears: > abcdefgh > ijklmn > opqrs > tuvwxyz > > here is what i did: > f = open("test.dat") > while 1: >

Re: best way to determine sequence ordering?

2006-04-28 Thread Kent Johnson
I V wrote: > Incidentally, does python have a built-in to do a binary search on a > sorted list? Obviously it's not too tricky to write one, but it would be > nice if there was one implemented in C. See the bisect module. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Regular Expression help

2006-04-28 Thread Kent Johnson
Edward Elliott wrote: > [EMAIL PROTECTED] wrote: >> If you are parsing HTML, it may make more sense to use a package >> designed especially for that purpose, like Beautiful Soup. > > I don't know Beautiful Soup, but one advantage regexes have over some > parsers is handling malformed html. Beaut

Re: can this be done without eval/exec?

2006-04-27 Thread Kent Johnson
Schüle Daniel wrote: > and now the obvious one (as I thought at first) > > >>> lst=[] > >>> for i in range(10): > ... lst.append(lambda:i) > ... > >>> lst[0]() > 9 > >>> i > 9 > >>> > > I think I understand where the problem comes from > lambda:i seems not to be fully evalutated > it jus

Re: list of functions question

2006-04-27 Thread Kent Johnson
val bykoski wrote: > Hi The List: >I have a modeling app where i'm detecting events (in temporal > dynamics) applying a set of (boolean) functions - kind of: > > event_list = "f1 f2 etc".split() # each fi detects a specific event > i have defs for functions fi, or simple boolean expressions

Re: Thanks from the Java Developer

2006-04-21 Thread Kent Johnson
Alex Martelli wrote: > Ant <[EMAIL PROTECTED]> wrote: > >> Python ruined my life. Python ruined me for Java coding too. > At least in the Bay Area, the jobmarket for Python programmers is wild, > right now -- firms such as Google, Pixar, BitTorrent, IronPort, etc, > etc, all hungry for Pythonist

Re: send cookie on request with urllib2

2006-04-20 Thread Kent Johnson
itay_k wrote: > Hi, > > I dont understand why this is so complicated, just to add one line of > cookie header on the GET request. > > This is my unworking code: > import time > import Cookie > import cookielib, urllib2 > > c= cookielib.Cookie(1,"Name","Tom", 80,False, "itay", False, False, > "d:

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

2006-04-20 Thread Kent Johnson
>> Hey, all.Now I wanna to transfer a object to other computer, Maybe I >> could serialize the object to a file by pickle moudle, then send the file >> and get it from the file.But I think the efficency is awful, because the >> disk io is very slow. >> Someone could do me a favor to give

Re: Method Call in Exception

2006-04-20 Thread Kent Johnson
Carl Banks wrote: > mwt wrote: >> In my latest attempt at some Python code, I've been tempted to write >> something in the form of: >> >> try: >> [...] #doing some internet stuff >> except IOError: >> alternate_method_that_doesnt_need_internet() >> >> This works when I try it, but I feel va

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: extracting a substring

2006-04-19 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > Hi, > I have a bunch of strings like > a53bc_531.txt > a53bc_2285.txt > ... > a53bc_359.txt > > and I want to extract the numbers 531, 2285, ...,359. > > One thing for sure is that these numbers are the ONLY part that is > changing; all the other characters are always f

Re: http request with cookie sending

2006-04-19 Thread Kent Johnson
itay_k wrote: > Hi, > > I want to send a cookie on some http request (with urllib2), > so I created a Cookie but I cant associate it with CookieJar object. You have to use a cookielib.Cookie, not Cookie.SimpleCookie(): import cookielib, urllib2 cj = cookielib.CookieJar() cookie = cookielib.Cook

Re: Writing backwards compatible code - when?

2006-04-19 Thread Kent Johnson
> Bob Greschke wrote: >> Is there a list of all of the Python commands and modules that tell when >> (what version) they were added to Python? I was hoping the new Essential >> Reference would have it, but it doesn't. The Library Reference page for a module or built-in often documents the vers

Re: A 'Box' Function

2006-04-18 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > Hey guys. > > I should warn you, first off, that I'm relatively new to Python. > Basically, what I'm trying to do is create a word-wrapping function > with the added complication that it add a character at the beginning > and end of each line, so that it encloses the tex

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: scanning through page and replacing all instances of 00:00:00.00

2006-04-18 Thread Kent Johnson
Kun wrote: > Fredrik Lundh wrote: >> "Kun" wrote: >> >>> I have a python-cgi file that pulls data from an sql database, i am >>> wondering what is the easiest way to remove all instances of >>> '00:00:00.00' in my date column. >>> >>> how would i write a python script to scan the entire page and de

Re: Python certification/training

2006-04-17 Thread Kent Johnson
Richard Marsden wrote: > Aahz wrote: >> Then may I suggest that you subscribe to the tutor list? That will give >> you a good place to ask questions; as you learn Python, answering other >> people's questions will give you a good way to hone your own knowledge. > > > Which is? :-) http://mail.

Re: Problem involving sets...

2006-04-14 Thread Kent Johnson
flamesrock wrote: > Kind of a fun but confusing problem... > > I have two lists. Each list contains elements of two-element lists. > l1 = [['c1',1],['c2',2],['c3',4]] > l2 = [['c1',1],['c2',2],['c4',4],['c3',3]] > > Exactly in this format, where > superlist[0][0] is always a string > superlist[0]

Re: Unicode, command-line and idle

2006-04-14 Thread Kent Johnson
Egon Frerich wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > What do you have in the IDLE options - General - Default source encoding? UTF-8 > > Egon > > Kent Johnson schrieb am 12.04.2006 12:40: > >> [EMAIL PROTECTED] wrote: >>> Hello

Re: requestion regarding regular expression

2006-04-14 Thread Kent Johnson
BartlebyScrivener wrote: > Kent, > > Running > > path = "d:/emacs files/emacsinit.txt" > lines = open(path).readlines() > # my defun lines are lowercase, > # next two lines are all on one > starts = [i for i, line in enumerate(lines) if > line.startswith('(defun')] > for i, start in starts: >

Re: requestion regarding regular expression

2006-04-14 Thread Kent Johnson
Kelie wrote: > Hello, > > I'm trying to analyze some autolisp code with python. In the file to > be analyzed there are many functions. Each function begins with a > "defun" statement. And before that, there may or may not have comment > line(s), which begins with ";". My goal is to export each

Re: nested functions

2006-04-14 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > hi > just curious , if i have a code like this? > > def a(): > def b(): > print "b" > def c(): > print "c" > > how can i call c() ?? c is a name in the local scope of a(). You can call c from within a, where the name is in scope, or you can return c or in

%g not the same as %e or %f

2006-04-14 Thread Kent Johnson
According to the docs, %g formatting is "Same as "e" if exponent is greater than -4 or less than precision, "f" otherwise." So I would expect that for any num, '%g'%num == '%e'%num or '%g'%num == '%f'%num. But this is not the case in fact: Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 b

Re: trying to grasp OO : newbie Q?

2006-04-13 Thread Kent Johnson
John Salerno wrote: > Couldn't we also say that this issue of namespace scope is a little more > specific to Python than OOP in general? I could very easily be wrong, > but I wouldn't want the poster to think that this is how OOP works always. No, the confusion in the OP was between class attrib

Re: Initializing defaults to module variables

2006-04-12 Thread Kent Johnson
Burton Samograd wrote: > Hi, > > I'm writing an app that stores some user configuration variables in a > file ~/.program/config, which it then imports like so: > > import sys > from posix import environ > sys.path.append(environ["HOME"]+"/.program") > import confi

Re: datetime: the date of the day one month ago...how?

2006-04-12 Thread Kent Johnson
gabor wrote: > hi, > > i'm trying to get the date of the day one month ago. > > for example: > > today = 12.apr.2006 > one-month-ago = 12.mar.2006 dateutil has one implementation of this: http://labix.org/python-dateutil Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Unicode, command-line and idle

2006-04-12 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > Hello again, I've investigated a little bit and this is what I found: > > If I run IDLE and type > import sys sys.stdin.encoding > > I get > > 'cp1252' > > But if I have a whatever.py file (it can even be a blank file), I edit > it with IDLE, I press F5 (Ru

  1   2   3   4   5   6   7   >