Re: Scanning a file

2005-10-31 Thread Lasse Vågsæther Karlsen
? 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: dreaming in Python

2005-10-30 Thread Lasse Vågsæther Karlsen
something esoteric and strange on the terminal but I was just having trouble logging in. End of dream. Anyone ever have a wierd engineering dream sometime in thier career? The Eternal Squire Just sit still while the men in white come to pick you up :) -- Lasse Vågsæther Karlsen http

Re: Need Python Pro for Help!! Plzz

2005-10-30 Thread Lasse Vågsæther Karlsen
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: how to associate files with application

2005-10-29 Thread Lasse Vågsæther Karlsen
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://usinglvkblog.blogspot.com/ mailto:[EMAIL PROTECTED] PGP KeyID: 0x2A42A1C2

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 whole franchise deal. It's an all-or-nothing package. With very few

Re: Suggestion for (re)try statement

2005-10-28 Thread Lasse Vågsæther Karlsen
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 event/lock, etc.). -- Lasse Vågsæther Karlsen http

Re: how to associate files with application

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

Re: Spambayes modifications with web services

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

Sorting with only a partial order definition

2005-10-27 Thread Lasse Vågsæther Karlsen
. Any help or pointers would be most welcome. -- 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
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 list. In other words, if I pick two random items from the list I may

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. snip Ok, managed to implement the algorithm. Might not be the optimal solution (memory and speed-wise) but it worked and doesn't take too

Re: Microsoft Hatred FAQ

2005-10-27 Thread Lasse Vågsæther Karlsen
, 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: Microsoft Hatred FAQ

2005-10-27 Thread Lasse Vågsæther Karlsen
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.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
, 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
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 those rules are set forth in a law somewhere

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
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 feature. snip -- Lasse Vågsæther Karlsen http://usinglvkblog.blogspot.com/ mailto:[EMAIL PROTECTED] PGP KeyID: 0x2A42A1C2

Re: Function to execute only once

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

Re: How to get a raised exception from other thread

2005-10-16 Thread Lasse Vågsæther Karlsen
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: Perl-Python-a-Day: Sorting

2005-10-13 Thread Lasse Vågsæther Karlsen
Diez B. Roggisch wrote: snip 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/ mailto:[EMAIL

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

2005-10-12 Thread Lasse Vågsæther Karlsen
, 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: crosswords helper program

2005-10-12 Thread Lasse Vågsæther Karlsen
to allow the user to input both some basic format for your program and convert it to a regular expression as well as input a full pattern, because then the user can have words that have a U or a E in the second letter, simply because he doesn't know which one is right yet. -- Lasse Vågsæther

Re: Perl-Python-a-Day: Sorting

2005-10-12 Thread Lasse Vågsæther Karlsen
of sorting and its implementation aspects are completely belied. belied how? It's interesting to note that these fact posts of yours are nothing bud badly worded opinions. -- Lasse Vågsæther Karlsen http://usinglvkblog.blogspot.com/ mailto:[EMAIL PROTECTED] PGP KeyID: 0x2A42A1C2 -- http

Re: Looking for info on Python's memory allocation

2005-10-11 Thread Lasse Vågsæther Karlsen
] 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 Karlsen http://usinglvkblog.blogspot.com/ mailto:[EMAIL PROTECTED

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

2005-10-11 Thread Lasse Vågsæther Karlsen
: 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://mail.python.org/mailman/listinfo/python-list

How to do *args, **kwargs properly

2005-10-11 Thread Lasse Vågsæther Karlsen
: 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: 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 probably pass a sequence to the method instead. You can do

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: snip 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. snip The removing duplicates problem would probably

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: snip 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 turn it into a list (or a tuple or a set

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

2005-10-11 Thread Lasse Vågsæther Karlsen
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: new forum -- homework help/chit chat/easy communication

2005-10-09 Thread Lasse Vågsæther Karlsen
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.blogspot.com/ mailto:[EMAIL PROTECTED] PGP KeyID: 0x2A42A1C2 -- http

Re: Jargons of Info Tech industry

2005-10-09 Thread Lasse Vågsæther Karlsen
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

Function decorator that caches function results

2005-10-08 Thread Lasse Vågsæther Karlsen
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: Function decorator that caches function results

2005-10-08 Thread Lasse Vågsæther Karlsen
if possible if key in cache: return cache[key] # Work out new value, cache it and return it result = fn(*args, **kwargs) cache[key] = result return result # Return wrapper function return cached_result -- Lasse Vågsæther Karlsen http

Re: Function decorator that caches function results

2005-10-08 Thread Lasse Vågsæther Karlsen
has the problem that dictionaries can't be used as dictionary keys, but that can be easily solved. I think I can simplify my solution with some of yours. The parameter names can be gotten by doing a inspect.getargspec(fn)[0] so that can be done by the decorator function. -- Lasse Vågsæther

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: snip Ok, here's my updated version: class cache(object): def __init__(self, timeout=0): self.timeout = timeout self.cache = {} def __call__(self, fn

Re: Function decorator that caches function results

2005-10-08 Thread Lasse Vågsæther Karlsen
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
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: Merging sorted lists/iterators/generators into one stream of values...

2005-10-08 Thread Lasse Vågsæther Karlsen
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æther Karlsen http

Re: Function decorator that caches function results

2005-10-08 Thread Lasse Vågsæther Karlsen
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: new forum -- homework help/chit chat/easy communication

2005-10-08 Thread Lasse Vågsæther Karlsen
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: 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 since that guy was born... Yes, of course, my

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: Jargons of Info Tech industry

2005-10-08 Thread Lasse Vågsæther Karlsen
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 Karlsen http://usinglvkblog.blogspot.com/ mailto:[EMAIL PROTECTED] PGP KeyID: 0x2A42A1C2 -- http

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

2005-10-08 Thread Lasse Vågsæther Karlsen
:) 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: Merging sorted lists/iterators/generators into one stream of values...

2005-10-07 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: 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

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 snip Ok, after working through the various sources and solutions, here's what I finally ended up with: def

Re: Contest snub?

2005-10-07 Thread Lasse Vågsæther Karlsen
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://usinglvkblog.blogspot.com/ mailto:[EMAIL PROTECTED

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

2005-10-06 Thread Lasse Vågsæther Karlsen
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 PROTECTED] PGP KeyID: 0x2A42A1C2 -- http://mail.python.org

Re: IDLE won't run on WinXP

2005-10-06 Thread Lasse Vågsæther Karlsen
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.python.org/mailman/listinfo

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
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

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

Question about stdin and PATHEXT on Windows XP

2005-10-02 Thread Lasse Vågsæther Karlsen
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

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: snip 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 yet, please let me know

Documenting members

2005-09-29 Thread Lasse Vågsæther Karlsen
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://mail.python.org/mailman/listinfo

Module organization

2005-09-28 Thread Lasse Vågsæther Karlsen
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 Vågsæther Karlsen http://usinglvkblog.blogspot.com/ mailto:[EMAIL PROTECTED] PGP KeyID

Documenting properties

2005-09-27 Thread Lasse Vågsæther Karlsen
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 document ? Whatever is preferred, what's the upside/downsides of the two beyond what I just explained? -- Lasse Vågsæther Karlsen http