Re: [Tutor] How to get script to detect whether a file exists?

2010-08-01 Thread Daniel Sarmiento
hat your code does, I think it will be something like: try: F_unused = open(path1, 'rb') F_used = open(path2, 'rb') except IOError: print("no") . else: unused_ints = pickle.load(F_unused) .. HTH Daniel Sarmiento S. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Tutor Digest, Vol 78, Issue 8

2010-08-01 Thread Daniel Sarmiento
gs ( http://en.wikipedia.org/wiki/Time-of-check-to-time-of-use ) Without knowing what your code does, I think it will be something like: try: F_unused = open(path1, 'rb') F_used = open(path2, 'rb') except IOError: print("no") . else: unused_ints = p

Re: [Tutor] Bowing out

2010-03-03 Thread Daniel Sarmiento
> > Date: Wed, 3 Mar 2010 08:17:45 -0500 > From: Kent Johnson > To: Tutor@python.org > Subject: [Tutor] Bowing out > Message-ID: ><1c2a2c591003030517r66cf067fgf2f5a052a4a08...@mail.gmail.com> > Content-Type: text/plain; charset=ISO-8859-1 > > Hi all, > > After six years of tutor posts my i

Re: [Tutor] python function to know the path of the program in execution *

2010-02-05 Thread Daniel Sarmiento
Date: Fri, 5 Feb 2010 17:43:37 +0530 From: Spoorthi To: "Rohit Roger$" Cc: tutor Subject: Re: [Tutor] python function to know the path of the program in execution * Message-ID: <6c9f52051002050413o57bd76bax7ac5986b17304...@mail.gmail.com> Content-Type: text/plain; charse

Re: [Tutor] Challenge

2009-09-22 Thread Daniel Sarmiento
[20]: outcomes = {'head':0, 'tail':0} In [21]: for i in range(100): : outcomes[choice(pos)] += 1 : : In [22]: print outcomes ---> print(outcomes) {'head': 46, 'tail': 54} HTH Daniel Sarmiento. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

[Tutor] PyQt Signal

2009-06-11 Thread Daniel Sarmiento
Hello I am starting to use PyQt, and I'm trying to send a signal across threads, but I get the following error: Traceback (most recent call last): File "/home/daniel/NetBeansProjects/aeropuerto/main.py", line 34, in form = AeropuertoDlg() File "/home/daniel/NetBeansProjects/aeropuerto/ma

Re: [Tutor] casting string to integer in a list of lists

2009-01-09 Thread Daniel Sarmiento
I am not an expert and don't know if this is considered 'elegant', but this is what I would try conv = [[j[0], int(j[1]), int(j[2])] + j[3:] for j in LoL] > Hi Your, > > I work with genomic datasets as well and have recently only started > working with python (so my advice is a bit naive) > >

Re: [Tutor] Name Generator

2008-09-19 Thread Daniel Sarmiento
Try taking a look at nltk: http://nltk.org > Date: Fri, 19 Sep 2008 12:05:39 +0200 > From: Daniele <[EMAIL PROTECTED]> > Subject: [Tutor] Name Generator > To: tutor@python.org > Message-ID: ><[EMAIL PROTECTED]> > Content-Type: text/plain; charset="utf-8" > > Hi list, > I'd like to implem

Re: [Tutor] Graphically Display Binary Trees

2008-08-24 Thread Daniel Sarmiento
Thank you for your suggestions, I created a working prototype now, http://dpaste.com/73630/ Daniel > On Sat, Aug 23, 2008 at 4:08 PM, Kent Johnson <[EMAIL PROTECTED]> wrote: > Graphviz's dot is an amazing way to produce graphics from graph data. > pydot can produce the dot files needed to creat

[Tutor] Graphically Display Binary Trees

2008-08-23 Thread Daniel Sarmiento
Hi I am working on a red-black binary tree class. I would like to print it in a nice, graphical way. I have never done any GUI programming, or generated any graphics in python, before. What libraries would you use, what's the most straight forward way to achieve what I want? Thank you. _

Re: [Tutor] Memory error - how to manage large data sets?

2008-07-28 Thread Daniel Sarmiento
>(the solution, of course, is to avoid storing all those numbers in the >first place) I tried this: fib = {0:0,1:1} sum = 0 for j in xrange (2,100): i = fib[j-1] + fib[j-2] if i % 2 == 0: sum += i fib = {j-1:fib[j-1], j:i} print sum I guess it should come up with the ri

Re: [Tutor] Memory error - how to manage large data sets?

2008-07-28 Thread Daniel Sarmiento
Hi I tried to run your code and checked (with top) the memory ussage and it uses more than 2 Gb of memory. I tried to modify the code a little bit to use less memory and came up with this: fib = {0:0,1:1} even = [] def fibonacci(x,y): return x+y for j in xrange (2,100): i = fib[j-1]

Re: [Tutor] Advice for my function, isPrime(n), please

2008-07-21 Thread Daniel Sarmiento
What about the following function? if x == 0: return False return True I am a beginner, but I think it is more clear (at least to me) what the function does. And it is only one line longer than value = (x != 0) return value ___ Tutor maillist -

Re: [Tutor] getting error in uploading a file

2008-07-15 Thread Daniel Sarmiento
That's a web server error, not a python error. You can find more information by checking the server's log. >From the error message it look like you are using apache and red hat. I use debian and my error logs are stored is in /var/log/apache2 by default. Check you apache configuration file and f