Re: Scanning a file

2005-10-31 Thread Lasse Vågsæther Karlsen
; than the file actually have? What if the encoded data happens to have the magic byte values for something else? -- Lasse Vågsæther Karlsen http://usinglvkblog.blogspot.com/ mailto:[EMAIL PROTECTED] PGP KeyID: 0x2A42A1C2 -- http://mail.python.org/mailman/listinfo/python-list

Re: Need Python Pro for Help!! Plzz

2005-10-30 Thread Lasse Vågsæther Karlsen
al people instead of just one. -- Lasse Vågsæther Karlsen http://usinglvkblog.blogspot.com/ mailto:[EMAIL PROTECTED] PGP KeyID: 0x2A42A1C2 -- http://mail.python.org/mailman/listinfo/python-list

Re: dreaming in Python

2005-10-30 Thread Lasse Vågsæther Karlsen
Just sit still while the men in white come to pick you up :) -- Lasse Vågsæther Karlsen http://usinglvkblog.blogspot.com/ mailto:[EMAIL PROTECTED] PGP KeyID: 0x2A42A1C2 -- http://mail.python.org/mailman/listinfo/python-list

Re: how to associate files with application

2005-10-29 Thread Lasse Vågsæther Karlsen
ght mouse click, select "Open With". There are several ways to do this using Windows Explorer. I was under the assumption the OP wanted to know how he could automate it since that is what you typically want to do with applications you write. -- Lasse Vågsæther Karlsen http://usi

Re: Spambayes modifications with web services

2005-10-28 Thread Lasse Vågsæther Karlsen
egitimate customers) Nice plan sherlock. -- Lasse Vågsæther Karlsen http://usinglvkblog.blogspot.com/ mailto:[EMAIL PROTECTED] PGP KeyID: 0x2A42A1C2 -- http://mail.python.org/mailman/listinfo/python-list

Re: how to associate files with application

2005-10-28 Thread Lasse Vågsæther Karlsen
own to behave and look through HKEY_CLASSES_ROOT\.ext to find the details you want. -- Lasse Vågsæther Karlsen http://usinglvkblog.blogspot.com/ mailto:[EMAIL PROTECTED] PGP KeyID: 0x2A42A1C2 -- http://mail.python.org/mailman/listinfo/python-list

Re: Suggestion for (re)try statement

2005-10-28 Thread Lasse Vågsæther Karlsen
t; would be more appropriate. A timeout is usually associated with starting a task and waiting for it to complete, and continuing if it fails to complete in a given timeframe, typically also aborting the task at the same time (ie. executing a database query, connecting to a server, waiting for an e

Re: Microsoft Hatred FAQ

2005-10-28 Thread Lasse Vågsæther Karlsen
David Schwartz wrote: > Lasse Vågsæther Karlsen wrote: > > >>David Schwartz wrote: > > >>>Burger King won't let you sell Whoppers or buy their burger >>>patties wholesale no matter what you want to call your store unless >>>you take the

Re: Microsoft Hatred FAQ

2005-10-27 Thread Lasse Vågsæther Karlsen
David Schwartz wrote: > Lasse Vågsæther Karlsen wrote: > > >>I would think that if I set up a shop and wanted to have the word >>"Microsoft" as part of the shop name, there would be some rules >>dictating what products I could and could not sell, yes. Wether

Re: Microsoft Hatred FAQ

2005-10-27 Thread Lasse Vågsæther Karlsen
> extract money from people and hand it to Microsoft and give those What, specifically, is the criminal act of which you speak? -- Lasse Vågsæther Karlsen http://usinglvkblog.blogspot.com/ mailto:[EMAIL PROTECTED] PGP KeyID: 0x2A42A1C2 -- http://mail.python.org/mailman/listinfo/python-list

Re: Microsoft Hatred FAQ

2005-10-27 Thread Lasse Vågsæther Karlsen
e law would prohibit them from doing so. Otherwise I could set up a shop, call it "Microsoft Porsgrunn" and sell machines with only Linux installed. I think Microsoft would be allowed to say "No, you can't do that". -- Lasse Vågsæther Karlsen http://usinglvkblog.blogs

Re: Microsoft Hatred FAQ

2005-10-27 Thread Lasse Vågsæther Karlsen
ure they would be obliged to do so either. However, controlling what an independant outlet is doing, that's different. -- Lasse Vågsæther Karlsen http://usinglvkblog.blogspot.com/ mailto:[EMAIL PROTECTED] PGP KeyID: 0x2A42A1C2 -- http://mail.python.org/mailman/listinfo/python-list

Re: Sorting with only a partial order definition

2005-10-27 Thread Lasse Vågsæther Karlsen
Lasse Vågsæther Karlsen wrote: > Paul Rubin wrote: > >> Lasse Vågsæther Karlsen <[EMAIL PROTECTED]> writes: >> >>> I have a list of items and a "rule" for ordering them. Ok, managed to implement the algorithm. Might not be the optimal solution (memor

Re: Sorting with only a partial order definition

2005-10-27 Thread Lasse Vågsæther Karlsen
Paul Rubin wrote: > Lasse Vågsæther Karlsen <[EMAIL PROTECTED]> writes: > >>I have a list of items and a "rule" for ordering them. >> >>Unfortunately, the rule is not complete so it won't define the correct >>order for any two items in that li

Sorting with only a partial order definition

2005-10-27 Thread Lasse Vågsæther Karlsen
I have a list of items and a "rule" for ordering them. Unfortunately, the rule is not complete so it won't define the correct order for any two items in that list. In other words, if I pick two random items from the list I may or may not have a rule that dictates the order of those two items. T

Re: sort problem

2005-10-20 Thread Lasse Vågsæther Karlsen
How about: list.sort(key=lambda x: x[3]) Does that work? -- http://mail.python.org/mailman/listinfo/python-list

Re: How to get a raised exception from other thread

2005-10-17 Thread Lasse Vågsæther Karlsen
#x27;t be interrupted - an exception thrown at the wrong time in a finally/except block might cause more problems than it intends to solve So until a good implementation exists, there shouldn't be any point in actually discussing the motives of the programmers who wishes to use the

Re: How to get a raised exception from other thread

2005-10-16 Thread Lasse Vågsæther Karlsen
boolean variable or similar for a magic value that means "now is a good time for you to terminate". -- Lasse Vågsæther Karlsen http://usinglvkblog.blogspot.com/ mailto:[EMAIL PROTECTED] PGP KeyID: 0x2A42A1C2 -- http://mail.python.org/mailman/listinfo/python-list

Re: Function to execute only once

2005-10-16 Thread Lasse Vågsæther Karlsen
Bengt Richter wrote: > >>> tmp = 0 > >>> def execute(): > ... global tmp, execute > ... tmp = cellvar = tmp + 1 > ... def execute(): > ... return cellvar > ... return tmp On man did this put my head into a sp

Re: Perl-Python-a-Day: Sorting

2005-10-13 Thread Lasse Vågsæther Karlsen
Diez B. Roggisch wrote: > Diez > > [1] http://xahlee.org/PageTwo_dir/Personal_dir/mi_pixra.html Oh man... Talk about ... bummer. Seriously, who do we call to get someone with a straightjacket to show up at his home? -- Lasse Vågsæther Karlsen http://usinglvkblog.blogspot.com/ mail

Re: Perl-Python-a-Day: Sorting

2005-10-12 Thread Lasse Vågsæther Karlsen
age syntax is tainted. In tainted how? > Perl, a complex construct is invented. In both camps, the basic invented how? > mathematics of sorting and its implementation aspects are completely > belied. belied how? It's interesting to note that these "fact posts" of you

Re: crosswords helper program

2005-10-12 Thread Lasse Vågsæther Karlsen
second letter, simply because he doesn't know which one is right yet. -- Lasse Vågsæther Karlsen http://usinglvkblog.blogspot.com/ mailto:[EMAIL PROTECTED] PGP KeyID: 0x2A42A1C2 -- http://mail.python.org/mailman/listinfo/python-list

Re: bizarro world (was Re: Python Doc Problem Example: sort() (reprise))

2005-10-11 Thread Lasse Vågsæther Karlsen
in the sense of limitations, but that crowd probably needs to be limited in one way or another, like "only 2 rotten fruits per person" or similar. -- Lasse Vågsæther Karlsen http://usinglvkblog.blogspot.com/ mailto:[EMAIL PROTECTED] PGP KeyID: 0x2A42A1C2 -- http://mail.python.org/mailman/listinfo/python-list

Re: Merging sorted lists/iterators/generators into one stream of values...

2005-10-11 Thread Lasse Vågsæther Karlsen
ot of time. > > George > Itertools, meh, there's that wheel again :) Didn't know about this one so thank you :) -- Lasse Vågsæther Karlsen http://usinglvkblog.blogspot.com/ mailto:[EMAIL PROTECTED] PGP KeyID: 0x2A42A1C2 -- http://mail.python.org/mailman/listinfo/python-list

Re: How to do *args, **kwargs properly

2005-10-11 Thread Lasse Vågsæther Karlsen
George Sakkis wrote: > "Lasse Vågsæther Karlsen" <[EMAIL PROTECTED]> wrote: >>I think I'll re-write to use a list instead > > > Actually in most cases you don't need to assume it's a list; any > iterable is usually good enough. You can always

Re: Merging sorted lists/iterators/generators into one stream of values...

2005-10-11 Thread Lasse Vågsæther Karlsen
Lasse Vågsæther Karlsen wrote: > > > Another idea for this method would be that in some cases I noticed that > it was useful to know which source each element would come from as well, > as well as removing duplicates from the results. > The "removing duplicates&quo

Re: How to do *args, **kwargs properly

2005-10-11 Thread Lasse Vågsæther Karlsen
Max M wrote: > Lasse Vågsæther Karlsen wrote: > >> I must be missing something but what is the proper way to do a >> function using such arguments ? > > >> - ability to take an unspecified number of "positional arguments" > > > You should pr

How to do *args, **kwargs properly

2005-10-11 Thread Lasse Vågsæther Karlsen
s): if "cmp" in options: comparison = options["cmp"] else: comparison = cmp # rest of function here and thus ignoring the wrong parameter names? -- Lasse Vågsæther Karlsen http://usinglvkblog.blogspot.com/ mailto:[EMAIL PROTECTED] PGP KeyID: 0x2A42A1C2 -- http://mail.python.org/mailman/listinfo/python-list

Re: Merging sorted lists/iterators/generators into one stream of values...

2005-10-11 Thread Lasse Vågsæther Karlsen
es[-1][0], iterables[-2][0]) > 0: iterables.sort(comparison, key=lambda x: x[0], reverse=True) except StopIteration: iterables.pop(-1) -- Lasse Vågsæther Karlsen http://usinglvkblog.blogspot.com/ mailto:[EMAIL PROTECTED] PGP KeyID: 0x2A42A1C2 -- http://mai

Re: Looking for info on Python's memory allocation

2005-10-11 Thread Lasse Vågsæther Karlsen
items, and use it like this: s = [k for k in iterable] if I know beforehand how many items iterable would possibly yield, would a construct like this be faster and "use" less memory? s = [0] * len(iterable) for i in xrange(len(iterable)): s[i] = iterable.next() -- Lasse Vågsæther

Re: Jargons of Info Tech industry

2005-10-09 Thread Lasse Vågsæther Karlsen
against captions? > > Giving photos captions is a *very* common practice. Perhaps he has a search engine that can find blue hats in an image and recognize people? -- Lasse Vågsæther Karlsen http://usinglvkblog.blogspot.com/ mailto:[EMAIL PROTECTED] PGP KeyID: 0x2A42A1C2 -- http://mail.python.org/mailman/listinfo/python-list

Re: new forum -- homework help/chit chat/easy communication

2005-10-09 Thread Lasse Vågsæther Karlsen
ed by themselves without running it inside that program, and as thus was a way to add minor functions and things to that program. Nowadays a lot of the scripting languages have turned programming languages so I think the difference is small. -- Lasse Vågsæther Karlsen http://usinglvkblog.

Re: new forum -- homework help/chit chat/easy communication

2005-10-08 Thread Lasse Vågsæther Karlsen
uot;scripting language" as well :) In other words, what is the difference between a "scripting language" and a "programming language". -- Lasse Vågsæther Karlsen http://usinglvkblog.blogspot.com/ mailto:[EMAIL PROTECTED] PGP KeyID: 0x2A42A1C2 -- http://mail.python.org/mailman/listinfo/python-list

Re: Jargons of Info Tech industry

2005-10-08 Thread Lasse Vågsæther Karlsen
ml and say "richly formatted", whatever that might mean in the future. But trying to keep your email world into a pure text-based no-formatting-whatsoever world, that's a fantasy bubble that is bound to burst, sooner rather than later. Deal with it. -- Lasse Vågsæther Karlse

Re: Daisy Daisy, give me your answer do

2005-10-08 Thread Lasse Vågsæther Karlsen
Leave Xah Lee alone, he's a troll, he got no interested in doing anything but to provoke people on usenet. -- Lasse Vågsæther Karlsen http://usinglvkblog.blogspot.com/ mailto:[EMAIL PROTECTED] PGP KeyID: 0x2A42A1C2 -- http://mail.python.org/mailman/listinfo/python-list

Re: new forum -- homework help/chit chat/easy communication

2005-10-08 Thread Lasse Vågsæther Karlsen
Fredrik Lundh wrote: > Lasse Vågsæther Karlsen wrote: > > >>Don't think so matey. > > > oh, come on. a site run by some random guy in North Carolina has to be > safer, faster and more reliable than a distributed communication system that > has been around

Re: new forum -- homework help/chit chat/easy communication

2005-10-08 Thread Lasse Vågsæther Karlsen
t 700 posts with usenet. Don't think so matey. Nice try though. -- Lasse Vågsæther Karlsen http://usinglvkblog.blogspot.com/ mailto:[EMAIL PROTECTED] PGP KeyID: 0x2A42A1C2 -- http://mail.python.org/mailman/listinfo/python-list

Re: Function decorator that caches function results

2005-10-08 Thread Lasse Vågsæther Karlsen
k here in a few days or even hours with another "task" where you can probably cough up dozens of existing source code solutions that I could use. For instance, there's this thing I've heard of called the "wheel". :) -- Lasse Vågsæther Karlsen http://usinglvkblog.blogspot.com/ mailto:[EMAIL PROTECTED] PGP KeyID: 0x2A42A1C2 -- http://mail.python.org/mailman/listinfo/python-list

Re: Merging sorted lists/iterators/generators into one stream of values...

2005-10-08 Thread Lasse Vågsæther Karlsen
ly. Might be a big difference if I have a lot of sources though as I bet the overhead in doing a sort of N items gets higher than doing a manipulation of a heap to place an item in the right spot, but with 4-5 or a few more sources might not make an impact at all. -- Lasse Vågsæthe

Re: Merging sorted lists/iterators/generators into one stream of values...

2005-10-08 Thread Lasse Vågsæther Karlsen
solution that Mike came up with slightly changed to accomodate tips and pointers from others in this thread. -- Lasse Vågsæther Karlsen http://usinglvkblog.blogspot.com/ mailto:[EMAIL PROTECTED] PGP KeyID: 0x2A42A1C2 -- http://mail.python.org/mailman/listinfo/python-list

Re: Function decorator that caches function results

2005-10-08 Thread Lasse Vågsæther Karlsen
ts, which I honestly don't believe I will. -- Lasse Vågsæther Karlsen http://usinglvkblog.blogspot.com/ mailto:[EMAIL PROTECTED] PGP KeyID: 0x2A42A1C2 -- http://mail.python.org/mailman/listinfo/python-list

Re: Function decorator that caches function results

2005-10-08 Thread Lasse Vågsæther Karlsen
Lasse Vågsæther Karlsen wrote: > Sam Pointon wrote: > >> What about not storing args at all? Something like this: Ok, here's my updated version: class cache(object): def __init__(self, timeout=0): self.timeout = timeout self.cache = {} def

Re: Function decorator that caches function results

2005-10-08 Thread Lasse Vågsæther Karlsen
etargspec(fn)[0] so that can be done by the decorator function. -- Lasse Vågsæther Karlsen http://usinglvkblog.blogspot.com/ mailto:[EMAIL PROTECTED] PGP KeyID: 0x2A42A1C2 -- http://mail.python.org/mailman/listinfo/python-list

Re: Function decorator that caches function results

2005-10-08 Thread Lasse Vågsæther Karlsen
return result # Return wrapper function return cached_result -- Lasse Vågsæther Karlsen http://usinglvkblog.blogspot.com/ mailto:[EMAIL PROTECTED] PGP KeyID: 0x2A42A1C2 -- http://mail.python.org/mailman/listinfo/python-list

Function decorator that caches function results

2005-10-08 Thread Lasse Vågsæther Karlsen
ve to consider fibonacci(50) and fibonacci(idx = 50) as the same call and thus retrieve the second one from the cache. -- Lasse Vågsæther Karlsen http://usinglvkblog.blogspot.com/ mailto:[EMAIL PROTECTED] PGP KeyID: 0x2A42A1C2 -- http://mail.python.org/mailman/listinfo/python-list

Re: Contest snub?

2005-10-07 Thread Lasse Vågsæther Karlsen
.. an irrational fear of snakes perhaps? > Clearly Python is superior because it doesn't need any code at all to do fractals. Surely you can see that? :) I question the timings though, 2+ minutes to execute nothing doesn't seem very pythonesque. -- Lasse Vågsæther Karlsen http://usi

Re: Merging sorted lists/iterators/generators into one stream of values...

2005-10-07 Thread Lasse Vågsæther Karlsen
Lasse Vågsæther Karlsen wrote: > I need to merge several sources of values into one stream of values. All > of the sources are sorted already and I need to retrieve the values from Ok, after working through the various sources and solutions, here's what I finally ended up

Re: Merging sorted lists/iterators/generators into one stream of values...

2005-10-07 Thread Lasse Vågsæther Karlsen
Thanks, that looks like Mike's solution except that it uses the built-in heapq module. While this one contains less code than Mike's solution it seems to lack the ability to control the comparison operation, which means it won't work in my case. I need to both be able to sort on an arbitrary field

Re: Merging sorted lists/iterators/generators into one stream of values...

2005-10-06 Thread Lasse Vågsæther Karlsen
Ok, that one looks more sleak than what I came up with. Couple of things I learn from your solution, please correct me if I misunderstood something: 1. list containing other lists will sort itself based on first element on lists inside ? 2. sort(), pop() is not costly operations Other than that

Re: IDLE won't run on WinXP

2005-10-06 Thread Lasse Vågsæther Karlsen
Lasse Vågsæther Karlsen wrote: > striker wrote: > >> I just downloaded and installed Python 2.4.2 on a Windows XP machine. >> Everything I have tried so far has worked except for IDLE. Is there > Just a thought though, during the installation of Python on one machine >

Re: IDLE won't run on WinXP

2005-10-06 Thread Lasse Vågsæther Karlsen
id something about Idle or Pythonwin, so it might be what you need. I think the name was something like MSVCRT71.DLL but don't think I got it 100% right just there... :P -- Lasse Vågsæther Karlsen http://usinglvkblog.blogspot.com/ mailto:[EMAIL PROTECTED] PGP KeyID: 0x2A42A1C2 -- http://mail

Merging sorted lists/iterators/generators into one stream of values...

2005-10-06 Thread Lasse Vågsæther Karlsen
application, 3 in another and 4-5 in a third), a simple 2-source method isn't enough but if it's better than what I do for 2 sources then I can make a wrapper for it, since that's what I do anyway. -- Lasse Vågsæther Karlsen http://usinglvkblog.blogspot.com/ mailto:[EMAIL PROT

Re: While and If messing up my program?

2005-10-05 Thread Lasse Vågsæther Karlsen
The specific error in your code, is that when cnto == len(ttllst), then doing ttllst[cnto] will give you that error. The list is indexed from 0 to len-1, which means that doing list[len(list)] will give that error. -- http://mail.python.org/mailman/listinfo/python-list

Re: New project coming up...stay with Python, or go with a dot net language??? Your thoughts please!

2005-10-04 Thread Lasse Vågsæther Karlsen
Ok, when re-reading my post it seems that I'm saying that Python has no roadmap. That was not my intent. I meant projects other than Python, even though the problems I got with 2.4.2 is real, I suspect there's something in Komodo that is the problem since I can run all my python programs with 2.4.2

Re: New project coming up...stay with Python, or go with a dot net language??? Your thoughts please!

2005-10-04 Thread Lasse Vågsæther Karlsen
While Microsoft and other big software vendors might have a roadmap that ties you very tightly in with their budget, and also changes that roadmap from time to time which breaks your current software, a lot of open source projects have no roadmap at all. This means that a .x.y.2 upgrade might very

Re: Question about stdin and PATHEXT on Windows XP

2005-10-02 Thread Lasse Vågsæther Karlsen
Lasse Vågsæther Karlsen wrote: > I got a loop like this: Ok, I've found some information. I don't like the answer but it doesn't seem to be any good way to do this without hacking it one way or the other. If someone has a brilliant answer that isn't in google y

Question about stdin and PATHEXT on Windows XP

2005-10-02 Thread Lasse Vågsæther Karlsen
in? I assume that since there is some magic involved in invoking python.exe here, stdin gets munged on the way. -- Lasse Vågsæther Karlsen http://usinglvkblog.blogspot.com/ mailto:[EMAIL PROTECTED] PGP KeyID: 0x2A42A1C2 -- http://mail.python.org/mailman/listinfo/python-list

Documenting members

2005-09-29 Thread Lasse Vågsæther Karlsen
g to that definition. I've tried finding an example in the lib code installed with Python but can't seem to track down anything that is documented like that. -- Lasse Vågsæther Karlsen http://usinglvkblog.blogspot.com/ mailto:[EMAIL PROTECTED] PGP KeyID: 0x2A42A1C2 -- http://mai

Module organization

2005-09-28 Thread Lasse Vågsæther Karlsen
the module in there, but now "import lvk.modulename" doesn't find the module. Is there a trick to this? Do I have to store my own modules beneath C:\Python24\Lib? or can I use the organization I've tried just with some minor fixes to make python locate my modules? -- Lasse

Documenting properties

2005-09-27 Thread Lasse Vågsæther Karlsen
then classname.close.__doc__ shows the text. So, my question is, is there a way to get __doc__ support for properties, in effect, use the """xxx""" syntax for documenting properties. Is the preferred way to use """xxx""" or # to doc