Re: [Tutor] __getitem__

2016-11-23 Thread Alan Gauld via Tutor
On 23/11/16 06:09, monik...@netzero.net wrote: > Can you please explain __getitem__? __getitem__ is the operator overload for indexing. It is like the __add__() method which overloads the + operator. So if you imple,ent __add__() in your class you can add two instances together using + and

Re: [Tutor] Python Help

2016-11-16 Thread Alan Gauld via Tutor
On 16/11/16 22:51, Omari Lamar wrote: > I am looking for assistance with the python language. Can you send out an > eblast asking that if anyone can offer 1 on 1 assistance via skype to cover > the basics that would be greatly appreciated. Further to Bens message, we don't offer private 1-1

Re: [Tutor] please help me with after method

2016-11-16 Thread Alan Gauld via Tutor
On 16/11/16 18:48, Freedom Peacemaker wrote: > Hi, i need help. I am using Python 3.4 and I have wrote little app for > windows only ( windows 7 and higher). Its timer and my app working but not > good. Some people said that i should use after method instead of update() after() executes a

[Tutor] Please ignore: just testing

2016-11-15 Thread Alan Gauld via Tutor
The group seems unusually quiet so I'm just testing the server is working ok -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos

Re: [Tutor] MEL to Python Translation of array index in conditional statement

2016-11-10 Thread Alan Gauld via Tutor
On 10/11/16 13:08, Brian Schindler wrote: > I'm trying to convert the following code from MEL (Maya Embedded Language) > to Python You'll probably get better support fromthe Maya community than here since most of us don;'t know anything about Maya's language. > and having trouble with syntax

Re: [Tutor] Question About the .format Method.

2016-11-10 Thread Alan Gauld via Tutor
On 09/11/16 22:30, Bryon Adams wrote: > Hello, > Working on a simple function to get an IP address and make it look > pretty for the PyNet course. I'm wondering if there's way to evenly > space text with the string.format() method similar to how I'm doing it > with the % operator. Yes,

Re: [Tutor] Python Script

2016-11-10 Thread Alan Gauld via Tutor
On 10/11/16 00:18, Jordan Trudell wrote: > Hello, I need help running a script, as I am getting an error. OK, But we need to know what version of Python and which OS you use. Also post the script and the full error message you get. (Don't send attachments because they usually get stripped by

Re: [Tutor] Fwd: IndentationError: unexpected indent

2016-11-08 Thread Alan Gauld via Tutor
On 08/11/16 14:47, Palanikumar Gopalakrishnan wrote: > Hi Guys, > I tried this code from internet, Its returns following please > guide me to solve this error > > * passwordFile = open('File.txt') secretPassword = > passwordFile.read() print('Enter your password.') typedPassword =

Re: [Tutor] Trouble Removing Whitespace

2016-11-07 Thread Alan Gauld via Tutor
On 07/11/16 03:25, Jason Durnen wrote: > This is the code that I type in, but the result will not trim the extra > space. The tricky thing about white space is that you can't se it, so how do you know it is there or not? One way is to surround it with something you can see: data = 'a string

Re: [Tutor] Q regarding external program calling

2016-11-06 Thread Alan Gauld via Tutor
On 06/11/16 01:44, Clayton Kirkwood wrote: > Looked all over, but haven't found the answer. If I have a (windows) program > which I wish to start, even shell scripts, and possibly capture the output > from, how do I do that? Others have already pointed you to the subprocess module. The

Re: [Tutor] sumHighest function help

2016-11-05 Thread Alan Gauld via Tutor
On 05/11/16 12:07, Peter Otten wrote: > sum_highest = lambda items, n: sum(sorted(items, reverse=True)[:max(n, 0)]) > > or better: > > import heapq > > def sum_highest(items, n): > return sum(heapq.nlargest(n, items)) No, the first solution is "better" because it used lambda and slicing

Re: [Tutor] sumHighest function help

2016-11-04 Thread Alan Gauld via Tutor
On 04/11/16 16:44, Lloyd Francis wrote: It looks suspiciously like you posted this same message from two addresses with different subjects, please don't do that as it splits the responses and makes searching archives more difficult. > I want to write a function that will calculate and return the

[Tutor] Fwd: Re: tar a directory

2016-11-04 Thread Alan Gauld via Tutor
Always use reply-all or reply-list when responding to tutor posts == The archive file changes each time so I need to set a variable based on the changing directory Sent from my iPhone > On Nov 4, 2016, at 5:54 AM, Alan Gauld via Tutor <tutor@python.org&

Re: [Tutor] tar a directory

2016-11-04 Thread Alan Gauld via Tutor
On 03/11/16 17:56, Bill Nolf wrote: > Test 4 > > archive = tarfile.open("test.tgz", "a:gz") > archive.add=(dirarchive, arcname="test") > archive.close() > > Create a gzip file called test.tgz in the current directory, which is close > but no cigar > What I would like is the following gzip file:

Re: [Tutor] Module webbrowser.os

2016-11-03 Thread Alan Gauld via Tutor
3. Module webbrowser.os (Palanikumar Gopalakrishnan) >>4. Re: implementing sed - termination error (Peter Otten) >>5. Re: Module webbrowser.os (Alan Gauld) >>6. Re: Module webbrowser.os (Steven D'Aprano) Please do not send the entire digest. Delete all that is no

Re: [Tutor] Module webbrowser.os

2016-11-03 Thread Alan Gauld via Tutor
On 03/11/16 01:31, Steven D'Aprano wrote: > On Wed, Nov 02, 2016 at 09:16:56AM +0000, Alan Gauld via Tutor wrote: >> >> webbrowser.os(umask(0x777)) > > I think you've missed the round brackets () and imagined a dot . :-) Umm, yes, here is the actual session from my xterm

Re: [Tutor] Module webbrowser.os

2016-11-02 Thread Alan Gauld via Tutor
On 02/11/16 06:44, Palanikumar Gopalakrishnan wrote: > After that i want to experiment with webbrowser.os module, But dont know > how to execute it. webbrowser.os seems to just be a link to the standard os module. So you should read the docs for os...and use the os module directly. > So I use

Re: [Tutor] Python code

2016-11-01 Thread Alan Gauld via Tutor
On 01/11/16 21:28, Haley Sandherr wrote: > Hello, I am new to python and need help with this question: What kind of help? What exactly do you find difficult? > > Compose a function odd ( ) Can you define a function? Any function? > that takes three bool arguments Can you define a function

Re: [Tutor] implementing sed - termination error

2016-11-01 Thread Alan Gauld via Tutor
On 02/11/16 00:18, bruce wrote: > Trying to do a search/replace over a file, for a given string, and > replacing the string with a chunk of text that has multiple lines. > > From the cmdline, using sed, no prob. however, implementing sed, runs > into issues, that result in a "termination error"

Re: [Tutor] looking for image library based on PIL Image

2016-10-30 Thread Alan Gauld via Tutor
On 30/10/16 15:32, Benjamin Fishbein wrote: > I’m trying to automate a lot of images using PIL’s Image library, > but I don’t want to write all the filters and manipulation > algorithms myself. Do you know of any good code that people > have written that does this? It depends on what kind of

Re: [Tutor] why it is showing attribute error in line7

2016-10-29 Thread Alan Gauld via Tutor
Please always post the full error text in future. Meanwhile I'll guess: On 29/10/16 05:42, SONU KUMAR wrote: > fname = raw_input("Enter file name: ") > if len(fname) < 1 : fname = "mbox-short.txt" > fh = open(fname) > count = 0 > for line in fh: >line=line.rstrip missing parens means you

Re: [Tutor] Assessing local variable outside function

2016-10-28 Thread Alan Gauld via Tutor
On 28/10/16 02:38, nils wagenaar wrote: > Hello, > > > Could i use a variable defined in a function in another function? By returning it to the caller. > def DatasetToSubset(file, LatUpbound, LatLowBound, LonUpBound, LonLowBound): > nc=netCDF4.Dataset(file) >

Re: [Tutor] New to Python

2016-10-27 Thread Alan Gauld via Tutor
On 28/10/16 01:05, Rusty Bayles wrote: > Thanks for the reply Alan, > Could you please tell me more detail on the videos? Like who made them. Some are just amateurs others are professional (or at least Youtube regulars) Here are a couple of links, but to be honest just about any of them would

Re: [Tutor] New to Python

2016-10-27 Thread Alan Gauld via Tutor
On 27/10/16 23:41, Rusty Bayles wrote: > I just installed 3.5.2 interpreter and cannot figure out how to run > program. I strongly suggest you go to Youtube and search for IDLE. There are several short (3-10min) videos there that should make it clear where you are going wrong. Watch a couple

Re: [Tutor] String within a string solution (newbie question)

2016-10-26 Thread Alan Gauld via Tutor
On 26/10/16 19:06, Wish Dokta wrote: > folders with a drive/directory. To do this I am storing each directory in a > dict as the key, with the value being the sum of the size of all files in > that directories (but not directories). > > For example: > > for "C:\\docs\\code" in key: > > Which

Re: [Tutor] What is wrong with my Python program that causes it to run but not give results?

2016-10-26 Thread Alan Gauld via Tutor
On 26/10/16 04:19, Ed Troy wrote: > I am pretty sure I installed python3. And, also, matplotlib, scipy, and > numpy. If I enter either python or python3, I get the >>> prompt, so I > may have both installed. Yes, that's normal. Ubuntu uses python 2 for some of its utilities. > How do I verify

Re: [Tutor] What is wrong with my Python program that causes it to run but not give results?

2016-10-25 Thread Alan Gauld via Tutor
On 25/10/16 20:24, Ed Troy wrote: > my Ubuntu machine. I created the diode IV curve data as per the article, > but I can't seem to get it to run. > edward@ubuntu:~$ python LED_model_utf8.py LED_IV.txt > Traceback (most recent call last): >File "LED_model_utf8.py", line 4, in > import

Re: [Tutor] Alternative to for/while loop

2016-10-25 Thread Alan Gauld via Tutor
On 25/10/16 09:31, Wolfgang Maier wrote: > A possible explanation is that, as you are saying, the book uses > python2. In python2, input does not return a string, but evaluates the > input from the user to produce different types of objects. So in Python2: Good catch Wolfgang, that's probably

Re: [Tutor] Alternative to for/while loop

2016-10-25 Thread Alan Gauld via Tutor
On 25/10/16 09:09, niraj pandey wrote: > Try this. > > my_string = '0,1,2,3' > my_lst=my_string.split(",") > leng = len(my_lst) > b=sum(my_lst) > avg=float(b/leng) > print avg It doesn't work because my_list is a list of strings and you can't sum() strings. The loop is needed to convert the

Re: [Tutor] Alternative to for/while loop

2016-10-25 Thread Alan Gauld via Tutor
On 25/10/16 02:38, Bryon Adams wrote: > question. The book I'm working through hasn't covered using flow control > yet so I'm thinking there should be a way to do this without the for > loop I used, but I'm at a loss here. Thee are ways to do it without using a for loop but they are all more

Re: [Tutor] Attaching program text to messages

2016-10-24 Thread Alan Gauld via Tutor
On 25/10/16 00:01, Ben Finney wrote: > I think because it is (declared by Elliott's mail user-agent to be) a > text attachment, it survives to the mailing list. That might be the reason. > A text attachment (provided you ensure it is declared that way, as > Elliott's message did) seems a better

Re: [Tutor] Python v3 Tkinter GUI program

2016-10-24 Thread Alan Gauld via Tutor
On 24/10/16 22:36, Elliott Andrews wrote: > Sorry is this sounds really broad, and I am happy to clarify and points. Sorry I just noticed another point that I can't overlook. You have code/comment: root = Tk() #The actual statment which opens the window, toplevel =

Re: [Tutor] Python v3 Tkinter GUI program

2016-10-24 Thread Alan Gauld via Tutor
On 24/10/16 22:36, Elliott Andrews wrote: > Hi there, I am making a program in python based on a Subway operation. All > descriptions and comments codes are provided in the attached program. Normally attachments are deleted by the server although yours seems to have gotten through (to me at

Re: [Tutor] Python

2016-10-24 Thread Alan Gauld via Tutor
On 24/10/16 15:40, Kadir Sertcanli wrote: > Hi! I have a function that I want to plot depending on a parameter (’a’), OK, But you will need to give us some more details. > I looked in the beginners guide Which beginner's guide are you using? Plotting is not something normally covered in a

[Tutor] Fwd: Re: Fwd: Re: Created map after opening file

2016-10-21 Thread Alan Gauld
like this: x=np.array [] and y=np.array[] and the inserting the data between the brackets, but then though wouldn't that defeat the purpose of the file? On Thu, Oct 20, 2016 at 12:45 PM, Alan Gauld <alan.ga...@alan-g.me.uk <mailto:alan.ga...@alan-g.me.uk>> wrote: Resending afte

Re: [Tutor] Help please

2016-10-20 Thread Alan Gauld via Tutor
On 20/10/16 21:25, Karen Palladino wrote: > I am new to python and programming for that matter. Basically, I don't know > much at all. I have python on my p/c which was put there by a former > co-worker who wrote a program that extracts bites of information to generate > a report. The format of

[Tutor] Fwd: Re: Created map after opening file

2016-10-20 Thread Alan Gauld
Resending after mail error, apologies if you get two! --- Always use Reply All (Or Reply List) to reply to the tutor list... On 20/10/16 14:45, Betty Cruz wrote: > I had actually attached the map and how the data looked. I guess the > pictures didn't go

Re: [Tutor] Created map after opening file

2016-10-20 Thread Alan Gauld via Tutor
Always use Reply All (Or Reply List) to reply to the tutor list... On 20/10/16 14:45, Betty Cruz wrote: > I had actually attached the map and how the data looked. I guess the > pictures didn't go through? I have added links. > The server often strips attachments, it's always better to include

Re: [Tutor] Created map after opening file

2016-10-20 Thread Alan Gauld via Tutor
On 20/10/16 05:31, Betty Cruz wrote: > Hello, I'm new to python. Hello, welcome. > ...I'm trying to create a map after reading a file. What kind of "map" - that's a very generic term. Do you mean a geographic map using GIS data? If so is it some kind of image output that you want? Or is it a

Re: [Tutor] selenium bindings...

2016-10-18 Thread Alan Gauld via Tutor
On 18/10/16 18:00, bruce wrote: > This is prob way off topic. Yep, more appropriate for a selenium group/list. There is one on gmane at gmane.comp.web.selenium.user Try asking there. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/

Re: [Tutor] Python Easy Word Problem (Grade 11)

2016-10-18 Thread Alan Gauld via Tutor
On 18/10/16 02:31, Zeel Solanki wrote: > I just recently started learning python and I am having trouble figure out > the following python problem. Can you please help me make the code for the > the problem below: We will help, but we won;t do the lesson for you. You will need to wr4ite the

Re: [Tutor] Python help

2016-10-16 Thread Alan Gauld via Tutor
On 15/10/16 23:48, Nicholas Hopkins wrote: > Please tell me what is wrong with my code and how I can put an if else > statement > inside of another if else statement You are almost right but... > This is my code: > path = input('Which path number will you take?') > if path == '1': >

Re: [Tutor] Code for python game

2016-10-12 Thread Alan Gauld via Tutor
On 12/10/16 18:40, tracey jones-Francis wrote: > I want to have a function that will ignore certain words that > i have specified in a dictionary. > the dictionary is called skip_words and has about 20 different strings in. We shouldn't care inside the function what the external data is

Re: [Tutor] Adding numbers within a string

2016-10-12 Thread Alan Gauld via Tutor
On 12/10/16 17:58, D.V.N.Sarma డి.వి.ఎన్.శర్మ wrote: > Sorry, I did not read the conditions that split and for should not be used. It is even more confusing - split() may NOT be used but 'for' MUST be used... -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/

Re: [Tutor] Adding numbers within a string

2016-10-12 Thread Alan Gauld via Tutor
On 12/10/16 01:37, LQ Soh wrote: > To whom it may concern, > Can someone enlighten me as to how you can create a function such > that sum_numbers('10 5 8'), when run, will give an answer of 23, without > using str.split() and using a for loop I'm assuming this is some kind of classroom exercise?

Re: [Tutor] Need help

2016-10-12 Thread Alan Gauld via Tutor
On 12/10/16 09:03, niraj pandey wrote: > Can you pls guide how to print this screen (Attached here) content in > printer ? As we already pointed out this is a text list so attachments are usually stripped off... However, printing from Tkinter is not easy. The simplest way is usually to create

Re: [Tutor] Cluster analysis script error

2016-10-11 Thread Alan Gauld via Tutor
On 11/10/16 22:13, Mike Armson wrote: > I am trying to run a script (attached) which determines the number of > clusters of fixations within a set of eye movement data. The script says to > enter the following command on python: > > "python fixationClusters.py outputPrefix input clusterDistance"

Re: [Tutor] Python Code Not Working

2016-10-11 Thread Alan Gauld via Tutor
On 09/10/16 21:39, jeremygaine...@gmail.com wrote: > Everytime I run this it says test is not defined . I don’t understand. It means test is not defined - that is, Python doesn't know about it. You call a function test() but there is no such function built into Python, so it complains.

Re: [Tutor] Advise with coding

2016-10-11 Thread Alan Gauld via Tutor
On 11/10/16 10:16, tracey jones-Francis wrote: > Is it possible someone on here can advise me where I am going wrong. Yesm, thats what this list is for but... We need to see code - we can't guess what you did. We need to know what input you used, what output you got and why its not what you

Re: [Tutor] Python dependencies in Anaconda

2016-10-11 Thread Alan Gauld via Tutor
On 10/10/16 16:54, David Wolfe wrote: > Anaconda (using Spyder or a Juypter notebook), so the dependencies are > included, so it's not an issue. So, what I'm wondering is, are the > dependencies that are included in Anaconda just contained in Anaconda, and > not actually accessible in Python,

Re: [Tutor] Decrypting a Password

2016-10-09 Thread Alan Gauld via Tutor
On 09/10/16 01:50, Linda Gray wrote: > I am working on a homework assignment that has me creating a password saver > using a ceasar cipher code. I was provided the key to the cipher and two > passwords. I need to look up and decrypt the passwords Are you sure? That's very bad practice and

Re: [Tutor] Python Shell

2016-10-09 Thread Alan Gauld via Tutor
On 08/10/16 20:43, Alan Clarke wrote: > I created a program called HW.py that runs under a command prompt, > but Python Shell gives the following error: How are you running it in the Python shell? > Traceback (most recent call last): > File "", line 1, in > HW.py >

Re: [Tutor] TDD: How to test input()?

2016-10-08 Thread Alan Gauld via Tutor
On 08/10/16 07:18, Steven D'Aprano wrote: > Testing code that depends on user input is always tricky. There are a > few ways to deal with it: > > (5) Or you could manually monkey-patch sys.stdin as you do. A variation on this that I have used is to read the input from stdin as usual but

Re: [Tutor] (no subject)

2016-10-06 Thread Alan Gauld via Tutor
On 06/10/16 23:16, Zeel Solanki wrote: > HelloI just started using python and my teacher has given us some problem I just noticed that you are the same person who posted earlier. The replies you have already received should answer your questions. Please don't start a second thread with the same

Re: [Tutor] (no subject)

2016-10-06 Thread Alan Gauld via Tutor
On 06/10/16 23:16, Zeel Solanki wrote: > HelloI just started using python and my teacher has given us some problem > to solve and I am having some problem soving the question below. I have > written some part of the code already, so can u please correct the code for > me to make it work. Please

Re: [Tutor] Python Word Problems(Student)

2016-10-06 Thread Alan Gauld via Tutor
On 06/10/16 17:50, Alan Gauld via Tutor wrote: > Nowadays this would more commonly be done using a list > comprehension rather than reduce. Sorry, I meant filter() not reduce(). -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan

Re: [Tutor] Python Word Problems(Student)

2016-10-06 Thread Alan Gauld via Tutor
On 06/10/16 15:15, Zeel Solanki wrote: > def filter_long_words(words, n): > for x in words.split(): > return filter(lambda x: len(x) > n, words) You are trying to be too clever here, you don't need the loop. words is the original string so your filter will only receive the full string

Re: [Tutor] Help regarding reg exp.

2016-10-05 Thread Alan Gauld via Tutor
On 05/10/16 10:03, rakesh sharma wrote: > Hi all > > I have a string of pattern ({A,BC},{(A,B),(B,C)(C,A)}. I'm not sure what you mean, can you send some real examples of the data rather than just a generic pattern? For example what do A,B and C signify? Are they literals? Are they uppercase

Re: [Tutor] remove ^ in field

2016-10-05 Thread Alan Gauld via Tutor
On 04/10/16 20:14, PERRAS Pierre wrote: > Hi, > > Sending lab result in HL7. You need to give us much more information. Do not assume we know what HL7 is, I certainly don't. Also this is a text list and attachments are usually stripped off, so if you sent something it didn't get through. > In

Re: [Tutor] Error

2016-10-04 Thread Alan Gauld via Tutor
On 04/10/16 18:41, Agnieszka Socha wrote: > I began to learn Python and after saving a file gra.py tried to reopen it > and got an error (in the Annex). This is a text only list so attachments tend to get stripped off. We need a lot more information I'm afraid. What are you using to "reopen"

Re: [Tutor] xpath - html entities issue --

2016-10-04 Thread Alan Gauld via Tutor
On 04/10/16 15:02, bruce wrote: > I did a quick replace ('','&') and it replaced the '' as desired. > So the content only had '&' in it.. You are preonbably better using your parseers escape/unescape facilities. Simple string replacement is notioriously hard to get right. > I can provide a more

Re: [Tutor] please help me modify this code so that I can utilize raw_input

2016-10-04 Thread Alan Gauld via Tutor
On 04/10/16 15:04, Richard Koeman wrote: > I would like to modify this code so that instead of me calling the function > with the list as shown [1,2,3,4], the user inputs the list with raw_input. > You don't need to modify your code you just need ton write a function that reads a list from the

Re: [Tutor] Need help

2016-10-03 Thread Alan Gauld via Tutor
On 03/10/16 10:54, niraj pandey wrote: > I want to add every lebels value here (ie fetch from DB and display in > front of every lebel or I had store every lable value in variable and > display here). You need to tell us which OS, Python version and GUI toolkit you are using. > [image: Inline

Re: [Tutor] How to test a function which runs a passed in function twice?

2016-10-02 Thread Alan Gauld via Tutor
On 02/10/16 23:47, boB Stepp wrote: > adequately testing it. I cannot even conceive of what might be edge > cases for this function. I meant to add, the obvious boundaries for this actual function are passing in non-callable values, or callables that require arguments. And to handle those

Re: [Tutor] How to test a function which runs a passed in function twice?

2016-10-02 Thread Alan Gauld via Tutor
On 02/10/16 23:47, boB Stepp wrote: > In exercise 3.2 of Downey's "Think Python 2" he has a function: > > def do_twice(f): > f() > f() > > As you know, I am trying to learn testing/TDD while doing these > exercises. How do I test such a *general* function? You are testing do_twice()

Re: [Tutor] Tutor Digest, Vol 152, Issue 3

2016-10-02 Thread Alan Gauld via Tutor
On 02/10/16 03:50, anish singh wrote: >> Possibly, but we can't tell because >> a) You don't show us the code that parses your input Thanks, that helps. > import os, sys, getopt > import re > import glob > > > def get_full_path(path, pattern): > for (dirpath, dirnames, filenames) in

Re: [Tutor] Testing print

2016-10-02 Thread Alan Gauld via Tutor
On 02/10/16 02:46, boB Stepp wrote: >> case. If I know that the result is always an int I can >> use the first case if I know its always a tuple I can >> use the second. But not knowing which is just plain >> messy. > > So in which sorts of scenarios would you use argument unpacking? Any time a

Re: [Tutor] Testing print

2016-10-01 Thread Alan Gauld via Tutor
On 01/10/16 23:08, boB Stepp wrote: > On Sat, Oct 1, 2016 at 11:35 AM, Alan Gauld via Tutor <tutor@python.org> > wrote: > >> ... Personally I don't like functions that >> sometimes return one and sometimes two results. I'd rather >> you returned a None first argu

Re: [Tutor] receiving regular expression from command line

2016-10-01 Thread Alan Gauld via Tutor
On 01/10/16 09:16, anish singh wrote: > I am trying to implement grep to just increase my knowledge > about regular expression. > > Below is the program usage: > python test.py -i Documents/linux/linux/ -s '\w+_readalarm*' > > However, due to my lack of knowledge about string handling > in

Re: [Tutor] Testing print

2016-10-01 Thread Alan Gauld via Tutor
On 01/10/16 16:12, boB Stepp wrote: >>> This module will take a string and right justify it so that the last >>> character >>> of the line will fall in column 70 of the display. The results will be >>> printed to stdout.''' >>> >> Do you need print_msgs()? >> Won't it work the same with >> >>

Re: [Tutor] Testing print

2016-10-01 Thread Alan Gauld via Tutor
On 01/10/16 05:24, boB Stepp wrote: > === > '''Exerise 3.1 from "Think Python 2" by Allen Downey. > > This module will take a string and right justify it so that the last character > of the line will fall in column 70 of

Re: [Tutor] Passing functions as arguments to other functions

2016-09-30 Thread Alan Gauld via Tutor
On 30/09/16 03:43, boB Stepp wrote: > Also, I note that if I just type a function name without the > parentheses in the interpreter, I will get something like this: > def f(): >pass > f > > > So the impression I am getting is that a function name by itself (with > no

Re: [Tutor] Help!!

2016-09-27 Thread Alan Gauld via Tutor
On 26/09/16 23:50, Shooby Herrmann wrote: > I am using JES. I've never heard of JES and know nothing about it. Fortunately it doesn't look like this problem has much to do with JES so that's not a problem this time... However in future when you submit a question (whether on this list or

Re: [Tutor] CSR generation script

2016-09-26 Thread Alan Gauld via Tutor
On 23/09/16 23:12, Srinivas Naga Kotaru (skotaru) wrote: > I am using pyOpenSSL module to automate CSR generation. Don't assume we know what that means. I know what pyOpenSSL is, but have no idea what CSR means to you. (To me it means Customer Service Representative!) > Not much

Re: [Tutor] python coding problem

2016-09-26 Thread Alan Gauld via Tutor
On 26/09/16 16:35, Richard Koeman wrote: > The function prints the first two print statements then nothing else > happens. > > def maximum(n1, n2): > print "the first number is" ,n1 > print "the second number is", n2 We know this works so far, so that's fine. > if n1 > n2: > return

Re: [Tutor] help with Numpy

2016-09-21 Thread Alan Gauld via Tutor
On 21/09/16 15:53, Paul Dentinger wrote: > Hello, > Sorry for such a basic question, but I am trying to get Numpy to work. I > have python 3.5 and working in IDLE. I need Numpy and Scipy and may need > matplotlib. To be honest while you can install all the bits separately I normally recommend

[Tutor] Testing tutor list server

2016-09-20 Thread Alan Gauld via Tutor
Just checkin' -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos ___ Tutor maillist - Tutor@python.org To

Re: [Tutor] Help with Max Number and Min number script

2016-09-18 Thread Alan Gauld via Tutor
On 17/09/16 00:08, Sharon Wallace wrote: > largest = None > smallest = None > > while True: > num = raw_input('Enter a number: ') > if num = 'done' : break should use == to test equality a single = is an assignment and would give an error here print num try :

Re: [Tutor] Help with Max Number and Min number script

2016-09-17 Thread Alan Gauld via Tutor
On 17/09/16 00:08, Sharon Wallace wrote: > inp = raw_input > largest = None > smallest = None > > while True: > num = raw_input('Enter a number: ') > if num = 'done' : break > print num > try : > num = float(inp)

Re: [Tutor] awk like functionality in python

2016-09-14 Thread Alan Gauld via Tutor
On 14/09/16 11:02, Alan Gauld via Tutor wrote: > - fileinput lets you process all files in a sub-directory tree. Duh, no it doesn't. It processes all the files in a list of filenames. Apologies. Correct usage is demonstrated below... > But using fileinput makes it slightly s

Re: [Tutor] awk like functionality in python

2016-09-14 Thread Alan Gauld via Tutor
On 13/09/16 18:27, Ron Williams wrote: > Hello, this is my first post. I'm glad a place like this exists. I'm coming > from primarily a shell scripting background and it was suggested I should > learn python because the two are closely related. Its often been said but its not strictly true.

Re: [Tutor] Need reference materials to learn flask + python for payroll project that would run both in windows (PC) and android/iOS.

2016-09-13 Thread Alan Gauld via Tutor
On 13/09/16 21:11, Glen Reytas wrote: > I have a basic knowledge in Python and I would like to enhance it by > engaging in a payroll project. For you to gauge my coding level, I finished > the Python course at codecademy.com but it was 2-3 years ago. Since then I > haven't coded aside from HTML.

Re: [Tutor] Error: 'IndexedVar' object is not callable

2016-09-10 Thread Alan Gauld via Tutor
On 10/09/16 17:23, Pooja Bhalode wrote: > I am trying to run Pyomo environment in Python on sublime text editor. OK, For the pyomo stuff you should ask on the pyomo support site (or I notice they do staxck overflow too) > Python version of 2.7.11. I am running the code in sublime itself. You

Re: [Tutor] Error: 'IndexedVar' object is not callable

2016-09-09 Thread Alan Gauld via Tutor
On 09/09/16 19:50, Pooja Bhalode wrote: > I was getting this error which read ' 'IndexedVar' object is not callable ' > for a variable type. Python error messages are very informative, but only if we can see them. Please post the entire error message not just a summary. > The variable is

Re: [Tutor] Hello!

2016-09-09 Thread Alan Gauld via Tutor
On 09/09/16 17:21, Eric Gardner wrote: > I don't know if i'm sending the email to the right address but here it > goes!. Would Python be a suitable language for first time learners like me? Yes, this is the right address, welcome. And yes, Python is an excellent language with which to learn

Re: [Tutor] crashes

2016-09-07 Thread Alan Gauld via Tutor
On 07/09/16 13:21, Rosalie de Klerk Bambara wrote: > Im trying to install python on my macbook air, I’ve installed these 3 > versions and deinstalled too. Python 2.7 should be installed by default since MacOS uses it. > By typing a ‘ the IDLE crash every time… > after the first ( the idle

Re: [Tutor] cannot find html file, in the same dir as python file

2016-09-06 Thread Alan Gauld via Tutor
On 06/09/16 03:18, monik...@netzero.net wrote: > I put > > print( os.getcwd() ) > > into my script, and got > > C:\Users\Monika\Documents\PythonWeb\class3code\class3code Is that the directory you expected? Is it where your html file lives? > So I put into my script: > > base_url = >

Re: [Tutor] cannot find html file, in the same dir as python file

2016-09-05 Thread Alan Gauld via Tutor
On 05/09/16 21:59, monik...@netzero.net wrote: > chromedriver = "resources/chromedriver" > os.environ["webdriver.chrome.driver"] = chromedriver > self.driver = webdriver.Chrome(chromedriver) > base_url = 'button.html' > self.driver.get(base_url) > >

Re: [Tutor] python memory management

2016-09-03 Thread Alan Gauld via Tutor
On 03/09/16 23:20, zakaria wrote: > Is there any practical usage of using reference cycling? There are a (very) few cases where data structures require the creation of cyclic references. One example I've used is in managing comms networks where nodes are multiply and/or cyclically linked and you

Re: [Tutor] What's the correct way to define/access methods of a member variable in a class pointing to an object?

2016-09-03 Thread Alan Gauld via Tutor
On 03/09/16 18:17, Steven D'Aprano wrote: > One classic example of the Law Of Demeter is: > > "If you want your dog to come to you, don't talk to your dog's legs, > talk to the dog." I love that, I've never seen it before but a great example. > But sometimes the Law Of Demeter should not

Re: [Tutor] python memory management

2016-09-03 Thread Alan Gauld via Tutor
On 03/09/16 04:25, monik...@netzero.net wrote: > Is this what you mean? > a = 5 > b = a > a = b No, you are confusing variable names with objects. Here you only have one object - the number 5. For a cycle you need at least 2 objects and those objects must be able to reference another object. In

Re: [Tutor] What's the correct way to define/access methods of a member variable in a class pointing to an object?

2016-09-03 Thread Alan Gauld via Tutor
On 03/09/16 06:55, Sharad Singla wrote: > What's the correct way to define/access methods of a member variable in a > class pointing to an object? Steven has already given you a long and comprehensive answer based on pragmatic python programming. But since you use the term "correct" I'll give

Re: [Tutor] Issue while using the python library

2016-09-02 Thread Alan Gauld via Tutor
On 02/09/16 15:07, Girish Grover wrote: > I am trying to use a python package from github and struggling to make it > work. Looking for experts to help me out. Technically its off topic for this list which is for core language and standard library issues. But if you were to tell us what package

Re: [Tutor] python memory management

2016-09-01 Thread Alan Gauld via Tutor
On 01/09/16 15:12, monik...@netzero.net wrote: > Can somebody please explain how memory is managed by python? > What kind of memory it uses? What structures use what kind of memory? I'm not sure what you have in mind? Do you want to know the internal structure of the various data types? Do you

Re: [Tutor] Inheritance vs Assignment

2016-09-01 Thread Alan Gauld via Tutor
On 01/09/16 04:18, kay Cee wrote: > Class a(): > def__init__(self, var): > pass > > Class b(a): > def__init__(self): > super().__init__(self, var) > pass > Is it better to do > > b = a() > > Instead of making b its own class? > Also, what would be the

Re: [Tutor] Help with NameError

2016-09-01 Thread Alan Gauld via Tutor
On 01/09/16 02:29, Bryan Callow wrote: > Could someone help me with a NameError that I can't seem to figure out. It is hard for us to figure out without seeing the error message. It should tell you which name is in error and where. Please repost with the full error message included. -- Alan G

Re: [Tutor] generator object

2016-08-31 Thread Alan Gauld via Tutor
On 31/08/16 08:56, Alan Gauld via Tutor wrote: > A generator function can return any kind of object including > basic types like numbers, bool etc.In addition, a generator > function yields values which can also be of any type. Hmmm. After reading Steven's response I played around a bi

Re: [Tutor] generator object

2016-08-31 Thread Alan Gauld via Tutor
On 31/08/16 05:12, monik...@netzero.net wrote: So generator function returns generator object according to Aaron Maxwell. I don't believe that's correct. A generator function can return any kind of object including basic types like numbers, bool etc.In addition, a generator function yields

Re: [Tutor] __init__

2016-08-30 Thread Alan Gauld via Tutor
On 30/08/16 22:08, monik...@netzero.net wrote: OK so somebodys remark that there is a default __init__ provided was not correct. It depends on how you interpret default. In so far as object is the default superclass (in v3) and it provides an init then there is a default, but its not part

Re: [Tutor] __init__

2016-08-30 Thread Alan Gauld via Tutor
On 30/08/16 17:59, monik...@netzero.net wrote: Assume you have a child class with no init, but it has empty, > default __init__ provided by pathon It inherits the empty init from object. and the same for its parent class. When instantiating child class, > child class's __new__ calls its

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