Re: tiny script has memory leak

2012-05-17 Thread Iain King
On Friday, 11 May 2012 22:29:39 UTC+1, gry wrote: sys.version -- '2.6 (r26:66714, Feb 21 2009, 02:16:04) \n[GCC 4.3.2 [gcc-4_3-branch revision 141291]] I thought this script would be very lean and fast, but with a large value for n (like 15), it uses 26G of virtural memory, and things

Re: Python Gotcha's?

2012-04-05 Thread Iain King
A common one used to be expecting .sort() to return, rather than mutate (as it does). Same with .reverse() - sorted and reversed have this covered, not sure how common a gotcha it is any more. Iain On Wednesday, 4 April 2012 23:34:20 UTC+1, Miki Tebeka wrote: Greetings, I'm going to

Re: Code Review

2011-05-25 Thread Iain King
On May 25, 2:44 pm, ad adsquai...@gmail.com wrote: On May 25, 4:06 am, Ulrich Eckhardt ulrich.eckha...@dominolaser.com wrote: ad wrote: Please review the code pasted below. I am wondering what other ways there are of performing the same tasks. On a unix system, you would call find

Re: use of index (beginner's question)

2011-04-28 Thread Iain King
On Apr 28, 2:45 am, Chris Angelico ros...@gmail.com wrote: Incidentally, you're allowed to put the comma on the last item too:  lists = [   ['pig', 'horse', 'moose'],   ['62327', '49123', '79115'], ] Often makes for easier maintenance, especially when you append array/list elements.

Re: Using nested lists and tables

2010-10-28 Thread Iain King
On Oct 28, 2:19 pm, Zeynel azeyn...@gmail.com wrote: On Oct 28, 4:49 am, Peter Otten __pete...@web.de wrote: Thank you this is great; but I don't know how to modify this code so that when the user types the string 's' on the form in the app he sees what he is typing. So, this will be in GAE.

Re: Using nested lists and tables

2010-10-28 Thread Iain King
On Oct 28, 2:35 pm, Iain King iaink...@gmail.com wrote: ... (a) I don't know if the order of resolution is predicated left-to- right in the language spec of if it's an implementation detail (b) columns[-1].startswith('s') would be better ... Ignore (b), I didn't read the original message

Re: replacing words in HTML file

2010-04-29 Thread Iain King
On Apr 29, 10:38 am, Daniel Fetchinson fetchin...@googlemail.com wrote: | Any idea how I can replace words in a html file? Meaning only the | content will get replace while the html tags, javascript, css are | remain untouch. | | I'm not sure what you tried and what you haven't but

Re: Usable street address parser in Python?

2010-04-20 Thread Iain King
On Apr 20, 8:24 am, John Yeung gallium.arsen...@gmail.com wrote: My response is similar to John Roth's.  It's mainly just sympathy. ;) I deal with addresses a lot, and I know that a really good parser is both rare/expensive to find and difficult to write yourself.  We have commercial,

Re: Code redundancy

2010-04-20 Thread Iain King
On Apr 20, 2:43 pm, Alan Harris-Reid aharrisr...@googlemail.com wrote: Hi, During my Python (3.1) programming I often find myself having to repeat code such as... class1.attr1 = 1 class1.attr2 = 2 class1.attr3 = 3 class1.attr4 = 4 etc. Is there any way to achieve the same result

Re: why (1, 2, 3) [1, 2, 3] is true?

2010-02-25 Thread Iain King
On Feb 25, 2:03 pm, fat bold cyclop fat.bold.cyc...@gmail.com wrote: Both are not equal, so the comparison returns an arbitrary result in Py2. Thanks, Stefan. If I understand you correctly the comparison is not valid. But I wonder if there is any logic behind this (in 2.x). Is it possible

Re: Ad hoc lists vs ad hoc tuples

2010-01-27 Thread Iain King
On Jan 27, 10:20 am, Floris Bruynooghe floris.bruynoo...@gmail.com wrote: One thing I ofter wonder is which is better when you just need a throwaway sequence: a list or a tuple?  E.g.: if foo in ['some', 'random', 'strings']:     ... if [bool1, bool2, boo3].count(True) != 1:    ... (The

Re: Symbols as parameters?

2010-01-21 Thread Iain King
On Jan 21, 7:43 am, Martin Drautzburg martin.drautzb...@web.de wrote: Hello all, When passing parameters to a function, you sometimes need a paramter which can only assume certain values, e.g.         def move (direction):                 ... If direction can only be up, down, left or

Re: substitution

2010-01-21 Thread Iain King
On Jan 21, 2:18 pm, Wilbert Berendsen wbs...@xs4all.nl wrote: Op maandag 18 januari 2010 schreef Adi: keys = [(len(key), key) for key in mapping.keys()] keys.sort(reverse=True) keys = [key for (_, key) in keys] pattern = (%s) % |.join(keys) repl = lambda x : mapping[x.group(1)] s =

Re: substitution

2010-01-18 Thread Iain King
On Jan 18, 10:21 am, superpollo ute...@esempio.net wrote: superpollo ha scritto: hi. what is the most pythonic way to substitute substrings? eg: i want to apply: foo -- bar baz -- quux quuux -- foo so that: fooxxxbazyyyquuux -- barxxxquuxyyyfoo bye i explain better:

Re: substitution

2010-01-18 Thread Iain King
On Jan 18, 12:41 pm, Iain King iaink...@gmail.com wrote: On Jan 18, 10:21 am, superpollo ute...@esempio.net wrote: superpollo ha scritto: hi. what is the most pythonic way to substitute substrings? eg: i want to apply: foo -- bar baz -- quux quuux -- foo so

Re: substitution

2010-01-18 Thread Iain King
On Jan 18, 2:17 pm, Adi Eyal a...@digitaltrowel.com wrote: From: superpollo ute...@esempio.net To: Date: Mon, 18 Jan 2010 11:15:37 +0100 Subject: substitution hi. what is the most pythonic way to substitute substrings? eg: i want to apply: foo -- bar baz -- quux quuux -- foo

Re: substitution

2010-01-18 Thread Iain King
On Jan 18, 4:26 pm, Steven D'Aprano st...@remove-this- cybersource.com.au wrote: On Mon, 18 Jan 2010 06:23:44 -0800, Iain King wrote: On Jan 18, 2:17 pm, Adi Eyal a...@digitaltrowel.com wrote: [...] Using regular expressions the answer is short (and sweet) mapping = {         foo : bar

Re: Writing a string.ishex function

2010-01-14 Thread Iain King
On Jan 14, 3:52 pm, chandra chyav...@gmail.com wrote: Folks, I am new to Python and could not find a function along the lines of string.ishex in Python. There is however, a string.hexdigits constant in the string module. I thought I would enhance the existing modlue but am unsure how I

Re: Different number of matches from re.findall and re.split

2010-01-11 Thread Iain King
On Jan 11, 3:35 pm, Jeremy jlcon...@gmail.com wrote: Hello all, I am using re.split to separate some text into logical structures. The trouble is that re.split doesn't find everything while re.findall does; i.e.: found = re.findall('^ 1', line, re.MULTILINE) len(found)    6439

Re: The rap against while True: loops

2009-10-20 Thread Iain King
On Oct 19, 7:51 am, Hendrik van Rooyen hend...@microcorp.co.za wrote: On Sunday, 18 October 2009 11:31:19 Paul Rubin wrote: Hendrik van Rooyen hend...@microcorp.co.za writes: Standard Python idiom: if key in d:   d[key] += value else:   d[key] = value The issue is that uses

Re: Simple if-else question

2009-09-30 Thread Iain King
On Sep 30, 7:12 am, Steven D'Aprano ste...@remove.this.cybersource.com.au wrote: On Tue, 29 Sep 2009 22:29:10 -0700, John Yeung wrote: On Sep 29, 1:15 pm, Carl Banks pavlovevide...@gmail.com wrote: Hmm, I wonder if Python should emit a warning if an else is used on a for block with no break

Re: easy question, how to double a variable

2009-09-24 Thread Iain King
On Sep 23, 7:36 pm, David C Ullrich dullr...@sprynet.com wrote: On Tue, 22 Sep 2009 02:34:53 +, Steven D'Aprano wrote: On Mon, 21 Sep 2009 13:50:23 -0500, David C Ullrich wrote: But you actually want to return twice the value. I don't see how to do that. What? Seriously? You're

Re: remove last 76 letters from string

2009-08-06 Thread Iain King
print nucleotides, seq[-76]      last_part = line.rstrip()[-76 : ] You all mean: seq[:-76] , right? (assuming you've already stripped any junk off the end of the string) Iain -- http://mail.python.org/mailman/listinfo/python-list

Re: remove last 76 letters from string

2009-08-06 Thread Iain King
On Aug 6, 11:34 am, MRAB pyt...@mrabarnett.plus.com wrote: Iain King wrote:      print nucleotides, seq[-76]      last_part = line.rstrip()[-76 : ] You all mean:   seq[:-76]   , right? (assuming you've already stripped any junk off the end of the string) The OP said cut out the last

Re: Confessions of a Python fanboy

2009-07-31 Thread Iain King
On Jul 31, 8:28 am, Steven D'Aprano st...@remove-this- cybersource.com.au wrote: On Thu, 30 Jul 2009 18:06:31 -0500, Robert Kern wrote: On 2009-07-30 16:44, r wrote: On Jul 30, 4:29 pm, Emmanuel Surleauemmanuel.surl...@gmail.com wrote: 1.) No need to use () to call a function with no

Re: Confessions of a Python fanboy

2009-07-31 Thread Iain King
On Jul 31, 4:08 pm, Ethan Furman et...@stoneleaf.us wrote: Steven D'Aprano wrote: On Thu, 30 Jul 2009 18:47:04 +0100, Tim Rowe wrote: That and the fact that I couldn't stop laughing for long enough to learn any more when I read in the Pragmatic Programmer's Guide that Ruby, unlike less

Re: string character count

2009-07-01 Thread Iain King
On Jun 30, 6:27 pm, noydb jenn.du...@gmail.com wrote: If I have a string for a file name such that I want to find the number of characters to the left of the dot, how can that be done? I did it this way: x = text12345.txt dot = x.find('.') print dot Was curious to see what method others

Re: do replacement evenly

2009-06-02 Thread Iain King
On Jun 2, 12:10 pm, oyster lepto.pyt...@gmail.com wrote: I have some strings, and I want to write them into a text files, one string one line but there is a requirement: every line has a max length of a certain number(for example, 10), so I have to replace extra SPACE*3 with SPACE*2, at the

Re: Adding a Par construct to Python?

2009-05-20 Thread Iain King
On May 19, 10:24 am, Steven D'Aprano ste...@remove.this.cybersource.com.au wrote: On Mon, 18 May 2009 02:27:06 -0700, jeremy wrote: Let me clarify what I think par, pmap, pfilter and preduce would mean and how they would be implemented. [...] Just for fun, I've implemented a parallel-map

Re: Any idea to emulate tail -f

2009-05-05 Thread Iain King
On May 5, 7:00 am, Joel Juvenal Rivera Rivera joel...@gmail.com wrote: I want to make something very similar to  the command tail -f (follow a file), i have been trying  with some while True and some microsleeps (about .1 s); did someone has already done something like this? And about the

Re: Scraping a web page

2009-04-08 Thread Iain King
On Apr 7, 1:44 pm, Tim Chase python.l...@tim.thechases.com wrote: f = urllib.urlopen(http://www.google.com;) s = f.read() It is working, but it's returning the source of the page. Is there anyway I can get almost a screen capture of the page? This is the job of a browser -- to render

Re: Why is lambda allowed as a key in a dict?

2009-03-10 Thread Iain King
On Mar 10, 6:38 am, Daniel Fetchinson fetchin...@googlemail.com wrote: On 3/9/09, bearophileh...@lycos.com bearophileh...@lycos.com wrote: See here Daniel Fetchinson: http://groups.google.com/group/comp.lang.python/browse_thread/thread/... But be quite careful in using that stuff, it has

Re: RELEASED Python 3.0 final

2008-12-04 Thread Iain King
On Dec 4, 1:51 am, Barry Warsaw [EMAIL PROTECTED] wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On behalf of the Python development team and the Python community, I am happy to announce the release of Python 3.0 final. Python 3.0 (a.k.a. Python 3000 or Py3k) represents a major

Re: Obama's Birth Certificate - Demand that US presidential electors investigate Obama's eligibility

2008-12-03 Thread Iain King
On Dec 3, 10:16 am, [EMAIL PROTECTED] wrote: On Dec 3, 12:53 am, Bryan Olson [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: This message is not about the meaningless computer printout called More importantly, it's not about Python. I'm setting follow-ups to talk.politics.

Re: Multiple equates

2008-11-25 Thread Iain King
On Nov 17, 7:41 pm, Tim Chase [EMAIL PROTECTED] wrote: It doesn't matter as none of this is valid Python. In Python you have to write array[x1] = False array[x2] = False Uh...not so much... a = [1,2,3,4,5] x1, x2 = 1, 3 a[x1] = a[x2] = False a [1, False, 3, False, 5]

Re: Multiple equates

2008-11-25 Thread Iain King
On Nov 25, 11:29 am, Iain King [EMAIL PROTECTED] wrote: On Nov 17, 7:41 pm, Tim Chase [EMAIL PROTECTED] wrote: It doesn't matter as none of this is valid Python. In Python you have to write array[x1] = False array[x2] = False Uh...not so much... a = [1,2,3,4,5] x1

Re: Accessing Modification Time of an Outlook Mail in Python

2008-11-25 Thread Iain King
On Nov 25, 5:11 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi all, I am writing a small application which reads the contents of an Outlook Mail using python. I am able to read the contents, subject along with senders and receivers of a mail using MAPI objects. But may I know how

Re: How to update value in dictionary?

2008-08-27 Thread Iain King
On Aug 27, 2:40 pm, ssecorp [EMAIL PROTECTED] wrote: dict.update({a:1}) SETS the dict item a 's value to 1. i want to increase it by 1. isnt that possible in an easy way? I should use a tuple for this? dict[a] += 1 Iain -- http://mail.python.org/mailman/listinfo/python-list

Re: use of Queue

2008-08-27 Thread Iain King
On Aug 27, 1:17 pm, Alexandru Mosoi [EMAIL PROTECTED] wrote: On Aug 27, 12:45 pm, Alexandru Mosoi [EMAIL PROTECTED] wrote: how is Queue intended to be used? I found the following code in python manual, but I don't understand how to stop consumers after all items have been produced. I

Re: gridSizer inside a panel element

2008-08-22 Thread Iain King
On Aug 22, 2:09 pm, Gandalf [EMAIL PROTECTED] wrote: why when I try to insert gridSizer to a panel which already inside another panel the gridSizer doesn't work? this is the code: panel3= wx.Panel(self, -1, (0, 60), size=(400, 240) , style=wx.SIMPLE_BORDER);

Re: Limits of Metaprogramming

2008-08-08 Thread Iain King
On Aug 4, 5:13 pm, Tomasz Rola [EMAIL PROTECTED] wrote: On Mon, 4 Aug 2008, Wilson wrote: Every sufficiently large application has a poor/incomplete implementation ofLISPembedded within it . Yep, this is either exact or very close copy of what I have read. It's Greenspun's Tenth Rule of

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-31 Thread Iain King
On Jul 31, 7:08 am, Russ P. [EMAIL PROTECTED] wrote: On Jul 30, 10:43 pm, Erik Max Francis [EMAIL PROTECTED] wrote: Russ P. wrote: On Jul 30, 9:27 pm, Erik Max Francis [EMAIL PROTECTED] wrote: You're sure going on about a distinction without a difference for a guy who childishly

Re: Attack a sacred Python Cow

2008-07-29 Thread Iain King
On Jul 29, 5:33 am, Russ P. [EMAIL PROTECTED] wrote: On Jul 28, 8:44 pm, alex23 [EMAIL PROTECTED] wrote: On Jul 29, 4:46 am, Russ P. [EMAIL PROTECTED] wrote: As I said, I could write a pre-processor myself to implement it in less than a day. So WHY DON'T YOU WRITE IT ALREADY? I'm

Re: Execution speed question

2008-07-25 Thread Iain King
On Jul 25, 10:57 am, Suresh Pillai [EMAIL PROTECTED] wrote: I am performing simulations on networks (graphs). I have a question on speed of execution (assuming very ample memory for now). I simplify the details of my simulation below, as the question I ask applies more generally than my

Re: Execution speed question

2008-07-25 Thread Iain King
On Jul 25, 1:46 pm, Iain King [EMAIL PROTECTED] wrote: On Jul 25, 10:57 am, Suresh Pillai [EMAIL PROTECTED] wrote: I am performing simulations on networks (graphs). I have a question on speed of execution (assuming very ample memory for now). I simplify the details of my simulation

Re: Execution speed question

2008-07-25 Thread Iain King
On Jul 25, 3:39 pm, Suresh Pillai [EMAIL PROTECTED] wrote: That's a good comparison for the general question I posed. Thanks. Although I do believe lists are less than ideal here and a different data structure should be used. To be more specific to my case: As mentioned in my original post,

Re: Execution speed question

2008-07-25 Thread Iain King
On Jul 25, 4:22 pm, Matthew Fitzgibbons [EMAIL PROTECTED] wrote: It seems like the probability calculation applies to all three equally, and can therefore be ignored for the simulations. The probability affects (1) more. My reasoning for this being: as probability gets lower the number of

Re: Python Written in C?

2008-07-21 Thread Iain King
On Jul 21, 6:58 am, Krishnakant Mane [EMAIL PROTECTED] wrote: First off all c# is absolute rubbish waist of time.  if I need to learn it then I better lern java or pythonfor that matter.  and by the way what is a real programmer? The story of a Real Programmer:

Re: Best Python packages?

2008-07-19 Thread Iain King
On Jul 19, 8:56 am, Stefan Behnel [EMAIL PROTECTED] wrote: Iain King wrote: Well, if you're looking for a list of excellent 3rd party Python libraries, then I can give you the ones I like and use a lot: [...] BeautifulSoup : for real-world (i.e. not-at-all-recommendation- compliant) HTML

Re: Best Python packages?

2008-07-18 Thread Iain King
On Jul 18, 11:23 am, Ben Sizer [EMAIL PROTECTED] wrote: On Jul 16, 3:31 pm, Fredrik Lundh [EMAIL PROTECTED] wrote: Ben Sizer wrote: make my development a lot easier. Knowing what kind of development you do might help, of course.  Some libraries are excellent in some contexts and suck

Re: start reading from certain line

2008-07-10 Thread Iain King
On Jul 10, 2:45 pm, jstrick [EMAIL PROTECTED] wrote: Here's a simple way to do it with a minimum amount of loopiness (don't forget to use 'try-except' or 'with' in real life): f = open(item1.txt) for preline in f:     if Item 1 in preline:         print preline,         for goodline in f:

Re: start reading from certain line

2008-07-10 Thread Iain King
On Jul 10, 4:54 pm, Iain King [EMAIL PROTECTED] wrote: On Jul 10, 2:45 pm, jstrick [EMAIL PROTECTED] wrote: Here's a simple way to do it with a minimum amount of loopiness (don't forget to use 'try-except' or 'with' in real life): f = open(item1.txt) for preline in f:     if Item 1

Re: How to make python scripts .py executable, not bring up editor

2008-07-08 Thread Iain King
On Jul 7, 10:56 pm, korean_dave [EMAIL PROTECTED] wrote: From command Prompt, i type in a script,  tryme.py. This, instead, brings up PythonWin editor and Interactive Window. Path variable is C:\Python24. (I need Python 2.4 installed, not 2.5) How do I make it so that the script runs? find

Re: How to bypass Windows 'cooking' the I/O? (One more time, please) II

2008-07-07 Thread Iain King
On Jul 7, 10:18 am, Dennis Lee Bieber [EMAIL PROTECTED] wrote: On Mon, 07 Jul 2008 01:03:10 -0700, norseman [EMAIL PROTECTED] declaimed the following in comp.lang.python:   Normal file I/O sequence:   fp = open(target, 'wb')   fp.seek(-1, 2)   fp.write(record)    Except it

Re: Win32.client, DAO.DBEngine and exceeding the file sharing count lock

2008-07-03 Thread Iain King
On Jul 2, 8:13 pm, Tim Golden [EMAIL PROTECTED] wrote: In case it helps, there's a recipe just shown up on the Python Cookbook which at least illustrates DAO use: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/572165 TJG On Jul 2, 6:30 pm, M.-A. Lemburg [EMAIL PROTECTED] wrote:

Win32.client, DAO.DBEngine and exceeding the file sharing count lock

2008-07-02 Thread Iain King
Hi. I'm using the win32 module to access an Access database, but I'm running into the File Sharing lock count as in http://support.microsoft.com/kb/815281 The solution I'd like to use is the one where you can temporarily override the setting using (if we were in VB): DAO.DBEngine.SetOption

Re: Win32.client, DAO.DBEngine and exceeding the file sharing count lock

2008-07-02 Thread Iain King
On Jul 2, 3:29 pm, Tim Golden [EMAIL PROTECTED] wrote: Iain King wrote: Hi.  I'm using the win32 module to access an Access database, but I'm running into the File Sharing lock count as inhttp://support.microsoft.com/kb/815281 The solution I'd like to use is the one where you can

Re: Interesting Math Problem

2008-06-05 Thread Iain King
On Jun 4, 9:03 am, BEES INC [EMAIL PROTECTED] wrote: I've been awfully busy programming lately. My Django-based side project is coming along well and I hope to have it ready for use in a few weeks. Please don't ask more about it, that's really all I can say for now. Anyways, I came across an

Re: Creating A Tuple From A List, Adding To Tuple As You Do

2008-06-05 Thread Iain King
On Jun 5, 1:41 pm, Jeff Nyman [EMAIL PROTECTED] wrote: Greetings all. The subject line of this thread is probably one of the worst ever. I was trying to encapsulate what I am doing. Based on my new-found knowledge from another thread, I'm able to get a list of directories and they come to me

Re: Python and Flaming Thunder

2008-05-23 Thread Iain King
On May 23, 3:35 am, Charles Hixson [EMAIL PROTECTED] wrote: On Thursday 22 May 2008 13:30:07 Nick Craig-Wood wrote: ... From Armstrong's book: The expression Pattern = Expression causes Expression to be evaluated and the result matched against Pattern. The match either succeeds or

Re: Bug in floating-point addition: is anyone else seeing this?

2008-05-22 Thread Iain King
On May 22, 1:14 am, bukzor [EMAIL PROTECTED] wrote: On May 21, 3:28 pm, Dave Parker [EMAIL PROTECTED] wrote: On May 21, 4:21 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote: Which is exactly what the python decimal module does. Thank you (and Jerry Hill) for pointing that out. If I want

Re: wxpython dialog - do something after ShowModal()?

2008-05-15 Thread Iain King
On May 14, 9:37 pm, David C. Ullrich [EMAIL PROTECTED] wrote: In article [EMAIL PROTECTED], Iain King [EMAIL PROTECTED] wrote: Hi. I have a modal dialog whcih has a Browse... button which pops up a file selector. This all works fine, but the first thing the user has to do when

Re: Rename field in Access DB

2008-05-15 Thread Iain King
On May 14, 4:29 pm, Tim Golden [EMAIL PROTECTED] wrote: Iain King wrote: I'm manipulating an MS Access db via ADODB with win32com.client. I want to rename a field within a table, but I don't know how to. I assume there is a line of SQL which will do it, but nothing I've tried (from

Rename field in Access DB

2008-05-14 Thread Iain King
I'm manipulating an MS Access db via ADODB with win32com.client. I want to rename a field within a table, but I don't know how to. I assume there is a line of SQL which will do it, but nothing I've tried (from searching) has worked. Basic code: import win32com.client connection =

wxpython dialog - do something after ShowModal()?

2008-05-13 Thread Iain King
Hi. I have a modal dialog whcih has a Browse... button which pops up a file selector. This all works fine, but the first thing the user has to do when they open the dialog is select a file, so I would like the dialog to automatically call the onBrowse function as soon as the dialog opens.

Re: wxpython dialog - do something after ShowModal()?

2008-05-13 Thread Iain King
On May 13, 2:20 pm, Larry Bates [EMAIL PROTECTED] wrote: Iain King wrote: Hi. I have a modal dialog whcih has a Browse... button which pops up a file selector. This all works fine, but the first thing the user has to do when they open the dialog is select a file, so I would like

Re: wxpython dialog - do something after ShowModal()?

2008-05-13 Thread Iain King
On May 13, 2:43 pm, Iain King [EMAIL PROTECTED] wrote: On May 13, 2:20 pm, Larry Bates [EMAIL PROTECTED] wrote: Iain King wrote: Hi. I have a modal dialog whcih has a Browse... button which pops up a file selector. This all works fine, but the first thing the user has to do when

Splitting MainWindow Class over several modules.

2008-04-16 Thread Iain King
Until recently almost all my python programs were held 1 file for 1 program. This had grown unwieldy for one of my projects, so i decided to refactor it, and ended up with something like this: --- import wx import options import gui import scf class MainWindow(wx.Frame): def

Re: Wxpython. Is it possible to change layout in a running application? Selfmade listbox

2008-04-07 Thread Iain King
On Apr 7, 12:50 pm, Soren [EMAIL PROTECTED] wrote: Hi, Id like to make my own special listbox.. I want to able (at the push of a button) to add another item to my special listbox... each item is a panel with a label, some buttons and maybe a text control. I've tried adding a new panel

Re: String To List

2008-03-17 Thread Iain King
On Mar 17, 6:56 am, Dan Bishop [EMAIL PROTECTED] wrote: On Mar 17, 1:15 am, Girish [EMAIL PROTECTED] wrote: I have a string a = ['xyz', 'abc'].. I would like to convert it to a list with elements 'xyz' and 'abc'. Is there any simple solution for this?? Thanks for the help... eval(a)

Re: String To List

2008-03-17 Thread Iain King
On Mar 17, 9:27 am, Iain King [EMAIL PROTECTED] wrote: On Mar 17, 6:56 am, Dan Bishop [EMAIL PROTECTED] wrote: On Mar 17, 1:15 am, Girish [EMAIL PROTECTED] wrote: I have a string a = ['xyz', 'abc'].. I would like to convert it to a list with elements 'xyz' and 'abc'. Is there any simple

Re: the annoying, verbose self

2007-11-27 Thread Iain King
On Nov 27, 9:20 am, Roy Smith [EMAIL PROTECTED] wrote: In article [EMAIL PROTECTED], Bruno Desthuilliers [EMAIL PROTECTED] wrote: Steven D'Aprano a écrit : On Mon, 26 Nov 2007 21:48:36 +0100, Ton van Vliet wrote: On Mon, 26 Nov 2007 20:14:50 +0100, Bruno Desthuilliers [EMAIL

Re: the annoying, verbose self

2007-11-27 Thread Iain King
On Nov 27, 12:03 pm, Duncan Booth [EMAIL PROTECTED] wrote: Iain King [EMAIL PROTECTED] wrote: FTR, I won't be using this :) I do like this syntax though: class Vector: def __init__(self, x, y, z): self.x = x self.y = y self.z = z def abs(self

Re: Best way to generate alternate toggling values in a loop?

2007-10-18 Thread Iain King
On Oct 18, 2:29 am, Grant Edwards [EMAIL PROTECTED] wrote: On 2007-10-17, Debajit Adhikary [EMAIL PROTECTED] wrote: # Start of Code def evenOdd(): values = [Even, Odd] state = 0 while True: yield values[state] state = (state + 1) % 2 I'd replace the

Re: Difference between two times (working ugly code, needs polish)

2007-09-12 Thread Iain King
On Sep 12, 1:31 am, Shawn Milochik [EMAIL PROTECTED] wrote: I suppose really oneDay should be a global (i.e. outside the function definition). Apart from that it would be hard to improve on: obvious, easy to read, in short - pythonic. Are you concerned about daylight savings? That could

Re: wxPython and threads

2007-07-19 Thread Iain King
On Jul 18, 3:41 am, Benjamin [EMAIL PROTECTED] wrote: I'm writing a search engine in Python with wxPython as the GUI. I have the actual searching preformed on a different thread from Gui thread. It sends it's results through a Queue to the results ListCtrl which adds a new item. This works

Re: edit a torrent file with python

2006-10-13 Thread Iain King
di0rz` wrote: hi, I am looking for a python script to edit .torrent files if anybody know one thx Not sure exactly what you are looking for, but the original bittorrent client is written in Python, so you could grab a copy of it and check the code. Iain --

Re: Is it possible to save a running program and reload next time ?

2006-09-21 Thread Iain King
[EMAIL PROTECTED] wrote: Hi, I have a program which will continue to run for several days. When it is running, I can't do anything except waiting because it takes over most of the CUP time. Is it possible that the program can save all running data to a file when I want it to stop, and can

Re: PIL cannot open TIFF image in Windows

2006-09-11 Thread Iain King
Michele Petrazzo wrote: Rob Williscroft wrote: I downloaded some test images from: url:http://www.remotesensing.org/libtiff/images.html I do the same and modified your code for try FreeImagePy and the results are: ok: 41 error: 20 total: 61 Better than PIL, but

Re: Looking For mp3 ID Tag Module

2006-08-18 Thread Iain King
Tim Daneliuk wrote: Iñigo Serna wrote: On 8/18/06, Tim Daneliuk [EMAIL PROTECTED] wrote: try mutagen. http://www.sacredchao.net/quodlibet/wiki/Development/Mutagen This module is more-or-less exactly what I needed. However, I am running into problems when the filenames or ID tags

Re: The Semicolon Wars as a software industry and human condition

2006-08-17 Thread Iain King
Xah Lee wrote: Of interest: • The Semicolon Wars, by Brian Hayes. 2006. http://www.americanscientist.org/template/AssetDetail/assetid/51982 in conjunction to this article, i recommend: • Software Needs Philosophers, by Steve Yegge, 2006

Re: FOR LOOPS

2006-08-01 Thread Iain King
OriginalBrownster wrote: I am using a class called UploadedFile. I want to create a for loop to itterate through the objects within file name class UploadedFile(SQLObject): filename = StringCol(alternateID=True) abspath = StringCol() uniqueid = IntCol() I'll show you a

Re: random shuffles

2006-07-21 Thread Iain King
Dustan wrote: Boris Borcic wrote: does x.sort(cmp = lambda x,y : cmp(random.random(),0.5)) pick a random shuffle of x with uniform distribution ? Intuitively, assuming list.sort() does a minimal number of comparisons to achieve the sort, I'd say the answer is yes. But I don't

Re: using names before they're defined

2006-07-20 Thread Iain King
[EMAIL PROTECTED] wrote: Iain, thanks - very helpful. Really I'm trying to write a simulation program that goes through a number of objects that are linked to one another and does calculations at each object. The calculations might be backwards or fowards (i.e. starting at the supply or

Re: question about what lamda does

2006-07-19 Thread Iain King
Steve Holden wrote: tac-tics wrote: [EMAIL PROTECTED] wrote: Hey there, i have been learning python for the past few months, but i can seem to get what exactly a lamda is for. What would i use a lamda for that i could not or would not use a def for ? Is there a notable difference ? I

Re: using names before they're defined

2006-07-19 Thread Iain King
[EMAIL PROTECTED] wrote: I have a problem. I'm writing a simulation program with a number of mechanical components represented as objects. When I create instances of objects, I need to reference (link) each object to the objects upstream and downstream of it, i.e. supply = supply()

Re: Full splitting of a file's pathname

2006-07-10 Thread Iain King
tac-tics wrote: I know about os.path.split(), but Is there any standard function for fully splitting a file's pathname? A function that is the opposite of the os.path.join() function? For example: ret = myster_function(./foo/bar/moo/lar/myfile.txt) print ret ['.', 'foo', 'bar', 'moo',

Re: List Manipulation

2006-07-05 Thread Iain King
Mike Kent wrote: Roman wrote: Thanks for your help My intention is to create matrix based on parsed csv file. So, I would like to have a list of columns (which are also lists). I have made the following changes and it still doesn't work. cnt = 0 p=[[], [], [], [], [], [],

Re: List Manipulation

2006-07-04 Thread Iain King
Roman wrote: I would appreciate it if somebody could tell me where I went wrong in the following snipet: When I run I get no result cnt = 0 p=[] reader = csv.reader(file(f:\webserver\inp.txt), dialect=excel, quotechar=', delimiter='\t') for line in reader:

Re: String Question

2006-06-30 Thread Iain King
Tim Roberts wrote: Iain King [EMAIL PROTECTED] wrote: You probably want: s.sendto('\xff'*6 + ('\x%s\x%s\x%s\x%s\x%s\x%s' % (str01, str02, str03, sttr04, str05, str06))*16, ('192.168.1.255', 80)) You probably should TRY suggestions before you post them. That will get an invalid \x

Re: conecting with a MsAcces DB by dao

2006-06-30 Thread Iain King
luis wrote: Hi I'm using activestate python 2.4 on win xp 2 ed. and Ms Access 2002 (reading first http://starship.python.net/crew/bwilk/access.html) I have writed the following code def append_from_Access(self): try: import ... conn =

Re: conecting with a MsAcces DB by dao

2006-06-30 Thread Iain King
luis wrote: Iain King ha escrito: luis wrote: while not rs.EOF: id=rs.Fields(colName.Value) #colName, valid column name ... rs.MoveNext() rs.Close() conn.Close() I don't know if it's the problem your asking about, but your

Re: conecting with a MsAcces DB by dao

2006-06-30 Thread Iain King
luis wrote: Iain King ha escrito: luis wrote: Iain King ha escrito: luis wrote: while not rs.EOF: id=rs.Fields(colName.Value) #colName, valid column name ... rs.MoveNext() rs.Close() conn.Close() I don't

Re: String Question

2006-06-28 Thread Iain King
[EMAIL PROTECTED] wrote: mac_string = '001485e55503' (This is the mac address of a computer.) I am using wake on LAN python script to start computer remote.It uses format like this s.sendto('\xff'*6 + '\x00\x014\x85\xe5\x55\x03'*16, ('192.168.1.255', 80)) where

Re: Feed wxComboBox with dictionary/hash

2006-06-22 Thread Iain King
Roland Rickborn wrote: Hi folks, I am relatively new to Python. Although I read a lot of howtos, introductions and wikis, I am still having trouble ;-) My querstion: As the subject says, I'd like to feed a wx.ComboBox with a dictionary/hash. According to the posting of Stano Paska

Re: .py and running in Windows:

2006-06-13 Thread Iain King
Andrew Gwozdziewycz wrote: You'll have better results posting this to it's own thread. He certainly should have, but since I've read it here anyway: On Jun 13, 2006, at 9:29 AM, Michael Yanowitz wrote: Hello: Presently in my Windows 2000 system, when I double-click on a .py file

Bug in list comprehensions?

2006-06-07 Thread Iain King
I was playing with list comprehensions, to try and work out how doubled up versions work (like this one from another thread: [i for i in range(9) for j in range(i)]). I think I've figured that out, but I found something strange along the way: alpha = [one, two, three] beta = [A, B, C] [x for

Re: pyqt show wizard

2006-06-07 Thread Iain King
David Boddie wrote: Summary of the usual mess made by the Google Groups web interface: I suspect that you really want to call w.exec_loop() instead, since this will only return control to the method after the user has finished interacting with the wizard. Take a look at the QWizard

Re: Trying to get FreeImagePy to work.

2006-06-05 Thread Iain King
Michele Petrazzo wrote: Iain King wrote: I'll try out FIPY's resizing tomorrow too. OTOH, I have functions to convert between PIL and wxPython, and functions to convert betweem PIL and FIPY, but I don't see a function to convert FIPY to wxPython? Image at: http

Re: Large Dictionaries

2006-06-05 Thread Iain King
Lawrence D'Oliveiro wrote: In article [EMAIL PROTECTED], Scott David Daniels [EMAIL PROTECTED] wrote: For example, time timsort (Python's internal sort) on pre-sorted data; you'll find it is handled faster than random data. But isn't that how a reasonable sorting algorithm should behave?

  1   2   >