Re: [Tutor] the and command

2007-08-24 Thread Alan Gauld
"max baseman" <[EMAIL PROTECTED]> wrote > im checking if a number is in all 5 of the other lists and when > i use the and command it seems to just be checking if it's in a > least > one of the others, > for num in l2 and l3 and l4 and l5 and l6: # here seems to be the Try: if num in I2 and nu

Re: [Tutor] the and command

2007-08-24 Thread max baseman
thanks much you really helped me if anyone wants here is the program: n2=2 n3=3 n4=4 n5=5 n6=6 n7=7 l2=[] l3=[] l4=[] l5=[] l6=[] l7=[] while n2 < 1000: l2.append(n2) n2=n2+2 while n3 < 1000: l3.append(n3) n3=n3+3 while n4 < 1000: l4.append(n4) n4=n4+4 while n5 < 1000

Re: [Tutor] the and command

2007-08-24 Thread Kent Johnson
max baseman wrote: > thanks much you really helped me if anyone wants here is the program: Hmmm...this is quite wordy. Some suggestions below: > > n2=2 > n3=3 > n4=4 > n5=5 > n6=6 > n7=7 > l2=[] > l3=[] > l4=[] > l5=[] > l6=[] > l7=[] > while n2 < 1000: > l2.append(n2) > n2=n2+2 This c

[Tutor] Off Topic: xrange, WAS: Re: the and command

2007-08-24 Thread Alan Gauld
"Kent Johnson" <[EMAIL PROTECTED]> wrote > possible = set(xrange(4, 1000, 4)).intersection(xrange(5, 1000, 5)) > \ > .intersection(xrange(6, 1000, 6)) > Kent, I've noticed in a few of your replie recemntly you have been using xrange rather than range. I was under the impression that

Re: [Tutor] Converting code to string

2007-08-24 Thread Bernard Lebel
Actually, regarding inspect.getsource() that raised IOErrors: Running it from imported module actually works! Thanks Bernard ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Off Topic: xrange, WAS: Re: the and command

2007-08-24 Thread Kent Johnson
Alan Gauld wrote: > "Kent Johnson" <[EMAIL PROTECTED]> wrote > >> possible = set(xrange(4, 1000, 4)).intersection(xrange(5, 1000, 5)) >> \ >> .intersection(xrange(6, 1000, 6)) >> > > Kent, > > I've noticed in a few of your replie recemntly you have been using > xrange rather than ra

Re: [Tutor] Converting code to string

2007-08-24 Thread Bernard Lebel
okay here "simple" examples about why I have to define callbacks as strings instead of code. In XSI, one of the GUI objects that you can create is called a "custom property". A custom property is basically a floating window in which there are widgets. Custom properties can define a layout or not.

Re: [Tutor] Converting code to string

2007-08-24 Thread Kent Johnson
Bernard Lebel wrote: > In the task I'm currently having, I have to dynamically create a > certain number of layout elements along its logic. The number of > elements to create changes from one execution to the next, as it is > driven by the user input. Since properpty plugins do not support such >

[Tutor] Help Request: Nested While commands

2007-08-24 Thread Paul W Peterson
Greeting! I'm learning Python through the book "Python Programming, Second Edition for the absolute beginner" by Michael Dawson. In it, he has the program "Guess my number" (code pasted below). His challenge is to modify the code so that there are only a limited number of attempts before the progr

Re: [Tutor] using in over several entities

2007-08-24 Thread Kent Johnson
Tino Dai wrote: > Hi there, > > I am wondering about a short cut to doing this. Let's say that we > have an array: > > dbs= ['oracle','mysql','postgres','infomix','access'] > > and we wanted to do this: > > if 'oracle' in dbs or 'mysql' in dbs or 'bdb' in dbs: ><... do something ...> >

Re: [Tutor] HOWTO: adding to sys.path the simplest way.

2007-08-24 Thread Tim Johnson
On Thursday 23 August 2007, Kent Johnson wrote: > > I would welcome some opinions on this matter. > > Make a file called mylibraries.pth with contents > /path/to/mylibraries Aha! User-defined .pth file is recognized by python > Put the file in your site-packages folder (I don't know wherethat is

[Tutor] using in over several entities

2007-08-24 Thread Tino Dai
Hi there, I am wondering about a short cut to doing this. Let's say that we have an array: dbs= ['oracle','mysql','postgres','infomix','access'] and we wanted to do this: if 'oracle' in dbs or 'mysql' in dbs or 'bdb' in dbs: <... do something ...> Is there a short way or writing this? S

Re: [Tutor] HOWTO: adding to sys.path the simplest way.

2007-08-24 Thread Tim Johnson
On Friday 24 August 2007, Tim Johnson wrote: > On Thursday 23 August 2007, Kent Johnson wrote: > > > I would welcome some opinions on this matter. > > > > Make a file called mylibraries.pth with contents > > /path/to/mylibraries > > Aha! User-defined .pth file is recognized by python > > > Put the

Re: [Tutor] using in over several entities

2007-08-24 Thread Chris Calloway
Tino Dai wrote: > I am wondering about a short cut to doing this. Let's say that we > have an array: > > dbs= ['oracle','mysql','postgres','infomix','access'] > > and we wanted to do this: > > if 'oracle' in dbs or 'mysql' in dbs or 'bdb' in dbs: ><... do something ...> > > Is there a

Re: [Tutor] the and command

2007-08-24 Thread Mike Hansen
> -Original Message- > ... > > for num in l2: > > if num in l3 and num in l4 and num in l5 and num in l6: > > possible.append(num) Yikes! Glancing at the code, I was reading l3, l4, l5, l6 as the numbers 13, 14, 15, 16..(Thirteen, Fourteen, Fifteen, Sixteen). I'd avoid us

Re: [Tutor] Help Request: Nested While commands

2007-08-24 Thread Alan Gauld
"Paul W Peterson" <[EMAIL PROTECTED]> wrote > "Guess my number" (code pasted below). His challenge is to modify the > code so that there are only a limited number of attempts before the > program exits with a chastising message. > > Try as I may, I cannot seem to get the syntax correct for nes

Re: [Tutor] A fun puzzle

2007-08-24 Thread Dick Moores
At 11:49 AM 8/23/2007, Kent Johnson wrote: >Dick Moores wrote: >>>Two reasons. First, looking up a name that is local to a function >>>is faster than looking up a global name. To find the value of >>>'str', the interpreter has to look at the module namespace, then >>>the built-in namespace. Thes

Re: [Tutor] Off Topic: xrange, WAS: Re: the and command

2007-08-24 Thread Dave Kuhlman
On Fri, Aug 24, 2007 at 09:52:16AM -0400, Kent Johnson wrote: Kent and Alan - Thanks for encouraging me to do a little reading and experimenting. I thought xrange() returned an iterator. I was wrong. Actually xrange() returns an xrange object which, according to the docs, is "an opaque sequenc

Re: [Tutor] using in over several entities

2007-08-24 Thread Alan Gauld
"Chris Calloway" <[EMAIL PROTECTED]> wrote > >>> dbs = set(['oracle','mysql','postgres','infomix','access']) > >>> mine = set(['oracle','mysql','bdb']) > >>> dbs & mine > set(['oracle', 'mysql']) > >>> dbs - mine > set(['access', 'infomix', 'postgres']) Interesting. I didn't know about the & an

Re: [Tutor] A fun puzzle

2007-08-24 Thread Kent Johnson
Dick Moores wrote: >>> This time I added "xrange(10, end, 10)" and did the timing using >>> the template in the timeit module: >>> template = """ >>> def inner(_it, _timer): >>> _t0 = _timer() >>> from itertools import chain >>> end = 100 >>> for _i in _it: >>> for

Re: [Tutor] using in over several entities

2007-08-24 Thread Alan Gauld
"Tino Dai" <[EMAIL PROTECTED]> wrote > dbs= ['oracle','mysql','postgres','infomix','access'] > > and we wanted to do this: > > if 'oracle' in dbs or 'mysql' in dbs or 'bdb' in dbs: > <... do something ...> > > Is there a short way or writing this? Something like >('oracle','mysql','bdb'

Re: [Tutor] Off Topic: xrange, WAS: Re: the and command

2007-08-24 Thread Kent Johnson
Dave Kuhlman wrote: > I thought xrange() returned an iterator. I was wrong. > > Actually xrange() returns an xrange object which, according to the > docs, is "an opaque sequence". Interesting. So an xrange object is an iterable sequence, not an iterator. Kent ___

Re: [Tutor] Off Topic: xrange, WAS: Re: the and command

2007-08-24 Thread Eric Brunson
Kent Johnson wrote: > Dave Kuhlman wrote: > >> I thought xrange() returned an iterator. I was wrong. >> >> Actually xrange() returns an xrange object which, according to the >> docs, is "an opaque sequence". >> > > Interesting. So an xrange object is an iterable sequence, not an iterator.

Re: [Tutor] using in over several entities

2007-08-24 Thread Chris Calloway
Alan Gauld wrote: > "Chris Calloway" <[EMAIL PROTECTED]> wrote > > dbs = set(['oracle','mysql','postgres','infomix','access']) > mine = set(['oracle','mysql','bdb']) > dbs & mine >> set(['oracle', 'mysql']) > dbs - mine >> set(['access', 'infomix', 'postgres']) > > Interesting. I

Re: [Tutor] Help Request: Nested While commands

2007-08-24 Thread Chris Calloway
Paul W Peterson wrote: > Could you provide a way to achieve this > using nested while statements, or suggest a better use of the ifs? You could use one while statement. while guess != the_number and tries < 5: I can't think of a *good* way to use nested whiles for your problem. > Ellicott, Col

Re: [Tutor] A fun puzzle

2007-08-24 Thread Dick Moores
At 10:22 AM 8/24/2007, Kent Johnson wrote: >Dick Moores wrote: This time I added "xrange(10, end, 10)" and did the timing using the template in the timeit module: template = """ def inner(_it, _timer): _t0 = _timer() from itertools import chain end = 1

Re: [Tutor] A fun puzzle

2007-08-24 Thread Kent Johnson
Dick Moores wrote: > At 10:22 AM 8/24/2007, Kent Johnson wrote: >> So you actually pasted that code into timeit.py? > > Yeah. :-( I think I learned on the Tutor list to do it that way, but I'm > not sure. Thanks for showing me a correct way. I hope not! >> Using timeit more conventionally I get

Re: [Tutor] A fun puzzle

2007-08-24 Thread Dick Moores
At 12:12 PM 8/24/2007, Kent Johnson wrote: Dick Moores wrote: At 10:22 AM 8/24/2007, Kent Johnson wrote: So you actually pasted that code into timeit.py?Yeah. :-( I think I learned on the Tutor list to do it that way, but I'm not sure. Thanks for showing me a correct way. I hope not! Using timei

Re: [Tutor] A fun puzzle

2007-08-24 Thread Dick Moores
Dick Moores wrote: >At 10:22 AM 8/24/2007, Kent Johnson wrote: >>So you actually pasted that code into timeit.py? >Yeah. :-( I think I learned on the Tutor list to do it that way, but >I'm not sure. Thanks for showing me a correct way. I hope not! >>Using timeit more conventionally I get unsurpr

Re: [Tutor] A fun puzzle

2007-08-24 Thread Ken Oliver
-Original Message- >From: Dick Moores <[EMAIL PROTECTED]> >Sent: Aug 24, 2007 4:30 PM >To: Python Tutor List >Subject: Re: [Tutor] A fun puzzle > >Dick Moores wrote: >>At 10:22 AM 8/24/2007, Kent Johnson wrote: >>>So you actually pasted that code into timeit.py? >>Yeah. :-( I think I lea

Re: [Tutor] A fun puzzle

2007-08-24 Thread Kent Johnson
Dick Moores wrote: >> Using your exact code, I just got >> 0.737564690484 >> 1.17399585702 >> Which is the reverse of your result, but on a slower computer. > > That result was gotten using Ulipad. Thought I'd try it at my command > line (several times, of course--I've reported what seemed to be

[Tutor] Spawning terminals from Python - A failed question

2007-08-24 Thread wormwood_3
Hello all, I had this question all written up, then found I had the answer:-) So I decided to share anyway in case anyone found it useful -- I am trying to write a script that will open terminal windows for me, based on certain criteria. In this case, gnome-termin

Re: [Tutor] Spawning terminals from Python - A failed question

2007-08-24 Thread Alan Gauld
"wormwood_3" <[EMAIL PROTECTED]> wrote > want to basically spawn the process so it keeps running regardless > of what the script does next (like running something with " &" after > it in linux). Umm, so just put the ampersand at the end of the command string and call os.system() > All I ended

[Tutor] Read dictionary data in a specific order...

2007-08-24 Thread Trey Keown
Hello. I would like to know, how can I read (or sort) a dictionary in a certain order? say this is my dictionary- attrs={u'title': u'example window title', u'name': u'SELF', u'icon': u'e.ico'} how could I get the data so that u'name' is read first, u'title' second, and u'icon' third? thanks so much

Re: [Tutor] the and command

2007-08-24 Thread Ricardo Aráoz
Alan Gauld wrote: > "max baseman" <[EMAIL PROTECTED]> wrote >> im checking if a number is in all 5 of the other lists and when >> i use the and command it seems to just be checking if it's in a >> least >> one of the others, > > >> for num in l2 and l3 and l4 and l5 and l6: # here seems to be th

Re: [Tutor] HOWTO: adding to sys.path the simplest way.

2007-08-24 Thread Ricardo Aráoz
Tim Johnson wrote: > I have a seperate library directory both on my work station on > the the remote servers that I write applications for.. > > I commonly use sys.path.append('/path/to/mylibraries') in my > python code. > > That code has to be placed in any standalone script that I write. > I c

Re: [Tutor] the and command

2007-08-24 Thread Kent Johnson
Ricardo Aráoz wrote: > Alan Gauld wrote: >> "max baseman" <[EMAIL PROTECTED]> wrote >>> im checking if a number is in all 5 of the other lists and when >>> i use the and command it seems to just be checking if it's in a >>> least >>> one of the others, >> >>> for num in l2 and l3 and l4 and l5 and

Re: [Tutor] Read dictionary data in a specific order...

2007-08-24 Thread Alan Gauld
"Trey Keown" <[EMAIL PROTECTED]> wrote > I would like to know, how can I read (or sort) a dictionary in a > certain > order? Dictionaries are by design unsorted and indeed may even change their order during their lifetime. > attrs={u'title': u'example window title', u'name': u'SELF', u'icon': >

Re: [Tutor] Spawning terminals from Python - A failed question

2007-08-24 Thread wormwood_3
>>Umm, so just put the ampersand at the end of the command string and >>call os.system() Not sure what the point of this variation would be if os is being deprecated along with commands... >>However both os.system and the commands module are deprecated in >>favour >>of the new(ish) subprocess m

Re: [Tutor] Read dictionary data in a specific order...

2007-08-24 Thread Trey Keown
> "Trey Keown" <[EMAIL PROTECTED]> wrote > >> I would like to know, how can I read (or sort) a dictionary in a >> certain >> order? > > Dictionaries are by design unsorted and indeed may even change > their order during their lifetime. > >> attrs={u'title': u'example window title', u'name': u'SELF'

[Tutor] Question about classes

2007-08-24 Thread Ara Kooser
Hello all, I am working on trying to understand classes by creating a character generator for a rpg. I know I am doing something silly but I am not sure what. When I run the program I and type no when prompted I get the following message: Traceback (most recent call last): File "/Users/ara/Do

Re: [Tutor] Question about classes

2007-08-24 Thread Noufal Ibrahim
Ara Kooser wrote: > Hello all, > >I am working on trying to understand classes by creating a > character generator for a rpg. I know I am doing something silly but I > am not sure what. When I run the program I and type no when prompted I > get the following message: > Traceback (most recent c