color propagation in tkinter

2009-04-20 Thread Alan G Isaac
I'm a tkinter novice. If I want to propagate changes to a font, I can just use a named font. What if I want to propagate color changes? (E.g., a change in background color for a number of widgets.) Thanks, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: color propagation in tkinter

2009-04-20 Thread Mike Driscoll
On Apr 20, 12:35 pm, Alan G Isaac wrote: > I'm a tkinter novice. > > If I want to propagate changes to a font, > I can just use a named font. > > What if I want to propagate color changes? > (E.g., a change in background color for > a number of widgets.) > > Thanks, > Alan Isaac One way would be

Re: best "void" return of a member function

2009-04-20 Thread Terry Reedy
Andreas Otto wrote: Hi, I'm writing a native language binding for a library. http://libmsgque.sourceforge.net/ Every native method called by PYTHON have to return a PyObject* even if the function itself does not return anything. I have 2 possibilities for return a PyObject*

Re: efficiently checking for string.maketrans conflicts?

2009-04-20 Thread Peter Otten
Saketh wrote: > Hi everyone: > > I'm using "translation" in the sense of string.maketrans here. > > I am trying to efficiently compare if two string translations > "conflict" -- that is, either they differently translate the same > letter, or they translate two different letters to the same one.

Re: iterate to make multiple variables?

2009-04-20 Thread Pascal Chambon
Mark Tolonen a écrit : "Tairic" wrote in message news:95ea7bdf-2ae8-4e5e-a613-37169bb36...@w35g2000prg.googlegroups.com... Hi, I'm somewhat new to programming and especially to python. Today I was attempting to make a sudoku-solver, and I wanted to put numbers into sets call box1, box2, ...

Re: Interest in generational GC for Python

2009-04-20 Thread Pascal Chambon
Martin v. Löwis a écrit : Is there any interest in generational garbage collection in Python these days ? Anyone working on it ? This is the time machine at work: the garbage collector in CPython *is* generational (with three generations). Regards, Martin -- http://mail.python.org/mailma

Re: Python and GMP.

2009-04-20 Thread Benjamin Peterson
gmail.com> writes: > > There are reasons why Python not used the GMP library for implementing > its long type? Basically, GMP only becomes faster when the numbers are huge. -- http://mail.python.org/mailman/listinfo/python-list

generating random tuples in python

2009-04-20 Thread per
hi all, i am generating a list of random tuples of numbers between 0 and 1 using the rand() function, as follows: for i in range(0, n): rand_tuple = (rand(), rand(), rand()) mylist.append(rand_tuple) when i generate this list, some of the random tuples might be very close to each other, nume

Programming in Python with a view to extending in C at a later date.

2009-04-20 Thread dug.armad...@googlemail.com
Hi, Say you set out to program in Python knowing that you will be converting parts of it into C ( or maybe C++) at a later date, but you do not know which parts. Can you give any general Python structure / syntax advice that if implemented from the start, will make this future task less painful.

Re: and [True,True] --> [True, True]?????

2009-04-20 Thread Pascal Chambon
AggieDan04 a écrit : On Apr 20, 2:03 am, bdb112 wrote: Is there any obvious reason why [False,True] and [True,True] gives [True, True] Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] X and Y == (Y if X else X) X or Y == (X if X else Y) [False, True] is t

Re: The Python standard library and PEP8

2009-04-20 Thread Echo
On Mon, Apr 20, 2009 at 9:31 AM, George Sakkis wrote: > On Apr 19, 6:01 pm, "Martin P. Hellwig" > > > Besides, calling Python Object-Orientated is a bit of an insult :-). I > > would say that Python is Ego-Orientated, it allows me to do what I want. > > +1 QOTW > So true. +1 QOTW -- -Brandon S

Re: getter and setter and list appends

2009-04-20 Thread Terry Reedy
dasacc22 wrote: Hi, I seem to be having a problem with a list being share across multiple instantiations of it and dont quite understand why this is happening. Class attributes are shared by all instances. My class looks like this, class Widget(object): _parent = None _children = []

Re: Python interpreter speed

2009-04-20 Thread Tim Wintle
On Sun, 2009-04-19 at 18:11 +0200, Ryniek90 wrote: > Hi. > > Standard Python interpreter's implementation is written in C language. C > code while compilation, is compilled into machine code (the fastest > code). Python code is compiled into into byte-code which is also some > sort of fast mach

Re: color propagation in tkinter

2009-04-20 Thread Alan G Isaac
On Apr 20, 12:35 pm, Alan G Isaac wrote: If I want to propagate changes to a font, I can just use a named font. What if I want to propagate color changes? (E.g., a change in background color for a number of widgets.) On 4/20/2009 1:59 PM Mike Driscoll apparently wrote: One way would be to

Re: generating random tuples in python

2009-04-20 Thread bearophileHUGS
per: > in other words i want the list of random numbers to be arbitrarily > different (which is why i am using rand()) but as different from other > tuples in the list as possible. This is more or less the problem of packing n equal spheres in a cube. There is a lot of literature on this. You can

Re: QT , Wxwidgets are not just UI framework ?

2009-04-20 Thread Old Listener
On Apr 20, 12:54 am, Phil Thompson wrote: > On Sun, 19 Apr 2009 20:32:23 -0700 (PDT), Old Listener > > > > wrote: > > On Apr 17, 10:20 am, Phil Thompson > > wrote: > >> On Fri, 17 Apr 2009 07:04:40 -0700 (PDT), Deep_Feelings > > >> wrote: > >> > On Apr 17, 1:52 pm, "Diez B. Roggisch" wrote: >

Re: sorting two corresponding lists?

2009-04-20 Thread Arnaud Delobelle
Esmail writes: > Hello all, > > I wonder if someone could help me with sorting two corresponding lists. > > For instance the first list contains some items, and the second list > contains their value (higher is better) > > items = [apple, car, town, phone] > values = [5, 2, 7, 1] > > I would like

Re: Python interpreter speed

2009-04-20 Thread Krishnakant
On Mon, 2009-04-20 at 20:12 +0100, Tim Wintle wrote: > > I can't remember Java properly, but... > > Firstly, speed will depend on what you're writing. I dont' actually know > how much slower python is, but I'm sure there are some things that run > faster in python. > I know many instences which

Re: generating random tuples in python

2009-04-20 Thread Arnaud Delobelle
per writes: > hi all, > > i am generating a list of random tuples of numbers between 0 and 1 > using the rand() function, as follows: > > for i in range(0, n): > rand_tuple = (rand(), rand(), rand()) > mylist.append(rand_tuple) > > when i generate this list, some of the random tuples might be

Re: Interest in generational GC for Python

2009-04-20 Thread Martin v. Löwis
> I'm lost there. Isn't CPython using reference counting (i.e updating the > object's state at each reference creation/deletion, and deleting the > objects as soon as they have no more references to them) ? It seemed to > me that generational GC only applied to periodic GCs, like tracing > garbage

Re: and [True,True] --> [True, True]?????

2009-04-20 Thread Martin v. Löwis
> Are they widespread? I haven't noticed, yet. > > I prefer to write it explicitly: > > if len(lst) > 0: I prefer to test explicitly for the truth value of the list. I don't want to test whether the length of the list is greater than 0 (in fact, I don't care about the length property of the list

Re: and [True,True] --> [True, True]?????

2009-04-20 Thread Aahz
In article , =?ISO-8859-1?Q?Gerhard_H=E4ring?= wrote: > >I prefer to write it explicitly: > >if len(lst) > 0: >... At the very least, IMO you should write this as if len(lst): ... There's no reason to be explicit about the numeric comparison. -- Aahz (a...@pythoncraft.com) <

Re: and [True,True] --> [True, True]?????

2009-04-20 Thread Grant Edwards
On 2009-04-20, Martin v. L?wis wrote: > I don't want to test whether the length of the list > is greater than 0 [...] - I want to know whether the > list is empty (or not empty). I fail to see the difference between "length greater than 0" and "list is not empty". They are, by definition, the s

Re: polar plots, clockwise, north

2009-04-20 Thread norseman
enric...@gmail.com wrote: Thanks, I had tried this earlier but by rotating the data in this fashion, it has problems connecting the endpoints between 0 and 360 and tries to go counter clockwise around. I am then left with an extra circle in all my plots where it attempts to connect the points be

Re: and [True,True] --> [True, True]?????

2009-04-20 Thread Martin v. Löwis
>> I don't want to test whether the length of the list >> is greater than 0 [...] - I want to know whether the >> list is empty (or not empty). > > I fail to see the difference between "length greater than 0" > and "list is not empty". They are, by definition, the same > thing, aren't they? Yes,

Re: and [True,True] --> [True, True]?????

2009-04-20 Thread Martin v. Löwis
>> I prefer to write it explicitly: >> >> if len(lst) > 0: >>... > > At the very least, IMO you should write this as > > if len(lst): > ... > > There's no reason to be explicit about the numeric comparison. I think in the mind-set that dislikes relying on boolean conversion of lists, re

Handling NameError in a list gracefully

2009-04-20 Thread Jesse Aldridge
from my_paths import * def get_selected_paths(): return [home, desktop, project1, project2] --- So I have a function like this which returns a list containing a bunch of variables. The real list has around 50 entries. Occasionally I'll remove a variable from my_paths and cause get_sele

Re: color propagation in tkinter

2009-04-20 Thread Terry Reedy
Alan G Isaac wrote: On Apr 20, 12:35 pm, Alan G Isaac wrote: If I want to propagate changes to a font, I can just use a named font. What if I want to propagate color changes? (E.g., a change in background color for a number of widgets.) On 4/20/2009 1:59 PM Mike Driscoll apparently wrote:

Re: Handling NameError in a list gracefully

2009-04-20 Thread Chris Rebert
On Mon, Apr 20, 2009 at 1:36 PM, Jesse Aldridge wrote: > from my_paths import * > > def get_selected_paths(): >    return [home, desktop, project1, project2] > > --- > > So I have a function like this which returns a list containing a bunch > of variables.  The real list has around 50 entries.

Re: Handling NameError in a list gracefully

2009-04-20 Thread Jesse Aldridge
Nevermind, I figured it out right after I clicked the send button :\ from my_paths import * def get_selected_paths(): return [globals()[s] for s in ["home", "desktop", "project1", "project2"] if s in globals()] -- http://mail.python.org/mailman/listinfo/python-list

Re: Handling NameError in a list gracefully

2009-04-20 Thread Jesse Aldridge
On Apr 20, 3:46 pm, Chris Rebert wrote: > On Mon, Apr 20, 2009 at 1:36 PM, Jesse Aldridge > wrote: > > from my_paths import * > > > def get_selected_paths(): > >    return [home, desktop, project1, project2] > > > --- > > > So I have a function like this which returns a list containing a bun

rectangles, or cavases, or ... ?

2009-04-20 Thread Alan G Isaac
I need to display many (e.e., 2000) small squares whose colors are udpated each time a computation is complete. One approach is to put rectangles on a single canvas. Another approach is to put many canvases in a single frame. Another approach is to create an image each iteration, which is placed

Re: Programming in Python with a view to extending in C at a later date.

2009-04-20 Thread Daniel Stutzbach
On Mon, Apr 20, 2009 at 1:57 PM, dug.armad...@googlemail.com < dug.armad...@googlemail.com> wrote: > Say you set out to program in Python knowing that you will be > converting parts of it into C ( or maybe C++) at a later date, but you > do not know which parts. > I often use Python for rapid pro

Re: Python and GMP.

2009-04-20 Thread Mark Dickinson
On Apr 20, 7:39 pm, Benjamin Peterson wrote: >   gmail.com> writes: > > > > > There are reasons why Python not used the GMP library for implementing > > its long type? > > Basically, GMP only becomes faster when the numbers are huge. That was true for one particular attempt in this direction (by

Re: Programming in Python with a view to extending in C at a later date.

2009-04-20 Thread Scott David Daniels
dug.armad...@googlemail.com wrote: Say you set out to program in Python knowing that you will be converting parts of it into C ( or maybe C++) at a later date, but you do not know which parts. Can you give any general Python structure / syntax advice that if implemented from the start, will make

Re: rectangles, or cavases, or ... ?

2009-04-20 Thread FogleBird
On Apr 20, 5:29 pm, Alan G Isaac wrote: > I need to display many (e.e., 2000) small squares whose colors are udpated > each time a computation is complete. > > One approach is to put rectangles on a single canvas. > Another approach is to put many canvases in a single frame. > Another approach is

Re: rectangles, or cavases, or ... ?

2009-04-20 Thread Scott David Daniels
Alan G Isaac wrote: I need to display many (e.e., 2000) small squares whose colors are udpated each time a computation is complete. One approach is to put rectangles on a single canvas. Another approach is to put many canvases in a single frame. Another approach is to create an image each iterat

Re: Python and GMP.

2009-04-20 Thread Mark Dickinson
On Apr 20, 10:36 pm, Mark Dickinson wrote: > The other major issue is licensing:  as far as I recall, the > various discussions never came to a conclusion about the legal > implications of using GMP. It took me a while to find it... See the thread starting at http://mail.python.org/pipermail/py

Re: Programming in Python with a view to extending in C at a later date.

2009-04-20 Thread Lawson English
Daniel Stutzbach wrote: On Mon, Apr 20, 2009 at 1:57 PM, dug.armad...@googlemail.com > wrote: Say you set out to program in Python knowing that you will be converting parts of it into C ( or maybe C++) at a later d

Re: Programming in Python with a view to extending in C at a later date.

2009-04-20 Thread Lawson English
Lawson English wrote: Daniel Stutzbach wrote: On Mon, Apr 20, 2009 at 1:57 PM, dug.armad...@googlemail.com > wrote: Say you set out to program in Python knowing that you will be converting parts of it into C ( or

Re: Programming in Python with a view to extending in C at a later date.

2009-04-20 Thread Terry Reedy
dug.armad...@googlemail.com wrote: Hi, Say you set out to program in Python knowing that you will be converting parts of it into C ( or maybe C++) at a later date, but you do not know which parts. I presume because you intend to wait for profile results. Good. Of course, you might even find y

Re: and [True,True] --> [True, True]?????

2009-04-20 Thread Gerhard Häring
Martin v. Löwis wrote: >> Are they widespread? I haven't noticed, yet. >> >> I prefer to write it explicitly: >> >> if len(lst) > 0: > > I prefer to test explicitly for the truth value of the > list. I don't want to test whether the length of the list > is greater than 0 (in fact, I don't care abo

the correct way to install python packages as non root user in non default path

2009-04-20 Thread News123
Hi, I'm having an Ubuntu host, but want to (experimentally) install some modules, which are newer than the Ubuntu ones (distros lag always a little behind and some tools need newer versions.) What would be a clean way to do this? I want to be sure, that any 'special hacks' on my host are cleanly

Re: and [True,True] --> [True, True]?????

2009-04-20 Thread Raymond Hettinger
> > No. Tests like > > > if items: > >    ... > > > to verify that items is a non-empty list are a widespread idiom in Python. > > They rely on the behaviour you observe. > > Are they widespread? I haven't noticed, yet. It's the preferred form (as recommended by PEP 8). Raymond -- http://mail.py

Re: rectangles, or cavases, or ... ?

2009-04-20 Thread Alan G Isaac
On 4/20/2009 5:59 PM Scott David Daniels apparently wrote: You should have said, but I'll guess you are using Tkinter. Yes, I should have, sorry. You are right, I'm using Tkinter. I'd put the rectangles on a canvas, myself. That's my current choice, but I'm not seeing into what the trade-

Re: rectangles, or cavases, or ... ?

2009-04-20 Thread John McMonagle
Alan G Isaac wrote: > I need to display many (e.e., 2000) small squares whose colors are udpated > each time a computation is complete. > > One approach is to put rectangles on a single canvas. > Another approach is to put many canvases in a single frame. > Another approach is to create an image e

Re: and [True,True] --> [True, True]?????

2009-04-20 Thread Terry Reedy
Gerhard Häring wrote: Martin v. Löwis wrote: Are they widespread? I haven't noticed, yet. I prefer to write it explicitly: if len(lst) > 0: I prefer to test explicitly for the truth value of the list. I don't want to test whether the length of the list is greater than 0 (in fact, I don't care

Re: Handling NameError in a list gracefully

2009-04-20 Thread Terry Reedy
Jesse Aldridge wrote: from my_paths import * def get_selected_paths(): return [home, desktop, project1, project2] --- So I have a function like this which returns a list containing a bunch of variables. The real list has around 50 entries. Occasionally I'll remove a variable from my_

Re: rectangles, or cavases, or ... ?

2009-04-20 Thread Alan G Isaac
On 4/20/2009 7:43 PM John McMonagle apparently wrote: Approach 1: put many rectangles on a single canvas This is the most flexible approach. It allows you to take advantage of Tkinter canvas tag bindings to interact with individual or groups of canvas items. It also allows you to use some pre

A Special Thanks

2009-04-20 Thread norseman
I'm one of those that tries to get an outline of the project and then puts in code as things become clear. Once the basics are working reasonably I go back and organize the thing for maintainability. Then finish flushing it out. It is the one stage I dread the most. Why not organize it up fr

Re: the correct way to install python packages as non root user in non default path

2009-04-20 Thread alex23
On Apr 21, 8:32 am, News123 wrote: > I'm having an Ubuntu host, but want to (experimentally) > install some modules, which are newer than the Ubuntu ones > (distros lag always a little behind and some tools need newer versions.) > > What would be a clean way to do this? I think virtualenv will he

Re: What is a real name, round 668

2009-04-20 Thread Ben Finney
a...@pythoncraft.com (Aahz) writes: > In article <87tz4jl66c@benfinney.id.au>, > Ben Finney wrote: > > > >(Is there hope that you could set your From field using your real > >name so we can discuss with a real person instead of a pseudonym?) > > Could you define what a "real name" is? > >

Re: What is a real name, round 668

2009-04-20 Thread Aahz
In article <87hc0iltal@benfinney.id.au>, Ben Finney wrote: >a...@pythoncraft.com (Aahz) writes: >> In article <87tz4jl66c@benfinney.id.au>, >> Ben Finney wrote: >>> >>>(Is there hope that you could set your From field using your real >>>name so we can discuss with a real person instead

is PyCodec_Encode() API returns New reference or Borrowed reference

2009-04-20 Thread rahul
Is PyCodec_Encode(PyObject *object,char *encoding,char *errors ) returns New reference or Borrowed reference -- http://mail.python.org/mailman/listinfo/python-list

Re: Self-intro and possible offtopic: creation of group integrating translators and experts in the fields they translate

2009-04-20 Thread Aahz
In article <44db189a-8e34-4c6f-bc4a-4843d2329...@z9g2000yqi.googlegroups.com>, vocabulo wrote: > >PS: I've also created a yahoo group by the name texchange, with the >same purpose. The reason I created one group at google's and another >at yahoo's is because people tend to polarize between these

Re: What is a real name, round 668

2009-04-20 Thread Ben Finney
a...@pythoncraft.com (Aahz) writes: > In article <87hc0iltal@benfinney.id.au>, > Ben Finney wrote: > >A rough working definition [of “real name”]: The name you would use > >to introduce yourself if you met me for the first time in a similar > >context but face to face. > > That's fine by me

Re: Python and GMP.

2009-04-20 Thread Paul Rubin
Benjamin Peterson writes: > Basically, GMP only becomes faster when the numbers are huge. In my experience GMP is about 4x faster than Python longs with 1024 bit numbers, a very common cryptographic size. -- http://mail.python.org/mailman/listinfo/python-list

Re: getter and setter and list appends

2009-04-20 Thread Rhodri James
On Mon, 20 Apr 2009 18:18:39 +0100, dasacc22 wrote: Ah thank you for clarifying, I did confuse instance and class attributes from creating the list in the class def. I actually just spiffed up that class to represent a portion of a much larger class that needs getter and setter for children. Do

Re: and [True,True] --> [True, True]?????

2009-04-20 Thread Steven D'Aprano
On Mon, 20 Apr 2009 15:13:15 -0500, Grant Edwards wrote: > I fail to see the difference between "length greater than 0" and "list > is not empty". They are, by definition, the same thing, aren't they? For built-in lists, but not necessarily for arbitrary list-like sequences. There's also the p

Re: and [True,True] --> [True, True]?????

2009-04-20 Thread Steven D'Aprano
On Tue, 21 Apr 2009 00:32:44 +0200, Gerhard Häring wrote: > The reason I preferred len(), btw., was only that len() make it clear > that the argument is a sequence. > > Maybe I was just too annoyed by lots of Python code I read that looked > like this: > > def foo(x, y, z): > if x: >

Re: is PyCodec_Encode() API returns New reference or Borrowed reference

2009-04-20 Thread Benjamin Peterson
rahul gmail.com> writes: > > Is PyCodec_Encode(PyObject *object,char *encoding,char *errors ) > returns New reference or Borrowed reference New -- http://mail.python.org/mailman/listinfo/python-list

Re: and [True,True] --> [True, True]?????

2009-04-20 Thread Steven D'Aprano
On Mon, 20 Apr 2009 15:53:41 +, Peter Pearson wrote: > Like Gerhard, I prefer the construction that explicitly says, "This is a > list, and this is what I'll do if it's not empty." To me, and I suspect > to a great many programmers, "if x:" does *not* mean "if x is not > empty", it means "if

Re: generating random tuples in python

2009-04-20 Thread Steven D'Aprano
On Mon, 20 Apr 2009 11:39:35 -0700, per wrote: > hi all, > > i am generating a list of random tuples of numbers between 0 and 1 using > the rand() function, as follows: > > for i in range(0, n): > rand_tuple = (rand(), rand(), rand()) mylist.append(rand_tuple) > > when i generate this list, s

Removing items from a list simultaneously

2009-04-20 Thread Ross
Is there a quick way to simultaneously pop multiple items from a list? For instance if i had the list a = [1,2,3,4,5,6,7] and I wanted to return every odd index into a new list, my output would be new_list = [2,4,6] or similarly if I wanted to return each index that was one away from the midpoint i

Re: Python and GMP.

2009-04-20 Thread casevh
On Apr 20, 11:39 am, Benjamin Peterson wrote: >   gmail.com> writes: > > > > > There are reasons why Python not used the GMP library for implementing > > its long type? > > Basically, GMP only becomes faster when the numbers are huge. Python 3.1 is significantly faster than Python 2.x on 64-bit p

Re: The Python standard library and PEP8

2009-04-20 Thread Steven D'Aprano
On Mon, 20 Apr 2009 06:18:17 -0700, Scott David Daniels wrote: > Steven D'Aprano wrote: >> ... There's an accepted definition for "objected oriented programming >> language": a language which provides "objects", which are constructs >> encapsulating both data and routines to operate on that data i

Re: Passing all extra commandline arguments to python program, Optparse raises exception

2009-04-20 Thread Rhodri James
On Sun, 19 Apr 2009 14:45:45 +0100, David Stanek wrote: On Thu, Apr 16, 2009 at 10:05 AM, sapsi wrote: Hello, Im using optparse and python 2.6 to parse some options, my commandline looks like prog [options] start|stop extra-args-i-will-pas-on The options are --b --c --d The extra options

Re: The Python standard library and PEP8

2009-04-20 Thread Tim Wintle
On Sun, 2009-04-19 at 18:43 +0200, Emmanuel Surleau wrote: > Hi there, > > Exploring the Python standard library, I was surprised to see that several > packages (ConfigParser, logging...) use mixed case for methods all over the > place. I assume that they were written back when the Python stylin

Re: Removing items from a list simultaneously

2009-04-20 Thread Steven D'Aprano
On Mon, 20 Apr 2009 20:09:12 -0700, Ross wrote: > Is there a quick way to simultaneously pop multiple items from a list? > For instance if i had the list a = [1,2,3,4,5,6,7] and I wanted to > return every odd index into a new list, my output would be new_list = > [2,4,6] or similarly if I wanted t

Re: Is there a programming language that is combination of PythonandBasic?

2009-04-20 Thread Rhodri James
On Sun, 19 Apr 2009 19:25:25 +0100, Scott David Daniels wrote: Chris Jones wrote: ... Intellectually, assembler programming is the less demanding since its level of abstraction does not go any further than mapping a few binary numbers to a small set of usually well-chosen mnemonics. Unless

Re: The Python standard library and PEP8

2009-04-20 Thread alex23
On Apr 21, 1:18 pm, Tim Wintle wrote: > There was some suggestion about introducing synonyms that followed PEP8 > and introducing deprecation warnings as you suggested, but I can't > remember the outcome. I'd suggest checking the dev archives. What about the possibility of offering an additional,

Re: and [True,True] --> [True, True]?????

2009-04-20 Thread John Machin
On Apr 20, 6:54 pm, Gerhard Häring wrote: > Peter Otten wrote: > > bdb112 wrote: > > >> Your explanation of Boolean ops on lists was clear. > >> It leads to some intriguing results: > > >> bool([False]) > >> --> True > > >> I wonder if python 3 changes any of this? > > > No. Tests like > > > if it

Re: efficiently checking for string.maketrans conflicts?

2009-04-20 Thread Michael Spencer
Saketh wrote: Hi everyone: I'm using "translation" in the sense of string.maketrans here. I am trying to efficiently compare if two string translations "conflict" -- that is, either they differently translate the same letter, or they translate two different letters to the same one. ... Anoth

Re: rectangles, or cavases, or ... ? under Tkinter

2009-04-20 Thread Alan G Isaac
On Apr 20, 5:29 pm, Alan G Isaac wrote: I need to display many (e.e., 2000) small squares whose colors are udpated each time a computation is complete. One approach is to put rectangles on a single canvas. Another approach is to put many canvases in a single frame. Another approach is to create

Re: generating random tuples in python

2009-04-20 Thread per
On Apr 20, 11:08 pm, Steven D'Aprano wrote: > On Mon, 20 Apr 2009 11:39:35 -0700, per wrote: > > hi all, > > > i am generating a list of random tuples of numbers between 0 and 1 using > > the rand() function, as follows: > > > for i in range(0, n): > >   rand_tuple = (rand(), rand(), rand()) mylis

Re: The Python standard library and PEP8

2009-04-20 Thread Aahz
In article <37d39064-b73d-4e47-9e1e-d07c14bfc...@z8g2000prd.googlegroups.com>, alex23 wrote: >On Apr 21, 1:18 pm, Tim Wintle wrote: >> >> There was some suggestion about introducing synonyms that followed PEP8 >> and introducing deprecation warnings as you suggested, but I can't >> remember the

Re: The Python standard library and PEP8

2009-04-20 Thread Steven D'Aprano
On Mon, 20 Apr 2009 21:30:20 -0700, Aahz wrote: > In article > <37d39064-b73d-4e47-9e1e-d07c14bfc...@z8g2000prd.googlegroups.com>, > alex23 wrote: >>On Apr 21, 1:18 pm, Tim Wintle wrote: >>> >>> There was some suggestion about introducing synonyms that followed >>> PEP8 and introducing deprecat

Failure of running a second script in same interactive session

2009-04-20 Thread pdlemper
When I open python.exe to the console or "interactive window" and import/run a script I am frustrated trying to import and run another script in the same session. eg I run the script alphasort once fine : >>> import alphasort < it runs > When its finished I then try to run the same

Re: What is a real name, round 668

2009-04-20 Thread Stephen Hansen
> Understood. In this case, I *am* sure (enough to make the assumption > publicly) that the poster is not using their real name in their ‘From’ > field, and was — politely, I hope — requesting that to be rectified. > Oh, how I find this attitude simultaneously absurd and offensive-- the only reas

Re: Python interpreter speed

2009-04-20 Thread Tim Roberts
Ryniek90 wrote: > >Standard Python interpreter's implementation is written in C language. C >code while compilation, is compilled into machine code (the fastest >code). Python code is compiled into into byte-code which is also some >sort of fast machine code. So why Python interpreter is slower

Re: generating random tuples in python

2009-04-20 Thread Tim Roberts
per wrote: > >i am generating a list of random tuples of numbers between 0 and 1 >using the rand() function, as follows: >... >how can i maximize the amount of "numeric distance" between the >elements of this list, but still make sure that all the tuples >have numbers strictly between 0 and 1 (in

Re: iterate to make multiple variables?

2009-04-20 Thread john
On Apr 19, 11:11 pm, Tairic wrote: > Hi, I'm somewhat new to programming and especially to python. Today I > was attempting to make a sudoku-solver, and I wanted to put numbers > into sets call box1, box2, ... box9, so that I could check new values > against the boxes > > I ended up declaring the

Re: iterate to make multiple variables?

2009-04-20 Thread john
On Apr 19, 11:11 pm, Tairic wrote: > Hi, I'm somewhat new to programming and especially to python. Today I > was attempting to make a sudoku-solver, and I wanted to put numbers > into sets call box1, box2, ... box9, so that I could check new values > against the boxes > > I ended up declaring the

Re: Failure of running a second script in same interactive session

2009-04-20 Thread Steven D'Aprano
On Mon, 20 Apr 2009 23:52:39 -0500, pdlemper wrote: > When I open python.exe to the console or "interactive window" and > import/run a script I am frustrated trying to import and run another > script in the same session. eg I run the script alphasort once fine : import alphasort

Re: sorting two corresponding lists?

2009-04-20 Thread Peter Otten
Esmail wrote: > I wonder if someone could help me with sorting two corresponding lists. > > For instance the first list contains some items, and the second list > contains their value (higher is better) > > items = [apple, car, town, phone] > values = [5, 2, 7, 1] > > I would like to sort the '

Re: Python interpreter speed

2009-04-20 Thread Stefan Behnel
Tim Roberts wrote: > The Python you're thinking of (CPython) is compiled to an intermediate > language, which is then interpreted by an interpreter loop, somewhat > remeniscent of Forth. It takes more cycles per instruction to run that > interpreter loop than it does to run the machine language, b

<    1   2