Re: [Tutor] Understanding cProfile output

2012-09-20 Thread Dave Angel
On 09/20/2012 05:15 PM, ranveer raghuwanshi wrote: > Thanks for the input everyone. > > @Dave, I basically implemented the sieve of eratosthenes to fiind the > number of prime numbers in a given range. So, yes I am looking for > suggestions to speed it up. > Please don't

Re: [Tutor] application whitelisting

2012-09-21 Thread Dave Angel
On 09/21/2012 06:51 AM, Albert-Jan Roskam wrote: > Hi, > > My company just started application whitelisting. Now a new version of a > (benign!!) dll does not work as it (or rather, its file hash, if I understood > it correctly) is not whitelisted. Is there any way I can use the same dll of > a n

Re: [Tutor] Question about lists

2012-09-21 Thread Dave Angel
On 09/21/2012 09:31 AM, Leo Degon wrote: > I'm trying to create a class where the main focus is creating a list whose > elements are lists and the elements of those lists are collection of zeros > and ones. I am trying to create functions to rotate the list ninety > degrees, to reflect it. Having a

Re: [Tutor] np array.any() question

2012-09-21 Thread Dave Angel
On 09/21/2012 11:25 AM, Steven D'Aprano wrote: > On 22/09/12 01:07, Bala subramanian wrote: >> Friends, >> May i know why do get a Valuerror if i check any value in a is between >> 3.0 to 5.0 ? To summarize, with a numpy array called a, the OP is getting an error doing: (3 < a < 5).any() >

Re: [Tutor] I don't know why this program doesn't run

2012-09-21 Thread Dave Angel
On 09/21/2012 07:34 PM, Gina wrote: > I don't know why this program doesn't run, but if you know, please > tell me. > -thanks > So what happens when you try? "Doesn't run" covers a multitude of possibilities. First one: python Car Salesperson.py python: can't open file 'Car': [Errno 2] No such

Re: [Tutor] I don't know why this program doesn't run

2012-09-21 Thread Dave Angel
Hi, you forgot to do a reply-all, so it didn't go to the list. I'm correcting that now, so don't worry about it. if your email doesn't support reply-all, then just add a cc of tutor@python.org On 09/21/2012 08:09 PM, Gina wrote: > On 9/21/2012 6:47 PM, Dave Angel wrote:

Re: [Tutor] Relative import help

2012-09-22 Thread Dave Angel
On 09/22/2012 08:33 AM, Matthew Ngaha wrote: >> You probably have a path that reaches into Domestic or Europe sub-package. >> That can happen if e. g. Project/Domestic/Europe is your current working >> directory. >> >> Try to cd into the Project folder's parent directory and see if >> >> $ python -

Re: [Tutor] Sudoku

2012-09-23 Thread Dave Angel
On 09/23/2012 09:34 AM, myles broomes wrote: Did you have a valid reason for making a brand new thread with the same title and practically the same code? Probably most readers just decided you were double-posting, and ignored the new message. Please use reply-all when continuing with a thread.

Re: [Tutor] Unzipping a Zip of folders that have zips within them that I'd like to unzip all at once.

2012-09-23 Thread Dave Angel
On 09/23/2012 10:26 PM, Gregory Lund wrote: > > > for item in zipContents: > if item.endswith('.zip'): > x = zipfile.Zipfile(item,'r') > x.extractall() > x.close() > > but now get a " x = zipfile.Zipfile(item,'r') > AttributeError: 'module' object has no attribute 'Z

Re: [Tutor] Python Assignment Question

2012-09-24 Thread Dave Angel
On 09/24/2012 03:20 PM, Aija Thompson wrote: > Hi! > I've been working on this question for a long time and for some reason it's > just not clicking. > I'm not sure if my loop for the question is the right one, or if I'm even on > the right track. > We're supposed to make a program that counts

Re: [Tutor] Python Assignment Question

2012-09-24 Thread Dave Angel
On 09/24/2012 04:56 PM, Aija Thompson wrote: > > Hi, By top-posting, you lose all the context. The convention is to quote those parts of the previous messages necessary to understand the context, and then add your own remarks immediately after the appropriate parts. > Yeah this is my first ass

Re: [Tutor] Usefulness of BIFs all() and any()?

2012-09-25 Thread Dave Angel
On 09/25/2012 07:55 AM, Richard D. Moores wrote: > > > And why all([]) > True any([]) > False > > Same problem as calling sum() with an empty list. What value should it have? Clearly, it should return its 'start' parameter, which defaults to zero. Well the all() has a start value of

Re: [Tutor] floating point rounding inconsistency

2012-09-28 Thread Dave Angel
On 09/19/2012 02:27 PM, Andrew Tritt wrote: > Hello, > > I am new to python, and I was experimenting with the round function, and > came across what appears to be a bug in floating point rounding. I am > guessing there is a valid explanation for it. Welcome to the Python tutor; hope you enjoy lea

Re: [Tutor] how to save text or dat file using python

2012-09-28 Thread Dave Angel
On 09/20/2012 12:14 PM, Preeti Gaikwad wrote: > Hello I am new user of python pls let me know how to save dat or txt file > using python? what is the basic cmd for this? thanks a lot in advance > > Have you written any code that READs files? Check out the open() function, in particular the "w"

Re: [Tutor] Help for Python Beginner with extracting and manipulating data from thousands of ASCII files

2012-09-30 Thread Dave Angel
On 09/30/2012 06:07 PM, Cecilia Chavana-Bryant wrote: > Hola again Python Tutor! > > With a friend's help I have the following code to extract reflectance data > from an ASCII data file, do a bit of data manipulation to calibrate the > data and then write the calibrated file into an out file. > > i

Re: [Tutor] python help?

2012-10-01 Thread Dave Angel
On 10/01/2012 08:16 PM, c smith wrote: > It is hard to see things like images and attachments. I think purely html > is preferred, but i would have to look over 'the list rules' again. Since this is a text mailing-list, it's text messages that are preferred. html messages frequently trash indenta

Re: [Tutor] python help?

2012-10-01 Thread Dave Angel
On 09/30/2012 02:02 AM, patrick Howard wrote: > I have to write a program that takes an input file, with students names and > various grades. > My vindictive teacher also added grades that are not supposed to count, so I > need to pick the grades that are 'HM1-4"; not HW, or TEST or anything else

Re: [Tutor] python help?

2012-10-01 Thread Dave Angel
On 10/01/2012 09:44 PM, Dave Angel wrote: > On 09/30/2012 02:02 AM, patrick Howard wrote: >> I have to write a program that takes an input file, with students names and >> various grades. >> My vindictive teacher also added grades that are not supposed to count, so I >&

[Tutor] Filename match on file extensions

2012-10-02 Thread Dave Wilder
Hello, Below is a snippet of a search I want to do for any file that contains the string "quarantine" in the filename. It works for picking up any file name containing "quarantine" except when "quarantine" is used as an extension. For example, the search would find quarantine.txt but fails to f

Re: [Tutor] Filename match on file extensions

2012-10-02 Thread Dave Wilder
>> Hello, >> Below is a snippet of a search I want to do for any file that contains the >> string "quarantine" in the filename. >> It works for picking up any file name containing "quarantine" except when >> "quarantine" is used as an extension. >> For example, the search would find quarantine

Re: [Tutor] Why difference between printing string & typing its object reference at the prompt?

2012-10-02 Thread Dave Angel
On 10/02/2012 11:15 PM, boB Stepp wrote: > After much diddling around I have finally settled on a text to study > (Programming in Python 3, 2nd edition, by Mark Summerfield) and have > defaulted to using IDLE, deferring worrying about editors/IDEs until I > feel comfortable in Python. > > I am puzz

Re: [Tutor] Filename match on file extensions

2012-10-02 Thread Dave Angel
On 10/02/2012 11:45 PM, Dave Wilder wrote: > >>> Hello, >>> Below is a snippet of a search I want to do for any file that contains the >>> string "quarantine" in the filename. >>> It works for picking up any file name containing "quarantine&

Re: [Tutor] Filename match on file extensions

2012-10-02 Thread Dave Wilder
Tutor] Filename match on file extensions On Wed, Oct 03, 2012 at 03:14:16AM +0000, Dave Wilder wrote: > > Hello, > > Below is a snippet of a search I want to do for any file that contains the > string "quarantine" in the filename. > It works for picking up any file name co

Re: [Tutor] forcing the None values of a dictionary

2012-10-03 Thread Dave Angel
On 10/03/2012 03:59 PM, Brannon, Terrence wrote: > I'm wondering if there is something I overlooked for this function I wrote... > and also whether it could've been done destrictively instead of returning a > new dictionary: > > def dictNoneValueTo(d, new_value=''): > """force None values in

Re: [Tutor] reloading a module

2012-10-03 Thread Dave Angel
On 10/03/2012 09:56 PM, Leo Degon wrote: > So Ive got code that i import a module to get certain saved variables, > where i edit the text file that comprises the module to edit those saved > variable. My problem is I cant reload the module to access those modified > variables. > I was wondering how

Re: [Tutor] Why difference between printing string & typing its object reference at the prompt?

2012-10-04 Thread Dave Angel
On 10/03/2012 11:11 PM, boB Stepp wrote: > Thanks to all who responded. > . > What happens if str() or repr() is not supported by a particular > object? Is an exception thrown, an empty string returned or something > else I am not imagining? Let's try it and see: >>> class A:pass ... >>> a = A()

Re: [Tutor] modifying lists of lists

2012-10-04 Thread Dave Angel
On 10/03/2012 11:52 PM, Ed Owens wrote: > You are fundamentally correct about my confusion, though I'm trying to work > with tuples as the lowest level, which may not be relevant here. The tuples are an example of an immutable object. An immutable object (which contains only immutable objects) may

Re: [Tutor] rounding up to the nearest multiple of 8

2012-10-05 Thread Dave Angel
On 10/05/2012 07:23 AM, Albert-Jan Roskam wrote: > - Original Message - > >> From: Asokan Pichai >> To: tutor@python.org >> Cc: >> Sent: Friday, October 5, 2012 11:06 AM >> Subject: Re: [Tutor] rounding up to the nearest multiple of 8 >> >> If you are doing so many times, it may be worth

Re: [Tutor] Through a glass, darkly: the datetime module

2012-10-06 Thread Dave Angel
On 10/06/2012 07:19 PM, Richard D. Moores wrote: > On Fri, Oct 5, 2012 at 7:15 AM, Walter Prins wrote: > >> Does this hint help? >> > import datetime > mydate = datetime.date(2012,10,5) > mydate = mydate + datetime.timedelta(days=30) > print mydate >> 2012-11-04 > Yes! Thanks to al

Re: [Tutor] Through a glass, darkly: the datetime module

2012-10-06 Thread Dave Angel
On 10/06/2012 09:10 PM, Richard D. Moores wrote: > On Sat, Oct 6, 2012 at 4:29 PM, Dave Angel wrote: > >> To turn an integer (0-6, or whatever) into a string, just use a tuple of >> the same size: >> >> tran = ("MONDAY", "TUESDAY", "WEDNESDA

Re: [Tutor] modulo

2012-10-07 Thread Dave Angel
On 10/07/2012 06:49 PM, Esteban Izaguirre wrote: > Hi, I'm following coursera's learn to program: the fundamentals, which > teaches programming basics in python. Our first assignement involves the > modulo operator with a negative divident, and while I've managed to get to > understand it enough fo

Re: [Tutor] modulo

2012-10-07 Thread Dave Angel
On 10/07/2012 07:16 PM, Oscar Benjamin wrote: > On 8 October 2012 00:07, Dave Angel wrote: >> On 10/07/2012 06:49 PM, Esteban Izaguirre wrote: >>> Hi, I'm following coursera's learn to program: the fundamentals, which >>> teaches programming basics in pytho

Re: [Tutor] modulo

2012-10-07 Thread Dave Angel
On 10/07/2012 08:00 PM, Jan Karel Schreuder wrote: > > > On Oct 7, 2012, at 7:24 PM, Dave Angel wrote: > >>>>> >>>> >> >> It still makes no sense to me. There are at least two equally silly >> ways to define the results of a negat

Re: [Tutor] finding digit in string

2012-10-08 Thread Dave Angel
On 10/08/2012 12:43 PM, Benjamin Fishbein wrote: > I figured out a solution for the question I asked on here. Why then did you start a new thread, instead of responding on the same one? You didn't even use the same subject string. > To find the next digit (0-9) in a string, I use: > text.find("0

Re: [Tutor] Saving GUIs

2012-10-09 Thread Dave Angel
On 10/09/2012 12:27 PM, tayo rotimi wrote: > Hi, > > > I have started creating GUIs. But my current challenge now is saving the GUIs > created. I have observed that > whenever I close the console, the GUIs also get closed. So, please what do I > need to do to save the GUIs, or call them back whe

Re: [Tutor] iterating over a changing list

2012-10-10 Thread Dave Angel
On 10/10/2012 03:52 PM, Ed Owens wrote: > I'm trying to iterate over a list of elements, and make changes to the list > in front of the element I'm currently working with. I can update the list, > but the 'for' doesn't see the new element. Here's the code: > > import string > > def add_element(

Re: [Tutor] Why difference between printing string & typing its object reference at the prompt?

2012-10-11 Thread Dave Angel
On 10/11/2012 04:40 AM, eryksun wrote: > On Wed, Oct 10, 2012 at 9:23 PM, boB Stepp wrote: > . >> What is the intended use of byte types? > > bytes objects are important for low-level data processing, such as > file and socket I/O. The fundamental addressable value in a computer > is a byte (at le

Re: [Tutor] Why difference between printing string & typing its object reference at the prompt?

2012-10-11 Thread Dave Angel
On 10/11/2012 05:21 AM, eryksun wrote: > On Thu, Oct 11, 2012 at 5:04 AM, Dave Angel wrote: >> >> Actually, the upper limit for a decoded utf-8 character is at least 6 >> bytes. I think it's 6, but it's no less than 6. > > Yes, but what would be the poi

Re: [Tutor] Files Merging

2012-10-11 Thread Dave Angel
On 10/11/2012 07:13 AM, Sunil Tech wrote: > Hi all, > > Greetings to you... > it been so helpful for me to go through your all mails & support & i wish > it still continues. > > I have two text files. > > text1 contains > > This is from Text1 --- 1st line > This is from Text1 --- 2nd line > This is

Re: [Tutor] need an explanation

2012-10-11 Thread Dave Angel
On 10/11/2012 03:24 PM, Matthew Ngaha wrote: > i need help on 2 topics. > > 1) can someone please tell me what sys is doing, and why its using weird > indexing? > > if __name__ == "__main__": > A_Class(*sys.argv[1:4]).A_Class_Method() sys isn't being indexed. sys is a module (presumably you h

Re: [Tutor] need an explanation

2012-10-11 Thread Dave Angel
that will run with some print >> statements in appropriate places to show us what is happening. That way >> you may well be able to answer your own questions and learn at the same >> time. >> >> sadly when i run the file i get an error so i dont know what to doto fix &g

Re: [Tutor] Consecutive Sequence

2012-10-17 Thread Dave Angel
On 10/13/2012 07:02 AM, syed zaidi wrote: > Hi,I am trying to develop a python code that takes a character string as > input and finds for the occurrence of letters that are occurring thrice or > more consecutively.For E.g. > a = 'ataattaaacagagtgagcagt'In the output I want a list of tho

Re: [Tutor] Python Error

2012-10-17 Thread Dave Angel
On 10/05/2012 11:55 PM, Benjamin Lee wrote: > Hello, > I am using python to calculate distances across the cell. > I used this command: python calculate_distances.py > This was the response: > Traceback (most recent call last): > file "calculate_distances.py" line 4, in > import celltool.simple_

Re: [Tutor] Objects, object references, object values and memory addresses

2012-10-17 Thread Dave Angel
On 10/17/2012 11:41 PM, boB Stepp wrote: > >From Programming in Python 3, 2nd edition (p. 22-23): > a = ["Retention", 3, None] b = ["Retention", 3, None] a is b > False b = a a is b > True > > My current understanding is as follows: On the first two lines, two > separate ob

Re: [Tutor] Help Passing Variables

2012-10-18 Thread Dave Angel
On 10/18/2012 03:08 AM, Daniel Gulko wrote: > > > > Hi Python Tutor, I have a write a simple function named > "SwapCaseAndCenter(a_string, width). So why did you define it with only one formal parameter? > The idea is to use the function swapcase and center so that when the > userenters a stri

Re: [Tutor] Help Passing Variables

2012-10-19 Thread Dave Angel
On 10/19/2012 11:40 AM, Daniel Gulko wrote: > Thanks David. This has been helpful in understanding a bit more on how > parameters are passed through. Please don't top-post. it ruins the sequence of events. Your comments above happened after the parts you quote below. So why are they not after t

Re: [Tutor] Print items from 3 lists in order

2012-10-21 Thread Dave Angel
On 10/21/2012 08:01 PM, Saad Javed wrote: > Hi, > a = ['Ron', 'Harry', 'Hermoine'] > b = ['25th oct', '27th oct', '29th oct'] > c = ['Charms', 'DADA', 'Potions'] > I want to print like this: > Ron - 25th oct > Charms > Harry - 27th oct > DADA > Hermoine - 29th oct > Potions > > The items in each li

Re: [Tutor] Help - Using Sort and Join

2012-10-22 Thread Dave Angel
On 10/22/2012 03:57 PM, Daniel Gulko wrote: > Hi Python Tutor, > > I have an issue trying to figure out how to print out final answers using > sort and join functions. > > Assignment Specification: > make a function that is a magic eight ball emulator. emulator will be a > function that returns o

Re: [Tutor] Doubt!

2012-10-23 Thread Dave Angel
On 10/23/2012 07:14 PM, Nitin Ainani wrote: > Dear Sir/Madam, > > I am new to python I have a question. It is as follows: > > Suppose *s* is a variable and *s* stores empty string > > s="" > Now if we write following statement > > > print(s[0]) # it gives error There is no 0th character, so

Re: [Tutor] Strings.

2012-10-23 Thread Dave Angel
On 10/23/2012 07:48 PM, Alexander wrote: > On Tue, Oct 23, 2012 at 7:24 PM, Nitin Ainani wrote: >> Dear Sir/Madam, >> >> I am new to python I have a question. It is as follows: >> >> Suppose s is a variable and s stores empty string >> >> emptyString = "" > #consider the string to be non-empty, t

Re: [Tutor] Python input function not working in 2.7 version

2012-10-24 Thread Dave Angel
On 10/24/2012 07:15 AM, Morten Engvoldsen wrote: > Hi, Hi. Welcome to the list. > I am facing issue with input() of Python 2.7. When i run the program it > doesn't display any line to take user input . Below is the code: > > def user_input() Need a trailing colon here. >fat_grams = input("Ho

Re: [Tutor] Help with class example

2012-10-26 Thread Dave Angel
On 10/18/2012 07:59 PM, Frank Pontius wrote: > Hello, > I'm taking a beginners course on Python. > > Have class example which is to be used in H/W, which I can't get to work. > Thus I figure the example is wrong. But I need this to get H/W done. > > Using 'import random' and random.randrange in fu

Re: [Tutor] greater precision?

2012-10-29 Thread Dave Angel
On 10/29/2012 05:49 AM, John Collins wrote: Did you really leave two very-similar messages 3 minutes apart? Or are you using a broken gateway, like Google-groups, and it hiccoughed? > Hi, > OS: XP > Py: 2.7.2 > > I am running some old scripts, not written by me, that produce > substantial calcu

Re: [Tutor] greater precision?

2012-10-29 Thread Dave Angel
On 10/29/2012 06:32 AM, John Collins wrote: > Hi Dave >> Did you really leave two very-similar messages 3 minutes apart? Or are >> you using a broken gateway, like Google-groups, and it hiccoughed? > Sorry, I didn't intend to - flunky LH mouse microswitch! I was only concer

Re: [Tutor] greater precision?

2012-10-29 Thread Dave Angel
On 10/29/2012 06:54 AM, John Collins wrote: > Hi Steve, > Thanks. From > >>>mkpoints.py 32 32.txt > > here's a sample of the output > > -0.396087591388 -0.781284022758 0.482400140683 > -0.967387012461 -0.0838047084421 -0.239037944614 > 0.0208969821213 -0.489420208746 0.871797668848 > 0.887250003871

Re: [Tutor] greater precision?

2012-10-29 Thread Dave Angel
On 10/29/2012 07:19 AM, John Collins wrote: > >> Equality. > Right, in a 1,0 sense. >> Because of rounding errors this is a dangerous operation for floating >> point >> numbers: > print 1.0 == .1 + .1 + .1 + .1 + .1 + .1 + .1 + .1 + .1 + .1 >> False > I take it that is because binary for .1 is

Re: [Tutor] greater precision?

2012-10-29 Thread Dave Angel
On 10/29/2012 07:49 AM, John Collins wrote: > Hi Dave, >> Not true. That's just what it was truncated to upon output. If you >> want to show 15 digits, then use formatted output instead of str() >> inside the realprint() function. > BIG light bulb moment! I had no

Re: [Tutor] greater precision?

2012-10-29 Thread Dave Angel
On 10/29/2012 08:14 AM, John Collins wrote: > >> But please don't just take the format string I supplied as "right." It >> is if you always want 15 decimal digits to the right of the decimal >> point. But if you have a number like 50 thousand, then many of those >> digits to the right are invali

Re: [Tutor] calling a module fails

2012-10-29 Thread Dave Angel
On 10/29/2012 09:00 PM, richard kappler wrote: > Methinks I'm missing something obvious, but can't quite put my finger on > it. If, in the interpreter, I enter the following code: > > def hungry(batVolt): > if batVolt >94: > return ("I am not hungry at the moment") > elif 64 < ba

Re: [Tutor] changing name value with function return

2012-10-30 Thread Dave Angel
On 10/30/2012 12:56 PM, richard kappler wrote: > If I have a variable and send it's value to a function to be modified and > returned, how do I get the function return to replace the original value of > the variable? > > Example: > > import random > > x = 50 > > def rndDelta(x): > d = random.un

Re: [Tutor] running multiple concurrent processes

2012-10-30 Thread Dave Angel
On 10/30/2012 03:18 PM, richard kappler wrote: > As I sit through the aftermath of Sandy, I have resumed my personal quest > to learn python. One of the things I am struggling with is running multiple > processes. I read the docs on threading and am completely lost so am > turning to the most excel

[Tutor] Obtaining result from a sendline

2012-10-30 Thread Dave Wilder
Okay, file this under RTFM, but even after research, I cannot figure out the answer to this simple question. When I do an ssh in python (version 2.7.3) to a device, I am trying to capture the output of the command. However, all I get back is a numerical value. I am looking to get the actual

Re: [Tutor] running multiple concurrent processes

2012-10-30 Thread Dave Angel
reading as > opposed to multi-processing. > > Dave, no offense taken, great write-up. Now I understand more, but am quite > possible even more confused, but will take what you wrote to guide me > through further research. This is enough to get me started though. I'm > thinkin

Re: [Tutor] Obtaining result from a sendline

2012-10-31 Thread Dave Wilder
just renamed it when I emailed my question, which was probably not a good idea. Thanks, Dave -Original Message- From: eryksun [mailto:eryk...@gmail.com] Sent: Wednesday, October 31, 2012 1:44 AM To: Dave Wilder Cc: tutor@python.org Subject: Re: [Tutor] Obtaining result from a

Re: [Tutor] Obtaining result from a sendline

2012-10-31 Thread Dave Angel
On 10/31/2012 09:28 AM, Dave Wilder wrote: > Sorry for the poor info on my part Steven et al. I did not do my homework. > > > > I thought that sshclient was an imported module, however it is pxssh that I > am importing as sshClient. > > import pxssh as sshClient > >

Re: [Tutor] need help

2012-11-01 Thread Dave Angel
On 11/01/2012 05:24 PM, Matthew Ngaha wrote: > working through my tutorial ive been told to set up a simple webserver. i > can't even get started because the 1st line of code its asked me to do > fails with a syntax error. here's the code: If you got an error, quote it in full in your message (usi

Re: [Tutor] need help

2012-11-01 Thread Dave Angel
On 11/01/2012 05:47 PM, Matthew Ngaha wrote: >> >> >> Always, *always* include the *full* error message, otherwise we have to >> guess. Not fun. Some other questions: What operating system are you using? >> What version of Python does your tutorial assume? Do you in fact have >> Python 3 install

Re: [Tutor] need help

2012-11-01 Thread Dave Angel
On 11/01/2012 05:55 PM, Matthew Ngaha wrote: >> If you got an error, quote it in full in your message (using copy/paste, >> not by retyping or paraphrasing. As it stands, we don't know if the >> error was in bash, in csh, in cmd, or in Python, and if it was in >> python, we don''t know what versio

Re: [Tutor] how to keep track of sorted lists

2012-11-03 Thread Dave Angel
On 11/03/2012 09:04 AM, Albert-Jan Roskam wrote: > Hello, (I haven't run the code, as it was not presented in a form that I could do a single copy/paste. So I may have missed some subtlety in the code.) > I want to make a get() method that uses a binary search. This requires the > data to be so

Re: [Tutor] how to keep track of sorted lists

2012-11-03 Thread Dave Angel
On 11/03/2012 10:40 AM, Albert-Jan Roskam wrote: >> On 11/03/2012 09:04 AM, Albert-Jan Roskam wrote: > >>> Hello, >> >> (I haven't run the code, as it was not presented in a form that I could >> do a single copy/paste. So I may have missed some subtlety in the code.) > > Hi, sorry about that. H

Re: [Tutor] Fraction - differing interpretations for number and string - presentation

2015-04-16 Thread Dave Angel
On 04/16/2015 01:24 PM, Jim Mooney wrote: Is this "inaccurate"? Well, in the sense that it is not the exact true mathematical result, yes it is, but that term can be misleading if you think of it as "a mistake". In another sense, it's not inaccurate, it is as accurate as possible (given the limi

Re: [Tutor] Unicode encoding and raw_input() in Python 2.7 ?

2015-04-17 Thread Dave Angel
On 04/17/2015 04:39 AM, Samuel VISCAPI wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA256 Hi, This is my first post to that mailing list if I remember correctly, so hello everyone ! Welcome to the list. I've been stuck on a simple problem for the past few hours. I'd just like raw_input

Re: [Tutor] lists, name semantics

2015-04-17 Thread Dave Angel
On 04/17/2015 11:51 PM, Ben Finney wrote: Ben Finney writes: Bill Allen writes: If I have a list defined as my_list = ['a','b','c'], what is the is differnce between refering to it as my_list or my_list[:]? ‘my_list’ is a reference to the object you've already described (the existing obje

Re: [Tutor] How (not!) lengthy should functions be?

2015-04-18 Thread Dave Angel
On 04/18/2015 03:01 PM, boB Stepp wrote: As I final note I want to emphasize that I am not writing a program to *create* a treatment plan. Nor am I writing a program that can *alter* an existing treatment plan. It is merely reading output from the treatment plan and evaluating that output agains

Re: [Tutor] lists, name semantics

2015-04-19 Thread Dave Angel
On 04/19/2015 12:07 AM, boB Stepp wrote: . Before Peter changed one of these changeable objects, he had: a = [1, ["x", "y"], 3] b = a[:] Now BOTH a[1] and b[1] now identify the location of the inner list object, ["x", "y"] . Apparently, Python, in its ever efficient memory management fash

Re: [Tutor] lists, name semantics

2015-04-19 Thread Dave Angel
On 04/19/2015 03:08 PM, boB Stepp wrote: On Sun, Apr 19, 2015 at 6:47 AM, Dave Angel wrote: On 04/19/2015 12:07 AM, boB Stepp wrote: [...] I hope this is helpful, and, if there are any misstepps, that when they are revealed both of our understandings will be enhanced! Some of your

Re: [Tutor] lists, name semantics

2015-04-19 Thread Dave Angel
On 04/19/2015 06:28 PM, Joel Goldstick wrote: On Sun, Apr 19, 2015 at 6:23 PM, boB Stepp wrote: On Sun, Apr 19, 2015 at 4:05 PM, Dave Angel wrote: On 04/19/2015 03:08 PM, boB Stepp wrote: Or is the real point that we are adding an abstraction layer so we don't even have to think

Re: [Tutor] bin to dec conversion puzzlement

2015-04-20 Thread Dave Angel
On 04/20/2015 04:15 PM, Jim Mooney wrote: The key is that the result gets multiplied by 2 each time so for an N bit number the leftmost digit winds up being effectively 2**N, which is what you want. Alan G Ah, the light dawns once it was restated. It would be even simpler if you could

Re: [Tutor] introspection

2015-04-21 Thread Dave Angel
On 04/21/2015 01:21 AM, Danny Yoo wrote: What's supposed to happen in this situation? ## class Person(object): def __init__(self): pass j = Person() john = j jack = j ## What single name should we get back fr

Re: [Tutor] enhanced subtration in an exponent

2015-04-21 Thread Dave Angel
On 04/20/2015 08:44 PM, Jim Mooney wrote: Why does the compiler choke on this? It seems to me that the enhanced subtraction resolves to a legitimate integer in the exponent, but I get a syntax error: B = '11011101' sum = 0 start = len(B) for char in B: sum += int(char) * 2**(start -= 1) ##

Re: [Tutor] name shortening in a csv module output

2015-04-23 Thread Dave Angel
On 04/23/2015 06:37 AM, Jim Mooney wrote: .. Ï»¿ is the UTF-8 BOM (byte order mark) interpreted as Latin 1. If the input is UTF-8 you can get rid of the BOM with with open("data.txt", encoding="utf-8-sig") as csvfile: Peter Otten I caught the bad arithmetic on name length, but where is t

Re: [Tutor] name shortening in a csv module output

2015-04-23 Thread Dave Angel
On 04/23/2015 02:14 PM, Jim Mooney wrote: By relying on the default when you read it, you're making an unspoken assumption about the encoding of the file. -- DaveA So is there any way to sniff the encoding, including the BOM (which appears to be used or not used randomly for utf-8), so you c

Re: [Tutor] name shortening in a csv module output

2015-04-23 Thread Dave Angel
On 04/23/2015 05:08 PM, Mark Lawrence wrote: Slight aside, why a BOM, all I ever think of is Inspector Clouseau? :) As I recall, it stands for "Byte Order Mark". Applicable only to multi-byte storage formats (eg. UTF-16), it lets the reader decide which of the formats were used. For exa

Re: [Tutor] name shortening in a csv module output

2015-04-24 Thread Dave Angel
On 04/24/2015 07:34 PM, Jim Mooney wrote: Apparently so. It looks like utf_8-sig just ignores the sig if it is present, and uses UTF-8 whether the signature is present or not. That surprises me. -- Steve I was looking things up and although there are aliases for utf_8 (utf8 and

Re: [Tutor] Please disable “digest mode” before participating

2015-04-26 Thread Dave Angel
On 04/26/2015 08:07 AM, Ben Finney wrote: Jim Mooney writes: On 25 April 2015 at 18:03, Ben Finney wrote: Digest mode should only ever be used if you know for certain you will never be responding to any message. That brings up a great shortcut if you use gmail. If you select some text bef

Re: [Tutor] Adding consecutive numbers

2015-04-27 Thread Dave Angel
On 04/27/2015 06:37 AM, Whom Isac wrote: Hi, I am trying to build a python mini program to solve a math problem . I wanted my program to ask two number from the operator and it can add those number as a integer but as consecutive number in range. For example, if num1 entry =1 & num2 entry = 100 ,

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 far

Re: [Tutor] if then statements

2015-04-29 Thread Dave Angel
On 04/28/2015 09:24 PM, Jacqueline G Solis wrote: hello, I keep getting a syntax error. Could you please explain why that happens and how to correct it. def main (): print( "Welcome to Gonzo Burger!") order= int(input("Enter 1 if you want a hamburger,\ or 2 if you want a cheese

Re: [Tutor] circular movement in pygame

2015-04-29 Thread Dave Angel
On 04/29/2015 03:15 AM, diliup gabadamudalige wrote: 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 pointe

Re: [Tutor] subprocess.Popen(..., cwd) and UNC paths

2015-04-29 Thread Dave Angel
On 04/29/2015 08:47 AM, Albert-Jan Roskam wrote: Hello, Windows has the 'feature' that the CD command does not work with UNC paths. So in the code below, I cannot use the 'cwd' parameter of subprocess.Popen. Therefore I use pushd/popd to accomplish the same effect. Is there a better way to do t

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] raise exception works as planned in program but not when imported into testing module

2015-04-29 Thread Dave Angel
On 04/29/2015 09:05 PM, Jim Mooney Py3.4.3winXP wrote: I raised an exception in the parse_string function in my math parser program, function_tosser.py, and caught it in the calling routine, and that worked fine. But when I imported function_tosser.py into a test program, tester.py, it threw the

Re: [Tutor] How to use Git from Windows PC for files on Solaris machine where Git cannot be installed?

2015-04-29 Thread Dave Angel
On 04/30/2015 12:28 AM, boB Stepp wrote: The main danger as I see it is that if I am not careful, then the code on the dev environment could diverge from the state of code on my Windows PC, i.e., I forgot to do the scp part. But when I am actively working on a section of code I always insert a fe

Re: [Tutor] Newbie problems

2015-04-30 Thread Dave Angel
On 04/29/2015 11:58 PM, Jag Sherrington wrote: Can anyone please tell me what I am doing wrong?As this code I have for the Roulette Wheel colours exercise, won't work. number = int(input('Enter a number between 0 and 36: '))green_number = (0) red_number = (1, 3, 5, 7, 9, 12, 14, 16, 18, 19, 21

Re: [Tutor] Good Taste Question: Using SQLite3 in Python

2015-04-30 Thread Dave Angel
On 04/30/2015 03:22 PM, Roel Schroeven wrote: Alan Gauld schreef op 2015-04-30 00:51: > ... Trying to visually scan for _ or even __ is hard. Also different fonts make _ and __ hard to distinguish. > ... But they will be. Almost for certain. It's human nature and the nature of code maint

Re: [Tutor] Newbie problems

2015-05-02 Thread Dave Angel
1) Please reply-list, or if your email program doesn't support that, do a reply-all. The idea is to make sure tutor@python.org is in your To: field. Otherwise you're just leaving private messages, and that's not what a public forum like this is about. 2) Please use text email, not html. As

Re: [Tutor] Having Unusual results

2015-05-02 Thread Dave Angel
On 05/02/2015 04:36 AM, Peter Otten wrote: Jag Sherrington wrote: With that the calculation becomes buns = 20 package_size = 8 whole_packages, missing_buns = divmod(buns, package_size) total_packages = whole_packages if missing_buns: total_packages += 1 ... total_packages 3 And that can b

Re: [Tutor] Sieve of Erastthotenes without sofisticated tools

2015-05-04 Thread Dave Angel
On 05/04/2015 03:19 AM, yvan moses Levy wrote: My code is wrong! You'd find it a lot easier to get responses if you'd say in what way the code is wrong. If you get an exception, show the full traceback. If you get printed results, show what you expected, and what you got instead. If it hu

Re: [Tutor] Python program malfunction

2015-05-04 Thread Dave Angel
On 05/04/2015 07:08 PM, Jag Sherrington wrote: Hi, Alan> Please don't top-post. Enter your new message *after* whatever portion of the previous message you're quoting. I'm rearranging the portion of your message to conform to that standard. On Monday, 4 May 2015, 17:35, Alan Ga

Re: [Tutor] Sieve of Erastthotenes without sofisticated tools

2015-05-04 Thread Dave Angel
mailer to use text. On 05/04/2015 10:07 PM, yvan moses levy wrote:> Le 04/05/15 13:00, Dave Angel a écrit : >> On 05/04/2015 03:19 AM, yvan moses Levy wrote: >>> My code is wrong! >> >> You'd find it a lot easier to get responses if you'd say in what wa

<    8   9   10   11   12   13   14   15   16   17   >