Re: Want to reduce steps of an operation with dictionaries

2006-10-24 Thread James Stroud
good grounding > in the basic concepts. > > http://docs.python.org/tut/> > The values in the example are sequentially ordered wrt the keys, which is perhaps what the OP intends. c = dict(((k,v) for (v,k) in enumerate(x for x in sorted(a.keys()) if b.has_key(x But, yes,

Re: Need help (Basic python)...what did I do wrong?

2006-10-28 Thread James Stroud
> I think you are wrong. The new trend is toward absolutely no instruction at all and the students must guess the assignment. In this regard, I believe the OP is doing very well. Don't you think? James -- http://mail.python.org/mailman/listinfo/python-list

Re: Name bindings for inner functions.

2006-10-28 Thread James Stroud
he loop variable > when executing the "def" statement. > > Andrea Yet another way to skin the same cat, maybe even less ugly, depending on taste. def make_inner(i): def inner(): return i return inner def functions(): return [make_inner(i) for i in range(5)] pri

enumerate improvement proposal

2006-10-29 Thread James Stroud
a bit more complicated than this one. Any thoughts? James -- http://mail.python.org/mailman/listinfo/python-list

Re: enumerate improvement proposal

2006-10-29 Thread James Stroud
James Stroud wrote: > I think that it would be handy for enumerate to behave as such: > > def enumerate(itrbl, start=0, step=1): > i = start > for it in itrbl: > yield (i, it) > i += step > > This allows much more flexibility than in the current enumerate,

Re: enumerate improvement proposal

2006-10-29 Thread James Stroud
ially become a divisor or perhaps the operand in a logarithm. James -- http://mail.python.org/mailman/listinfo/python-list

Re: enumerate improvement proposal

2006-10-29 Thread James Stroud
Fredrik Lundh wrote: > James Stroud wrote: > >> def enumerate(itrbl, start=0, step=1): >>i = start >>for it in itrbl: >> yield (i, it) >> i += step > > that's spelled > > izip(count(start), sequence) > > in to

Re: enumerate improvement proposal

2006-10-29 Thread James Stroud
Fredrik Lundh wrote: > James Stroud wrote: > >> The code is for an economist. She is insistent on starting with the >> first bin as 1. > > leaky abstractions in reverse, in other words? that's not a good design > approach. > > > I'm not sure I

Re: enumerate improvement proposal

2006-10-29 Thread James Stroud
Fredrik Lundh wrote: > James Stroud wrote: > >> The code is for an economist. She is insistent on starting with the >> first bin as 1. > > > leaky abstractions in reverse, in other words? that's not a good design > approach. > > > Okay, I'

Re: enumerate improvement proposal

2006-10-30 Thread James Stroud
o much criticism, I challenge even the most skilled python programmer to find his or her own faculty economist (or statistician or physicist) and get them to radically change their computational tools. When you've walked a mile in my shoes, leaky abstractions won't seem like such a b

Re: enumerate improvement proposal

2006-10-30 Thread James Stroud
Steve Holden wrote: > How could you end up marrying > someone who counts from one and not zero? ;-) She's the only other person I've ever met who used vi key binding at the command line. James -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los A

Re: make a simple search function for homepage

2006-10-30 Thread James Stroud
; > words = ["the"] > x = SearchParser(words) > data = file("input.htm").read() > x.feed(data) > if x.found: > y = HightLightParser(file("output.htm", "w"),words) > y.feed(data) > google "google". Seriously though, perhaps you may want to index your pages first. Maybe checkout divmod (http://divmod.org/trac/wiki/DivmodXapwrap). James -- http://mail.python.org/mailman/listinfo/python-list

Re: High level csv reader

2006-11-01 Thread James Stroud
the standard library and (2) using google. http://docs.python.org/lib/module-csv.html James -- http://mail.python.org/mailman/listinfo/python-list

Re: Regular Expression for a string

2006-11-01 Thread James Stroud
[0-9]" at the end. but this is optional > > can any one please help me out pls > > > Teja.P > This is as general as could be constructed given your vague requirements: "[a-zA-Z][a-zA-Z0-9_]+" You may need to provide examples. James -- James Stroud U

Re: Python Classes and dynamic class members

2006-11-03 Thread James Stroud
, something like this would be possible: > > >>>>WeatherData.max_time >>>>[0.01,0.02,0.03,0.04,0.05,0.06,0.07,0.08,0.09,0.10,0.11,0.12] > > > Any help would be appreciated. > setattr(Weatherdata, "max_time", max_time) -- James S

Re: Python Classes and dynamic class members

2006-11-03 Thread James Stroud
[EMAIL PROTECTED] wrote: > James Stroud wrote: > >>[EMAIL PROTECTED] wrote: >> >>>I have a text file that I am parsing. Each line is of the form: >>> >>>max_time 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.10 0.11 0.12 >>> >>>

Re: Programming Language that is Spreadsheet/Table Based

2006-11-03 Thread James Stroud
nality. But, I'm curious about how people see such a beast working, though. Please don't criticize unless you have a better idea about the API of a Table. I want to hear genuine and concrete ideas and not abstruse pontification about programming or design! Statements of "I wouldn't do this thing here" should be immediately followed by "--rather, I would do this other thing for which I've created a concrete example below." If you think this interface is genius, well my ego wants to hear about that as well, but its not terribly necessary. James -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Programming Language that is Spreadsheet/Table Based

2006-11-04 Thread James Stroud
0:2] # if we know what column numbers we want instead > > t[1:3][0:2] and so on would be more intuitive to me, possibly > t[1:3]['First':'Age'] This looks better than my slicing, and to argue with it I'd have to break my own rules and point out that it would require making an intermediate table in the implementation. I am emulating numarray slicing closely, which itself is probably focused on implementation and speed. James -- http://mail.python.org/mailman/listinfo/python-list

Re: PySchool - Online Python Web Framework Workshop.

2006-11-04 Thread James Stroud
RobJ wrote: > Hi! My Name is Rob Johnson and I am a graduate student at The Richard > Stockton College of NJ. To make a long story short, I'm working on my > Masters project in the MAIT program (Masters of Arts in Instructional > Technology). I have written a proposal to put together a free on-line

Re: Programming Language that is Spreadsheet/Table Based

2006-11-04 Thread James Stroud
e >dt_customers = ds.tables["customers"] >view = DataView( dt_customers ) >view.rowfilter = "lastname LIKE 'A*' and Age < 60" > > I'm not saying imitate this, but maybe some value in studying the > OO-bondage approach. Thank you, this is very good stuff to think about. James -- http://mail.python.org/mailman/listinfo/python-list

Re: finding the list of the matched strings

2006-11-05 Thread James Stroud
[EMAIL PROTECTED] wrote: > Hi, I have a list of strings. And I want to find the subset which > matches a particular regular expression. > > import re > ll = ('a', 'b', 's1', 's2', '3s') > p = re.compile('^s.*') > newList = filter(lambda s: p.match(s), ll) > > I suppose there should be simple func

Re: Is there a commas-in-between idiom?

2006-11-05 Thread James Stroud
gt; > > Thx, > Ernesto print ",".joint(some_list) Where what you have named "list" is now called "some_list" because it is terribly ill-advised to reassign the name of a built-in type. James -- http://mail.python.org/mailman/listinfo/python-list

Re: tkFileDialog

2006-11-08 Thread James Stroud
ith > tkFileDialog. Does someone have a solution for that? import tkFileDialog afile = tkFileDialog.askopenfile() print afile.name James -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Py3K idea: why not drop the colon?

2006-11-10 Thread James Cunningham
On 2006-11-10 15:24:50 -0500, Bjoern Schliessmann <[EMAIL PROTECTED]> said: > Marc 'BlackJack' Rintsch wrote: > >> No it doesn't -- look again at the example given above. It's >> legal syntax in Python but doesn't have the semantics implied by >> the example. > > Sorry, I don't understand -- w

Re: Py3K idea: why not drop the colon?

2006-11-10 Thread James Cunningham
hear of it. Don't you know that with insufficient test cases, everything is right? Sheesh. Best, James -- http://mail.python.org/mailman/listinfo/python-list

Re: How to choose the right GUI toolkit ?

2006-11-10 Thread James Cunningham
Carbon), and GTK; it does not wrap Qt. On this page is a list of WxWidgets ports: http://wiki.wxwidgets.org/docbrowse.cgi/wxwin_wxplatforminfo.html According to the WxWidgets wiki, there's nothing stopping a person from writing a Qt port. http://www.wxwidgets.org/wiki/index.php/WxWidgets_

Re: refactoring so that multiple changes can be made with one variable?

2006-11-14 Thread James Stroud
def adjust_attributes(self): self.health += self._health_char_inc + self_health_base_inc self.armor += self._armor_char_inc + self._armor_base_inc # etc James -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Python v PHP: fair comparison?

2006-11-15 Thread James Cunningham
om or something. > > -Jeff Dirt-cheap Dreamhost also offers Python with Django (as well as Ruby with Rails), though I haven't used those capabilities so I can't judge how good the environment is. I suspect it isn't that great. The people at Dreamhost are great; the service its

Re: Python v PHP: fair comparison?

2006-11-15 Thread James Cunningham
eamhost. But with deals you can get it down to about that low, at least for the first year. I suppose I'm lucky enough not to miss $8 a month otherwise. Best, James -- http://mail.python.org/mailman/listinfo/python-list

Re: Python v PHP: fair comparison?

2006-11-16 Thread James Cunningham
On 2006-11-16 05:46:45 -0500, Steve Holden <[EMAIL PROTECTED]> said: > James Cunningham wrote: >> On 2006-11-15 20:59:26 -0500, "walterbyrd" <[EMAIL PROTECTED]> said: >> >>> Bruno Desthuilliers wrote: >>>> walterbyrd a écrit : >>

Re: Python v PHP: fair comparison?

2006-11-16 Thread James Cunningham
On 2006-11-16 09:08:43 -0500, Steve Holden <[EMAIL PROTECTED]> said: > James Cunningham wrote: >> On 2006-11-16 05:46:45 -0500, Steve Holden <[EMAIL PROTECTED]> said: >> >>> James Cunningham wrote: >>>> On 2006-11-15 20:59:26 -0500, "wa

Re: Python v PHP: fair comparison?

2006-11-16 Thread James Cunningham
On 2006-11-16 12:46:05 -0500, "walterbyrd" <[EMAIL PROTECTED]> said: > > James Cunningham wrote: > >> Nope. It disproves your assertion that "certainly all of the lower >> priced hosters" use Apache 1.3. > > Okay, where can I get Python

Re: Using a package like PyInstaller

2006-05-28 Thread James Stroud
is 'myjpegs'): import binascii import myjpegs import cStringIO def get_jpeg_as_opened_file(jpegname, module): jpegascii = module.__dict__[jpegname] jpegbin = binascii.a2b_base64(jpegascii) return cStringIO.StringIO(jpegbin) # getting that pik get_jpeg_as_opened_file('coo

Re: How to use tk.call ?

2006-05-29 Thread James Stroud
(tk, text='button') py> b.tk py> b.tk.call > I have tried the following: > > self.table.bind("",self.table.tk.call(self.table._w,'yview','scroll',-5,'units') I haven't used Table, but are you sure that what you are calling &q

Re: ideas for programs?

2006-05-31 Thread James Stroud
come from a java background, and that seems > the only language I can pay the bills with:). Particularly in the US > paid python jobs are hard to come by. James -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstrou

Re: Can Python format long integer 123456789 to 12,3456,789 ?

2006-06-01 Thread james . wondrasek
A.M wrote: > Hi, > > Is there any built in feature in Python that can format long integer > 123456789 to 12,3456,789 ? > > Thank you, > Alan I did this for putting commas into monetary amounts (thus the .2f): def commas(value): return "".join(commafy("%.2f" % value)) def commafy(s):

Re: Reversible replacement of whitespace characters with visible characters

2006-06-02 Thread James Stroud
e it. > > Micah > Try urllib. py> import urllib py> astr = 'faf\tfasf dsf\ndsfds dsf dsaf \t\r' py> urllib.quote(astr) 'faf%09fasf%20dsf%0Adsfds%20dsf%20dsaf%20%09%0D' py> print astr faf fasf dsf dsfds dsf dsaf James -- James Stroud UCLA-DOE

Re: Making a second window with Tkinter

2006-06-02 Thread James Stroud
rom Tkinter import * root = Tk() def callback(e=None): t = Toplevel() Label(t, text='blah').pack() b = Button(root, text='new top', command=callback) b.pack() root.mainloop() Also, do not do this twice in the same script: Tk(). James -- James Stroud UCLA-DOE Institute

Re: Little question about Tkiner: window focus

2006-06-05 Thread James Stroud
> windows. I have looked into the "takefocus" option, but doesn't seem > to have any effect. > > I'm using Python 2.4 on Windows XP Pro SP1. > > > Thanks > Bernard You should post a code snippet so we can see if there is anything amiss. James -- Jame

Re: what is often before a pattern ?

2006-06-08 Thread James Stroud
> appears 4/4. > > maybe have you some suggestions or idioms where i should look after > > best. > Look into suffix trees. http://www.csse.monash.edu.au/~lloyd/tildeAlgDS/Tree/Suffix/ -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Most elegant way to generate 3-char sequence

2006-06-09 Thread James Stroud
27;d'] > > def generator(): > for char in alpha: > for char2 in alpha2: > for char3 in alpha3: > yield char + char2 + char3 > > x = generate() > x.next() # etc, etc, etc, > import string alpha = string.lowercase def generator(choices, length): fo

Re: Most elegant way to generate 3-char sequence

2006-06-09 Thread James Stroud
> > def generator(): > for char in alpha: > for char2 in alpha2: > for char3 in alpha3: > yield char + char2 + char3 > > x = generate() > x.next() # etc, etc, etc, > A touch more efficient: import string alpha = string.lowercase def generator(c

Re: Most elegant way to generate 3-char sequence

2006-06-09 Thread James Stroud
7;] > > def generator(): > for char in alpha: > for char2 in alpha2: > for char3 in alpha3: > yield char + char2 + char3 > > x = generate() > x.next() # etc, etc, etc, > Yet a little more efficient. import string alpha = string.lowercase def gener

Re: Most elegant way to generate 3-char sequence

2006-06-09 Thread James Stroud
esn't do so well for something like aaa aab . . . zzy zzzzzzz James

Re: Most elegant way to generate 3-char sequence

2006-06-10 Thread James Stroud
SuperHik wrote: > James Stroud wrote: > >> SuperHik wrote: >> >>> and the winner is... :D >>> David Isaac wrote: >>> >>>> alpha = string.lowercase >>>> x=(a+b+c for a in alpha for b in alpha for c in alpha) >>> >

Re: Most elegant way to generate 3-char sequence

2006-06-10 Thread James Stroud
Steve Holden wrote: > James Stroud wrote: > >> Rob Cowie wrote: >> >>> Hi all, >>> >>> I wish to generate a sequence of the form 'aaa', 'aab', aac' 'aba', >>> 'abb', 'abc' etc. all

Re: Most elegant way to generate 3-char sequence

2006-06-10 Thread James Stroud
Steve Holden wrote: > James Stroud wrote: > >> SuperHik wrote: >> >>> and the winner is... :D >>> David Isaac wrote: >>> >>> >>>> alpha = string.lowercase >>>> x=(a+b+c for a in alpha for b in alpha for c in alpha) &

Re: Most elegant way to generate 3-char sequence

2006-06-10 Thread James Stroud
James Stroud wrote: > SuperHik wrote: > >> James Stroud wrote: >> >>> SuperHik wrote: >>> >>>> and the winner is... :D >>>> David Isaac wrote: >>>> >>>>> alpha = string.lowercase >>>>> x=(a+b+

Re: Most elegant way to generate 3-char sequence

2006-06-10 Thread James Stroud
Steve Holden wrote: > James Stroud wrote: > >> SuperHik wrote: >> >>> and the winner is... :D >>> David Isaac wrote: >>> >>> >>>> alpha = string.lowercase >>>> x=(a+b+c for a in alpha for b in alpha for c in alpha) &

Re: Most elegant way to generate 3-char sequence

2006-06-11 Thread James Stroud
Fredrik Lundh wrote: > James Stroud wrote: > >> See the actual question: >> >> >How would you construct a generator to acheive this? > > > if you don't think the context provided by the subject line and the > sentence before the question is impo

Re: learning python idioms

2006-06-11 Thread James Stroud
ient and which aren't? > > Thanks in advance, > Ben > As an experiment, I googled 'python idioms' and got a few good hits right at the top. I probably should have done this a long time ago. James -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Bo

Re: Tuple Syntax and ()

2006-06-13 Thread James Stroud
in relation to tuples at all, do they? > Aside from grouping, they are special to construct an empty tuple. py> () == tuple() True Also, don't underestimate their relationship with tuples when it comes to grouping: py> a, b, c = 1, 2, 3 py> py> a == a, b, c (True, 2, 3) py&g

Re: "groupby" is brilliant!

2006-06-13 Thread James Stroud
ly your question (which you didn't really have). I'm sure I will regret this becuase, as you will find, suggesting code on this list with additional utility is somewhat discouraged by the vociferous few who make a religion out of 'import this'. Also, I still have no idea what 'groupby' does. It looks interesting thgough, thanks for pointing it out. James -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: "groupby" is brilliant!

2006-06-13 Thread James Stroud
James Stroud wrote: > Frank Millman wrote: > >> Hi all >> >> This is probably old hat to most of you, but for me it was a >> revelation, so I thought I would share it in case someone has a similar >> requirement. >> >> I had to convert an ol

Re: "groupby" is brilliant!

2006-06-14 Thread James Stroud
Alex Martelli wrote: > James Stroud <[EMAIL PROTECTED]> wrote: >... > >>def doit(rows, doers, i=0): >> for r, alist in groupby(rows, itemgetter(i)): >> if len(doers) > 1: >> doit(alist, doers[1:], i+1) >> doers[0](r) > >

Re: "groupby" is brilliant!

2006-06-14 Thread James Stroud
Alex Martelli wrote: > James Stroud <[EMAIL PROTECTED]> wrote: >... > >>def doit(rows, doers, i=0): >> for r, alist in groupby(rows, itemgetter(i)): >> if len(doers) > 1: >> doit(alist, doers[1:], i+1) >> doers[0](r) > >

Re: Negative hex to int

2006-06-14 Thread James Stroud
7', 16) > > 231 > --- > > Does anyone have a clue a to what I need to do? > > Thanks! > > Andreas Lydersen > py> t = lambda x: int(x, 16) - ((int(x, 16) >> 7) * 256) py> t('e7') -25 -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: a good programming text editor (not IDE)

2006-06-15 Thread James Stroud
e fun kind of memory) and all of those mind boggling keystrokes begin to feel like an artistic expression reminiscent of playing the piano. James -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Looking for examples related to advanced python string, list and map operations

2006-06-15 Thread James Stroud
108, 111, 44, 32, 119, 111, 114, 108, 100, 33] > > print filter(lambda n: n % 2 == 0, numbers) > > > > numbers = [72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100, 33] > > print reduce(lambda x, y: x+y, numbers) > > > > Thank you, > > Alan

Re: a good programming text editor (not IDE)

2006-06-16 Thread James Stroud
ue...maybe personality #2 should be > arguing for brown instead). > > My best friend is an emacs user, and I'm a vimmer...it doesn't > come between us. :) > > -tkc Yes, heartwarming, but if you are thinking marriage... -- James Stroud UCLA-DOE Institute for G

Re: Pycrypto

2006-06-16 Thread James Stroud
) > ECB cipher. Why we have this limitation? > > Laszlo > > CBC mode is cipher block chaining, so it still works as a block cipher, which means that it must be that len(text) % block_size == 0. In other words, CBC does not shift by one byte but by block_size bytes. See: http://e

Re: interactive multi-file search and replace

2006-06-19 Thread James Stroud
common task and I don't want to re-invent the > wheel. > > Ryan Most people probably use something like vim rather than re-inventing the wheel themselves. James -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud

Re: Absolute noob to Linux programming needs language choice help

2006-06-20 Thread James Stroud
s. I'm not so sure C is better suited. Definitely resist "shell scripting". Several chapters in Mark Lutz's _Programming Python_ will help with networking (after you have read through _Learning Python_ or equivalent). NewRiders publishes _Python Web Programming_ authored by Ste

Re: tkMessagebox.askyesno always returns False

2006-06-21 Thread James Stroud
> This problem seems to be beyond the code you provide. Is this part of a larger program? Is it possible to show the entire script? James -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: How to generate all permutations of a string?

2006-06-22 Thread James Stroud
7;.join(t)) > return l > > This gives me a syntax error! > I need to output a list that has all the permutations of the input string. > > > > >>-- >>http://mail.python.org/mailman/listinfo/python-list >> > > p = ["".join(s) for s in permute('abcdefg')] -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: How to generate all permutations of a string?

2006-06-22 Thread James Stroud
ows: > > def permute(seq): > l = [] > if len(seq) == 0: > yield [] > else: > for i in range(0,len(seq)): > for rest in permute(seq[:i] + seq[i+1:]): > yield (seq[i],) + rest > > def main(stringList): >

Re: Looking for Python code to obsfucate mailto links on web site

2006-06-26 Thread James Stroud
Dan Sommers wrote: > On Sun, 25 Jun 2006 21:10:31 +0100, > Andrew McLean <[EMAIL PROTECTED]> wrote: > > >>I'm looking at putting some e-mail contact addresses on a web site, >>and wanted to make it difficult for spammers to harvest them. > > > [ ... ] > > >>Searching the web it looks like the

Re: Having problems with strings in HTML

2006-06-26 Thread James Stroud
blue=yes&local_file_name=%(OUT_FILE_NAME)s&show_instructions=no&expt_link=NASCArrays&max_adjust=2&view_size=large&highlight=%(HI_LITE_FILE_NAME)s">GraphicalOutput > > > ''' % {'OUT_FILE_NAME': OUT_FILE_NAME, 'HI_

Re: Beginner question: use function to read text file

2006-06-26 Thread James Stroud
;=== You have assigned open (which, by the way, is a builtin!) in a function *after* you have referenced it. You have over-ridden the open name with the assignment, but you have referenced it 'before assignment', as your error mesage says. This is a favorite trip-up of newer pytho

curiosity about the nature of identity (in python)

2006-06-28 Thread James Stroud
+2) 149679044 py> id(7*6) 149679044 So, I guess my question is to what extent is this equivalency implementation dependent? Is this equivalency a requirement for a legitimate python implementation? Won't these checks slow down evaluation of 'is' considerably? Does '==

Re: Maximize main window with code

2006-06-30 Thread James Stroud
lHello = Label(F, text="Hello") > lHello.pack() > bQuit = Button(F, text="Quit", command=F.quit) > bQuit.pack() > # set the loop running > top.mainloop() > This gets pretty close: top.geometry('%sx%s+0+0' % top.maxsize()) James -- James Stroud U

Easier way to save result of a function?

2006-07-04 Thread James Mitchelhill
t decorators as they seem like they could be used for this, but I've no idea how exactly, or even if they're the appropriate tool. Thanks. -- James Mitchelhill [EMAIL PROTECTED] http://disorderfeed.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Easier way to save result of a function?

2006-07-04 Thread James Mitchelhill
On Tue, 4 Jul 2006 16:53:27 -0700, Alex Martelli wrote: > James Mitchelhill <[EMAIL PROTECTED]> wrote: >> I'm trying to write a class that analyses some data. I only want it to >> do as much work as necessary, so it saves method results to a >> dictionary &

Re: A Sort Optimization Technique: decorate-sort-dedecorate

2006-08-28 Thread William James
[EMAIL PROTECTED] wrote: > I would be interested in comments about how Common Lisp, Scheme, and > Haskell deal with the decorate-sort-dedecorate technique. %w(FORTRAN LISP COBOL).sort_by{|s| s.reverse} ==>["COBOL", "FORTRAN", "LISP"] -- Common Lisp did kill Lisp. Period. ... It is to Lisp

Re: Need Python for Linux (Suse 10.1)

2006-08-31 Thread James Oakley
t;Software Management", select the search filter, and enter python in the search box. There's a ton of Python stuff on SUSE, and there's even more in my YaST-compatible repo at http://repos.opensuse.org/home:/jimfunk/ . -- James Oakley [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Building Python Based Web Application

2006-09-08 Thread James Stroud
oriented web development with a focus on applying my python skills. Any suggestions will be greatly appreciated. James -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: best split tokens?

2006-09-08 Thread James Stroud
ho', 'art', 'in', 'heaven', 'hallowed', 'be', 'their', 'names', 'did', 'forthwith', 'declare', 'that', 'all', 'men', 'are', 'created', 'to

Re: Looking for a regexp generator based on a set of known string representative of a string set

2006-09-08 Thread James Stroud
n Eddy and colleagues: http://hmmer.janelia.org/ http://selab.janelia.org/people/eddys/ James -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Looking for a regexp generator based on a set of known string representative of a string set

2006-09-09 Thread James Stroud
#x27;(?:c|n)(?:p|s)(?:k|u|d)g-3(?:1|0)0(?:A|0)(?:A|B|1|0|3|2|6|8)' print rgx_str But, if you get much more complicated that this, you will definitely want to check out hmmer, especially if you can align your sequences. James -- James Stroud UCLA-DOE Institute for Genomics and Proteomics

Re: Simple regex with whitespaces

2006-09-10 Thread James Stroud
27; object has no attribute 'group' py> patt_3plus.search(s1).group(0) Traceback (most recent call last): File "", line 1, in ? AttributeError: 'NoneType' object has no attribute 'group' py> patt_2plus.search(s1).group(0) Traceback (most recent call la

Re: Simple regex with whitespaces

2006-09-11 Thread James Stroud
ing one of the most accessible modules (to me, anyways)--and well worth learning. However, in complicated applications, regex is usually still fun and valuable as an intellectual exercise. James -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: table (ascii text) lin ayout recognition

2006-09-12 Thread James Stroud
he columns. Zeros will indicate high probability of between-column. Code tomorrow if no one else posts. Must run... -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: table (ascii text) lin ayout recognition

2006-09-13 Thread James Stroud
if v is not isit: indices.append(i) isit = not isit indices.append(i+1) indices = [t for t in zip(indices[::2],indices[1::2])] columns = [[line[t[0]:t[1]].strip() for line in lines] for t in indices] In case you want rows: rows = zip(*columns) James -- http://mail.python.org/mailman/listinfo/python-list

Re: table (ascii text) lin ayout recognition

2006-09-13 Thread James Stroud
James Stroud wrote: > indices = [t for t in zip(indices[::2],indices[1::2])] (Artefact of cut-and-paste.) Make that: indices = zip(indices[::2],indices[1::2]) James -- http://mail.python.org/mailman/listinfo/python-list

Re: Tkinter.Button(... command) lambda and argument problem

2006-09-15 Thread James Stroud
;, x return highliter class Test: def __init__(self, parent): buttons = [tk.Button(parent, text=str(x+1), command=make_it(x)) for x in range(5)] for button in buttons: button.pack(side=tk.LEFT) root = tk.Tk() d = Test(root) root.mainloop() -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: find class where method was defined ?

2006-09-19 Thread James Stroud
Simon Burton wrote: >>>>class A(object): > > ... def foo(self): pass > ... > >>>>class B(A): > > ... pass > ... > >>>>b=B() >>>>b.foo > > > > > How can I work out what class b.foo was defined in

Re: Pythonic way to condese my array

2006-09-19 Thread James Stroud
k this is, but I would do it thus: dicts = [{'column':1}, {'column':2}, {'column': 4}, {'column': 8}, {'column':4}] vals = list(set(d['column'] for d in dicts)) vals.sort() amap = dict((b,a) for (a,b) in enumerate(vals)) for d in dic

Re: naming objects from string

2006-09-20 Thread James Stroud
is this possible? > Depends on your namespace, but for the local namespace, you can use this: py> a = object() py> a py> locals()['bob'] = a py> bob A similar approach can be used for the global namespace. James -- James Stroud UCLA-DOE Institute for Genomics

Re: view page source or save after load

2006-09-20 Thread James Stroud
uot;?".join([baseurl, fetchparams])) afile = open(filename, "w") afile.write(wwwf.read()) afile.close() James -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list

Evaluation of Truth Curiosity

2006-09-21 Thread James Stroud
an artefact of the CPython implementation? James -- http://mail.python.org/mailman/listinfo/python-list

Re: Evaluation of Truth Curiosity

2006-09-21 Thread James Stroud
Everyone wrote: > [something intelligent] Ah, clarity. My confusion can undoubtedly be traced to a non-existent formal training in computer programming. Thank you. -- http://mail.python.org/mailman/listinfo/python-list

Re: view page source or save after load

2006-09-21 Thread James Stroud
e file object, so this won't work; you have to > bind the file to a temporary variable to be able to close it. Strictly speaking, "have to" is not perfectly correct. The ".close()" part can simply be eliminated as the file should close via garbage collection once leaving the local namespace. James -- http://mail.python.org/mailman/listinfo/python-list

Re: Retrieve HTML from site using cookies

2006-09-21 Thread James Stroud
r its good code from others. Names have been changed to protect the innocent. James #! /usr/bin/env python import sys import os.path import time import random import urllib import urllib2 import cookielib class DummyError(Exception): pass

Re: how to use timer in python

2006-09-21 Thread James Stroud
yxh wrote: > how to use timer in python. > the functionnality is like the MFC SetTimer() > > Try this (a little more flexible than Timer): http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/464959 -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los

Re: Tkinter button not working as expected

2006-09-21 Thread James Stroud
;red") # note change here self.button["command"] = functools.partial(self.getPath, t) self.button.pack(side=LEFT) def getPath(self, t): dirPath = tkFileDialog.askdirectory(initialdir="c:\\") print dirPath t.set(dirPath) root = Tk() app = App(root) root.mainloop() -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list

Building things with setup.py

2006-09-21 Thread James Stroud
e special in this regard? I'm running Linux FC4 on a dual intel p4 (~3.2 GHz) with sundry libraries in non-standard places. Is this non-standard part what's killing me? James -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jam

Re: Building things with setup.py

2006-09-21 Thread James Stroud
James Stroud wrote: > Hello All, > > This is annoying. I am trying to build scipy right now but every .so > file requires my adding "-lpython2.5 -lpthread -lm -lutil -ldl -shared" > to the ld flags. > > Main Question: When building with "setup.py", whe

Re: Building things with setup.py

2006-09-21 Thread James Stroud
Robert Kern wrote: > James Stroud wrote: > >> Hello All, >> >> This is annoying. I am trying to build scipy right now but every .so >> file requires my adding "-lpython2.5 -lpthread -lm -lutil -ldl >> -shared" to the ld flags. > > >>

Re: Building things with setup.py

2006-09-22 Thread James Stroud
Robert Kern wrote: > James Stroud wrote: >> I did build my own python 2.5, yesterday, requiring me to rebuild all >> extensions. > > Do other extensions build correctly? If so, it's beginning to look like > a problem in numpy.distutils . It seems that every thi

Re: Building things with setup.py

2006-09-22 Thread James Stroud
Martin v. Löwis wrote: > James Stroud schrieb: >> This is annoying. I am trying to build scipy right now but every .so >> file requires my adding "-lpython2.5 -lpthread -lm -lutil -ldl -shared" >> to the ld flags. > > That shouldn't be necessary.

<    7   8   9   10   11   12   13   14   15   16   >