Re: [Tutor] Creating custom GUI elements

2010-09-04 Thread Che M
> How would I go about creating custom GUI elements? For example, > if I wanted to make a simple LEGO maker app, how would I write the > code for the bricks so that the user could drag them around and then > build LEGO models? For 2D legos, using the wxPython widget toolkit, you could probab

Re: [Tutor] iterating over less than a full list

2010-09-04 Thread Bill Allen
Thanks to everyone who replied. Some of the methods presented where some I had thought of, others were new to me. Particularly, I did not realize I could apply a slice to a list. The for x in some_stuff[:value] form worked very well for my purposes. I can also see I need to look into the ite

Re: [Tutor] Giving a name to a function and calling it, rather than calling the function directly

2010-09-04 Thread bob gailer
On 9/4/2010 10:14 AM, lists wrote: Hi folks, I'm new to Python, I'm working my way through some intro books, and I have a question that I wonder if someone could help me with please? This is my attempt at solving an exercise where the program is supposed to flip a coin 100 times and then tell

Re: [Tutor] Giving a name to a function and calling it, rather than calling the function directly

2010-09-04 Thread Steven D'Aprano
On Sun, 5 Sep 2010 08:39:07 am lists wrote: > while tossNo <= 99: > coinToss = random.randint Move that out of the loop. There's no need to make the assignment 100 times. > tossNo += 1 > if coinToss(1,2) == 1: > heads += 1 > else: > tails += 1 Rather than count

Re: [Tutor] Giving a name to a function and calling it, rather than calling the function directly

2010-09-04 Thread lists
>>     if coinToss(1,2) == 1: >>         heads += 1 >>         tossNo += 1 >>     else: >>         tails += 1 >>         tossNo += 1 > > Looking good. You can hoist "tossNo += 1" out of each branch of your if > statement too, if you like, to make it even more streamlined (In > other words, execute

Re: [Tutor] Giving a name to a function and calling it, rather than calling the function directly

2010-09-04 Thread R. Alan Monroe
> if coinToss(1,2) == 1: > heads += 1 > tossNo += 1 > else: > tails += 1 > tossNo += 1 Looking good. You can hoist "tossNo += 1" out of each branch of your if statement too, if you like, to make it even more streamlined (In other words, execute it once, righ

Re: [Tutor] Giving a name to a function and calling it, rather than calling the function directly

2010-09-04 Thread lists
>> On 9/4/10, lists wrote: >> > Hi folks, >> > >> > I'm new to Python, I'm working my way through some intro books, and I >> > have a question that I wonder if someone could help me with please? >> > >> > This is my attempt at solving an exercise where the program is >> > supposed to flip a coin 1

Re: [Tutor] Creating custom GUI elements

2010-09-04 Thread Alan Gauld
"aug dawg" wrote How would I go about creating custom GUI elements? For example, if I wanted to make a simple LEGO maker app, how would I write the code for the bricks so that the user could drag them around and then build LEGO models? You find the nearest widget to what you want then you

Re: [Tutor] Giving a name to a function and calling it, rather than calling the function directly

2010-09-04 Thread Kushal Kumaran
- Original message - > On 9/4/10, lists wrote: > > Hi folks, > > > > I'm new to Python, I'm working my way through some intro books, and I > > have a question that I wonder if someone could help me with please? > > > > This is my attempt at solving an exercise where the program is > > su

Re: [Tutor] iterating over less than a full list

2010-09-04 Thread Dave Angel
Bill Allen wrote: Say I have and iterable called some_stuff which is thousands of items in length and I am looping thru it as such: for x in some_stuff etc... However, what if I want only to iterate through only the first ten items of some_stuff, for testing purposes. Is there a concise

Re: [Tutor] Creating custom GUI elements

2010-09-04 Thread Greg
On Sat, Sep 4, 2010 at 1:40 PM, aug dawg wrote: > Hey guys, > > How would I go about creating custom GUI elements? For example, if I wanted > to make a simple LEGO maker app, how would I write the code for the bricks > so that the user could drag them around and then build LEGO models? > > Thanks

Re: [Tutor] Giving a name to a function and calling it, rather than calling the function directly

2010-09-04 Thread Dave Angel
lists wrote: Hi folks, I'm new to Python, I'm working my way through some intro books, and I have a question that I wonder if someone could help me with please? This is my attempt at solving an exercise where the program is supposed to flip a coin 100 times and then tell you the number of heads

Re: [Tutor] iterating over less than a full list

2010-09-04 Thread Steven D'Aprano
On Sun, 5 Sep 2010 03:14:24 am Bill Allen wrote: > Say I have and iterable called some_stuff which is thousands of items > in length and I am looping thru it as such: > > for x in some_stuff > etc... > > However, what if I want only to iterate through only the first ten > items of some_stuff,

Re: [Tutor] iterating over less than a full list

2010-09-04 Thread Mark Lawrence
On 04/09/2010 18:29, Sander Sweers wrote: On 4 September 2010 19:25, Sander Sweers wrote: for x in some_stuff: if x<= 10: print x else: break Oops, corrected version... count = 0 for x in some_stuff: if count< 10: print x count +=1 else:

[Tutor] Creating custom GUI elements

2010-09-04 Thread aug dawg
Hey guys, How would I go about creating custom GUI elements? For example, if I wanted to make a simple LEGO maker app, how would I write the code for the bricks so that the user could drag them around and then build LEGO models? Thanks! ___ Tutor mailli

Re: [Tutor] iterating over less than a full list

2010-09-04 Thread Sander Sweers
On 4 September 2010 19:25, Sander Sweers wrote: > for x in some_stuff: >    if x <= 10: >        print x >    else: >        break Oops, corrected version... count = 0 for x in some_stuff: if count < 10: print x count +=1 else: break Greets Sander ___

Re: [Tutor] iterating over less than a full list

2010-09-04 Thread Sander Sweers
On 4 September 2010 19:14, Bill Allen wrote: > Say I have and iterable called some_stuff which is thousands of items in > length and I am looping thru it as such: > > for x in some_stuff > etc... > > However, what if I want only to iterate through only the first ten items of > some_stuff, for

Re: [Tutor] iterating over less than a full list

2010-09-04 Thread Nitin Pawar
if its a dictionary, then I think you will need to use limit if its normal array you can use range(0,10) and access some_stuff[i] On Sat, Sep 4, 2010 at 10:44 PM, Bill Allen wrote: > Say I have and iterable called some_stuff which is thousands of items in > length and I am looping thru it as su

[Tutor] iterating over less than a full list

2010-09-04 Thread Bill Allen
Say I have and iterable called some_stuff which is thousands of items in length and I am looping thru it as such: for x in some_stuff etc... However, what if I want only to iterate through only the first ten items of some_stuff, for testing purposes. Is there a concise way of specifying tha

Re: [Tutor] Giving a name to a function and calling it, rather than calling the function directly

2010-09-04 Thread Alex Hall
On 9/4/10, lists wrote: > Hi folks, > > I'm new to Python, I'm working my way through some intro books, and I > have a question that I wonder if someone could help me with please? > > This is my attempt at solving an exercise where the program is > supposed to flip a coin 100 times and then tell y

[Tutor] Giving a name to a function and calling it, rather than calling the function directly

2010-09-04 Thread lists
Hi folks, I'm new to Python, I'm working my way through some intro books, and I have a question that I wonder if someone could help me with please? This is my attempt at solving an exercise where the program is supposed to flip a coin 100 times and then tell you the number of heads and tails. AT

Re: [Tutor] nested functions

2010-09-04 Thread Evert Rol
> hello, > i have to plug two functions b() and c() inside another one a(); > i wonder if the code defining b and c must be in the same text file of > a or it is possible to import b and c somehow, hence giving the code a > neater appearance Definitely! Read through http://docs.python.org/tutorial

[Tutor] nested functions

2010-09-04 Thread roberto
hello, i have to plug two functions b() and c() inside another one a(); i wonder if the code defining b and c must be in the same text file of a or it is possible to import b and c somehow, hence giving the code a neater appearance thank you ! -- roberto

Re: [Tutor] Iterating through a list of replacement regex patterns

2010-09-04 Thread Steven D'Aprano
On Sat, 4 Sep 2010 11:57:00 am David Hutto wrote: > First of all, I'll respond more thoroughly tomorrow, when I can > review what you said more clearly, but for now I'll clarify. > > Here is the whole code that I'm using: > > http://pastebin.com/Ak8DFjrb David, in genrandfiles() you say this:

Re: [Tutor] best practices for where to set instance member variables

2010-09-04 Thread Alan Gauld
"Gregory, Matthew" wrote Is there a guideline on where instance member variables should be set within a class? That is, is it a bad idea to set self variables within private member functions rather than returning them to the enclosing caller? There is nothing really specific to OOPP its j