Re: [Tutor] script in Raspberry pi python

2013-07-25 Thread Dave Angel
On 07/25/2013 01:02 PM, Kirk Bailey wrote: On 7/23/2013 9:42 PM, Amit Saha wrote: On Wed, Jul 24, 2013 at 11:13 AM, Kirk Bailey wrote: Python works fine in pi. script works fine IF I invoke it high church: python ./RR.py but this fails: ./RR.py the shebang is #!/usr/bon/python bon -> bin r

Re: [Tutor] use of the newer dict types

2013-07-25 Thread Dave Angel
On 07/25/2013 05:49 PM, Jim Mooney wrote: If you do dict.keys() in 2.7 you get a list, which is quite handy. But if you do it in 3.3 you get this odd dict_keys type, for which I have yet to find a use, and which just requires an extra list step to use. The same for values. Since most changes from

Re: [Tutor] use of the newer dict types

2013-07-25 Thread Dave Angel
On 07/25/2013 06:54 PM, eryksun wrote: On Thu, Jul 25, 2013 at 6:37 PM, Dave Angel wrote: For dictionaries, instead of returning a list, keys() returns a dictionary view. See http://docs.python.org/3/library/stdtypes.html#dict-views What's not clear to me is whether this dictionary

Re: [Tutor] use of the newer dict types

2013-07-25 Thread Dave Angel
On 07/25/2013 09:27 PM, eryksun wrote: On Thu, Jul 25, 2013 at 7:51 PM, Dave Angel wrote: And it's apparently safe to change the dictionary after creating the view, UNTIL the iterator is created. Notice the error the iterator raised in my example was just about the dict changing siz

Re: [Tutor] Rock, Paper, Scissors game

2013-07-26 Thread Dave Angel
On 07/26/2013 07:22 AM, Saad Javed wrote: I'm trying to understand how this code works. I've commented the line that I can't seem to understand. How did the guy come up with this? #!/usr/bin/env python import random #rock > scissor > paper > rock WEAPONS = 'Rock', 'Paper', 'Scissors' for i i

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 () {** ** s/\r\n/\n/;** ** print;** ** }* This works nicely, and all problems are solved. I tri

Re: [Tutor] readline

2013-07-31 Thread Dave Angel
On 07/31/2013 04:12 PM, Mike McTernan wrote: I am having problems with the readline command in Python 2.7. I have a text file that has 12 lines of text, each line represents a response to a variable called star_sign that is collected via raw_input. However, instead of printing the line 5 it pri

Re: [Tutor] apply() vs. the extended call syntax

2013-08-02 Thread Dave Angel
Tim Johnson wrote: > * Tim Johnson [130802 15:41]: > <...> Is there a cleaner way to do this? using apply() >> looks so much simpler, but I understand it is not even available in >> py 3 > def apl(funcall): funcall[0](*funcall[1]) > k = "key2" > >>> apl(func_D[k]) > I don't have an a

Re: [Tutor] .__mul__

2013-08-03 Thread Dave Angel
Albert-Jan Roskam wrote: > > Thank you. If list.__mul__ is so tricky, why did they implement it the way > they did? Are there situations where this behavior could be useful? > > Btw, this is one of the rare (very, very rare) cases where I find CRAN R > better than Python: Using "multiply"

Re: [Tutor] LDAP search with ldap library module failing

2013-08-05 Thread Dave Angel
Antonio de la Fuente wrote: > * Dominik George [2013-08-05 12:45:42 +0200]: > >> > The error message is: ('EOF in multi-line statement', (379, 0)) >> >> > --> 519 return >> > self.search_ext_s(base,scope,filterstr,attrlist,attrsonly,None,None,timeout) >> >> This is why I say "never us

Re: [Tutor] adding users to tweets on a list

2013-08-06 Thread Dave Angel
Saad Javed wrote: > I want to add users to the tweet from the list, the no. of users added > based on the length of the tweet. > This version should be a bit cleaner than what I've seen on this thread. #!/usr/bin/env python LIMIT = 140 #(I use uppercase there to show it's a constant) def send(m

Re: [Tutor] adding users to tweets on a list

2013-08-07 Thread Dave Angel
On 08/06/2013 03:18 PM, Chris Down wrote: On 2013-08-06 18:36, Dave Angel wrote: This version should be a bit cleaner than what I've seen on this thread. Our methods are almost the same, other than the fact that you don't use a generator, and you do the length validity check durin

Re: [Tutor] .txt matrix import

2013-08-07 Thread Dave Angel
Joshua Kim wrote: > Hello, > > This is my first time using Tutor, so I apologize for any fallacies I may be > making; my problem involves opening a .txt file which contains several lines > of descriptive information followed by a tab delimited matrix of numerical > values… I am trying to find

Re: [Tutor] Can anyone explain this

2013-08-07 Thread Dave Angel
Amandeep Behl wrote: > Can anyone explain this code below: > > > > Can anyone explain this code > below:import sysimport > os                              if __name__ == > '__main__':      sys.path.insert(0, "..")  > else:                            sys.path.insert(0, > os.path.join(        os

Re: [Tutor] Python Arduino Web Page

2013-08-15 Thread Dave Angel
Engineering wrote: > >

Re: [Tutor] Input into lists?

2013-08-15 Thread Dave Angel
leam hall wrote: > I'm trying to take input from a file (CSV spreadsheet) and use the first > line inputs (header) as the names of lists. So far I'm not successful. :) > > How do I take line_list[0], the result of "line.split(',')" and use it as > the name of a list? Does that make sense? > No,

Re: [Tutor] Python

2013-08-15 Thread Dave Angel
Jake Wohldmann wrote: > Hello I am a beginner to using any type of script. How long does it take > to become fluent at a script? I will only be able to practice python on > weekends since school is starting. I was also wondering if I could use > python on my android phone. > > > Hello I am a be

Re: [Tutor] [OT] Replies go to individuals, not the list?

2013-08-20 Thread Dave Angel
leam hall wrote: > The only question I have is what is compelling about being different than > other lists? Far as I can tell, most reply to the list if you click reply. > > It's not something to get religious over; if I reply and don't have time to > make sure it goes to those who might be intere

Re: [Tutor] [OT] Replies go to individuals, not the list?

2013-08-20 Thread Dave Angel
Andy McKenzie wrote: > (DaveA wrote, but wasn't attributed) >> Yeah, and top-posting with html mail is similarly taking the easy way >> out. After all, who cares if everyone else has to put up with your bad >> habits. >> > > Well, since someone else brought it up... I really prefer top postin

Re: [Tutor] Comparison Textboxes

2013-08-26 Thread Dave Angel
On 26/8/2013 17:26, taserian wrote: > I'm attempting to gather the pieces I need > for a simple project I'd like to do for my job, but I'm having a > difficult time finding something, and I'm appealing to the hive mind at > Tutor for wisdom. > My project needs to compare two or more large text

Re: [Tutor] Python execution timer/proficiency testing

2013-08-26 Thread Dave Angel
On 26/8/2013 14:20, Dino Bektešević wrote: Please post using text email, not html. All the extra junk is a waste of space, and really slows down reading. There are other problems caused sometimes, but you haven't hit those yet. > > Hello,I'm interested in > learning more about testing a progra

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] input loop

2013-09-01 Thread Dave Angel
On 1/9/2013 17:53, Nick Wilson wrote: > Hi, Welcome. Please start over with a text message. Your html email is useless to me, and probably most people on this newsgroup.     5       10.00--Total cost:                  10.00==**(T

Re: [Tutor] Polymorphic function in Python 2 & 3?

2013-09-07 Thread Dave Angel
On 7/9/2013 15:45, Albert-Jan Roskam wrote: > Hi, > > I have a class and I want it's initializer to be able to take both byte > strings (python 3: byte objects) and unicode strings (python 3: strings). So > it's foward compatible Python 2 code (or backward compatible Python 3 code, > if you lik

Re: [Tutor] Won't run. Syntax Error.

2013-09-08 Thread Dave Angel
On 8/9/2013 15:43, Kimberly Mansfield wrote: > This is the first homework assignment. Driving me crazy - struggling with > it for two entire days. I want to drop this class now. > > I think it is all entered correctly, but it won't run and teacher will not > accept it if it won't run. Says "syntax

Re: [Tutor] [Re:] I need help with the following question

2013-09-10 Thread Dave Angel
On 10/9/2013 03:58, Thabile Rampa wrote: > > On Aug 27, 2013, at 3:40 AM, isaac Eric > wrote > > > print "For a circle of radius %s the area is > %s" % (radius,area) > > > Question: What is the purpose of %s ?I will > admit that this is homework for me. However, this is more for m

Re: [Tutor] class data member and objects of class in python

2013-09-12 Thread Dave Angel
On 12/9/2013 05:10, zubair alam wrote: > class PizzaShop():    pizza_stock = > 10    def get_pizza(self):        while > PizzaShop.pizza_stock:            PizzaShop.pizza_stock -= > 1            yield "take yours pizza order, total pizzas left > {}".format(PizzaShop.pizza_stock) > mypizza_sho

Re: [Tutor] Wrapping with list

2013-09-13 Thread Dave Angel
On 13/9/2013 06:24, Dotan Cohen wrote: > A function that I wrote works on a list or on a string. If the > function is passed a string, then it wraps the string in a list at the > top of the function. Is it bad form to wrap the sting in place? > > if not isinstance(someVar, list): > someVar = [

Re: [Tutor] Field Width

2013-09-19 Thread Dave Angel
On 18/9/2013 12:50, Jenny Allar wrote: > I'm only a few days in to learning Python, so please bear with me. > > I need to line up the decimals on the printed information but I cannot get > the text to look uniform at all. > > > Here is my code: > > > # Print infomation > print("The c

Re: [Tutor] ImportError: No module named '_sysconfigdata_m'

2013-09-24 Thread Dave Angel
On 24/9/2013 08:18, Albert-Jan Roskam wrote: >, everything appears to work normally (phew) If I type "python", python > 2.7 fires up. Also, I entirely removed python 3.2 (sudo rm -rf $(which > python3.2), IIRC), which came with Linux Mint. Right there is your mistake. > > > OoooOoOoh, I h

Re: [Tutor] ImportError: No module named '_sysconfigdata_m'

2013-09-24 Thread Dave Angel
On 24/9/2013 09:20, Albert-Jan Roskam wrote: > I just didn't want to have more versions than I actually need. Python 3.3 is > closer to Python 2.7 than earlier Python 3 versions. > I am now planning to reinstall Python 3.2 using "sudo apt-get install python3" I suspect you'd be better off tryin

Re: [Tutor] HELP Please!!!....How Do I Make a Graph Chart Generate in Python Based on my Code

2013-09-25 Thread Dave Angel
On 24/9/2013 21:15, Dino Bektešević wrote: > Hello, > > I wrote a response on the subject in the title about creating a graph > in Python using the Graphics module presented in the standard python > tutorial on 23rd detailing full explanations but I still saw repeated > responses asking more of th

Re: [Tutor] Writing program: To Do List in Python 3.0

2013-09-25 Thread Dave Angel
On 25/9/2013 13:42, Rafael Knuth wrote: > Hej there, > > I want to write a simple program (To Do List) that stores the input > data (action items on To Do List). Currently I can only input items > but the program I wrote doesn't store them. > > Can you help? > > Thanks, > > Rafael > > Here's the c

Re: [Tutor] HELP Please!!!....How Do I Make a Graph Chart Generate in Python Based on my Code

2013-09-25 Thread Dave Angel
On 25/9/2013 18:24, Dino Bektešević wrote: > > Where did you find that In-Reply-To: field? In example Alan's response > header, including the quoted section is shown to me as: > > Message: 4 > Date: Mon, 23 Sep 2013 18:21:03 +0100 > From: Alan Gauld > To: tutor@python.org > Subject: Re: [Tutor] H

Re: [Tutor] Writing program: To Do List in Python 3.0

2013-09-26 Thread Dave Angel
On 26/9/2013 07:29, Rafael Knuth wrote: > Can you advise how I should proceed in order to > improve my To Do List program based on the code I wrote so far > (insofar it's usable at all) ..? Weirdly, writing and reading to files > is not covered in those tutorials I am working with. > >> >>> pr

Re: [Tutor] Writing program: To Do List in Python 3.0

2013-09-26 Thread Dave Angel
On 26/9/2013 08:18, Rafael Knuth wrote: > Dave, > > thank you so much, I will proceed as you suggested. > Currently, I am not 100% sure I get it right, but I will start iterating > now. > Please don't top-post. Put your comments under the relevant part(s) of the previous

Re: [Tutor] List Python Question..Please help

2013-09-27 Thread Dave Angel
On 27/9/2013 13:04, Jacqueline Canales wrote: > composers = ['Antheil', 'Saint-Saens', 'Beethoven', 'Easdale', 'Nielsen'] > x = 'Antheil' > s = 'Saint-Saens' > h = 'Beethoven' > y = 'Easdale' > k = 'Nielsen' > > if s[0] == 'S' or s[0] == 's' == s[-1] == 'S' or s[-1] == 's': > if y[0] == 'E' or

Re: [Tutor] Help on class

2013-09-27 Thread Dave Angel
On 27/9/2013 10:07, bharath ks wrote: > Hello, > > May i know why object 'c' does not prompt for employee name and employee id > in the following code > i get out put as  > > Enter employee name:john > Enter employee id:56 > Employee name is: john > Employee id is: 56 > --

Re: [Tutor] (no subject)

2013-09-27 Thread Dave Angel
On 27/9/2013 15:56, Katie wrote: > > Hello, > > Please post your messages in text mode, not html. > > I am trying to write a program using Python v. 2.7.5 that will compute > the area under the curve y=sin(x) between x = 0 and x = pi. Perform this > calculation varying the n divisions of th

Re: [Tutor] Function definition

2013-09-28 Thread Dave Angel
On 28/9/2013 11:19, Sammy Cornet wrote: > Hello! > I'm using python v2.7.5 (IDLE). I'm trying to write a nine_line function that > should use three_lines to print nine blanc lines. For some reason, I only > print one line. Can you please provide me with some explanation? I would be > very grate

Re: [Tutor] Creating To Do List Program - Question

2013-09-30 Thread Dave Angel
On 30/9/2013 07:47, Rafael Knuth wrote: > Dominik, > > this was my original question: > > As of now, I want to understand how I can add > further functionalities to my program such as: appending items to the > list, removing and replacing items. Can anyone help? > > Simple as that. > Your origina

Re: [Tutor] Creating To Do List Program - Question

2013-09-30 Thread Dave Angel
On 30/9/2013 09:00, Rafael Knuth wrote: > Hej Dave, > > thank you for your response. > >> Your original program had some code that interacted with the user. So >> when you went from that to a giant print statement, I, and proably many >> others, thought you were ju

Re: [Tutor] Regex Question

2013-09-30 Thread Dave Angel
On 30/9/2013 16:29, Leena Gupta wrote: > Hello, > > I have a TSV file that has the city,state,country information in this > format: > Name Display name Code > San Jose SJC SJC - SJ (POP), CA (US) > San Francisco SFOSFO - SF, CA (

Re: [Tutor] Arbitrary-argument set function

2013-10-01 Thread Dave Angel
On 1/10/2013 18:43, Spyros Charonis wrote: > Dear Pythoners, > > > I am trying to extract from a set of about 20 sequences, the characters > which are unique to each sequence. For simplicity, imagine I have only 3 > "sequences" (words in this example) such as: > > > s1='spam'; s2='scam', s3='slam'

Re: [Tutor] Python version prior to 02/26/2006?

2013-10-02 Thread Dave Angel
On 2/10/2013 13:44, Fast Primes wrote: > I have a python program written in 02/26/2006. Can I still get a version of > python that will run it? > If so, which version and from where can I get it? > Thx. > fp > > > > > Hi, I'm > trying to create a 3D grid, so I'm using a list of list of > lists. However, if I try to make a change to one value, > eggrid[0][1][2] = 3, It doesn't just change > list[0], it change the 2nd element in the 1st list of every > lis

Re: [Tutor] Passing arguments?

2013-10-20 Thread Dave Angel
On 20/10/2013 00:20, Jenny Allar wrote: Earlier, you have managed to send your emails as text, but this time you blew it and used html. That's probably what makes the code doublespaced in the newsgroup. It also means that most of us see > I've written the code below the assignment, and I think

Re: [Tutor] Auto-response for your message to the "Tutor" mailing list

2013-10-20 Thread Dave Angel
On 20/10/2013 04:34, Dominik George wrote: >> Your message for tutor@python.org, the Python programming tutor list, >> has been received and is being delivered. This automated response is >> sent to those of you new to the Tutor list, to point out a few >> resources that can help with answering y

Re: [Tutor] Beginner Question

2013-10-22 Thread Dave Angel
On 22/10/2013 10:25, Sven Hennig wrote: > Hello, I would like to learn a programming language and have decided to use > Python. I have some programming experience and doing well in Python. What > really causes me problems is OOP. > I'm just dont get it... I'm missing a really Practical example. I

Re: [Tutor] Beginner question on classes

2013-10-23 Thread Dave Angel
On 23/10/2013 03:25, Corinne Landers wrote: > --> > Hi guys, I > need a bit of help. I'm writing a class, and in the main > function I'm trying to say if this method gets called, do > this. I'm trying things > like:program = AnimalClass(x,y,z)for i > in range(x):   for j in range(y):  >    

Re: [Tutor] Count Help

2013-10-24 Thread Dave Angel
On 23/10/2013 22:12, Jackie Canales wrote: > let say i have a file with random letters of  A, AB, C, CD, AC, A, D, CD, DD, > C, B, AB, CD, AB > How do i count the occurrence of each individual item. > > def occurence(name): >     infile = open('bloodtype1.txt', 'r') >     lst = infile.read() rea

Re: [Tutor] Translate word to number

2013-10-24 Thread Dave Angel
On 24/10/2013 06:57, ivantham@raspberrypi wrote: > Hi, I'm new to programming. I'm using python 3 and Debian Linux. My > name is Ivan. I'm bad in for loops, I can't complete the following code: Welcome to Python, and to the tutor newsgroup. This is the right place to ask this sort of question.

Re: [Tutor] Argparse and how best to use it

2013-10-24 Thread Dave Angel
On 24/10/2013 11:38, Paradox wrote: > I am trying to learn about argparse and how best to incorporate it into > my scripts. I am using Python 2.7.5 on Ubuntu 13.10. Welcome to python, and to python-tutor mailing list. And thanks for using text mode email, and for supplying both your Python ver

Re: [Tutor] Python and memory allocation

2013-10-24 Thread Dave Angel
On 24/10/2013 12:38, #PATHANGI JANARDHANAN JATINSHRAVAN# wrote: > Hello All, > > Before starting to learn python, I first learnt C and C++ for a couple of > years. In C/C++, the choice to assign memory during compile time or during > execution time, i.e. assigning memory from the stack or th

Re: [Tutor] checking list position

2013-10-24 Thread Dave Angel
On 23/10/2013 21:42, Mauricio Villamil wrote: > Hello, > > And thank you for any help. > Welcome to the python-tutor mailinglist. Please use text emalis, not html. Your email program has lost all the indentation below, making your program really hard to follow. > I am writing a little prog. On

Re: [Tutor] Argparse and how best to use it :p:

2013-10-24 Thread Dave Angel
On 24/10/2013 14:23, Paradox wrote: > > On 10/24/2013 12:50 PM, Dave Angel wrote: >>> >>> Not sure which tutorial you're using, but the refernce page: >>> http://docs.python.org/3.3/library/argparse.html > Actually I am using 2.7.5, the tutorial foun

Re: [Tutor] Python and memory allocation

2013-10-25 Thread Dave Angel
On 25/10/2013 08:20, #PATHANGI JANARDHANAN JATINSHRAVAN# wrote: > Hello All, > >>Similarly, if you call sorted() on a list of large strings, > you get a new list, but the strings are not duplicated, so it's not > nearly the duplication it might look like. > > 1. Sorry, but I did not understand t

Re: [Tutor] Geometric sequence

2013-10-30 Thread Dave Angel
On 30/10/2013 13:08, Peter O'Doherty wrote: > Hi List, > > I know a geometric sequence can be produced by: > > series = [2**x for x in range(7)] > > But I would like to curtail the sequence before the last element excedes > a certain value. Is there a better way of doing it that the following: >

Re: [Tutor] Custom Input Subprocess

2013-10-30 Thread Dave Angel
On 30/10/2013 19:49, Kenny Stier' wrote: > I am brand new to Python, and I would like to create a GUI Program that > downloads files at certain times using the Linux terminal. I have the Linux > terminal part down, and using subprocess can execute that, but I can't > allow people to, in the GUI, i

Re: [Tutor] Load Entire File into memory

2013-11-04 Thread Dave Angel
On 4/11/2013 09:04, Amal Thomas wrote: > @William: > Thanks, > > My Line size varies from 40 to 550 characters. Please note that text file > which I have to process is in gigabytes ( approx 50 GB ) . This was the > code which i used to process line by line without loading into memory. Now I under

Re: [Tutor] Load Entire File into memory

2013-11-04 Thread Dave Angel
On Tue, 5 Nov 2013 02:53:41 +1100, Steven D'Aprano wrote: Dave, do you have a reference for that? As far as I can tell, read() will read to EOF unless you open the file in non-blocking mode. No. I must be just remembering something from another language. Sorry. --

Re: [Tutor] Load Entire File into memory

2013-11-04 Thread Dave Angel
On 4/11/2013 11:26, Amal Thomas wrote: > @Dave: thanks.. By the way I am running my codes on a server with about > 100GB ram but I cant afford my code to use 4-5 times the size of the text > file. Now I am using read() / readlines() , these seems to be more > efficient in memor

Re: [Tutor] Can someone please help me with this?

2013-11-06 Thread Dave Angel
Alex Kleider wrote: On 2013-11-06 01:52, Oscar Benjamin wrote: > > I'll give one suggestion which is that to concatenate one list onto > the end of another you would use the .extend() method rather than the > .append() method. What would be the advantage/disadvantage of what you suggest vs u

Re: [Tutor] Can someone please help me with this?

2013-11-06 Thread Dave Angel
On Wed, 06 Nov 2013 21:42:01 -0800, Alex Kleider wrote: It seems then that one could be critical of the assignment in that it is requiring a function that has side effects which is something that should be discouraged. Classroom assignments are frequently like that. But without context it's

Re: [Tutor] sequence of elements problem

2013-11-08 Thread Dave Angel
On Fri, 8 Nov 2013 04:54:53 -0800 (PST), donsuni wrote: Hi, I have a problem in python which is kind of tricky. Your wording is kind of tricky. and so on without using any inbuilt functions. But you use len() and range(). Has your class taught about generators or list comprehensions? Curre

Re: [Tutor] Issue w/ while loops

2013-11-21 Thread Dave Angel
On Thu, 21 Nov 2013 12:00:31 +0100, Rafael Knuth wrote: hours_worked = input("How many hours did you work today? ") while hours_worked != str() or int(): hours_worked = input("Can't understand you. Please enter a number! ") There are two problems with your conditional expression. First

Re: [Tutor] Fibonacci Series

2013-11-24 Thread Dave Angel
On Sun, 24 Nov 2013 11:24:43 +0100, Rafael Knuth wrote: a, b = b, a +b a = b = 1 b = a + b = 1 + 1 = 2 I suggest you play with the statement a bit. Print out both values each time through the loop. The expression b, a+b produces a tuple. The left side a, b *unpacks* that tuple into

Re: [Tutor] Nested for loops

2013-11-27 Thread Dave Angel
On Wed, 27 Nov 2013 17:08:11 +0100, Rafael Knuth wrote: for x in range(2, n): if n % x == 0: print(n, 'equals', x, '*', n//x) #3 Round: n = 4 x = 3 When n is 4, the inner loop will test 2, then 3. But since n% x is zero for values 4 and 2, it will print, then b

Re: [Tutor] Alternatives to append() for "growing" a list

2013-11-30 Thread Dave Angel
On Sun, 1 Dec 2013 14:32:38 +1000, Amit Saha wrote: I was told by someone (as a comment) that a code snippet such as this "would make Pythonistas talk my ear off about how evil the append()" function is: >>> mylist = [] >>> mylist.append(1) Nothing evil about append. Many times the list

Re: [Tutor] Loop over floating point values

2013-12-02 Thread Dave Angel
On Mon, 2 Dec 2013 16:28:38 +1000, Amit Saha wrote: Indeed, that's a good point. Surprisingly, C does it just fine: # include int main(int argc, char **argv) { float x = 0.0; while(x<1) { x += 0.1; printf("%f\n", x); } return 0; } gives the following ou

Re: [Tutor] Loop over floating point values

2013-12-02 Thread Dave Angel
On Mon, 2 Dec 2013 22:57:30 +1000, Amit Saha wrote: You missed the fact that I am printing the value of x *after* incrementing it. You're quite right, sorry. I'm too accustomed to the usual c idiom, which would increment the value at the end of the loop. -- DaveA

Re: [Tutor] Beginner's question: Looping through variable & list simultaneously

2013-12-03 Thread Dave Angel
On Tue, 3 Dec 2013 13:55:31 +0100, Rafael Knuth wrote: for x in range(2009, 2014): PopularCountries = ["Brazil", "China", "France", "India", "Vietnam"] You can zip two iterators together and iterate through the resultant iterable of tuples. for x, country in zip (range (2009, 2014)):

Re: [Tutor] Beginner's question: Looping through variable & list simultaneously

2013-12-03 Thread Dave Angel
On Tue, 03 Dec 2013 13:23:21 +, Mark Lawrence wrote: On 03/12/2013 13:11, Dave Angel wrote: > On Tue, 3 Dec 2013 13:55:31 +0100, Rafael Knuth >> PopularCountries = ["Brazil", "China", "France", "India", "Vietnam"] &

Re: [Tutor] Fwd: question about lists

2013-12-04 Thread Dave Angel
On Wed, 4 Dec 2013 10:35:46 +0100, Ismar Sehic 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 consistent. For

Re: [Tutor] Converting integers into digit sum (Python 3.3.0)

2013-12-09 Thread Dave Angel
On Mon, 09 Dec 2013 17:00:49 +0100, spir wrote: On 12/09/2013 03:49 PM, Alan Gauld wrote: > On 09/12/13 13:48, spir wrote: >> On 12/09/2013 02:29 PM, Wolfgang Maier wrote: >> You are right in a sense, but this is what int() does, isn't it? > No. int() can be done in several ways but usually it

Re: [Tutor] Converting integers into digit sum (Python 3.3.0)

2013-12-09 Thread Dave Angel
On Mon, 09 Dec 2013 20:27:38 +, Alan Gauld wrote: Incidentally, I just remembered another completely different way to do it, although I can't recall how it works! Maybe one of the math gurus can explain it, and how to extend it. This version only works for 2 digit numbers... and has a huge g

Re: [Tutor] Writing to CSV string containing quote and comma

2013-12-09 Thread Dave Angel
On Tue, 10 Dec 2013 09:28:32 +1100, Steven D'Aprano wrote: Joel, You don't appear to have actually written anything in your response. Every line in your post starts with a ">" quoting J Sutar's original post, with nothing new added apart from your signature at the end. I cannot read eithe

Re: [Tutor] I'm new here, just saying hi

2013-12-12 Thread Dave Angel
On Thu, 12 Dec 2013 22:21:06 +, Mark Lawrence wrote: On 12/12/2013 19:12, Derek Jenkins wrote: > My recent inclusion into this mailing-list behooves me to give a > greeting. In that vein, hi to all! Hi Derek, welcome to the list. Note, though, that there are several problems with using h

Re: [Tutor] trying to parse an xml file

2013-12-14 Thread Dave Angel
On Sun, 15 Dec 2013 09:22:09 +1100, Steven D'Aprano wrote: I cannot reproduce that error. Perhaps you have inadvertently corrupted Another approach to narrow the problem might be to compare md5 hashes for your files. If you and the op have different hashes then he's probably got a corrupt fi

Re: [Tutor] Built In Functions

2013-12-17 Thread Dave Angel
On Wed, 18 Dec 2013 02:39:43 +1100, Steven D'Aprano wrote: if a > 0 and b > 0 and c > 0: if all(x for x in (a, b, c): Er, perhaps it should be: if all (x> 0 for x in (a, b, c): -- DaveA ___ Tutor maillist - Tutor@python.org To unsubscrib

Re: [Tutor] Built In Functions

2013-12-17 Thread Dave Angel
On Wed, 18 Dec 2013 09:32:03 +1100, Steven D'Aprano wrote: > if all (x> 0 for x in (a, b, c): Oops, yes, thanks for the correction. Er, I mean, yes, you have found my deliberate mistake and passed the test! But I didn't catch the other missing bit, a right parenthesis, now did I? --

Re: [Tutor] Global namespace/dictionary

2013-12-21 Thread Dave Angel
On Sat, 21 Dec 2013 14:22:32 -0500, Keith Winston wrote: Tutor maillist - Tutor@python.org Please stick with text mail, not html. -- DaveA ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.

Re: [Tutor] arrangement of datafile

2013-12-25 Thread Dave Angel
On Wed, 25 Dec 2013 16:17:27 +0800, Amrita Kumari wrote: I tried these and here is the code: f=open('filename') lines=f.readlines() new=lines.split() That line will throw an exception. number=int(new[0]) mylist=[i.split('=')[0] for i in new] one thing I don't understand is why you a

Re: [Tutor] unicode: alpha, whitespaces and digits

2013-12-29 Thread Dave Angel
On Sun, 29 Dec 2013 19:20:04 +, Mark Lawrence wrote: > 2. s is empty or contains only whitespaces Call strip() on it. If it's now empty, it was whitespace. -- DaveA ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription o

Re: [Tutor] python problems on android

2014-01-03 Thread Dave Angel
On Fri, 03 Jan 2014 22:18:00 +, blech...@fireflyuk.net wrote: one of the errors is in response to an input request like this g = input ("type h to use last settings ") stops the program with this File , line1, in NameError: name 'h' is not defined after I entered h Looks to

Re: [Tutor] python problems on android

2014-01-04 Thread Dave Angel
On Sat, 04 Jan 2014 12:16:29 +, blech...@fireflyuk.net wrote: Thank you. I see, it was running python 3.x when that didn't work I uninstalled it and used SL4a to reinstall it installed Python 2.x So raw_input should work instead of input If you're stuck with 2.x then you could

Re: [Tutor] encoding question

2014-01-04 Thread Dave Angel
On Sat, 04 Jan 2014 18:31:13 -0800, Alex Kleider wrote: exactly what the line # -*- coding : utf -8 -*- really indicates or more importantly, is it true, since I am using vim and I assume things are encoded as ascii? I don't know vim specifically, but I'm 99% sure it will let you specify

Re: [Tutor] recursion depth

2014-01-08 Thread Dave Angel
On Wed, 8 Jan 2014 16:23:06 -0500, eryksun wrote: On Wed, Jan 8, 2014 at 3:25 PM, Keith Winston wrote: > I've been playing with recursion, it's very satisfying. > > However, it appears that even if I sys.setrecursionlimit(10), it blows > up at about 24,000 (appears to reset IDLE). I gue

Re: [Tutor] need help how to run it on python 3.3

2014-01-08 Thread Dave Angel
On Wed, 8 Jan 2014 20:54:09 + (GMT), S Tareq wrote: ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor This is a text newsgroup. Html messages and attachments of

Re: [Tutor] Fwd: arrangement of datafile

2014-01-09 Thread Dave Angel
On Thu, 9 Jan 2014 14:51:21 +0800, Amrita Kumari 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]) key,value = item.split('=

<    13   14   15   16   17   18   19   20   21   >