[Tutor] Fwd: Problem Euler 26

2008-06-30 Thread Andre Engels
use methods similar to the once you use for a long division with pen and paper. -- Andre Engels, [EMAIL PROTECTED] ICQ: 6260644 -- Skype: a_engels ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] How to create array of variants?

2008-07-08 Thread Andre Engels
eed an array here. Just don't know the correct way > of doing it. So what does the code of line.SetXData(dataType, dataValue) look like? >From that code you should be able to discern what argument type is wanted. -- Andre Engels, [EMAIL PR

Re: [Tutor] I can't believe this needs to be this complex

2008-08-02 Thread Andre Engels
On Sat, Aug 2, 2008 at 11:07 AM, Dick Moores <[EMAIL PROTECTED]> wrote: > I'm pretty new to Python's dictionaries, but I had a need for a function > that would find the values in a dict that have more than one key each. It > took me several hours to write. See >

[Tutor] Python installing in root

2008-08-26 Thread Andre Engels
I am installing Python 2.5 using the Windows installer (running Vista). On my private computer this works as it should, but on my work computer, it installs in the root directory of C: whatever directory I specify it to be installed into. Is this a known problem, and does anybody know what to do ab

Re: [Tutor] Python installing in root

2008-08-26 Thread Andre Engels
On Tue, Aug 26, 2008 at 2:44 PM, Lie Ryan <[EMAIL PROTECTED]> wrote: > I have installed Python 2.5 on Windows Vista (Home Basic) on C:\Program > Files, so clearly this is not a global problem. My guess is that at the > work computer, you don't have write access to the directory you're > installing

Re: [Tutor] Hello and some questions.

2008-09-28 Thread Andre Engels
On Mon, Sep 29, 2008 at 1:36 AM, <[EMAIL PROTECTED]> wrote: > I did get some help in the python forums with this and I have come up the > following, but I am getting a syntax error on the line that calls out "total" > as a variable. Here is the code: The actual problem is in the previous line:

Re: [Tutor] How trustworthy are pseudo-random numbers?

2008-10-03 Thread Andre Engels
On Fri, Oct 3, 2008 at 4:11 PM, Daniele <[EMAIL PROTECTED]> wrote: > >From here > http://en.wikipedia.org/wiki/Pseudorandom_number_generator#Periodicity > and here > http://en.wikipedia.org/wiki/Mersenne_twister#Advantages > > I think it can be argued that the randomness is pretty trustworthy :o)

Re: [Tutor] How trustworthy are pseudo-random numbers?

2008-10-03 Thread Andre Engels
calculation will be about 10^460. The unnamed last number that way becomes something like 10^940 (in reality, because of all the rounding up, more like 10^930). That's less than 1/10^600 of 10^1600 - I'd say that's dwarved by any definition of the word. > On Fri, Oct 3, 2008 at 10:

Re: [Tutor] How trustworthy are pseudo-random numbers?

2008-10-03 Thread Andre Engels
On Fri, Oct 3, 2008 at 5:32 PM, Andre Engels <[EMAIL PROTECTED]> wrote: > On Fri, Oct 3, 2008 at 5:25 PM, Luke Paireepinart > <[EMAIL PROTECTED]> wrote: >> Is your math correct? That's ridiculously large. > > 1 year equals 3600 * 24 * 365 makes about 3*10

Re: [Tutor] Distinction between tuples and lists

2009-01-01 Thread Andre Engels
On Thu, Jan 1, 2009 at 3:07 PM, Christopher Mutel wrote: > Hello all- > > I stumbled across some discussion of why the fundamental difference > between lists and tuples is not mutability, but hetero- versus > homogeneous data, e.g. > > http://jtauber.com/blog/2006/04/15/python_tuples_are_not_just_

Re: [Tutor] Distinction between tuples and lists

2009-01-01 Thread Andre Engels
On Thu, Jan 1, 2009 at 3:43 PM, jadrifter wrote: > Both data types are indexed and both can contain homogeneous (same as) > or heterogeneous (different than) data. I get that lists are analogous > to a C linked lists as tuples are to C structs. I get that the > flexibility of one and the stabil

Re: [Tutor] tuple & object's attributes (changed)

2009-01-02 Thread Andre Engels
On Fri, Jan 2, 2009 at 10:37 PM, Kent Johnson wrote: > Forwarding to the list with comments. > > On Fri, Jan 2, 2009 at 2:47 PM, spir wrote: >> Now, remains one major question: >> Why do lists hold heterogeneous items? (Why did Guido do that choice, and >> then assert that >> lists are for homo

Re: [Tutor] Add all natural numbers that are multiples of 3 and 5

2009-01-03 Thread Andre Engels
On Sun, Jan 4, 2009 at 1:06 AM, Benjamin Serrato wrote: > Hello, > > I'm trying to correctly solve the first projecteuler.net problem. The > question is as so: Find the sum of all the multiples of 3 or 5 below 1000. > > I wrote the following program, but the number found is incorrect. I created >

Re: [Tutor] Add all natural numbers that are multiples of 3 and 5

2009-01-04 Thread Andre Engels
On Sun, Jan 4, 2009 at 3:43 AM, Benjamin Serrato wrote: > I think it does what I wanted it to do, but Kent pointed out I wanted > it to do was a false solution. So, I can create a list of all common > multiples below 1000, sum them, subtract them from 266 333. Or, what > I prefer, create a list

Re: [Tutor] Getting multi-line input from user

2009-01-06 Thread Andre Engels
On Wed, Jan 7, 2009 at 4:31 AM, wormwood_3 wrote: > On point 2, say I enter: > Enter text, 'done' on its own line to quit: > I am a sentence. I am another sentence. > > I am a new paragraph. > done > > What I get out is: > I am a sentence. I am another sentence. I am a new paragraph. > > But tha

Re: [Tutor] Convert values in a list back and forth from ints

2009-01-07 Thread Andre Engels
On Wed, Jan 7, 2009 at 9:45 AM, prasad rao wrote: > hello > Sorry to interject. > This class seems asymmetric. > Class Value: > def __init__(self,inte='',stri=''): > self.inte=inte > self.stri=stri > def setvalue(inte='',stri=''): > self.stri=str(self.inte) >

Re: [Tutor] re

2009-01-07 Thread Andre Engels
On Wed, Jan 7, 2009 at 10:57 AM, prasad rao wrote: > Hello > I am trying to get a value as integer and a string. class Value: > def __init__(self,inte='',stri=''): > self.inte=inte > self.stri=stri > def setvalue(self,inte='',stri=''): > self.stri=str(

Re: [Tutor] Brand new to python have simple problem

2009-01-07 Thread Andre Engels
On Wed, Jan 7, 2009 at 7:06 AM, mickth wrote: > > I'm brand new to python and every time i start to learn it i get the same > problem and end up giving up and moving on to another language. > > the print statement doesn't work in either the comand line or IDLE i get > this in IDLE: > SyntaxError:

Re: [Tutor] lists and Entry

2009-01-14 Thread Andre Engels
On Wed, Jan 14, 2009 at 11:52 AM, Mr Gerard Kelly wrote: > There is a little Tkinter program. It lets you type something in a box, > and will display it at the command line. > > > from Tkinter import * > > master = Tk() > > e = Entry(master) > e.pack() > > e.focus_set() > > def callback(): > s=e.

Re: [Tutor] strings and int()

2009-01-15 Thread Andre Engels
On Thu, Jan 15, 2009 at 1:14 AM, Mr Gerard Kelly wrote: > If you have a string "6", and you do int("6"), you get the number 6. > > But if you have a string "2*3" and you do int("2*3") you get a name error. > > How do you take an expression in a string, and evaluate the expression > to get a number

Re: [Tutor] eval and floating point

2009-01-15 Thread Andre Engels
On Thu, Jan 15, 2009 at 1:08 PM, Alan Gauld wrote: > > "Mr Gerard Kelly" wrote > >> I've noticed that the eval() function gives an integer, so eval("3/2") >> gives back 1. float(eval("3/2")) doesn't seem to work, any way to get a >> floating point number back with eval()? > > Move the float insid

Re: [Tutor] "Pointer" to a function? Storing a function as an object property? Passing arguments by value/by reference?

2009-01-16 Thread Andre Engels
On Fri, Jan 16, 2009 at 1:51 PM, Vicent wrote: > I am posting this question to two Python forums: Tutor and Python(x,y). > > In the case of Tutor [1], I think it's the right place to ask questions for > a newbie like me. > > In the case of Python(x,y) Discussion Group [2], I am posting also becaus

Re: [Tutor] calculator will not multiply

2009-01-18 Thread Andre Engels
On Sun, Jan 18, 2009 at 4:37 PM, David wrote: > Everything else works + - / but not * > why? > thanks > -david It works for me. However, I do have another issue with your code: > def compute(arg1, arg2, arg3): >if sys.argv[2] == "+": >total = add(int(sys.argv[1]), int(sys.argv[3]))

Re: [Tutor] calculator will not multiply

2009-01-18 Thread Andre Engels
There's an editing error in my previous message. The corrected function should not be: def compute(arg1, arg2, arg3): if sys.arg2 == "+": total = add(int(sys.arg1), int(sys.arg3)) print total elif sys.arg2 == "-": total = sub(int(sys.arg1), int(sys.arg3)) print t

Re: [Tutor] cube root

2009-01-19 Thread Andre Engels
On Mon, Jan 19, 2009 at 12:11 PM, Brett Wilkins wrote: > The only language I've run into so far (I haven't used many, mind) that > doesn't have this issue is Scheme :) > (Just learning it at the moment.) It doesn't? That would surprise me. The only one that I know to do this kind of thing correct

Re: [Tutor] cube root

2009-01-19 Thread Andre Engels
On Mon, Jan 19, 2009 at 1:13 PM, spir wrote: > Do you know any common algorithm to convert decimal (in the sense of > fractional) decimals (in the sense of base 10 numbers) into binaries? > > 123.456 --> 011.bbb... > and/or > 123456 * 10**(-3) --> bbb... * 2**(-bbb...) >

Re: [Tutor] fetching wikipedia articles

2009-01-22 Thread Andre Engels
On Thu, Jan 22, 2009 at 6:08 PM, amit sethi wrote: > hi , I need help as to how i can fetch a wikipedia article i tried changing > my user agent but it did not work . Although as far as my knowledge of > robots.txt goes , looking at en.wikipedia.org/robots.txt it does not seem it > should block a

Re: [Tutor] fetching wikipedia articles

2009-01-23 Thread Andre Engels
On Fri, Jan 23, 2009 at 9:09 AM, amit sethi wrote: > Well that is interesting but why should that happen in case I am using a > different User Agent because I tried doing > status=rp.can_fetch('Mozilla/5.0', > "http://en.wikipedia.org/wiki/Sachin_Tendulkar";) > but even that returns false > Is th

Re: [Tutor] fetching wikipedia articles

2009-01-23 Thread Andre Engels
On Fri, Jan 23, 2009 at 10:37 AM, amit sethi wrote: > so is there a way around that problem ?? Ok, I have done some checking around, and it seems that the Wikipedia server is giving a return code of 403 (forbidden), but still giving the page - which I think is weird behaviour. I will check with t

Re: [Tutor] fetching wikipedia articles

2009-01-23 Thread Andre Engels
On Fri, Jan 23, 2009 at 11:25 AM, Andre Engels wrote: > In the __init__ of the class URLopener, add the following at the end: > > self.addheaders = [header for header in self.addheaders if header[0] > != "User-Agent"] + [('User-Agent', '')] > &g

Re: [Tutor] fetching wikipedia articles

2009-01-23 Thread Andre Engels
On Fri, Jan 23, 2009 at 12:07 PM, amit sethi wrote: > well thanks ... it worked well ... but robotparser is in urllib isn't there > a module like robotparser in > urllib2 You'll have to ask someone else about that part... -- André Engels, andreeng...@gmail.com _

Re: [Tutor] fetching wikipedia articles

2009-01-23 Thread Andre Engels
On Fri, Jan 23, 2009 at 11:25 AM, Andre Engels wrote: > On Fri, Jan 23, 2009 at 10:37 AM, amit sethi > wrote: >> so is there a way around that problem ?? > > Ok, I have done some checking around, and it seems that the Wikipedia > server is giving a return code of 403 (

Re: [Tutor] finding words that contain some letters in their respective order

2009-01-23 Thread Andre Engels
On Sat, Jan 24, 2009 at 12:02 AM, Emad Nawfal (عماد نوفل) wrote: > Hello Tutors, > Arabic words are build around a root of 3 or 4 consonants with lots of > letters in between, and also prefixes and suffixes. > The root ktb (write) for example, could be found in words like: > ktab : book > mktob: l

Re: [Tutor] finding words that contain some letters in their respective order

2009-01-23 Thread Andre Engels
I made an error in my program... Sorry, it should be: def hasRoot(word, root): # This order I find more logical loc = 0 for letter in root: loc = word.find(letter,loc) # I missed the ,loc here... if loc == -1: return false return true # main infile = open("my

Re: [Tutor] finding words that contain some letters in their respective order

2009-01-23 Thread Andre Engels
2009/1/24 Emad Nawfal (عماد نوفل) : > > > 2009/1/23 Emad Nawfal (عماد نوفل) >> >> >> On Fri, Jan 23, 2009 at 6:57 PM, Andre Engels >> wrote: >>> >>> I made an error in my program... Sorry, it should be: >>> >>> def hasRoot(

Re: [Tutor] Defining "bit" type -- why not '!' ?

2009-01-29 Thread Andre Engels
On Thu, Jan 29, 2009 at 10:19 AM, spir wrote: > Why not '!' for not, instead of '~'? I mean, '!' is used in logic, in many > languages and even in python (!=). On the other hand, I had never encountered > '~' meaning not. Although ! is indeed usual in computer languages, I disagree when you sa

Re: [Tutor] Properties of an object

2009-01-29 Thread Andre Engels
On Thu, Jan 29, 2009 at 7:59 PM, Vicent wrote: > This is an easy question, I guess, but I am not able to find out the answer. > > In fact, it is both a Python question and a general programming "style" > question. > > I want to define a class that contains a list (or a NumPy array) of elements > o

Re: [Tutor] methods split and join in sequence

2009-01-31 Thread Andre Engels
On Sat, Jan 31, 2009 at 4:09 PM, David wrote: > Dear list, > > many thanks for all your help - much appreciated. > Today I have continued reading Harrington, and produced the following code, > which works flawlessly. > I wonder, though, how I could join all the supplied words with underscores > _w

[Tutor] Re : Is instance of what?

2009-01-31 Thread Andre Engels
On Sat, Jan 31, 2009 at 5:57 PM, Tim Johnson wrote: > Using python 2.5.1 > > If I create a class a > > class a: > > pass > > initialize o as: > > o=a > > and call > > isinstance(o,a) > > the return value is True. Actually, it is false. To make it true, you have to do o=a() rather than o=a > Is t

Re: [Tutor] newton's square root formula

2009-02-03 Thread Andre Engels
On Tue, Feb 3, 2009 at 3:59 AM, WM. wrote: > # program to find square root > square = float(raw_input ("Please enter a number to be rooted, ")) > guess = input("Please guess at the root, ") > i = 0 > while guess**2 != square: >i+=1 ># Newton's formula >guess = guess - (gues

Re: [Tutor] re division problem

2009-02-03 Thread Andre Engels
On Tue, Feb 3, 2009 at 2:46 PM, prasad rao wrote: > hi >>Right now you skip by x+((len(v))/columns) >>which will be different for each row. > How is it possible. len(v)=98.A constant. > Is it not. > Does len(v) changes with each iteration? No, but x does. -- André Engels, andreeng...@gmail.com

Re: [Tutor] transforming an integer to a list of integers

2009-02-03 Thread Andre Engels
On Tue, Feb 3, 2009 at 4:17 PM, H.G. le Roy wrote: > Hi, > > recently I learned about Project Euler (http://projecteuler.net/) and now > I'm trying to work me through. At the moment I'm thinking about > http://projecteuler.net/index.php?section=problems&id=8 > > One step for my solution should be

Re: [Tutor] transforming an integer to a list of integers

2009-02-03 Thread Andre Engels
On Tue, Feb 3, 2009 at 4:24 PM, Andre Engels wrote: > On Tue, Feb 3, 2009 at 4:17 PM, H.G. le Roy wrote: >> Hi, >> >> recently I learned about Project Euler (http://projecteuler.net/) and now >> I'm trying to work me through. At the moment I'm thinking about

Re: [Tutor] weird bool

2009-02-03 Thread Andre Engels
On Tue, Feb 3, 2009 at 11:40 AM, prasad rao wrote: > hi a=2.1 a%1==True > False a%1==False > False b=3.8 b%1==True > False b%1==False > False > If it gives correct bool, it could be put to good use. == gives a high degree of equality. In your idea, it would not be a

Re: [Tutor] reading file, adding to each line, writing file

2009-02-04 Thread Andre Engels
On Wed, Feb 4, 2009 at 3:30 PM, David wrote: > Hello everybody, > > I have easily spent some four hours on this problem, and I am now asking for > rescue. > > Here is what I am trying to do: I have a file ("step2", with some 30 or so > lines. To each line I would like to add " -d" at the end. Fina

Re: [Tutor] noob

2010-11-29 Thread Andre Engels
On Mon, Nov 29, 2010 at 6:57 AM, Mary wrote: > Dear Tutors: > > Thank you for your time.I am trying to do first assignment (ps1a+b) onMIT > open study, finding the 1000th prime in part a and doing something with > import.math and logs in part b, but I'm not there yet. The little build i > did to f

Re: [Tutor] age program

2010-11-29 Thread Andre Engels
We will not make your homework for you. However, we may well give you hints and perhaps solve small parts that you are unable to do yourself. For that, however, we need to know *what* it is that you are having problems with. Thus: You said that you have tried everything you can. What have you trie

Re: [Tutor] Composing lists from both items and other lists

2011-02-01 Thread Andre Engels
On Tue, Feb 1, 2011 at 9:40 PM, John Simon wrote: > I'm looking for a way to flatten lists inside a list literal, kind of like > this: > start = '(' end = ')' items = ['abc', '+', 'def'] [start, *items, end] > ['(', 'abc', '+', 'def', ')'] > Of course, the star doesn't work the

Re: [Tutor] help

2011-02-24 Thread Andre Engels
On Thu, Feb 24, 2011 at 5:15 AM, Chris Schiro wrote: > Hi, > > I am completely new to programming aside from working with basic many years > ago. I purchased a Python book for beginners so I could start from scratch > which has been walking me through just fine until: writing a program to > intera

Re: [Tutor] Convert string to long

2011-02-24 Thread Andre Engels
On Thu, Feb 24, 2011 at 3:03 PM, tee chwee liong wrote: '0x' + hex(543)[2:].zfill(5) > '0x0021f' > > this is a good way but it's still in string format. but if i convert it to > long, then the leading 0s will be truncated. i guess can't have it both way. A long is just a number. You cannot s

Re: [Tutor] Does try-except "lock out scope" or similar?

2011-03-07 Thread Andre Engels
On Tue, Mar 8, 2011 at 5:40 AM, Benjamin Serrato wrote: > I wrote a short script to clean up a csv file but had trouble when > date_time = time.strptime(date_string, "%m/%d/%y") >  would choke on intermittent Null characters in the file.  I put it into a > try-except, but then I found I couldn't d

Re: [Tutor] Need help with dates in Python

2011-03-09 Thread Andre Engels
On Wed, Mar 9, 2011 at 9:21 AM, nookasree ponamala wrote: > Hi, > > I need help in finding the minimum date and maximum date in a file. > Here is my test file: > s.no:   dt1     amt     id1     id2 > 452     2010-02-20      $23.26      059542        06107 > 452     2010-02-05      $20.78      0595

Re: [Tutor] Static Variable in Functions

2011-03-14 Thread Andre Engels
On Mon, Mar 14, 2011 at 9:56 AM, Alan Gauld wrote: > "Yasar Arabaci" wrote > >> >>> a=["a"] >> >>> b=[a] >> >>> a.append("c") >> >>> b >> [['a', 'c']] >> >> Apperantly, I can change something (which is mutable) inside  a list >> without even touching the list itself :) > > But the point is that y

Re: [Tutor] Efficiency of while versus (x)range

2011-03-17 Thread Andre Engels
On Thu, Mar 17, 2011 at 8:45 AM, Stefan Behnel wrote: > Note that a web application involves many things outside of your own code > that seriously impact the performance and/or resource requirements. Database > access can be slow, excessively dynamic page generation and template engines > can bec

Re: [Tutor] what is it mean--- File "", line 1

2011-03-20 Thread Andre Engels
On Mon, Mar 21, 2011 at 1:58 AM, sihong lin wrote: > Hi, > > I just write a simplest file test.py with only one line--print "hello", > when I run it in command line: > >>> python test.py > > the follow message comes out: > > File "" , line 1 > python test > > SyntaxError: invalid syntax > > but

Re: [Tutor] Recursively flatten the list

2011-03-24 Thread Andre Engels
2011/3/24 Rafael Durán Castañeda : > I can do it with two list comprehensions: > list_ = [1, 2, [3, 4], 5, [6, 7, 8], 9] [x[i] for x in list_ if isinstance(x, list) for i in range(len(x))] + [x for x in list_ if not isinstance(x, list)] > [3, 4, 6, 7, 8, 1, 2, 5, 9] > > But i lo

Re: [Tutor] Removing values from a dictionary if they are present in a list

2011-04-01 Thread Andre Engels
On Fri, Apr 1, 2011 at 9:52 AM, ranjan das wrote: > I have the following information > > A={'g2': [4,5,3], 'g1': [1, 3]} > > B=[2,3,5] > > Now I want to remeove the elements in B if they are present (as values) in > dictionary A. > > My expected solution is > > A= {'g2': [4], 'g1': [1] } > > I wro

Re: [Tutor] Passing a Variable

2011-04-04 Thread Andre Engels
On Mon, Apr 4, 2011 at 7:27 AM, Ryan Strunk wrote: >> I've read your code. Frankly I don't understand your problem. I also don't > see any occurrence of "health". > There isn't a reference to health here. My goal is to have this code act as > a checker for health, fatigue, time_remaining, or any o

Re: [Tutor] (sqlite3) Testing if a table has been created.

2011-04-06 Thread Andre Engels
On Wed, Apr 6, 2011 at 4:06 PM, michael scott wrote: > Is this really a python tutor question? Oh, well, try this: > http://lmgtfy.com/?q=sqlite+test+if+table+exists > > -- > Joel Goldstick > > > My apologies, I was not aware that there were questions I could and could > not ask. I understand n

Re: [Tutor] Help needed

2011-04-08 Thread Andre Engels
On Fri, Apr 8, 2011 at 3:57 AM, Aaron Brown wrote: > I am in an online python class and am failing badly.  I am not sure where > the problem is here but any insight would be great. > > def main(): >     while (True): >     allowed = int(input("Please enter minutes allowed between 100 and > 700

Re: [Tutor] A Dictionary question

2011-04-11 Thread Andre Engels
On Mon, Apr 11, 2011 at 1:01 PM, Sophie DeNofrio wrote: > Hi Everyone, > > I am a super beginner and am little muddled right now. So I apologize for > the low level question but I am trying to write a function that will return > a dictionary of a given list of strings containing two coordinates se

Re: [Tutor] Combining two Dictionaries

2011-04-30 Thread Andre Engels
On Sun, May 1, 2011 at 5:49 AM, Ryan Strunk wrote: > When I initialize the class which holds these dictionaries, though, I need > to make sure that all the keys contained in d2 match the keys of d1. Thus I > tried: > d1 = {'a': 0, 'b': 0, 'c': 0} > d2 = d1 > My understanding was that d2 looked at

Re: [Tutor] triple-nested for loop not working

2011-05-05 Thread Andre Engels
I have not checked the rest of your code, but: > for line in seqalign: >     for i in len(finalmotif_seqs):      # for item in finalmotif_seqs: >         for i in len(finalmotif_annot):     # for item in finalmotif_annot: I see two problems here: 1. You are using the same loop variable in both lo

Re: [Tutor] assigning a variable a value

2011-05-05 Thread Andre Engels
On Thu, May 5, 2011 at 2:19 AM, Kyle Benak wrote: > I am learning python and I am trying to write a simple "guess the number" > game. I wrote the program in the IDLE, and I set the variable tries=1 to > keep up with the number of tries it takes to guess the number, but when I > try to run the pro

Re: [Tutor] Python Hard_way 40

2011-05-11 Thread Andre Engels
On Wed, May 11, 2011 at 5:24 PM, Robert . wrote: > Hi all, > > My first post ever! :) > I'm following the guide "Learn Python the Hard Way" and have reached a point > where I am struggling to understand the code and unfortunately the authors > guide hasn't cleared it up for me. (excercise 40 for r

Re: [Tutor] how to read two files and substitute

2011-05-17 Thread Andre Engels
First read file1, and keep the result in a useful data structure (for this simple case it can be nothing more than a dictionary with the value in column 1 as key and the value in column 4 as value, but perhaps it's better to find something else if you want to do more with the data). Then go through

Re: [Tutor] Please help, the program is not behaving as I want

2011-05-17 Thread Andre Engels
I am not able to check your code (I get an error message about the usage of urllib, but that might be a difference in Python installations); however, my first guess is that you neglected to take case into account: The page contains the text "Water", not "water", so if you input "water", halal_haram

Re: [Tutor] Data conversion

2011-05-18 Thread Andre Engels
On Thu, May 19, 2011 at 6:36 AM, Joe Aquilina wrote: > I am new to this list and very much a beginner to Python. Please excuse me > if this is a silly question, but in all my searches this morning I have not > been able to find an answer. > > I have a (single table) database file (SQLite3). It ha

Re: [Tutor] Data conversion

2011-05-19 Thread Andre Engels
On Thu, May 19, 2011 at 8:15 AM, Joe Aquilina wrote: > I realised after I read your response that I probably hadn't included enough > information, partly due to my  inexperience in Python and partly due to > haste on my part. > > AFter my original post, I had a little play in Python and was able

Re: [Tutor] Python Variables Changing in Other Functions

2011-05-24 Thread Andre Engels
On Wed, May 25, 2011 at 6:14 AM, Rachel-Mikel ArceJaeger wrote: > I am having trouble with determining when python is passing by reference and > by value and how to fix it to do what I want: > > I am writing a program that will take in a list of book titles and will allow > many people to rank

Re: [Tutor] if statement

2011-06-07 Thread Andre Engels
On Tue, Jun 7, 2011 at 11:26 PM, Matthew Brunt wrote: > i'm very new to python (currently going through a python for beginners > book at work to pass the time), and i'm having trouble with an if > statement exercise.  basically, i'm creating a very simple password > program that displays "Access G

Re: [Tutor] Step Value

2011-06-17 Thread Andre Engels
On Fri, Jun 17, 2011 at 11:03 PM, Alan Gauld wrote: > > "Vincent Balmori" wrote > >> Here is my updated code. As simple as this may be, I am a little lost >> again. > > I'm not sure why you are lost because that's pretty much it. > >> ... at this point (especially after one week) this is when me

Re: [Tutor] Using class methods

2011-06-21 Thread Andre Engels
On Tue, Jun 21, 2011 at 10:12 AM, David Merrick wrote: > I need help using Class methods in another class. I have a class called > Critter and I want to create two critters in a farm  Class Farm and use > Class Critter's methods Could you please specify where your current code does not suffice -

Re: [Tutor] Trivia

2011-06-24 Thread Andre Engels
On Fri, Jun 24, 2011 at 8:56 AM, Vincent Balmori wrote: > > << > point = int(next_line(the_file)) > > If x is a string that can be interpreted as an integer number, int(x) is > that integer number; if the string is not the representation of an integer, > this will lead to a ValueError. > > -- > An

Re: [Tutor] Blackjack Betting

2011-07-01 Thread Andre Engels
On Fri, Jul 1, 2011 at 9:29 AM, Vincent Balmori wrote: > > Here is the other one that occurs when I lose > > Traceback (most recent call last): > File > > "/Users/vincentbalmori/Desktop/Python/py3e_source/chapter09/blackjackbetting.py", > line 240, in >main() > File > > "/Users/vincentbalmo

Re: [Tutor] getting error while solving a series that estimates the value of pi

2011-07-18 Thread Andre Engels
On Mon, Jul 18, 2011 at 6:10 PM, surya k wrote: > Hi, > > The problem is to estimate the value of pi using the following series. > *1 / pi = (( 2 * sqrt(2) )/ 9801 ) * SIGMA of k[ (4k)! (1103 + 26390*k) > / (k!^ 4 ) * 396^(4k) ]* > *where k is [0, infinity)* > * Problem is located at : ThinkP

Re: [Tutor] NameError: is defined

2011-07-19 Thread Andre Engels
On Wed, Jul 20, 2011 at 4:37 AM, brandon w wrote: > ** > Hi > I am running Linux with Python 2.6.6. I have done lists, tuples, > dictionaries, etc. Now I want to move on to creating a "class". I keep > getting an error for everything I try. Here is the error: * > > NameError: name 'MyClass' is no

Re: [Tutor] List problem

2011-07-24 Thread Andre Engels
On Mon, Jul 25, 2011 at 4:19 AM, David Merrick wrote: > def append(self,item): > '''Adds an item to the end of the List''' > > current = self.head > previous = None > while current.getNext() != None: > previous = current > current

Re: [Tutor] Puzzled again

2011-08-02 Thread Andre Engels
On Wed, Aug 3, 2011 at 8:07 AM, Richard D. Moores wrote: > On Tue, Aug 2, 2011 at 21:59, Dave Angel wrote: > > > When I paste that from your email into a file and run Python 2.7 on it, > it > > behaves fine with no errors. That's in Linux. > > I should have said that I'm using Wing IDE Professio

Re: [Tutor] How have I transgressed??

2011-08-21 Thread Andre Engels
On Sun, Aug 21, 2011 at 7:25 PM, Emile van Sebille wrote: > On 8/21/2011 10:08 AM Lisi said... > > I have just received the following.* In what way have I transgressed? I >> apologise to you all - but as I mentioned, I had been stuck for weeks and >> am >> running out of time. And I certainly

Re: [Tutor] Syntax error with if statement

2011-08-24 Thread Andre Engels
On Wed, Aug 24, 2011 at 7:40 PM, Ray Parrish wrote: > Hello, > > I haven't been programming for a while and today I am working on something > and have encountered an error I cannot figure out. > > Here is my code: > > thisFile = column[6] > if thisFile == "/Images/My%20Face.JPG"

Re: [Tutor] Finding the differences between two lists

2011-08-25 Thread Andre Engels
On Thu, Aug 25, 2011 at 9:08 PM, Justin Wendl wrote: > Hi John, > > Thanks for the quick response. Unfortunately it is returning the same > result.. > > This is caused by the else: break part of the the code. Break breaks out of the loop, thus you skip all following elements if you go throu

Re: [Tutor] a quick Q: what does the "collapse" mean?

2011-09-08 Thread Andre Engels
On Thu, Sep 8, 2011 at 4:16 PM, lina wrote: > On Thu, Sep 8, 2011 at 9:59 PM, Alan Gauld > wrote: > > On 08/09/11 14:02, lina wrote: > >> > >> Hi, > >> > >> I failed to understand the "collpase" meaning in a string. > >> > >> can someone give me a simple example? > > > > Can you give us some con

Re: [Tutor] making lists of prime numbers

2011-09-14 Thread Andre Engels
On Thu, Sep 15, 2011 at 4:01 AM, c smith wrote: > hi list, i am trying the MIT opencourseware assignments. > one was to find the 1000th prime. > since this isn't actually my homework, I modified the solution as I would > like to collect lists of primes and non-primes up to N, also some log() > rat

Re: [Tutor] IndentationError:

2011-11-16 Thread Andre Engels
On Wed, Nov 16, 2011 at 9:21 AM, lina wrote: > it still complaining. I set the gedit, use space not tab, > Now I even typed space by space, avoid using tab, it still has the same > problem. > > How can I fixed it? > The line if list1[i][j] != list1[i][j+1]: still contains a tab, th

Re: [Tutor] (no subject)

2011-11-17 Thread Andre Engels
On Thu, Nov 17, 2011 at 2:14 PM, Nidian Job-Smith wrote: > Hi all, > > I'm new to programming (thus Python), so after reading the > basics, I wanted to practise what I've learnt . I've come across a > beginners exercise which is to programme rot13. > > I've written some code but it doesn't seem t

Re: [Tutor] new to python

2017-07-25 Thread Andre Engels
The problem here is that you have doubled the "for line in f:" line. Given that you say you know some programming, I'll just cut to the technical name of the problem you are having: You are changing the value of a loop variable (by starting an inner loop with the same loop variable) inside a loop.

<    1   2