Re: [Tutor] Fwd: Re: Adding consecutive numbers

2015-05-06 Thread Whom Isac
Thanks, Steven. I think you are right about those mistake. But you could tell that the code was incomplete so the interact() was not defined. I have updated some parts (basically writing from the scratch). I am busy with a new project and learning how to create GUI app in python, although there

Re: [Tutor] Fwd: Re: Adding consecutive numbers

2015-05-06 Thread Alan Gauld
On 06/05/15 15:01, Dave Angel wrote: def adding_all(x): total = 0 for num in x: total +=num return total Good function. Except for the fact that the built-in sum() function does the same thing with a lot less typing... -- Alan G Author of the Learn to Program web

Re: [Tutor] Fwd: Re: Adding consecutive numbers

2015-05-06 Thread Mark Lawrence
Forwarded Message Subject: Re: [Tutor] Adding consecutive numbers Date: Wed, 6 May 2015 21:13:15 +1000 From: Whom Isac wombing...@gmail.com To: Alan Gauld alan.ga...@btinternet.com I am actually using the latest version of python (3.5) in windows 7 operating

Re: [Tutor] Fwd: circular movement in pygame

2015-05-03 Thread diliup gabadamudalige
for what ever it's worth I'd like to share the code below with you. I got the code to do what I wanted. Object falls onto a rotating platform and stays there without falling off. video is here - https://www.youtube.com/watch?v=I6c5cKhLuo4 import sys, os, pygame from pygame.locals import * from

Re: [Tutor] Fwd: circular movement in pygame

2015-04-30 Thread diliup gabadamudalige
Thanks all for the very informative responses especially to Alan for being descriptive. I am now going to make my movement linear and move away from my current circular one. I hope a little bit of fun and Thank you emails fall into the order of the day.. :) On Thu, Apr 30, 2015 at 9:13 AM,

Re: [Tutor] Fwd: Function works one time then subsequently fails

2015-04-30 Thread Jim Mooney Py3.4.3winXP
Sure, but let me include the full working program after fixup On 29 April 2015 at 19:09, Cameron Simpson c...@zip.com.au wrote: These could all do with docstrings. add() is pretty obvious, but the distinction between minus() and subtract() could do with elaboration. etc, etc. Thanks.

Re: [Tutor] Fwd: circular movement in pygame

2015-04-29 Thread diliup gabadamudalige
Thanks all for the responses. Charles Cossé - yes I can write a simple pygame program that makes a sprite move in a circle but it may not be the style and order that many may approve or accept. I consider myself a student. :) No one has pointed out why the object moves in a circle properly in the

Re: [Tutor] Fwd: circular movement in pygame

2015-04-29 Thread Alan Gauld
On 29/04/15 08:15, diliup gabadamudalige wrote: 1. x = some code That is what I used and it worked. I was trying to find how we can do the same thing by updating the current position by doing 2. x += some code Above 1 works. 2 does not. Why is that? Because they do completely different

Re: [Tutor] Fwd: circular movement in pygame

2015-04-29 Thread Alan Gauld
On 29/04/15 09:03, diliup gabadamudalige wrote: Thank you Alan. Understood. I already knew that. My question is How to to do it the second way. some code = what? The point is you cannot do it. The second approach always uses the current value of x. The first approach may or may not use the

Re: [Tutor] Fwd: circular movement in pygame

2015-04-29 Thread Alan Gauld
On 29/04/15 10:15, diliup gabadamudalige wrote: x=42 good x += 42 -x ? That does not go by a mile of what I asked. You've asked three different things: 1) Why the += form gives different results from the assignment form, 2) Why some code you apparently wriotre worked outside a class but

Re: [Tutor] Fwd: circular movement in pygame

2015-04-29 Thread diliup gabadamudalige
I do not understand how Alan does not get the code that is in this thread. Anyway I can conclude by saying that a friend of mine who is not in this thread solved the problem and I would like to share it with you. He has changed only a very smal portion in the original code that i posted in this

Re: [Tutor] Fwd: circular movement in pygame

2015-04-29 Thread Danny Yoo
On Wed, Apr 29, 2015 at 11:37 AM, diliup gabadamudalige dili...@gmail.com wrote: I do not understand how Alan does not get the code that is in this thread. Hi Dilliup, Please try to avoid using the phrase, I don't understand how X does not get Y You might not realize it, but it's

Re: [Tutor] Fwd: circular movement in pygame

2015-04-29 Thread diliup gabadamudalige
Thanks Alan. It is partly due to curiosity but I also wanted to have a common update method. And as I almost always use the x+= some code, y+=some code for animation stuff I wanted to know how it could be done using this method rather than finding each position separately and assigning with x=

Re: [Tutor] Fwd: circular movement in pygame

2015-04-29 Thread Alan Gauld
On 29/04/15 21:19, diliup gabadamudalige wrote: It is partly due to curiosity but I also wanted to have a common update method. And as I almost always use the x+= some code, y+=some code for animation stuff I wanted to know how it could be done using this method rather than finding each

Re: [Tutor] Fwd: Function works one time then subsequently fails

2015-04-29 Thread Cameron Simpson
On 29Apr2015 08:34, Jim Mooney Py3.4.3winXP cybervigila...@gmail.com wrote: On 28 April 2015 at 22:40, Cameron Simpson c...@zip.com.au wrote: We can pick over your code as well if you like. Should we? Sure, but let me include the full working program after fixup. Although I still have to

Re: [Tutor] Fwd: circular movement in pygame

2015-04-29 Thread diliup gabadamudalige
question to Lucas. Not sure if this is what you're looking for, but I would also use cos for the x coordinate as suggested. If: self.rect.x = self.radius * math.cos(self.angle) + self.center_x self.rect.y = self.radius * math.sin(self.angle) + self.center_y Take a derivative (assume: angle +=

Re: [Tutor] Fwd: circular movement in pygame

2015-04-29 Thread diliup gabadamudalige
Thank you Alan. Understood. I already knew that. My question is How to to do it the second way. some code = what? My question is, how does one arrive at the code to put in place of some code? The code I used does not work correctly. The code is in this chain of email. I hope I am clear in what I

Re: [Tutor] Fwd: circular movement in pygame

2015-04-29 Thread diliup gabadamudalige
x=42 good x += 42 -x ? That does not go by a mile of what I asked. Alan, are you telling me that there is no way that one can arrive at X2 which is the NEXT place that X1 will be after some increment? old x position = X1 new x position= X1 + some increment value which can be written as :new X =

Re: [Tutor] Fwd: circular movement in pygame

2015-04-29 Thread Dave Angel
On 04/29/2015 02:37 PM, diliup gabadamudalige wrote: I do not understand how Alan does not get the code that is in this thread. There are at least 3 ways of posting to this thread: A) email B) newsgroup C) googlegroups and at least 5 ways of looking at this thread A) email B)

Re: [Tutor] Fwd: circular movement in pygame

2015-04-28 Thread Dave Angel
On 04/28/2015 02:37 PM, diliup gabadamudalige wrote: I thank all those who responded to my question Here is the code that I had written. When updating is applied to a surface object the rotation works but when it is applied through a class to an object it goes wrong in about 3 rotations. As

Re: [Tutor] Fwd: circular movement in pygame

2015-04-28 Thread diliup gabadamudalige
I thank all those who responded to my question Here is the code that I had written. When updating is applied to a surface object the rotation works but when it is applied through a class to an object it goes wrong in about 3 rotations. As far as I can see the code is the same. What is wrong? If

Re: [Tutor] Fwd: circular movement in pygame

2015-04-28 Thread Alan Gauld
On 28/04/15 16:38, diliup gabadamudalige wrote: -- Forwarded message -- From: diliup gabadamudalige dili...@gmail.com Date: Tue, Apr 28, 2015 at 6:22 PM Subject: circular movement in pygame To: pygame-us...@seul.org It's good that you tried the python-game list for a pygame

Re: [Tutor] Fwd: circular movement in pygame

2015-04-28 Thread Oscar Benjamin
On 28 April 2015 at 16:38, diliup gabadamudalige dili...@gmail.com wrote: Looking at the code on this page lines 47 48 http://programarcadegames.com/python_examples/show_file.php?file=sprite_circle_movement.py is there a way to do self.rect.x +*= some value* self.rect.y += some value

Re: [Tutor] Fwd: circular movement in pygame

2015-04-28 Thread Oscar Benjamin
On 28 April 2015 at 19:37, diliup gabadamudalige dili...@gmail.com wrote: I thank all those who responded to my question Here is the code that I had written. When updating is applied to a surface object the rotation works but when it is applied through a class to an object it goes wrong in

Re: [Tutor] Fwd: Re: Fwd: Need help with find error

2015-02-19 Thread Danny Yoo
2015-02-18 8:25 GMT+02:00 Danny Yoo d...@hashcollision.org: I do not have time to help you right now. Please continue correspondence with the main tutor list. On Wed, Feb 18, 2015 at 11:34 AM, Андрей Пугачев pugachov.and...@gmail.com wrote: ok, thanks, I will Following up: have you been

Re: [Tutor] Fwd: Re: Lost message re serial comms

2015-02-01 Thread Mark Lawrence
On 01/02/2015 14:28, Alan Gauld wrote: This was the problematic serial question. *From:*Doug Basberg [mailto:dbasb...@comcast.net] *Sent:* Friday, January 30, 2015 5:29 PM *To:* 'tu...@python.org' *Subject:* doing rs232 serial with binary data ?? with pyserial?? Hello group; I am new to

Re: [Tutor] Fwd: Re: Lost message re serial comms

2015-02-01 Thread Alan Gauld
On 01/02/15 14:28, Alan Gauld wrote: So, in Python I found pyserial and wish to use it to send binary to controlled devices (in this case to a Modbus protocol solar charge controller (TriStar TS-60). In C++ I would setup ‘structs’ or class attributes to hold the byte oriented commands and

Re: [Tutor] Fwd: Newbie

2015-01-05 Thread Mark Lawrence
On 02/01/2015 18:21, Rohan Ds wrote: -- Forwarded message -- From: Rohan Ds rohan0...@gmail.com Date: 2 Jan 2015 23:46 Subject: Newbie To: tut...@python.org Cc: Hello everybody :) I am Rohan from India. I'm new to Python. I have a basic understanding as to how Python works. I

Re: [Tutor] Fwd: Tutor Digest, Vol 131, Issue 14

2015-01-03 Thread Alan Gauld
Forwarded to list for info. Please use ReplyAll in responses to the tutor list. And please do not quote the entire digest, delete any irrelevant parts. On 03/01/15 16:00, pramod gowda wrote: Hello , I have chaged the code as per your input, except port number. If i change the port number it

Re: [Tutor] Fwd: Tutor Digest, Vol 131, Issue 14

2015-01-03 Thread Alan Gauld
On 03/01/15 18:07, Alan Gauld wrote: Forwarded to list for info. Please use ReplyAll in responses to the tutor list. Apologies, you did. It was stuck in the moderation queue. I've now taken you off moderation. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/

Re: [Tutor] Fwd: Newbie

2015-01-02 Thread Steven D'Aprano
On Fri, Jan 02, 2015 at 11:51:04PM +0530, Rohan Ds wrote: Hello everybody :) I am Rohan from India. I'm new to Python. I have a basic understanding as to how Python works. I want to contribute to PSF. The information available on the site didn't really answer my questions. What sort of

Re: [Tutor] Fwd: Newbie

2015-01-02 Thread Alan Gauld
On 02/01/15 18:21, Rohan Ds wrote: Hello everybody :) Hi, welcome. I am Rohan from India. I'm new to Python. I have a basic understanding as to how Python works. I want to contribute to PSF. The information available on the site didn't really answer my questions. It will help if you tell

Re: [Tutor] Fwd: pickle module error in source code

2015-01-01 Thread Alan Gauld
On 01/01/15 14:06, Vedhi Shreya Marwaha wrote: Hi! My name is Shreya Marwaha. I’m class 12th student in India. I’m using 2.7.5 python version [MSC v.1500 64 bit (AMD64)] on win32 as instructed by CBSE (central board of secondary education). I’ve been having problem in using pickle module. OK,

Re: [Tutor] Fwd: Re: Simple guessing game - need help with the math

2014-11-03 Thread Dave Angel
You're still using html mail, and still top-posting. But my curiosity is still begging me for an answer regarding my original approach. Is there a way to manage the functionality of be round function such that it does not strip any data to the right of the decimal point? That's the

Re: [Tutor] Fwd: Fwd: Re: Output 'Strings' to directory

2014-09-09 Thread Alan Gauld
From: Felisha Lawrence felisha.lawre...@gmail.com Date: Tue, Sep 9, 2014 at 8:53 AM Subject: Re: [Tutor] Fwd: Re: Output 'Strings' to directory To: Danny Yoo d...@hashcollision.org Also, I had this code working import os path = '/Users/felishalawrence/testswps/vol1' for file in os.listdir

Re: [Tutor] Fwd: Fwd: Re: Output 'Strings' to directory

2014-09-09 Thread Felisha Lawrence
Thanks! Thats exactly what my problem was. I fixed it On Tue, Sep 9, 2014 at 12:57 PM, Alan Gauld alan.ga...@btinternet.com wrote: From: Felisha Lawrence felisha.lawre...@gmail.com Date: Tue, Sep 9, 2014 at 8:53 AM Subject: Re: [Tutor] Fwd: Re: Output 'Strings' to directory To: Danny Yoo d

Re: [Tutor] Fwd: Embedding resources

2014-08-20 Thread Danny Yoo
On Wed, Aug 20, 2014 at 6:45 AM, diliup gabadamudalige dili...@gmail.com wrote: Hi Danny! The routine works fine and so does this one. http://www.pygame.org/pcr/zipshow/index.php The only problem with all these are that that the time taken to read these files and to either make a list or

Re: [Tutor] Fwd: Printing multi-line variables horizontally

2014-08-09 Thread Steven D'Aprano
On Sat, Aug 09, 2014 at 12:39:37PM +0200, Chris “Kwpolska” Warrick wrote: It looks ilke this WONDERFUL mailing list which does not do something as basic as a sane Reply-to header made me send a response to the OP only. Here it is again: [...] Although I personally agree with you that setting

Re: [Tutor] Fwd: Re: Tips

2014-06-21 Thread Alan Gauld
On 21/06/14 01:45, Alex Kleider wrote: The only applicability that fits in with anything I've experienced has to do with the necessity of globals to represent command line parameters That's not a necessity and I hardly ever do that... :-) But it is one pattern for handling CL args. Other

Re: [Tutor] Fwd: Re: Tips

2014-06-21 Thread Mark Lawrence
On 21/06/2014 18:23, Alan Gauld wrote: On 21/06/14 01:45, Alex Kleider wrote: The only applicability that fits in with anything I've experienced has to do with the necessity of globals to represent command line parameters That's not a necessity and I hardly ever do that... :-) But it is one

Re: [Tutor] Fwd: Problem reading large files in binary mode

2014-06-12 Thread Peter Otten
Mirage Web Studio wrote: I am new to python programming. while trying it out i find that in my code file io.read is not reading large files particularly over 1 gb. my code is posted below. i am working on python 3.3 on windows with ntfs partition and intel corei3 ram 3gb. the execution

Re: [Tutor] Fwd: glob and file names

2014-06-06 Thread Peter Otten
Gabriele Brambilla wrote: 2014-06-05 22:10 GMT-04:00 Peter Romfeld peter.romfeld...@gmail.com: On Friday, June 06, 2014 10:04 AM, Gabriele Brambilla wrote: fiLUMOname = 'Lsum_' + period + '_' + parts[2] + '_' + parts[3] + '_' + parts[4] + '_*.dat' aaa = glob.glob(fiLUMOname) print(aaa)

Re: [Tutor] Fwd: glob and file names

2014-06-06 Thread Gabriele Brambilla
oh yes! I had a problem inside the file name! (I had a lot of file to open and I changed the one I was looking at!the one I was trying to open has a wrong filename...) Sorry for the misunderstanding. Gabriele 2014-06-06 3:05 GMT-04:00 Peter Otten __pete...@web.de: Gabriele Brambilla wrote:

Re: [Tutor] Fwd: class to function

2014-05-26 Thread rahmad akbar
thanks guys for the replies, Danny, your explanation helped alot, i'll have a go on Alan Gaud's tutorial. super thanks On Mon, May 26, 2014 at 9:04 AM, Danny Yoo d...@hashcollision.org wrote: -- Forwarded message -- From: diliup gabadamudalige dili...@gmail.com Date: Sunday,

Re: [Tutor] Fwd: class to function

2014-05-26 Thread Danny Yoo
On Mon, May 26, 2014 at 12:27 AM, rahmad akbar matbioi...@gmail.com wrote: thanks guys for the replies, Danny, your explanation helped alot, i'll have a go on Alan Gaud's tutorial. super thanks You should probably thank Diliup Gabadamudalige instead; I just forwarded his message. Best of

Re: [Tutor] Fwd: Puzzle - Next Step to our interviewing process - Pramati Technologies!

2014-04-23 Thread Sunil Tech
i have {'extreme_fajita': [*{5: 4.0}*, *{6: 6.0}*], 'fancy_european_water': [*{5: 8.0}*, *{6: 5.0}*]} if the keys of the dictionaries(bold italic) are equal. I want to add bold dict values, italic dict values. result should some thing like this [{5:12.0},{6:11.5}] i tried to do... but

Re: [Tutor] Fwd: Puzzle - Next Step to our interviewing process - Pramati Technologies!

2014-04-23 Thread Danny Yoo
Hi Sunil, Try a simpler but related problem first. Say that you have two lists of numbers, like: ## nums1 = [3, 1, 4] nums2 = [2, 7, 1] ## Can you design a function addLists() that takes two lists of numbers of equal length, and adds them together? For example, addLists(nums1,

Re: [Tutor] Fwd: Puzzle - Next Step to our interviewing process - Pramati Technologies!

2014-04-23 Thread brian arb
nums1 = [3, 1, 4] nums2 = [2, 7, 1] [ sum(i) for i in zip(nums1, nums2)] [5, 8, 5] On Wed, Apr 23, 2014 at 1:12 PM, Danny Yoo d...@hashcollision.org wrote: Hi Sunil, Try a simpler but related problem first. Say that you have two lists of numbers, like: ## nums1 = [3, 1, 4]

Re: [Tutor] Fwd: Puzzle - Next Step to our interviewing process - Pramati Technologies!

2014-04-23 Thread Danny Yoo
Hi Brian, I would suggest not providing homework solutions. Look at the beginning of this thread to see why just giving homework solutions is not helpful for the questioner. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription

Re: [Tutor] Fwd: Puzzle - Next Step to our interviewing process - Pramati Technologies!

2014-04-23 Thread brian arb
My Bad On Wed, Apr 23, 2014 at 1:53 PM, Danny Yoo d...@hashcollision.org wrote: Hi Brian, I would suggest not providing homework solutions. Look at the beginning of this thread to see why just giving homework solutions is not helpful for the questioner.

Re: [Tutor] Fwd: Puzzle - Next Step to our interviewing process - Pramati Technologies!

2014-04-23 Thread Danny Yoo
Hi Brian, No problem. Just be more careful next time. In particular, look at the context. The homework question I'm posing to Sunil is fairly basic, intentionally so, but is designed so that if he solves it with basic, standard tools (fresh list construction, list iteration, list appending),

Re: [Tutor] Fwd: Puzzle - Next Step to our interviewing process - Pramati Technologies!

2014-04-15 Thread Danny Yoo
So, what is your question? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Fwd: Puzzle - Next Step to our interviewing process - Pramati Technologies!

2014-04-15 Thread Sunil Tech
Hi Danny, Thank you for replying.. I need the python program which takes the attached csv on running the program which will give me the results as Data File data.csv 1, 4.00, burger 1, 8.00, tofu_log 2, 5.00, burger 2, 6.50, tofu_log Program Input program

Re: [Tutor] Fwd: Puzzle - Next Step to our interviewing process - Pramati Technologies!

2014-04-15 Thread Walter Prins
Hi, On 15 April 2014 15:49, Sunil Tech sunil.tech...@gmail.com wrote: Hi Danny, Thank you for replying.. I need the python program which takes the attached csv on running the program which will give me the results as snip That is still not a question. It's a requirements statement. I

Re: [Tutor] Fwd: Puzzle - Next Step to our interviewing process - Pramati Technologies!

2014-04-15 Thread Ben Finney
Sunil Tech sunil.tech...@gmail.com writes: I need the python program This is a resource for tutoring, not for others to write your program. Please approach this as an opportunity to do the work yourself *while* learning. It's still you that needs to write the program. -- \ “If I held

Re: [Tutor] Fwd: Python bingo game.

2014-04-02 Thread zhijun long
matrix = [ ... [1, 2, 5, 7, 9], ... [25, 67, 78, 23, 34], ... [33, 22, 66, 88, 98], ... [32, 31, 41, 56, 78], ... [21, 34, 58, 99, 76], ... ] for item in [[row[i] for row in matrix] for i in range(5)]: ... print item ... [1, 25, 33, 32, 21] [2,

Re: [Tutor] Fwd: Python bingo game.

2014-03-31 Thread Danny Yoo
Can some one help me with displaying a matrix vertically. For example my output matrix is:- [1 2 5 7 9] [25 67 78 23 34] [33 22 66 88 98] [32 31 41 56 78] [21 34 58 99 76] And i want my matrix to look like this:- [1 25 33 32 21] [2 67 22 31 34] [5 78 66 41 58] [7 23 88 56 99] [9 34

Re: [Tutor] Fwd: Python bingo game.

2014-03-31 Thread Danny Yoo
What difficulty are you having? I need to be straightforward so that you understand, without ambiguity: we do not do your homework. We will not violate the honor code of your institution. To do so is anathema to why folks here volunteer to help beginners. I do want to apologize if the

Re: [Tutor] Fwd: arrangement of datafile

2014-01-09 Thread Amrita Kumari
Hi, Sorry for delay in reply(as internet was very slow from past two days), I tried this code which you suggested (by saving it in a file): import csv with open('19162.csv') as f: reader = csv.reader(f) for row in reader: print(row) row[0] = int(row[0]) key,value =

Re: [Tutor] Fwd: arrangement of datafile

2014-01-09 Thread Evans Anyokwu
First, the error message means 'item' is missing. You will need to assign your row as the item. And if you want nil where there is no value, then use if statement to check there is something otherwise make that empty value 'nil'. Sorry, gotta run my train just arrived.

Re: [Tutor] Fwd: arrangement of datafile

2014-01-09 Thread Dave Angel
On Thu, 9 Jan 2014 14:51:21 +0800, Amrita Kumari amrita@gmail.com wrote: days), I tried this code which you suggested (by saving it in a file): import csv with open('19162.csv') as f: reader = csv.reader(f) for row in reader: print(row) row[0] = int(row[0])

Re: [Tutor] Fwd: arrangement of datafile

2014-01-07 Thread Steven D'Aprano
On Mon, Jan 06, 2014 at 04:57:38PM +0800, Amrita Kumari wrote: Hi Steven, I tried this code: import csv with open('file.csv') as f: reader = csv.reader(f) for row in reader: print(row) row[0] = int(row[0]) up to this extent it is ok; it is ok it is giving

Re: [Tutor] Fwd: arrangement of datafile

2014-01-06 Thread Keith Winston
Hi Amrita: I tried to figure out, for kicks, how to do what I THINK is what you're trying to do... I've never even opened a .txt file in Python before, so you can take all this with a big grain of salt... Anyway, if you take your example of your original database: 1 GLY HA2=3.7850 HA3=3.9130 2

Re: [Tutor] Fwd: arrangement of datafile

2014-01-06 Thread Keith Winston
oops, I see Steven pointed out a much cleaner approach. Oh well. Shock surprise ;) Keith On Mon, Jan 6, 2014 at 3:27 AM, Keith Winston keithw...@gmail.com wrote: Hi Amrita: I tried to figure out, for kicks, how to do what I THINK is what you're trying to do... I've never even opened a .txt

Re: [Tutor] Fwd: arrangement of datafile

2014-01-06 Thread Amrita Kumari
Hi Steven, I tried this code: import csv with open('file.csv') as f: reader = csv.reader(f) for row in reader: print(row) row[0] = int(row[0]) up to this extent it is ok; it is ok it is giving the output as: ['1' , ' GLY' , 'HA2=3.7850' , 'HA3=3.9130' , ' ' , ' '

Re: [Tutor] Fwd: arrangement of datafile

2014-01-06 Thread Keith Winston
Amrita, it doesn't seem like the code you are providing is the code you are running. I wonder if you are running it all at the Python command line or something, and have to type it in every time? You should put it in a file, and save run that file, and then cut and paste it directly into your

Re: [Tutor] Fwd: arrangement of datafile

2014-01-06 Thread Alan Gauld
On 06/01/14 08:57, Amrita Kumari wrote: up to this extent it is ok; it is ok it is giving the output as: ['1' , ' GLY' , 'HA2=3.7850' , 'HA3=3.9130' , ' ' , ' ' , ' ' , ' '] [ '2' , 'SER' , 'H=8.8500' , 'HA=4.3370' , 'N=115.7570' , ' ' , ' ' , ' '] --

Re: [Tutor] Fwd: arrangement of datafile

2014-01-05 Thread Keith Winston
Hi Amrita, I'm just a beginner but I notice that, after the first two entries on each line (i.e. 10,ALA), the rest might fit nicely into a dict, like this {H: 8.388, HB1: 1.389, ...}. That would give you a lot of flexibility in getting at the values later. It would be easy enough to replace the =

Re: [Tutor] Fwd: arrangement of datafile

2014-01-05 Thread Keith Winston
I should have included an example. If you can, and if it doesn't make your file too long, and if I'm right that this is easy to do in the output module of wherever this is coming from, add some white space so you can read/debug easier, though it's not at all necessary (strings have to be quoted

Re: [Tutor] Fwd: arrangement of datafile

2014-01-05 Thread Steven D'Aprano
Hi Amrita, On Sun, Jan 05, 2014 at 10:01:16AM +0800, Amrita Kumari wrote: I have saved my data in csv format now it is looking like this: If you have a file in CSV format, you should use the csv module to read the file. http://docs.python.org/3/library/csv.html If you're still using Python

Re: [Tutor] Fwd: arrangement of datafile

2014-01-05 Thread Keith Winston
Amrita, on a closer read of your very first post I (think I) see you already successfully read your data into a series of dicts (mylist in your example), so if you still want the output you posted in the first post, then you can do some version of the loops that I described. That said, I'm sure

Re: [Tutor] Fwd: What's in a name?

2014-01-04 Thread spir
On 01/04/2014 06:36 AM, Steven D'Aprano wrote: Now, it's true that when *debugging code*, being able to see the name of the variable and the contents of the variable is useful. But in ordinary code, why would you care to print the name of the variable and its contents. Who cares what the

Re: [Tutor] Fwd: What's in a name?

2014-01-03 Thread Asokan Pichai
On Fri, Jan 03, 2014 at 02:45:04AM -0500, Keith Winston wrote: And to beat that poor horse in the same example, my current way of doing that would be: for alist in lista, listb: print(alist, eval(alist)) Since you know both pieces, namely the name of the entity alist and its actual

Re: [Tutor] Fwd: What's in a name?

2014-01-03 Thread Steven D'Aprano
On Fri, Jan 03, 2014 at 01:55:29AM -0500, Keith Winston wrote: [...] I want to iterate through a bunch of lists, subsequently printing both list members (via indexing, for example) and the name of the list I'm on. Why? What does this gain you? Now, it's true that when *debugging code*, being

Re: [Tutor] Fwd: What's in a name?

2014-01-02 Thread Mark Lawrence
On 03/01/2014 06:18, Keith Winston wrote: Shoot: I sent this response directly to Mark, without even trimming. Here it is to the list... Hi Mark: sorry for unclarity. I am probably going to make a hash of explaining this, but here goes: I want to iterate a variable across a list of objects,

Re: [Tutor] Fwd: What's in a name?

2014-01-02 Thread Keith Winston
Mark wrote: You enjoy making life difficult for yourself :) You've assigned strings to the name func, just assign the functions themselves? Like. for func in max, min: print(func.__name__, func(range(5))) Output. max 4 min 0 I wouldn't say I enjoy making life difficult for myself,

Re: [Tutor] Fwd: What's in a name?

2014-01-02 Thread Mark Lawrence
On 03/01/2014 06:55, Keith Winston wrote: Mark wrote: You enjoy making life difficult for yourself :) You've assigned strings to the name func, just assign the functions themselves? Like. for func in max, min: print(func.__name__, func(range(5))) Output. max 4 min

Re: [Tutor] Fwd: What's in a name?

2014-01-02 Thread Keith Winston
I spoke about iterating through a bunch of lists in my last post, but in fact I'm iterating through a bunch of dicts in the example I gave. Sorry. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options:

Re: [Tutor] Fwd: What's in a name?

2014-01-02 Thread Keith Winston
And to beat that poor horse in the same example, my current way of doing that would be: for alist in lista, listb: print(alist, eval(alist)) ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options:

Re: [Tutor] Fwd: Re: How to post: Was Re: The Charms of Gmail

2013-12-23 Thread Mark Lawrence
On 23/12/2013 16:26, Steven D'Aprano wrote: With permission of the author, I have been asked to forward this to the list. I trust that those vigilantees on the warpath against gmail are happy now, as there is one fewer gmail user using Python. what excellent news. With any luck we'll soon be

Re: [Tutor] Fwd: Re: How to post: Was Re: The Charms of Gmail

2013-12-23 Thread Danny Yoo
Would everyone mind dropping this thread, at least for a few days? As far as I can tell, there's zero Python content in it, so I'm not getting much information from it. More than that, it's affecting my morale in a fairly negative manner. Thanks. ___

Re: [Tutor] Fwd: Re: How to post: Was Re: The Charms of Gmail

2013-12-23 Thread Tim Johnson
* Danny Yoo d...@hashcollision.org [131223 07:48]: Would everyone mind dropping this thread, at least for a few days? As far as I can tell, there's zero Python content in it, so I'm not getting much information from it. More than that, it's affecting my morale in a fairly negative manner.

Re: [Tutor] Fwd: Re: How to post: Was Re: The Charms of Gmail

2013-12-23 Thread Keith Winston
Yikes, as the progenitor of the antecedent of this screed... I'm sorry! I have found, by and large, this to be a very helpful list, there's no question it has kept me moving forward at times that I might not have in python. Lots of generosity and knowledge. And when someone suggested a way of

Re: [Tutor] Fwd: question about lists

2013-12-04 Thread Dave Angel
On Wed, 4 Dec 2013 10:35:46 +0100, Ismar Sehic i.she...@gmail.com wrote: so please, i need some pointers in how to get these lists related, regarding i cannot use indexing, because i don't always have the same number of items in list. First question is whether the data is assumed to be self

Re: [Tutor] Fwd: question about lists

2013-12-04 Thread spir
On 12/04/2013 10:35 AM, Ismar Sehic wrote: [...] Your presentation is a bit abscure (to me, at least): it is hard to help you. Maybe you could explain better, and progressively: * what is the purpose of your software, and its context * what are your input data and what they mean, and whether

Re: [Tutor] Fwd: question about lists

2013-12-04 Thread Steven D'Aprano
On Wed, Dec 04, 2013 at 10:35:46AM +0100, Ismar Sehic wrote: hello, good people. i have a pretty urgent question.the situation is like this, i have following lists, as results of numerous psycopg2 queries, here are two examples : Ismar, the following don't look like Python lists to me. It's

Re: [Tutor] Fwd: Re: Passing arguments?

2013-10-22 Thread Jenny Allar
Thank you all for your help with this program. Each of your answers helped me piece together an understanding of the assignment. After several days and clearly over-thinking the entire process, I ended up using the following code: def main (): name = input(Please enter the name of the

Re: [Tutor] Fwd: Re: Passing arguments?

2013-10-22 Thread Alan Gauld
On 22/10/13 03:23, Jenny Allar wrote: I ended up using the following code: One wee improvement you could consider: def cal_shiprate(product_name, product_weight): if product_weight 10: ship_rate = 1.5 elif product_weight = 10 and product_weight 25: ship_rate =

Re: [Tutor] Fwd: Re: Passing arguments?

2013-10-22 Thread Ricardo Aráoz
- Did you notice your assignment specifically asks for a while loop for validation? That means you are expected to validate input. Run your program and when the program asks Please enter the weight of the product in pounds: answer 123...this is a mistake, what does it happen? Your program

Re: [Tutor] Fwd: Re: Passing arguments?

2013-10-22 Thread Alan Gauld
On 22/10/13 14:21, Ricardo Aráoz wrote: - Did you notice your assignment specifically asks for a while loop for validation? ... (tip: you should be using while and on error) on error? You're not thinking of VB by any chance? :-) In Python it would be a try/except block or maybe a straight

Re: [Tutor] Fwd: Re: Passing arguments?

2013-10-22 Thread Ricardo Aráoz
El 22/10/13 10:44, Alan Gauld escribió: On 22/10/13 14:21, Ricardo Aráoz wrote: - Did you notice your assignment specifically asks for a while loop for validation? ... (tip: you should be using while and on error) on error? You're not thinking of VB by any chance? :-) In Python it would be a

Re: [Tutor] Fwd: Re: Passing arguments?

2013-10-22 Thread Mark Lawrence
On 22/10/2013 03:23, Jenny Allar wrote: Plenty of sound advice as always so I'll just point out that... elif product_weight = 10 and product_weight 25: can be written as elif 10 = product_weight 25: -- Python is the second best programming language in the world. But the best has yet

Re: [Tutor] Fwd: Re: Passing arguments?

2013-10-22 Thread Alan Gauld
On 22/10/13 14:55, Ricardo Aráoz wrote: Sorry, meant try/except (I was thinking VFP). Wouldn't if/else be more difficult when validating if an input is a valid float? I find try/except easier. Maybe, but typical programming classes don't teach try/except till much later in the course. Since

Re: [Tutor] Fwd: we need assistance in my school

2013-10-15 Thread Kengesbayev, Askar
Hi Okechukwu, I would recommend to use Khan Academy. It is free resource of use. He covers python basic plus they built sophisticated system that track performance of each student. That would help you a lot and see weak sides of your students. https://www.khanacademy.org/cs For more

Re: [Tutor] Fwd: we need assistance in my school

2013-10-14 Thread Alan Gauld
On 14/10/13 11:54, Okechukwu Nkaronye wrote: Hi my name is okechukwu . I teaches computer at a low grade of 8, 9, 10, 12 years ages . Please I would be pleased if you could assist us in helping our children to get to know programming skills I am not very vast in programming and know little in

Re: [Tutor] Fwd: we need assistance in my school

2013-10-14 Thread brian arb
This looks like a very fun way to teach programming at an early age http://scratch.mit.edu/ On Mon, Oct 14, 2013 at 6:54 AM, Okechukwu Nkaronye okero...@gmail.comwrote: -- Forwarded message -- From: Okechukwu Nkaronye okero...@gmail.com Date: Fri, 11 Oct 2013 13:04:10 +

Re: [Tutor] Fwd: Need help returning a null/blank value when using string indexes

2013-08-28 Thread Dave Angel
On 27/8/2013 22:41, Robyn Perry wrote: part2 = (fragA[-7:-5] + '') But it asks me to use a string, not a blank space. part2 needs begin with 'da' so I can produce 'Udacity' in Test Case 2, but needs to somehow end with a null kind of value so I can produce 'Ucity' in Test Case 3. See

Re: [Tutor] Fwd: script in Raspberry pi python

2013-07-30 Thread Dave Angel
On 07/29/2013 10:42 PM, Kirk Bailey wrote: ok, I read linked article, then copied the perl script text, which bombs. The TEXT: * #!/usr/local/bin/perl -w** ** use strict;** ** ** while (STDIN) {** ** s/\r\n/\n/;** ** print;** ** }* This works nicely, and all problems are solved.

Re: [Tutor] Fwd: script in Raspberry pi python

2013-07-29 Thread Kirk Bailey
originally edited on a windows box, then copied over with a usb stick. I suppose I better open it, copy it to mouse then paste it to a nw file- or what? Please advise. On 7/25/2013 3:45 PM, Walter Prins wrote: Hi, On 25 July 2013 19:45, Kirk Bailey kbai...@howlermonkey.net

Re: [Tutor] Fwd: script in Raspberry pi python

2013-07-29 Thread Kirk Bailey
ok, I read linked article, then copied the perl script text, which bombs. The TEXT: * #!/usr/local/bin/perl -w** ** use strict;** ** ** while (STDIN) {** ** s/\r\n/\n/;** ** print;** ** }* This works nicely, and all problems are solved. I tried to download the program using

<    1   2   3   4   >