python-mode problem, doesnt load whole module?

2008-09-17 Thread cnb
>>> a = parsing.unserialize("C:/users/saftarn/desktop/twok.txt") Traceback (most recent call last): File "", line 1, in File "C:\Python25\Progs\NetflixRecSys\parsing.py", line 91, in unserialize return pickle.load(open(filename, 'r')) File "C:\Python25\lib\pickle.py", line 1370, in load

Re: How do I add permanently to Pythons sys.path?

2008-09-16 Thread cnb
On Sep 16, 10:53 pm, "Aaron \"Castironpi\" Brady" <[EMAIL PROTECTED]> wrote: > On Sep 16, 3:16 pm, cnb <[EMAIL PROTECTED]> wrote: > > > > > On Sep 16, 7:49 pm, "Aaron \"Castironpi\" Brady" > > > > Now I have my pe

Re: How do I add permanently to Pythons sys.path?

2008-09-16 Thread cnb
On Sep 16, 7:49 pm, "Aaron \"Castironpi\" Brady" <[EMAIL PROTECTED]> wrote: > On Sep 16, 10:13 am, cnb <[EMAIL PROTECTED]> wrote: > > > > > >>> sys.path > > > ['C:\\Python25\\Progs\\NatLangProc', 'C:\\Python25\\

Re: How do I add permanently to Pythons sys.path?

2008-09-16 Thread cnb
On Sep 16, 5:25 pm, Python <[EMAIL PROTECTED]> wrote: > On 16 sep 2008, at 17:13, cnb wrote: > > > > >>>> sys.path > > ['C:\\Python25\\Progs\\NatLangProc', 'C:\\Python25\\Lib\\idlelib',   > > 'C:\ > > \Windows\\system32\\p

How do I add permanently to Pythons sys.path?

2008-09-16 Thread cnb
>>> sys.path ['C:\\Python25\\Progs\\NatLangProc', 'C:\\Python25\\Lib\\idlelib', 'C:\ \Windows\\system32\\python25.zip', 'C:\\Python25\\lib\\site-packages\ \orange', 'C:\\Python25\\lib\\site-packages\\orange\\OrangeWidgets', 'C:\\Python25\\lib\\site-packages\\orange\\OrangeCanvas', 'C:\ \Python25\\D

recursion gotcha?

2008-09-14 Thread cnb
this recursive definition of sum thrumped me, is this some sort of gotcha or am I just braindead today? and yes i know this is easy a a for x in xs acc += x or just using the builtin. def suma(xs, acc=0): if len(xs) == 0: acc else: suma(xs[1:], acc+x

Profiling, sum-comprehension vs reduce

2008-09-13 Thread cnb
This must be because of implementation right? Shouldn't reduce be faster since it iterates once over the list? doesnt sum first construct the list then sum it? --- >>> RESTART >>> reduce with named function: 37

problem with permutations

2008-09-07 Thread cnb
I am trying to translate this elegant Erlang-code for finding all the permutations of a list. I think it is the same function as is but it doesn't work in Python. -- is upd in Python. It works as it should. perms([]) -> [[]]; perms(L) -> [[H|T] || H <- L, T <- perms(L--[H])]. def perms(lista):

Cathing several potential errors?

2008-09-06 Thread cnb
if i do try: something except TypeError, IndexError: pass only the first error will get caught. I dont want to use Exception and catch all errors, but just 2. how can i do that? -- http://mail.python.org/mailman/listinfo/python-list

Multicore-programming?

2008-09-06 Thread cnb
If I buy a multicore computer and I have really intensive program. How would that be distributed across the cores? Will algorithms always have to be programmed and told specifically to run on several cores so if not told it will only utilize one core? So is the free lunch really over or is this j

Numpy/Scipy set field of matrix?

2008-09-02 Thread cnb
, 'argmax', 'argmin', 'argsort', 'astype', 'base', 'byteswap', 'choose', 'clip', 'compress', 'conj', 'conjugate', 'copy', 'ctypes', 'cumprod', 'cumsum', 'data', 'diagonal', 'dtype', 'dump', 'dumps', 'fill', 'flags', 'flat', 'flatten', 'getA', 'getA1', 'getH', 'getI', 'getT', 'getfield', 'imag', 'it

Re: Large amount of files to parse/organize, tips on algorithm?

2008-09-02 Thread cnb
over 17000 files... netflixprize. -- http://mail.python.org/mailman/listinfo/python-list

Re: Large amount of files to parse/organize, tips on algorithm?

2008-09-02 Thread cnb
On Sep 2, 7:06 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Tue, 02 Sep 2008 09:48:32 -0700, cnb wrote: > > I have a bunch of files consisting of moviereviews. > > > For each file I construct a list of reviews and then for each new file I >

Large amount of files to parse/organize, tips on algorithm?

2008-09-02 Thread cnb
I have a bunch of files consisting of moviereviews. For each file I construct a list of reviews and then for each new file I merge the reviews so that in the end have a list of reviewers and for each reviewer all their reviews. What is the fastest way to do this? 1. Create one file with reviews,

Re: Which is faster?

2008-08-30 Thread cnb
how does doing something twice not change complexity? yes it maybe belongs to the same complexity-class but is still twice as slow no? -- http://mail.python.org/mailman/listinfo/python-list

Which is faster?

2008-08-29 Thread cnb
For a big nbr of it might matter? Is av_grade O(n*2) and the first O(n) when it comes to adding or is "sum x for x in y" just traversing the list ones, accumulating the values, it doesnt first build the list and then travese it for sum? def averageGrade(self): tot = 0 for review i

Using class-attribute as key to sort?

2008-08-29 Thread cnb
In median grade, can I sort on Review-grade somehow? something like: sr = self.reviews.sort(key=self.reviews.instance.grade) class Review(object): def __init__(self, movieId, grade, date): self.movieId = movieId self.grade = grade self.date = date class Customer(object

Re: Memory Leek, critique me. Thanks!!!

2008-08-29 Thread cnb
you could prob abstract away a lot of that code, very similar-looking. then it would be easier to find bugs. -- http://mail.python.org/mailman/listinfo/python-list

Re: When to use try and except?

2008-08-29 Thread cnb
On Aug 29, 7:40 pm, Daniel <[EMAIL PROTECTED]> wrote: > On Aug 29, 11:23 am, cnb <[EMAIL PROTECTED]> wrote: > > > If I get zero division error it is obv a poor solution to do try and > > except since it can be solved with an if-clause. > > > However if a p

return reduce(lambda x, y: x.grade+y.grade, self.reviews)

2008-08-29 Thread cnb
class Customer(object): def __init__(self, idnumber, review): self.idnumber = idnumber self.reviews = [review] def addReview(self, review): self.reviews.append(review) def averageGrade(self): tot = 0 for review in self.reviews: tot +

When to use try and except?

2008-08-29 Thread cnb
If I get zero division error it is obv a poor solution to do try and except since it can be solved with an if-clause. However if a program runs out of memory I should just let it crash right? Because if not then I'd have to write exceptions everywhere to prevent that right? So when would I actual

How come Python software, tools and libraries is so good? A hug to Gvr and the Python community!

2008-08-27 Thread cnb
I have been testing different tools for cvs, math etc and I am constantly amazed how many great tools and libraries there are for Python. SAGE, Mercurial as 2 outstanding tools and there a re excellent libraries fro anything you want, natural language processing, any kind of parsing, math, simulati

Re: Are dictionaries the same as hashtables?

2008-08-26 Thread cnb
On Aug 26, 9:43 am, Martin Marcher <[EMAIL PROTECTED]> wrote: > On 2008-08-26 00:32:20, cnb wrote: > > > Are dictionaries the same as hashtables? > > Yes, but there is nothing in there that does sane collision handling > like making a list instead of simply overwriting.

Are dictionaries the same as hashtables?

2008-08-26 Thread cnb
Are dictionaries the same as hashtables? -- http://mail.python.org/mailman/listinfo/python-list

Re: Return a string result with out breaking loop

2008-08-25 Thread cnb
ok post exactly what you do when this hapens: ault: :cannot marshal objects"> it complains you are trying to marshal a generator object rather than the file you are yielding. also, something I am not sure about: >>> def f(x): try: open("C:/ruby/progs/blandat/infixtoprefix.rb") or open

Re: Return a string result with out breaking loop

2008-08-25 Thread cnb
On Aug 26, 2:50 am, cnb <[EMAIL PROTECTED]> wrote: > def somefunc(): >        for action, files in results: >                full_filename = os.path.join(path_to_watch, files) >                theact = ACTIONS.get(action, "Unknown") >                yield  str(ful

Re: Return a string result with out breaking loop

2008-08-25 Thread cnb
def somefunc(): for action, files in results: full_filename = os.path.join(path_to_watch, files) theact = ACTIONS.get(action, "Unknown") yield str(full_filename) + " " + str(theact) ? Here is an example if that doesn't work, using yield, to

Mutability, copying lists but not sharing?

2008-08-25 Thread cnb
Is it not possible to have mutability without this? I know I can use sorted and list(reversed) instead of .sort and .reverse but if I want to copy a list and then change that list without changing the first one? And there isn't a .copy function so I have to "new = [] for element in list: new.append

emacs-mode for python, run the interpreter doesnt work

2008-08-24 Thread cnb
how do I run the interpreter In emacs? pythonmode works but I cant start the interpreter. do I need to add it to my load-path? what should I add exactly then? python.exe or pythonw.exe? -- http://mail.python.org/mailman/listinfo/python-list