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 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 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] 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] 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] 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] __init__

2016-08-29 Thread Alan Gauld via Tutor
On 29/08/16 20:03, monik...@netzero.net wrote: If __init__ is not defined in a class, will it be called when creating an instance? What in a case if this class inherits from parent with __init__ and without __init__? The easiest way to find out is try it and see what happens! Just put

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] 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] __init__

2016-08-30 Thread Alan Gauld via Tutor
On 30/08/16 12:50, eryksun wrote: On Tue, Aug 30, 2016 at 9:09 AM, Alan Gauld via Tutor <tutor@python.org> wrote: new() that sets up the memory then calls init(). So init is only used to initialise the object after it has been constructed. __new__ and __init__ are called by the met

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

Re: [Tutor] ImportError: cannot import name

2016-08-30 Thread Alan Gauld via Tutor
On 30/08/16 10:25, fa306...@skynet.be wrote: Hello, I use python 3.5.1 and try to import sompy and get the following error: File "C:\Anaconda3\lib\site-packages\sompy-1.0-py3.5.egg\sompy\__init__.py", line 30, in from sompy import SOMFactory ImportError: cannot import name 'SOMFactory'

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] Error help

2016-08-30 Thread Alan Gauld via Tutor
On 30/08/16 03:22, Matthew Lehmberg wrote: I've been getting this error over and over and was wondering if someone could help me fix it. [image: Inline image 1] This is a text mailing list so attachments dont get through. Plese repost with your error message cut n paste into the message. Alan

Re: [Tutor] __init__

2016-08-30 Thread Alan Gauld via Tutor
On 29/08/16 23:52, monik...@netzero.net wrote: I cannot really try it. If I have a class without __init__ and the class does not > inherit from a class that has init there is really no place > for me to put print statement. Fair enough but in that case there is no __init__ to call. The top

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] 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] 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] 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] 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] 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] 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] 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 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] 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] 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] 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] 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] 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 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] (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] 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] 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] 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 :

[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 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

Re: [Tutor] simple troubleshooting question

2016-08-17 Thread Alan Gauld via Tutor
On 17/08/16 23:15, Ken Mayer wrote: > I'm new to Python. I'm trying to do 3 things that are giving me invalid > syntax or other problems: > > 1) import numpy as np > > ImportError: No module named 'numpy' Numpy is not part of standard Python. You need to install it seperately or, my

Re: [Tutor] Running Python code without python installed

2016-08-27 Thread Alan Gauld via Tutor
On 27/08/16 07:26, Jade Beckmann wrote: > I'm just wondering how someone who doesn't have the python software > installed on their PC or mac would be able to run the program? They can't. You need the interpreter to be able to run Python code. The good news is that Macs come with Python

Re: [Tutor] tkinter/sqlite3?

2016-08-26 Thread Alan Gauld via Tutor
On 26/08/16 02:34, Jim Byrnes wrote: > Exception in Tkinter callback > Traceback (most recent call last): ... >File "tk_pwds.py", line 56, in fill_accounts_lb > cur.execute('''SELECT Account FROM pwds WHERE Category=? ORDER BY > Account COLLATE NOCASE''', category) >

Re: [Tutor] syntax error help

2016-08-26 Thread Alan Gauld via Tutor
On 30/03/16 19:05, Awais Mamoon wrote: > Hi my code should be working however keeps coming up with invalid syntax but > I know there isn’t one. You are wrong. There is. I suspect the error message tells you where it is. In future please include the full error message with your code. Look

Re: [Tutor] Problem

2016-08-28 Thread Alan Gauld via Tutor
On 28/08/16 15:46, shahan khan wrote: Theorem: If it is possible to buy x, x+1,…, x+5 sets of McNuggets, for some x, then it is possible to buy any number of McNuggets >= x, given that McNuggets come in 6, 9 and 20 packs. Here is my code: for a in range(1,10): for b in range(1,5): for c in

Re: [Tutor] Problem

2016-08-29 Thread Alan Gauld via Tutor
On 28/08/16 23:53, shahan khan wrote: I changed the code a bit and this is the result: for a in range(1,11): for b in range(1,6): for c in range(1,6): mc=(6*a)+(9*b)+(20*c) if mc==50: print 'For 50 McNuggets:''a=',a,'b=',b,'c=',c if mc==51: print 'Fpr 51 McNuggets:''a=',a,'b=',b,'c=',c if

Re: [Tutor] I Need Help

2016-08-24 Thread Alan Gauld via Tutor
On 24/08/16 11:26, Micheal Emeagi wrote: > forcast values. Ft is the forcast list whose length should be one element > greater than the Yt list. I want the elements of ft to increment by one > while I use it to generate the subsequent element. But for some reasons I > don't understand, it keeps

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

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

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

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] 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] __getitem__

2016-11-23 Thread Alan Gauld via Tutor
On 23/11/16 12:25, monik...@netzero.net wrote: > I have two questions in regards to below code: > 1. largest is a list, not a list of lists. > [('deit', 4), ('acer', 3), ('aceilmr', 2), ('arst', 2)] > so why when I do largest[0] I get the whole list again, I don't know you will need to show us

Re: [Tutor] __getitem__ another problem

2016-11-23 Thread Alan Gauld via Tutor
On 23/11/16 12:33, monik...@netzero.net wrote: > So numbermap.__getitem__ brings back 1, then 2,then 3, then 4. > Then it looks up 1 ,2, 3, 4 in month but there is no key with value 1, 2, or > or in 4. > What am I missing? Your problem is not with getitem but with sorted. You need to read up

Re: [Tutor] inquiry

2016-11-26 Thread Alan Gauld via Tutor
On 26/11/16 04:59, zxjhust1 wrote: > Dear tutors: >I have some questions about memory mechanism of python. Depending on the level of detail you need this might be more appropriate to the general Python list. Implementation details are usually a bit too advanced for most readers of tutor.

Re: [Tutor] __getitem__ another problem

2016-11-23 Thread Alan Gauld via Tutor
On 23/11/16 06:26, monik...@netzero.net wrote: > I do not understand how numbermap.__getitem__ brings back month's key. numbermap returns the integer corresponding to the key. That number is then used by sorted as the basis for sorting month. So for the first entry sorted receives the value 1,

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 code

2016-11-24 Thread Alan Gauld via Tutor
On 24/11/16 23:14, urfa jamil wrote: > I need help to write a code for this problem. > > Please help OK, But what exactly do you want help with? Have you written any code yet? If so show us. Also if you get an error message post it. > Ask the user to enter a series of numbers. Can you do this

Re: [Tutor] how to move an executable into path

2016-11-27 Thread Alan Gauld via Tutor
On 23/11/16 00:33, Benjamin Fishbein wrote: > I should probably learn how to handle paths and file systems, etc., You definitely should if you intend doing any serious programming on MacOS. Learn to drive the Terminal tool and the basic Unix command line tools and you will have much more

Re: [Tutor] Help on Software Design decisions

2016-11-28 Thread Alan Gauld via Tutor
On 28/11/16 21:53, Juan C. wrote: > I'm a student and my university uses Moodle as their learning management > system (LMS). Never heard of it but hopefully that doesn't matter :-) > 1. Bachelor's Degree in Computer Science (duration: 8 semesters) > > 1.1. Unit 01: Mathematics Fundamental

Re: [Tutor] Help with Python Queue

2016-11-26 Thread Alan Gauld via Tutor
On 26/11/16 09:07, anish singh wrote: > I have below code but it is giving this error: > AttributeError: Queue instance has no attribute 'taskdone' Please post the full error not just a summary. Also please post the actual code... > import threading > from Queue import Queue I get an import

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] 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] 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] 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-03 Thread Alan Gauld via Tutor
On 03/11/16 06:43, Palanikumar Gopalakrishnan wrote: > On Wed, Nov 2, 2016 at 7:36 AM, wrote: ... >> Today's Topics: >> >>1. Re: Python code (Danny Yoo) >>2. Re: implementing sed - termination error (c...@zip.com.au) >>3. Module webbrowser.os (Palanikumar

<    1   2   3   4   5   6   7   8   9   10   >