Re: Parameterized functions of no arguments?

2011-02-10 Thread Arnaud Delobelle
Rotwang writes: > On 11/02/2011 06:19, Paul Rubin wrote: >> Rotwang writes: >>> menu = Tkinter.Menu(master, tearoff = 0) >>> for k in x: >>> def f(j = k): >>> [do something that depends on j] >>> menu.add_command(label = str(k), command = f) >>> >>> Still

Re: Problem with giant font sizes in tkinter

2011-02-10 Thread Chris Jones
On Thu, Feb 10, 2011 at 09:08:01PM EST, Steven D'Aprano wrote: > On Thu, 10 Feb 2011 15:48:47 +, Cousin Stanley wrote: > > > Steven D'Aprano wrote: > > > >> I have a tkinter application under Python 2.6 which is shows text in a > >> giant font, about twenty(?) times larger than expected. > >>

Re: Parameterized functions of no arguments?

2011-02-10 Thread Rotwang
On 11/02/2011 06:19, Paul Rubin wrote: Rotwang writes: menu = Tkinter.Menu(master, tearoff = 0) for k in x: def f(j = k): [do something that depends on j] menu.add_command(label = str(k), command = f) Still, I'd like to know if there's a more elegant me

Re: Parameterized functions of no arguments?

2011-02-10 Thread Rotwang
On 11/02/2011 05:59, Carl Banks wrote: Rotwang wrote: On 11/02/2011 04:54, Rotwang wrote: Mmmmnngh, that obviously wasn't going to work. Here's something that does work: menu = Tkinter.Menu(master, tearoff = 0) for k in x: def f(j = k): [do something that dep

Re: Parameterized functions of no arguments?

2011-02-10 Thread Rotwang
On 11/02/2011 05:42, Ben Finney wrote: Rotwang writes: Here's something that does work: menu = Tkinter.Menu(master, tearoff = 0) for k in x: def f(j = k): [do something that depends on j] menu.add_command(label = str(k), command = f) Still, I'd like t

Re: Parameterized functions of no arguments?

2011-02-10 Thread Paul Rubin
Rotwang writes: > menu = Tkinter.Menu(master, tearoff = 0) > for k in x: > def f(j = k): > [do something that depends on j] > menu.add_command(label = str(k), command = f) > > Still, I'd like to know if there's a more elegant method for creating > a set of funct

Re: Parameterized functions of no arguments?

2011-02-10 Thread Carl Banks
Rotwang wrote: > On 11/02/2011 04:54, Rotwang wrote: > Mmmmnngh, that obviously wasn't going to work. Here's something that > does work: > > menu = Tkinter.Menu(master, tearoff = 0) > for k in x: > def f(j = k): > [do something that depends on j] > menu.add

Re: Parameterized functions of no arguments?

2011-02-10 Thread Chris Rebert
On Thu, Feb 10, 2011 at 8:54 PM, Rotwang wrote: > Hi all > > Sorry if this is a dumb question, I would guess it's answered in an FAQ > somewhere but I haven't been able to find anything that helps. I'm trying to > use Tkinter to create a menu whose entries and corresponding commands depend > on so

Re: Parameterized functions of no arguments?

2011-02-10 Thread Ben Finney
Rotwang writes: > Here's something that does work: > > menu = Tkinter.Menu(master, tearoff = 0) > for k in x: > def f(j = k): > [do something that depends on j] > menu.add_command(label = str(k), command = f) > > Still, I'd like to know if there's a more elegan

Re: Parameterized functions of no arguments?

2011-02-10 Thread Rotwang
On 11/02/2011 04:54, Rotwang wrote: Hi all Sorry if this is a dumb question, I would guess it's answered in an FAQ somewhere but I haven't been able to find anything that helps. I'm trying to use Tkinter to create a menu whose entries and corresponding commands depend on some list x. I want the

Parameterized functions of no arguments?

2011-02-10 Thread Rotwang
Hi all Sorry if this is a dumb question, I would guess it's answered in an FAQ somewhere but I haven't been able to find anything that helps. I'm trying to use Tkinter to create a menu whose entries and corresponding commands depend on some list x. I want the menu options to be labelled by th

Re: Easy function, please help.

2011-02-10 Thread Westley Martínez
On Tue, 2011-02-08 at 21:52 -0800, Nanderson wrote: > def num_digits(n): > count = 0 > while n: > count = count + 1 > n = n / 10 > return count > > This is a function that basically says how many digits are in a > number. For example, > >>>print num_digits(44) > 2 > >>

Re: returning all matching groups with re.search()

2011-02-10 Thread Roland Mueller
Hello, On 02/07/2011 06:26 PM, Mauro Caceres wrote: >>> import re >>> help(re.findall) Help on function findall in module re: findall(pattern, string, flags=0) Return a list of all non-overlapping matches in the string. If one or more groups are present in the pattern, return a list

How does IDLE do it?

2011-02-10 Thread Richard D. Moores
I recently wrote some code that prints information about the 'jukugo' used in Japanese newspaper articles. A jukugo is a Japanese word written with at least 2 kanji. An example of a 2-kanji jukugo is 危機 (kiki -- crisis). I found that I could not use my usual IDE to render the Japanese correctly in

Re: Problem with giant font sizes in tkinter

2011-02-10 Thread Westley Martínez
On Fri, 2011-02-11 at 03:13 +, Steven D'Aprano wrote: > On Thu, 10 Feb 2011 18:35:09 -0800, Paul Rubin wrote: > > > Steven D'Aprano writes: > labelfont = '-Adobe-Helvetica-Bold-R-Normal-*-140-*' > >> Nevertheless, I'd like to learn how to diagnose these sorts of font > >> issues. C

Re: Easy function, please help.

2011-02-10 Thread alex23
rantingrick wrote: > 1. When has 2 bytecode instructions EVER out weighed a solid > readability feature's incorporation into Python? The original point was whether or not the code is identical, which Terry showed it was not. > The load constant should only happen once. The > COMPARE_OP could be

Re: Problem with giant font sizes in tkinter

2011-02-10 Thread rantingrick
On Feb 10, 8:08 pm, Steven D'Aprano wrote: > On Thu, 10 Feb 2011 15:48:47 +, Cousin Stanley wrote: > >   Will the more simplistic type of tuple spec not work in your tkinter > >   application ? > > I don't know, but I'll give it a try. > > Nevertheless, I'd like to learn how to diagnose these

Re: Problem with giant font sizes in tkinter

2011-02-10 Thread Steven D'Aprano
On Thu, 10 Feb 2011 18:35:09 -0800, Paul Rubin wrote: > Steven D'Aprano writes: labelfont = '-Adobe-Helvetica-Bold-R-Normal-*-140-*' >> Nevertheless, I'd like to learn how to diagnose these sorts of font >> issues. Can anyone suggest where I should start? > > Is the -140- a font size i

Re: OO Python

2011-02-10 Thread Rhodri James
[Re-ordered to get rid of the top-posting] On Thu, 10 Feb 2011 17:11:16 -, Paul Symonds wrote: On 10 Feb 2011, at 16:36, Dan Stromberg wrote: On Wed, Feb 9, 2011 at 1:50 PM, Paul Symonds wrote: Are there any good resources to learn OO Python from? Yes, plenty, but it's important f

Re: Problem with giant font sizes in tkinter

2011-02-10 Thread Paul Rubin
Steven D'Aprano writes: >>> labelfont = '-Adobe-Helvetica-Bold-R-Normal-*-140-*' >>> > Nevertheless, I'd like to learn how to diagnose these sorts of font > issues. Can anyone suggest where I should start? Is the -140- a font size in points (1 point = 1/72 inch) or something like that? Tr

Re: Easy function, please help.

2011-02-10 Thread Steven D'Aprano
On Thu, 10 Feb 2011 12:01:57 -0500, Terry Reedy wrote: > On 2/10/2011 11:52 AM, Ethan Furman wrote: >> Jason Swails wrote: > > >>> How is "while n != 0:" any worse? > > 1. It is redundant, just like 'if bool_value is not False:'. Python > programmers should understand the null value idiom. I f

Re: Problem with giant font sizes in tkinter

2011-02-10 Thread Steven D'Aprano
On Thu, 10 Feb 2011 15:48:47 +, Cousin Stanley wrote: > Steven D'Aprano wrote: > >> I have a tkinter application under Python 2.6 which is shows text in a >> giant font, about twenty(?) times larger than expected. >> >> The fonts are set using: >> >> titlefont = '-Adobe-Helvetica-Bold-R-Norma

Re: Programmatic Parsing of ps

2011-02-10 Thread Dan Stromberg
FWIW, Linux' /proc is very different from pretty much all other *ix's. I like Linux' design better, but it might be good to put the Linux /proc assumption in one place, in case you need to port to another *ix someday. On Thu, Feb 10, 2011 at 4:26 PM, bsergean wrote: > If you're on Linux you shou

Re: Programmatic Parsing of ps

2011-02-10 Thread James Mills
On Thu, Feb 10, 2011 at 4:58 AM, octopusgrabbus wrote: > I have Python 2.6.6. I would like to get this output > > ps -ef | grep 'fglgo csm' > > into a list. What is the best way to do that? I've been reading the > documentation, and am lost. Have you checked out psutil (1) to see if it meets your

Re: Programmatic Parsing of ps

2011-02-10 Thread bsergean
If you're on Linux you should * Have a look at the /proc/ filesystem, there's probably what you want there. Here's a small script that print all the pid/cmd from the process ran with your user. #!/usr/local/bin/python import os import re import stat from os.path import join for pid in (pid for

Re: Ipython Ctypes conflict

2011-02-10 Thread Robert Kern
On 2/10/11 1:57 PM, Wanderer wrote: When I try to use program that uses ctypes to load a dll in Ipython. The IPython mailing list is over here: http://mail.scipy.org/mailman/listinfo/ipython-dev You can also report bugs here: https://github.com/ipython/ipython/issues -- Robert Kern "I

Re: toy list processing problem: collect similar terms

2011-02-10 Thread WJ
Pascal J. Bourguignon wrote: > Xah Lee writes: > > > > here's a interesting toy list processing problem. > > > > I have a list of lists, where each sublist is labelled by > > a number. I need to collect together the contents of all sublists > > sharing > > the same label. So if I have the list

Re: Easy function, please help.

2011-02-10 Thread Jason Swails
On Thu, Feb 10, 2011 at 12:01 PM, Terry Reedy wrote: > On 2/10/2011 11:52 AM, Ethan Furman wrote: > > Jason Swails wrote: >> > > > How is "while n != 0:" any worse? >>> >> > 1. It is redundant, just like 'if bool_value is not False:'. > Python programmers should understand the null value idiom.

Ipython Ctypes conflict

2011-02-10 Thread Wanderer
When I try to use program that uses ctypes to load a dll in Ipython. I get Traceback (most recent call last): File "... \console.py" line 671, in hook_wrapper_23 res = ensire_str(readline_hook(prompt)) File "...\rlmain.py", lin 342, in readline return self.mode.readline(prompt)

Re: Easy function, please help.

2011-02-10 Thread rantingrick
On Feb 10, 11:01 am, Terry Reedy wrote: > On 2/10/2011 11:52 AM, Ethan Furman wrote: > > > Jason Swails wrote: > >> How is "while n != 0:" any worse? > > 1. It is redundant, just like 'if bool_value is not False:'. > Python programmers should understand the null value idiom. > > 2. It does 2 compa

Re: Problem with giant font sizes in tkinter

2011-02-10 Thread Jason Swails
On Thu, Feb 10, 2011 at 11:52 AM, rantingrick wrote: > > Oh, and about your problem. READ THE FREAKING MANUAL! > > Google Translation: i have no clue -- Jason M. Swails Quantum Theory Project, University of Florida Ph.D. Graduate Student 352-392-4032 -- http://mail.python.org/mailman/listinfo/

Re: Shared memory python between two separate shell-launched processes

2011-02-10 Thread Jean-Paul Calderone
On Feb 10, 12:21 pm, "Charles Fox (Sheffield)" wrote: > On Feb 10, 3:43 pm, Jean-Paul Calderone > wrote: > > > > > > > > > > > On Feb 10, 9:30 am, "Charles Fox (Sheffield)" > > wrote: > > > > Hi guys, > > > I'm working on debugging a large python simulation which begins by > > > preloading a hug

Re: OO Python

2011-02-10 Thread Paul Symonds
I have coded in VB using modules and functions but never coded a complete project in OO. I understand the theory of OO, it's more the syntax and Python nuances that I need to be up to speed on. On 10 Feb 2011, at 16:36, Dan Stromberg wrote: > On Wed, Feb 9, 2011 at 1:50 PM, Paul Symonds wr

Re: Shared memory python between two separate shell-launched processes

2011-02-10 Thread Charles Fox (Sheffield)
On Feb 10, 3:43 pm, Jean-Paul Calderone wrote: > On Feb 10, 9:30 am, "Charles Fox (Sheffield)" > wrote: > > > Hi guys, > > I'm working on debugging a large python simulation which begins by > > preloading a huge cache of data.  I want to step through code on many > > runs to do the debugging.   P

Re: Problem with giant font sizes in tkinter

2011-02-10 Thread uahmed
Hi , I am new one but ur talked make me laugh too :D , although here is relevant link for you " if Tk cannot come up with an exact match, it tries to find a similar font. If that fails, Tk falls back to a platform-specific default font. Tk's idea of what is "similar enough" probably doesn't corre

Re: Easy function, please help.

2011-02-10 Thread Terry Reedy
On 2/10/2011 11:52 AM, Ethan Furman wrote: Jason Swails wrote: How is "while n != 0:" any worse? 1. It is redundant, just like 'if bool_value is not False:'. Python programmers should understand the null value idiom. 2. It does 2 comparisons, 1 unneeded, instead of 1. For CPython, it adds

Re: Problem with giant font sizes in tkinter

2011-02-10 Thread rantingrick
On Feb 10, 12:59 am, Steven D'Aprano wrote: > I have a tkinter application under Python 2.6 which is shows text in a > giant font, about twenty(?) times larger than expected. > > The fonts are set using: > > titlefont = '-Adobe-Helvetica-Bold-R-Normal-*-180-*' > buttonfont = '-Adobe-Helvetica-Bold

Re: Easy function, please help.

2011-02-10 Thread Ethan Furman
Jason Swails wrote: On Wed, Feb 9, 2011 at 8:16 PM, Ethan Furman wrote: while n: is plenty readable. n is either something or nothing, and something evaluates to True, nothing to False. Sure it's readable. But then you have to make sure that the loop will eventually take n down to 0.

Re: OO Python

2011-02-10 Thread Dan Stromberg
On Wed, Feb 9, 2011 at 1:50 PM, Paul Symonds wrote: > Are there any good resources to learn OO Python from? Yes, plenty, but it's important for us to know so we can advise you: Do you know any other OO languages yet? -- http://mail.python.org/mailman/listinfo/python-list

Re: email.encoders.encode_base64 creates one line only

2011-02-10 Thread spam
This is with python 3.1.2 (r312:79147). I have not tried with 2.7. When I create an attachment with email.mime.image.MIMEImage, by default it uses email.encoders.encode_base64 for the encoder, but that results in a single line base64 string, instead of the recommended multiple 76-chars lines.

Re: Problem with giant font sizes in tkinter

2011-02-10 Thread Cousin Stanley
Steven D'Aprano wrote: > I have a tkinter application under Python 2.6 which is shows text > in a giant font, about twenty(?) times larger than expected. > > The fonts are set using: > > titlefont = '-Adobe-Helvetica-Bold-R-Normal-*-180-*' > buttonfont = '-Adobe-Helvetica-Bold-R-Normal-*-140-*' >

Re: Shared memory python between two separate shell-launched processes

2011-02-10 Thread Jean-Paul Calderone
On Feb 10, 9:30 am, "Charles Fox (Sheffield)" wrote: > Hi guys, > I'm working on debugging a large python simulation which begins by > preloading a huge cache of data.  I want to step through code on many > runs to do the debugging.   Problem is that it takes 20 seconds to > load the cache at each

Re: Easy function, please help.

2011-02-10 Thread Jason Swails
On Thu, Feb 10, 2011 at 3:31 AM, Benjamin Kaplan wrote: > > > On Wed, Feb 9, 2011 at 5:34 PM, MRAB wrote: > > >>> Or typecast to an int if you want to neglect decimals before converting > >>> to a string, etc. > >>> > >> [snip] > >> Python doesn't have typecasting. :-) > > > > Because these basic

Shared memory python between two separate shell-launched processes

2011-02-10 Thread Charles Fox (Sheffield)
Hi guys, I'm working on debugging a large python simulation which begins by preloading a huge cache of data. I want to step through code on many runs to do the debugging. Problem is that it takes 20 seconds to load the cache at each launch. (Cache is a dict in a 200Mb cPickle binary file). So

Yappi error "context not found"

2011-02-10 Thread Brian
I'm posting here because I can't find a Yappi specific mailing list. I've been using the rather brilliant Yappi from http://code.google.com/p/yappi/ It works well for small programs with a few threads. However, when trying to run it over large programs with several hundred threads I've been gettin

Re: PDB how to define a global inspection function?

2011-02-10 Thread Charles Fox (Sheffield)
On Feb 8, 11:37 am, Peter Otten <__pete...@web.de> wrote: > CharlesFox(Sheffield) wrote: > > Hi guys, I'm new to this group and have a question about debugging. > > I'm stepping through my code (using emacs pdbtrack and python-mode.el) > > and would like to isnpect objects as I go.  So I've defi

Re: Algorithm for generating pitch-class sets in prime form

2011-02-10 Thread John O'Hagan
On Sat, 5 Feb 2011, Charles Turner wrote: > Hi- > > Do you knowof Christopher Ariza's AthenaCL? > > > > HTH, Charles Wow. That looks like a much more complete and elaborate version of what I'm doing, although from what I can tell I

Re: Reassign or discard Popen().stdout from a server process

2011-02-10 Thread John O'Hagan
On Wed, 9 Feb 2011, Nobody wrote: > On Fri, 04 Feb 2011 15:48:55 +, John O'Hagan wrote: > > But I'm still a little curious as to why even unsuccessfully attempting > > to reassign stdout seems to stop the pipe buffer from filling up. > > It doesn't. If the server continues to run, then it's ig

Re: Easy function, please help.

2011-02-10 Thread Benjamin Kaplan
On Thu, Feb 10, 2011 at 12:03 AM, Jason Swails wrote: > > > On Wed, Feb 9, 2011 at 5:34 PM, MRAB wrote: >> >> On 09/02/2011 21:42, Jason Swails wrote: >>> >>> You've gotten several good explanations, mainly saying that 0 -> False >>> and not 0 -> True, which is why the while loop exits.  You've a

Re: Markdown to reStructuredText

2011-02-10 Thread Michele Simionato
Looks cool, I will have a look at it, thanks! -- http://mail.python.org/mailman/listinfo/python-list