Re: [Tutor] how can I use Set.interaction function on a dictionary
1. I have a dictionary with 4 keys and some repeated values for each key. dida {'NM_001033044': [32842023, 32842023, 32842023, 32842023, 32842023, 32842023, 32842023, 32842023, 32842023, 32842023, 32842023, 32842023, 32843894, 32843894, 32843894, 32843894, 32843894, 32843894, 32843894, 32843894, 32843894, 32843894, 32844846, 32844846, 32844846, 32844846, 32844846, 32844846, 32844846, 32844846, 32844846, 32844846, 32845745], [cut] 1. How can I get A^B^C^D(^ = intersection) where A, B, C and D are keys from dida or didi. What would be a few concrete examples of this operation? What would be a concrete instance of this problem, and the expected result? That is, let's call this operation intersection() for the moment, and just pretend that it exists. Can you construct a simple, sample call to this imaginary intersection() function? What expected value do we get back? Wishful thinking through examples is a good technique when one is not quite sure how to do something yet. (Plus it will be less ambiguous than English --- I have to admit that I do not understand the problem statement yet.) Also, simplify the problem a little more: doing an operation on four elements at once seems a bit arbitrary. Rather than four, let's bring the problem's complexity down a bit. If you had a function to do it on two items: A ^ B where A and B are either from dida or didi, would this be easier for you to consider? Would you be able to do this smaller problem? I'd recommend tackling this first before going all out on the bigger problem. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] looking to hire a tutor
Books: Dont forget to carry these whereever your go: 1. Alan Gauld's : Learn to Program using Python 2. Mark Lutz'z: Learning Python While I appreciate the compliment I feel I should point out that my book is really a beginners tutorial and, even when I wrote it, I expected it to have limited value as a reference book (except perhaps for some of the CS concepts). Lutz' book is similar but is at least more in-depth although even it can be quickly outgrown. The best current ready reference is Python in a Nutshell. And Lutz' much bigger volume - Programming Python - is also worth keeping on your desk if not in your bag... Alan G Author of the learn to program web tutor http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] hash.update( argv[0] )
Hi! I've been struggling to find a way up seed hash.update() with the sha1 (or similar) of the file that is the program running. this is not a security task but rather a means to generate reasonably unique filenames based on various parameters including changes to the program: name = hash.hexdigest() so new files are generated when the program or parameters are changed; but cached files are used when identical results are expected. help! I cannot figure out how to pass the program body as a seed to hash.update(). // George -- George Georgalis, systems architect, administrator IXOYE http://galis.org/ cell:646-331-2027 mailto:[EMAIL PROTECTED] ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Tutor FAQ?
When Ed brought up the tutor/tutorial FAQ idea and yes, I'll change tutorial FAQ to tutor FAQ, to make things a bit less confusing. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Locking a specific variable
On Sun, 23 Apr 2006, Tino Dai wrote: I am wondering if you could lock a specific variable with thread locking. Let me illustrate: def ftpQueuePut(filename=):: if len(filename) 0: try: fileQueue.put(filename,True,1)#Variable that I would like to lock except Queue.full: print Queue is full else: pass def ftpQueueGet(): try: filename=fileQueue.get(True,1) #Variable that I would like to lock return filename except Queue.Empty: pass Hi Tino, I'm not quite sure I get it, but ok. *grin* I'll assume that fileQueue is an instance of the Queue class: http://www.python.org/doc/lib/module-Queue.html If so: why not allow fileQueue to grow unbounded? Presently, the only way that I can see to do this using Python is to combine the two functions into one and lock and unlock the entire thing . That doesn't seem efficient and/or elegant to me. Any pointers about this? Do you know about the thread-locking primitives? There are a few kinds provided by Python's threading module: http://www.python.org/doc/lib/module-threading.html Are you already familiar with the concept of a RLock or a Lock? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] hash.update( argv[0] )
On Sun, 23 Apr 2006, George Georgalis wrote: Hi! I've been struggling to find a way up seed hash.update() with the sha1 (or similar) of the file that is the program running. this is not a security task but rather a means to generate reasonably unique filenames based on various parameters including changes to the program: name = hash.hexdigest() so new files are generated when the program or parameters are changed; but cached files are used when identical results are expected. help! I cannot figure out how to pass the program body as a seed to hash.update(). Hi George, I'm slightly confused. Isn't this a matter of doing: ### def prepare_md5(filename): m = md5.new() m.update(open(filename).read()) ## not so smart: do this ## progressively in real life! return m ### So I think I'm missing something. Are you asking instead: how do I get the filename of the currently running program? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor