Re: [Tutor] Dictionary Issue

2015-08-06 Thread Alan Gauld
On 07/08/15 01:15, Ltc Hotspot wrote: Question1: How type of argument should I use for dict, i.e.,user argument or list argument. Read captured traceback: TypeError Traceback (most recent call last) C:\Users\vm\Desktop\apps\docs\Python\assignment_9_4_26.py in () 1 fname = raw_input("Ente

Re: [Tutor] Fraction Class HELP ME PLEASE!

2015-08-06 Thread Quiles, Stephanie
Hello again Cameron, Thank you, your reply is most helpful. Responses and updated code below. Thoughts would be appreciated. The assignment has been sent as my deadline was 11pm EST. But i was able to implement your suggestions and tips right before i submitted. responses are below and here is

Re: [Tutor] Fraction Class HELP ME PLEASE!

2015-08-06 Thread Quiles, Stephanie
thanks Cameron! Here is what i have so far… new question… how do i test the iadd, imul, etc. operators? Hopefully this time the indents show up. And yes the beginning code came out of our text book I added on some functions myself but they give you a big chunk of it. I am hoping that this is wha

Re: [Tutor] Dictionary Issue

2015-08-06 Thread Ltc Hotspot
Mark, I'm following the instructor's video exercise, available at https://www.youtube.com/watch?v=3cwXN5_3K6Q. View attached screen shot file, image file shows a copy of the counter: cou[wrd] =cou.get(wrd,0) +1 Please, explain the differences in counter methods? Hal On Thu, Aug 6, 2015 at 4

Re: [Tutor] Dictionary Issue

2015-08-06 Thread Ltc Hotspot
Question1: How type of argument should I use for dict, i.e.,user argument or list argument. Read captured traceback: TypeError Traceback (most recent call last) C:\Users\vm\Desktop\apps\docs\Python\assignment_9_4_26.py in () 1 fname = raw_input("Enter file name: ") 2 handle = open (fn

Re: [Tutor] Fraction Class HELP ME PLEASE!

2015-08-06 Thread Cameron Simpson
On 06Aug2015 23:50, Quiles, Stephanie wrote: thanks Cameron! Here is what i have so far… new question… how do i test the iadd, imul, etc. operators? Like the others, by firing them. You test __add__ by running an add between two expressions: F1 + F2 You test __iadd__ by running the augmen

Re: [Tutor] Dictionary Issue

2015-08-06 Thread Mark Lawrence
On 06/08/2015 20:05, Ltc Hotspot wrote: On my breath and soul, I did: Counter objects have a dictionary interface except that they return a zero count for missing items instead of raising a KeyError : That's nice to know. What do the

Re: [Tutor] Dictionary Issue

2015-08-06 Thread Alan Gauld
On 07/08/15 00:11, Ltc Hotspot wrote: Questions(1):Why does print line, prints blank space; and, (2) print address prints a single email address: See my previous emails. You are not storing your addresses so address only holds the last address in the file. line is at the end of the file so is

Re: [Tutor] Dictionary Issue

2015-08-06 Thread Ltc Hotspot
On Thu, Aug 6, 2015 at 3:00 PM, Alan Gauld wrote: > On 06/08/15 19:30, Ltc Hotspot wrote: > > I moved counter outside the loop and below dict, maxval = None >> maxkee = None are both positioned outside the loop. >> > > You moved counter but it is still a dict() and you > don't use it anywhere. >

Re: [Tutor] About python intrepeters on Android.

2015-08-06 Thread Alan Gauld
On 06/08/15 23:22, Ali Moradi wrote: Hi, i noticed that the Python intrepeters on Android OS does not have Tkinter! Why they couldn't bring Tkinter on Android too? Two reasons: 1) Tkinter is just a thin wrapper around the Tcl/Tk UI toolkit. If Tk isn't on Android then Tkinter will not be.

[Tutor] About python intrepeters on Android.

2015-08-06 Thread Ali Moradi
Hi, i noticed that the Python intrepeters on Android OS does not have Tkinter! Why they couldn't bring Tkinter on Android too? It there anyway ti use tkintr on android too ? Tnx :) ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscrip

Re: [Tutor] Dictionary Issue

2015-08-06 Thread Alan Gauld
On 06/08/15 19:30, Ltc Hotspot wrote: I moved counter outside the loop and below dict, maxval = None maxkee = None are both positioned outside the loop. You moved counter but it is still a dict() and you don't use it anywhere. URL link to the revisions are available at http://tinyurl.com/nvz

Re: [Tutor] Fraction Class HELP ME PLEASE!

2015-08-06 Thread Cameron Simpson
On 06Aug2015 16:55, Quiles, Stephanie wrote: I need to do the following assignment. I need to know how do i hard code an example for each of the operators I am implementing? What i have so far is below? He said he does not care if we plug in some numbers or if we have user input numbers, howev

Re: [Tutor] Dictionary Issue

2015-08-06 Thread Ltc Hotspot
On my breath and soul, I did: Counter objects have a dictionary interface except that they return a zero count for missing items instead of raising a KeyError : >>> >>> c = Counter(['eggs', 'ham']) On Thu, Aug 6, 2015 at 11:59 AM, Mark

Re: [Tutor] who makes FOR loop quicker

2015-08-06 Thread John Doe
Thank You, Alan. This is THE FIRST time, when I've got a pleasure from the opponent. You're maintain status of a thinking human and, as a humble DAOist, I always say THANK YOU, when I talk to such a Man. 'Cause wisdom bring us the beauty. So, what else I can add. Just a little bit. It would b

Re: [Tutor] Dictionary Issue

2015-08-06 Thread Ltc Hotspot
Mark, Visit the following URL link to view a captured copy of the latest code revision, available at http://tinyurl.com/nvzdw8k Regards, Hal On Thu, Aug 6, 2015 at 10:17 AM, Ltc Hotspot wrote: > > > On Thu, Aug 6, 2015 at 8:28 AM, Mark Lawrence > wrote: > >> On 06/08/2015 05:22, Ltc Hotspot w

Re: [Tutor] Dictionary Issue

2015-08-06 Thread Ltc Hotspot
Hi Alan, I moved counter outside the loop and below dict, maxval = None maxkee = None are both positioned outside the loop. URL link to the revisions are available at http://tinyurl.com/nvzdw8k Question: How do I define Counter Revised code reads: fname = raw_input("Enter file name: ") handle =

Re: [Tutor] Dictionary Issue

2015-08-06 Thread Alan Gauld
On 06/08/15 18:17, Ltc Hotspot wrote: Replace count[address]= count.get(address,0) +1 with c = Counter(['address'])? You didn't do what Mark suggested. Did you read the documentation about Counter? NameError Traceback (most recent call last) 2 handle = open (fname, 'r') > 3 c =

Re: [Tutor] Dictionary Issue

2015-08-06 Thread Mark Lawrence
On 06/08/2015 18:17, Ltc Hotspot wrote: On Thu, Aug 6, 2015 at 8:28 AM, Mark Lawrence wrote: On 06/08/2015 05:22, Ltc Hotspot wrote: Please don't top post here, it makes following long threads difficult. Mark, Replace count[address]= count.get(address,0) +1 with c = Counter(['address'])?

Re: [Tutor] who makes FOR loop quicker

2015-08-06 Thread Alan Gauld
On 06/08/15 14:28, John Doe wrote: Well, I think, both of us understands that any reference isn't about any sort of a language. It's about REGISTER = [ALU, FPU, ...] No thats about the implementation. The language and implemewntation are completely separate. There can be many different impleme

Re: [Tutor] Dictionary Issue

2015-08-06 Thread Alan Gauld
On 06/08/15 18:17, Ltc Hotspot wrote: View revised code here: fname = raw_input("Enter file name: ") handle = open (fname, 'r') c = Counter(['address']) count = dict () maxval = None maxkee = None for kee, val in count.items(): maxval = val maxkee = kee for line in handle:

Re: [Tutor] who makes FOR loop quicker

2015-08-06 Thread John Doe
Well... Try this look. But I'm just a human and can make mistakes.:)) Passing value - allocates stack and creates NEW memory position. Passing reference - makes stack pointer pointing to any position. Dereference - makes stack pointer pointing to any position AND TAKES VALUE. So, You can count

Re: [Tutor] who makes FOR loop quicker

2015-08-06 Thread John Doe
Thank You, Steven. I've already written to Your colleague, so You will can see about. And when I'm saying 'ALLOCATION' I keep in mind the REGISTER, not a glossary or thesaurus. Language is created for us, not for CPU. Do You agree? Passing VALUE is a time-expensive procedure. Python can't rea

Re: [Tutor] Dictionary Issue

2015-08-06 Thread Ltc Hotspot
On Thu, Aug 6, 2015 at 8:28 AM, Mark Lawrence wrote: > On 06/08/2015 05:22, Ltc Hotspot wrote: > > Please don't top post here, it makes following long threads difficult. > > Mark, >> >> Replace count[address]= count.get(address,0) +1 with c = >> Counter(['address'])? >> > > Try it at the intera

Re: [Tutor] who makes FOR loop quicker

2015-08-06 Thread John Doe
Well, I think, both of us understands that any reference isn't about any sort of a language. It's about REGISTER = [ALU, FPU, ...] That's why reference inevitable. While You're talking about Python - You're talking ONLY about interpreter for a BYTEcode Alas, CPU don't speak BYTEcode but BITco

[Tutor] Fraction Class HELP ME PLEASE!

2015-08-06 Thread Quiles, Stephanie
Hello All, I need to do the following assignment. I need to know how do i hard code an example for each of the operators I am implementing? What i have so far is below? He said he does not care if we plug in some numbers or if we have user input numbers, however I am unsure of how to write a pr

[Tutor] Problem with battleship game

2015-08-06 Thread asets...@gmail.com
Hello. I'm writing battleship game. I have one class for bot field:https://bpaste.net/show/b3ddcd7724f4 and one class for player field:https://bpaste.net/show/6a7981fb4634 I made class for player field from bot field class. For some reason I can't place ship properly for player. Full text of

Re: [Tutor] how to define constant width errorbars on log-log plot

2015-08-06 Thread Laura Creighton
In a message of Thu, 06 Aug 2015 12:41:22 -0300, Colin Ross writes: >Does anyone have an example code that shows how to plot errorbars with a >constant line width for a dataset on a log log plot? Thank you. Assuming you want to use matplotlib (there are other python programs that do this) see: h

Re: [Tutor] how to define constant width errorbars on log-log plot

2015-08-06 Thread Mark Lawrence
On 06/08/2015 16:41, Colin Ross wrote: Does anyone have an example code that shows how to plot errorbars with a constant line width for a dataset on a log log plot? Thank you. Directly no, but is there anything from one or more of the examples here http://matplotlib.org/gallery.html that you

[Tutor] how to define constant width errorbars on log-log plot

2015-08-06 Thread Colin Ross
Does anyone have an example code that shows how to plot errorbars with a constant line width for a dataset on a log log plot? Thank you. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailma

Re: [Tutor] Dictionary Issue

2015-08-06 Thread Mark Lawrence
On 06/08/2015 05:22, Ltc Hotspot wrote: Please don't top post here, it makes following long threads difficult. Mark, Replace count[address]= count.get(address,0) +1 with c = Counter(['address'])? Try it at the interactive prompt and see what happens. Regards, Hal On Wed, Aug 5, 2015 at

Re: [Tutor] who makes FOR loop quicker

2015-08-06 Thread Steven D'Aprano
On Thu, Aug 06, 2015 at 08:57:34AM -0400, Joel Goldstick wrote: > On Thu, Aug 6, 2015 at 4:34 AM, John Doe wrote: > > Can You, please, elaborate this "..Passing in Python is different than in C > > or other languages..." > > > I hesitate, because this question is usually the fuel of flaming wars.

Re: [Tutor] who makes FOR loop quicker

2015-08-06 Thread Steven D'Aprano
On Thu, Aug 06, 2015 at 11:34:51AM +0300, John Doe wrote: > Can You, please, elaborate this "..Passing in Python is different than > in C or other languages..." Argument passing in Python is: - different to Perl, C, Scala, Algol and Pascal; - the same as Ruby, Lua, Applescript and Javascript;

Re: [Tutor] who makes FOR loop quicker

2015-08-06 Thread Joel Goldstick
On Thu, Aug 6, 2015 at 4:34 AM, John Doe wrote: > Can You, please, elaborate this "..Passing in Python is different than in C > or other languages..." > I hesitate, because this question is usually the fuel of flaming wars. So in short: C can pass a value or a reference to a value (the address of

Re: [Tutor] How can this code be made even better ?

2015-08-06 Thread Laura Creighton
In a message of Thu, 06 Aug 2015 11:24:21 +0545, Aadesh Shrestha writes: >import re > >text = input('Enter your text with phone number using xx-xxx format \n') >contact = re.compile(r'\d\d-\d\d\d\d\d\d\d') > >for i in range(len(text)): >chunk = text[i:i+10] >mo = contact.search(chunk) >

Re: [Tutor] output formatting question

2015-08-06 Thread Alan Gauld
On 06/08/15 05:08, tom arnall wrote: i have read -- with what i think is a reasonable amount of attention -- all of the doc' i can find about string formatting in python. for the life of me, i cannot see how any of the other methods do more than you can do with, ... percent style formatting...

Re: [Tutor] How can this code be made even better ?

2015-08-06 Thread Alan Gauld
On 06/08/15 06:39, Aadesh Shrestha wrote: import re text = input('Enter your text with phone number using xx-xxx format \n') contact = re.compile(r'\d\d-\d\d\d\d\d\d\d') for i in range(len(text)): chunk = text[i:i+10] mo = contact.search(chunk) if mo: print('Phone Nu

Re: [Tutor] Pep 8, about indentation

2015-08-06 Thread Alan Gauld
On 06/08/15 04:40, Steven D'Aprano wrote: Um, the oldest standard for TABs is *eight* spaces, not 3 or 4, Yes, but that comes from the days of mechanical typewriters not any study of code comprehension. I was referring to the recommended spacing for comprehending code. There were a lot of st

Re: [Tutor] Dictionary Issue

2015-08-06 Thread Alan Gauld
On 06/08/15 03:27, Ltc Hotspot wrote: The output as reported by the latest code revision: c...@iupui.edu 1← Mismatch Looks like python continues to print the wrong data set: Python will print what you ask it to. Don't blame the tool! :-) > for line in handle: >

Re: [Tutor] who makes FOR loop quicker

2015-08-06 Thread John Doe
Can You, please, elaborate this "..Passing in Python is different than in C or other languages..." 'Cause as far as I know - default major Python's implementation CPython is written in C. Joel Goldstick 於 08/05/2015 03:44 PM 寫道: On Wed, Aug 5, 2015 at 3:53 AM, John Doe wrote: To pass by

Re: [Tutor] Dictionary Issue

2015-08-06 Thread Ltc Hotspot
Mark, Replace count[address]= count.get(address,0) +1 with c = Counter(['address'])? Regards, Hal On Wed, Aug 5, 2015 at 9:03 PM, Mark Lawrence wrote: > On 05/08/2015 23:58, Ltc Hotspot wrote: > >> Hi Mark, >> >> Address identifies the email address with the maximum number of sends: >> c...

Re: [Tutor] Dictionary Issue

2015-08-06 Thread Ltc Hotspot
Hi Alan The output as reported by the latest code revision: c...@iupui.edu 1 ← Mismatch Looks like python continues to print the wrong data set: In [11]: print val 1 In [12]: print kee r...@media.berkeley.edu In [13]: print address c...@iupui.edu In order to complete the assignment, using data

[Tutor] output formatting question

2015-08-06 Thread tom arnall
i have read -- with what i think is a reasonable amount of attention -- all of the doc' i can find about string formatting in python. for the life of me, i cannot see how any of the other methods do more than you can do with, to use a concrete example: print "Here %s a number: %3d" % ("is",

Re: [Tutor] Dictionary Issue

2015-08-06 Thread Ltc Hotspot
The revised output reads: In [3]: %run assignment_9_4_9.py Enter file name: mbox-short.txt c...@iupui.edu 14 The desired output: c...@iupui.edu 5 Question: How do I trace the source of the count? Revised data code reads: fname = raw_input("Enter file name: ") handle = open (fname, 'r') count

[Tutor] How can this code be made even better ?

2015-08-06 Thread Aadesh Shrestha
import re text = input('Enter your text with phone number using xx-xxx format \n') contact = re.compile(r'\d\d-\d\d\d\d\d\d\d') for i in range(len(text)): chunk = text[i:i+10] mo = contact.search(chunk) if mo: print('Phone Number Found:'+mo.group()) Thanks *