[Tutor] Simple way to compare Two lists

2007-08-10 Thread Jaggo
Hello!

I desperately need a simple way to compare whether any item of SmallList is in 
BigList.

My current way,

def IsAPartOfList(SmallList,BigList)
for item in SmallList:
if item in BigList:
return True
return False

Takes up waay too much time to process.
Can anyone think of any better way?

Usually, SmallList is generated using range(Long, Long+ ~300)
BigList is usually of a few hundreds of long numbers.
The long numbers themselves represent date in seconds-since-the-epoch time. 
(E.G: time.time() is now in seconds-since-the-epoch,
1186739653.467
at the time of writing.)

Thank you for your help,
Omer Tabach.

Now playing: Haggard - Requiem in D-Minor
posted with FoxyTunes

   
-
Looking for a deal? Find great prices on flights and hotels with Yahoo! 
FareChase.___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Simple way to compare Two lists

2007-08-16 Thread Jaggo
Thank you Kent, Michael, Tom and anyone else I'm forgetting who took time to 
reply.

I don't work quite so fast, very limited personal computer time means I only do 
it on weekends,

I read through your suggestions and eventually found a way to speed-up the 
proccess through sorting the Two lists, then manually iterating through each of 
them. This way I've completely canceled the need to compare Two lists: instead 
just ensuring I start from a point not taken in One list and having to only 
check whether Item not in BigList.

[If anyone's interested, I should have the script finished and thoroughly 
tested on, ah, next weekend, and I could post a link here.]

Again, Thx.
-Omer.

Message: 1
Date: Fri, 10 Aug 2007 08:11:47 -0400
From: Kent Johnson 
Subject: Re: [Tutor] Simple way to compare Two lists
To: Tom Fitzhenry , tutor@python.org
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Tom Fitzhenry wrote:
> On Fri, Aug 10, 2007 at 02:54:44AM -0700, Jaggo wrote:
>> Can anyone think of any better way?
> 
> If SmallList and BigList are sorted (in order), there is a faster method:
> 
> def IsAPartOfList(SmallList,BigList):
> for i in BigList:
> for j in SmallList:
> if i==j:
> return true
> if i>j:
> break
> return false
> 
> (I'm not sure how encouraged using break statements are, so wait for a tutor 
> to
> answer)

break is fine! If the list you are searching is sorted you can use the 
bisect module to do a binary search instead of the linear search above.

> If one list is already sorted but the other isn't, it may still be faster to
> sort the unsorted list then use the method above.

I don't think BigList has to be sorted in the above algorithm. If both 
lists are sorted I suppose you could write it like a merge sort, walking 
along both lists looking for a match.

Kent



   
-
Park yourself in front of a world of choices in alternative vehicles.
Visit the Yahoo! Auto Green Center.___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] The whole Roman to Dec and vice versa issue

2007-03-11 Thread Jaggo
Hey,
I'm a rather new programmer, but it seems to me the digital to roman should be 
coded:
While Digital_Input > 0:
If Digital_Input > 1000 then: Roman = + M, Digital_Input = - 1000
elif Digital_Input > 900 then: Roman = + C, Digital_Input = - 900
...
Now if someone could please clarify [or forward me to clarifications of-] 
separation of data from logics I should be very grateful.

[Come to that, if someone could point me to a *simple* gui which I can use in 
python, keep in mind I did learn a little VB, I should be grateful as well.]

Thank you.
Omer Tabach.



Quoting Bob Gailer :

>>
>> Digital to Roman pseudocode:
>>
>> 1. if digital_input is greater than 1000:
>> subtract 1000 from it and add "M" to string roman_result
>> # How do you do that, add one character to the end of an existing string?
>>
> Start with an empty string:
>
> roman_result = ""
>
> To add a character at the end:
>
> roman_result += "M" # Python shorthand for roman_result = roman_result + "M"
>
roman_result + "M" would also work, right/ I'm just trying to save  
time on typing in the code, right
>
>> # also, how do I modify the digital_input variable (it's an integer)
> digital_input -= 1000

is that somewhat like digital_result = digital result - int(1000)?

>> several times through the conversion process?
>>
> You will be processing the input in a loop (while or for).

running = True and
while running

is how I've tended to set

(my pseudocode)

> As you gain familiarity with Python you will develop ways to separate
> data from logic. I might say more about this later, but right now I'm
> about to drive north a bit.
>
I have already gained some familiary with separating data manipulation  
(data and logic, as a whole) from the code for the user interface,  
that's something that oen of my advisors has been big on.



 
-
Now that's room service! Choose from over 150,000 hotels 
in 45,000 destinations on Yahoo! Travel to find your fit.___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Money Matters

2007-03-22 Thread Jaggo
Hello!

I read this list because I'm new to Python and I really am learning an average 
of something new I did not know from every digest hitting my inbox.

I have no interest on the matter of money.

Just my .02$.

-Omer Tabach

[EMAIL PROTECTED] wrote:
Message: 3
Date: Wed, 21 Mar 2007 23:13:57 -0400
From: Kirk Bailey 
Subject: [Tutor] MONEY MATTERS
To: tutor@python.org
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

ok, SHOULD THIS BE A THREAD OR A SEPERATE LIST?

Many of ius are independants, and write code for the love of it- or to 
promote and sell independantly. So possibly a thread discussing ways to 
  turn useful code into moiney is a useful idea. If the wish of the list 
is a thread here, we can do that, or we can start a seperate list for 
it. What are the wishes of this list?

-- 
Salute!
 -Kirk Bailey
   Think
  +-+
  | BOX |
  +-+
   knihT

Fnord.


 
-
Don't pick lemons.
See all the new 2007 cars at Yahoo! Autos.___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Tutor Digest, Vol 37, Issue 62

2007-03-24 Thread Jaggo
Message: 2
Date: Sat, 24 Mar 2007 19:25:10 -0400
From: Jay Mutter III 
Subject: [Tutor] parsing text
[...]
1.) when i do readlines and create a list and then print the list it  
adds a blank line between every line of text
[...]
ideas?

Thanks again

jay
Well,
regarding your first question:
"print string" automatically breaks a line at the end of string. Use "print 
string," instead [note that trailin' , .]

[I'm not sure about your n. 2, that's why no answer is included.

 
-
TV dinner still cooling?
Check out "Tonight's Picks" on Yahoo! TV.___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] What has Editor X got that PyWin32 hasn't?

2008-08-12 Thread Jaggo
Hello.

I haven't much experience with programming.

I'd like to point this question to programmers who write in editors other
than the default PyWin32:

Why do you use your editor rather than using Pywin? What feature has editor
X got that PyWin hasn't?
(That is, other than "My editor runs on unix / linux"; while that does count
for something it is rather irrelevant to my current situation.)

Thanks in advance,
Omer.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Inserting an Indent in IDLE?

2008-09-11 Thread Jaggo
In Pywin, and so I assume IDLE follows, you can just select more than One
line and press tab.

On Sun, Sep 7, 2008 at 5:41 PM, Alan Gauld <[EMAIL PROTECTED]>wrote:

>
> "Wayne Watson" <[EMAIL PROTECTED]> wrote
>
>  Signature.htmlOccasionally I would like to indent 20-30 lines of code.
>> I don't see a way to do this in IDLE other than brute force.
>>
>
> Format->Indent region?
>
> Ctrl-]
>
> Format Dedent region
>
> Ctrl-[
>
> Seems to work for me.
>
> Alan G
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Hay Variables

2008-09-14 Thread Jaggo
... or maybe a dict of class[class-name]=grade

On Fri, Sep 12, 2008 at 10:42 PM, Kent Johnson <[EMAIL PROTECTED]> wrote:

> On Fri, Sep 12, 2008 at 2:13 PM,
> <[EMAIL PROTECTED]> wrote:
> >
> > I would use a list of grades and the length of the list.
>
> or perhaps a list of (class name, grade) pairs.
>
> Kent
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor