Re: [Tutor] string to binary and back... Python 3

2012-07-20 Thread Alan Gauld
On 20/07/12 06:48, wolfrage8...@gmail.com wrote: Thanks I will give this a try. Can you explian a little further for me what exactly this: newhexdata = bytes("%x" % numdata, "ascii") line is doing? I don't quite understand the use of the "%x" % on numdata. It is standard string formatting in

Re: [Tutor] Creating a dictionary on user filter

2012-07-20 Thread Peter Otten
Mike Nickey wrote: > What I have is this: > firstList = ['a', 'b', 'c'] > secondList = [1,2,3] > thirdList = [1.20, 1.23, 2.54] > > What I am looking for is something like this for output: > {'a': [1, 1.20], 'b': [2, 1.23], 'c': [3, 2.54]} To get this combine second and third into the list of va

Re: [Tutor] Invalid Token Problem

2012-07-20 Thread Alan Gauld
On 20/07/12 02:01, Ross Wilson wrote: More specifically, eval() is dangerous if you try to evaluate a string supplied by someone else. You really can't predict what will happen. It really doesn't matter who provides the string, Python and eval() don't care. They will behave just as dangerous

Re: [Tutor] Join email list

2012-07-20 Thread Alan Gauld
On 19/07/12 22:09, Lily Tran wrote: ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor The server does not respond to subject-line commands, you have to visit the web

Re: [Tutor] suggestion for an editor

2012-07-20 Thread Steven D'Aprano
Bala subramanian wrote: Friends, At present i write programs using vi editor. I am interested to change to something else. My specific need is that i want to select a portion/small segment of my program (for eg. a nested loop) and then monitor processing time it takes for that portion while i run

Re: [Tutor] Flatten a list in tuples and remove doubles

2012-07-20 Thread Steven D'Aprano
PyProg PyProg wrote: Hi all, I would get a new list as: [(0, '3eA', 'Dupont', 'Juliette', '11.0/10.0', '4.0/5.0', '17.5/30.0', '3.0/5.0', '4.5/10.0', '35.5/60.0'), (1, '3eA', 'Pop', 'Iggy', '12.0/10.0', '3.5/5.0', '11.5/30.0', '4.0/5.0', '5.5/10.0', '7.5/10.0', '40.5/60.0')] ... from this one:

Re: [Tutor] check against multiple variables

2012-07-20 Thread Walter Prins
On 19 July 2012 23:20, Steven D'Aprano wrote: > Selby Rowley-Cannon wrote: >> >> I am using a hash table in a small randomization program. I know that some >> hash functions can be prone to collisions, so I need a way to detect >> collisions. > This entire question seems like a remarkable case of

Re: [Tutor] Problem When Iterating Over Large Test Files

2012-07-20 Thread Steven D'Aprano
Ryan Waples wrote: I count only 19 lines. yep, you are right. My bad, I think I missing copy/pasting line 20. The first group has only three lines. See below. Not so, the first group is actually the first four lines listed below. Lines 1-4 serve as one group. For what it is worth, line f

Re: [Tutor] Problem When Iterating Over Large Test Files

2012-07-20 Thread Steven D'Aprano
Alan Gauld wrote: On 19/07/12 07:00, Steven D'Aprano wrote: for reads, lines in four_lines( INFILE ): ID_Line_1, Seq_Line, ID_Line_2, Quality_Line = lines Shouldn't that be for reads, lines in enumerate( four_lines(INFILE) ): ID_Line_1,

Re: [Tutor] check against multiple variables

2012-07-20 Thread Steven D'Aprano
Walter Prins wrote: On 19 July 2012 23:20, Steven D'Aprano wrote: Selby Rowley-Cannon wrote: I am using a hash table in a small randomization program. I know that some hash functions can be prone to collisions, so I need a way to detect collisions. This entire question seems like a remarkab

[Tutor] Where to put small auxiliary function

2012-07-20 Thread Jose Amoreira
Hi. This is a question about style. I have a class definition that calls a small auxiliary function. Because this function isn't used anywhere else, I'd like to include it inside the class definition. However, if I do that, I'll have to use "self" in the call argument, which is (I think) rather awk

Re: [Tutor] Where to put small auxiliary function

2012-07-20 Thread Mark Lawrence
On 20/07/2012 11:07, Jose Amoreira wrote: Hi. This is a question about style. I have a class definition that calls a small auxiliary function. Because this function isn't used anywhere else, I'd like to include it inside the class definition. However, if I do that, I'll have to use "self" in the

Re: [Tutor] Invalid Token Problem

2012-07-20 Thread Ross Wilson
On 20/07/12 17:25, Alan Gauld wrote: On 20/07/12 02:01, Ross Wilson wrote: More specifically, eval() is dangerous if you try to evaluate a string supplied by someone else. You really can't predict what will happen. It really doesn't matter who provides the string, Python and eval() don't car

Re: [Tutor] Where to put small auxiliary function

2012-07-20 Thread Joel Goldstick
On Fri, Jul 20, 2012 at 6:32 AM, Mark Lawrence wrote: > On 20/07/2012 11:07, Jose Amoreira wrote: >> >> Hi. >> This is a question about style. I have a class definition that calls a >> small auxiliary function. Because this function isn't used anywhere >> else, I'd like to include it inside the cl

Re: [Tutor] Where to put small auxiliary function

2012-07-20 Thread Jose Amoreira
Hi Mark, Thanks. > [SNIP] >> Let me give an example: >> >> def is_odd(k): >> if k % 2 == 0: >> return False >> else: >> return True > > > I'll point out before anyone else does that you can write this function as a > one line return. I'll leave you to work out how. Pe

Re: [Tutor] Where to put small auxiliary function

2012-07-20 Thread Mark Lawrence
On 20/07/2012 12:20, Jose Amoreira wrote: Hi Mark, Thanks. [SNIP] Let me give an example: def is_odd(k): if k % 2 == 0: return False else: return True I'll point out before anyone else does that you can write this function as a one line return. I'll leave y

Re: [Tutor] Where to put small auxiliary function

2012-07-20 Thread Steven D'Aprano
Jose Amoreira wrote: Hi. This is a question about style. I have a class definition that calls a small auxiliary function. Because this function isn't used anywhere else, I'd like to include it inside the class definition. *shrug* Then do so. class Whatever: @staticmethod def is_odd(

[Tutor] Where do I start developing from?

2012-07-20 Thread Santosh Kumar
Hello There, First time I came in contact with Python programming languages was nearly 1 year (I am learning this languages from my home). Prior to this I was good at PHP, HTML and CSS (this doesn't mean that I want to say that I wanted to become a web developer). I have read many books and tutori

Re: [Tutor] Where do I start developing from?

2012-07-20 Thread leam hall
Santosh, It is fun to try new activities. Maybe implement some of the PHP things you did in Python. I find myself making small games or tools for games when I want to try something out. You might also want to work with Eclipse and some of the IDE tools, as well as learn Unittesting and stuff like

Re: [Tutor] suggestion for an editor

2012-07-20 Thread Wayne Werner
On Fri, 20 Jul 2012, Steven D'Aprano wrote: Bala subramanian wrote: Friends, At present i write programs using vi editor. I am interested to change to something else. My specific need is that i want to select a portion/small segment of my program (for eg. a nested loop) and then monitor proce

Re: [Tutor] string to binary and back... Python 3

2012-07-20 Thread eryksun
On Fri, Jul 20, 2012 at 3:16 AM, Alan Gauld wrote: > On 20/07/12 06:48, wolfrage8...@gmail.com wrote: > > Using the format method it would look like: > > newhexdata = bytes("{0:x}".format(numdata), "ascii") binascii.unhexlify needs an even number of hexadecimal digits (two per byte). So you need

Re: [Tutor] suggestion for an editor

2012-07-20 Thread Walter Prins
On 20 July 2012 14:07, Wayne Werner wrote: >>> At present i write programs using vi editor. I am interested to change to >>> something else. My specific need is that i want to select a portion/small >>> segment of my program (for eg. a nested loop) and then monitor processing >>> time it takes for

[Tutor] A simple AJAX script needed

2012-07-20 Thread Surya K
Here is what i need: I want to create a HTML button.. when clicked (should only work for once) should invoke a python script. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription optio

Re: [Tutor] Invalid Token Problem

2012-07-20 Thread Alan Gauld
On 20/07/12 11:31, Ross Wilson wrote: But what is the difference if I write incorrect code and *execute* it or write an the same code in a string and *eval()* it. The result is the same whether eval() is used or not. Same result, same risk. No, a much bigger risk because you can manipulate

Re: [Tutor] Where do I start developing from?

2012-07-20 Thread Alan Gauld
On 20/07/12 12:36, Santosh Kumar wrote: Now I feel bored to learn more and want to implement my knowledge somewhere. I have no idea what to do, I probably won't program a software from starch. I want to test how much I am up to. Have you tried the Python Challenge yet? Google it. It will tak

Re: [Tutor] A simple AJAX script needed

2012-07-20 Thread Alan Gauld
On 20/07/12 16:41, Surya K wrote: Here is what i need: I want to create a HTML button.. when clicked (should only work for once) should invoke a python script. So what bit do you need help on? Can you create a web page? Can you create a form? Can you script a button? Can you write a Python we

Re: [Tutor] suggestion for an editor

2012-07-20 Thread Alan Gauld
On 20/07/12 09:43, Steven D'Aprano wrote: I don't think that what you want exists. As far as I know, even full-featured IDEs (Integrated Development Environments) don't include profiling of selected sections of code. There are a few commercial IDEs that can do this but I've only seen it for c

Re: [Tutor] Where do I start developing from?

2012-07-20 Thread Mark Lawrence
On 20/07/2012 12:36, Santosh Kumar wrote: Hello There, First time I came in contact with Python programming languages was nearly 1 year (I am learning this languages from my home). Prior to this I was good at PHP, HTML and CSS (this doesn't mean that I want to say that I wanted to become a web d

[Tutor] Rapidly Importing CSVs with Python into MySQL

2012-07-20 Thread Fred G
Hi-- This question has to do with MySQL but is fundamentally a python question, so apologies if it seems tangential initially... I've written a long python file that creates all the tables in database UN. Here is the first few lines: import MySQLdb as mysql statement = """CREATE DATABASE UN""" d

Re: [Tutor] Rapidly Importing CSVs with Python into MySQL

2012-07-20 Thread Walter Prins
Hi Fred, On 20 July 2012 21:34, Fred G wrote: > Here is the first few lines: Rather than paraphrase and omit details that might be relevant to the problem you're having, please try to whittle down your code to a bare test program that is runnable by us as-is that demonstrates your problem. Th