Re: [Tutor] Can we talk with a Real Time Clock hardware by Python?

2017-02-13 Thread Alan Gauld via Tutor
On 13/02/17 06:44, Thanh Tuan Le wrote: > I have a board that have a Real Time Clock (RTC) chip on that board. I need > to communicate with that RTC chip by Python. > > Following is my hardware info. > - Board from Variscite: > http://www.variscite.com/products/single-board-computers/dt6customboar

Re: [Tutor] Issue with set_value function

2017-02-13 Thread Alan Gauld via Tutor
On 13/02/17 07:23, Yap Gerald wrote: > I have a problem with the functions set_value which I could not find a > solution on the net. This is very confusing. You don't use set_value() anywhere in the code you posted? You don't describe what the actual problem with set_ value() is. And most of all

Re: [Tutor] GUI for ANSI colors

2017-02-13 Thread Alan Gauld via Tutor
On 13/02/17 09:40, Freedom Peacemaker wrote: > I'm trying to put my script with randomly colored letters (ANSI escape > code) into GUI but cant find any. I've tried tkinter but it isn't good > choice. Why not? It can certainly do what you want. As can virtually any other GUI toolkit. But program

Re: [Tutor] Resending question with smaller file

2017-02-13 Thread Alan Gauld via Tutor
On 13/02/17 16:06, Lisa Hasler Waters wrote: > We are trying to use the random function in the Tkinter module > from tkinter import * > import random This looks for the random module and tries your local folder first. If you have a file called random.py it tries to import that. Based on your e

Re: [Tutor] Help with random in Tkinter

2017-02-13 Thread Alan Gauld via Tutor
On 13/02/17 13:30, Lisa Hasler Waters wrote: > It runs fine when we use IDLE. But, we love PyCharmEDU as it is much more > user-friendly and so we hope to run the same programs in it as we can in > IDLE. That shouldn't make much difference unless PyCharm sets its default folders differently? BTW

[Tutor] Fwd: Re: GUI for ANSI colors

2017-02-13 Thread Alan Gauld via Tutor
= ascii_letters + digits word = ''.join(choice(chars) for i in range(12)) red = '\033[91m' yel = '\033[93m' blu = '\033[34m' grn = '\033[32m' colors = [red, yel, blu, grn] final_word = ''.join(choice(colors) + char for char in word) print(

Re: [Tutor] Access a .tcl file in python

2017-02-13 Thread Alan Gauld via Tutor
On 13/02/17 19:37, Lily ANTONY wrote: > I have a .tcl file.Does anyone know how to load a .tcl file in to python?I > need to call the .tcl file in > a python program..Thanks! In general you can't run code for one language in a program written in another language. (There are a few exceptions, usua

Re: [Tutor] Fwd: Re: GUI for ANSI colors

2017-02-13 Thread Alan Gauld via Tutor
On 14/02/17 00:58, Alan Gauld forwarded: > red = '\033[91m' > yel = '\033[93m' > blu = '\033[34m' > grn = '\033[32m' These are indeed the ANSI codes for the colours but ANSI codes only work in an ANSI terminal and GUIs are not ANSI terminals. Instead they have their own ideas on colours and you n

Re: [Tutor] Q about .join() Thanks!

2017-02-13 Thread Alan Gauld via Tutor
On 13/02/17 18:34, SIJIA CHEN wrote: > I find out that the outcome for using .join() on a dictionary is > totally different than it using on list or string. Not really, it just looks like that :-) > > >>> seq4 = {'hello':1,'good':2,'boy':3,'doiido':4} > >>> p

Re: [Tutor] NameError: name 'hurst' is not defined

2017-02-14 Thread Alan Gauld via Tutor
On 14/02/17 01:55, Allan Tanaka via Tutor wrote: > Hi. Not sure why this code produces the error like this. This error appears > when i run the code of print "Hurst(GBM): %s" % hurst(gbm): > Traceback (most recent call last): File "", line 1, in > print "Hurst(GBM): %s" % hurst(gbm)Name

Re: [Tutor] NameError: name 'hurst' is not defined

2017-02-14 Thread Alan Gauld via Tutor
On 14/02/17 10:11, Alan Gauld via Tutor wrote: >>>> ts.adfuller(goog['Adj Close'], 1 > > there seems to be a missing closing paren here? > Also where does 'ts' come from, its not defined above? Ah! I see from Peters post that I missed the firs

Re: [Tutor] Exponential function

2017-02-14 Thread Alan Gauld via Tutor
On 14/02/17 12:03, Aaliyah Ebrahim wrote: > For the function 1*10^x, is there a specific way of computing *10^x or will > it just be the following : > > 1*10**x To compute it if you don't know x in advance then yes, use something like value = 10**x But if you know the value in advance you can

Re: [Tutor] Tutor Digest, Vol 156, Issue 33

2017-02-14 Thread Alan Gauld via Tutor
As per my offline reply, just send messages to the list and the whole group will act as a virtual mentor. One other thing though. Please start new topics with a new message. Do NOT reply to an existing thread as it messes up the archives. And especially do not reply to a digest message. And use a

Re: [Tutor] Exponential function

2017-02-15 Thread Alan Gauld via Tutor
On 15/02/17 04:43, eryk sun wrote: >> value = 1e5 # or 3e7 or whatever... > > 10**5 is an int and 1e5 is a float. Good point, I'd forgotten about that distinction. > Replacing 10**5 with 10 is a compile-time optimization And didn't know about that one. Thanks for the clarification. --

Re: [Tutor] Please explain part of this code

2017-02-15 Thread Alan Gauld via Tutor
On 15/02/17 22:37, Jim wrote: > self.choices = { > "1": self.show_notes, > "2": self.search_notes, > "3": self.add_note, > "4": self.modify_note, > "5": self.quit > } > > The author says

Re: [Tutor] Need help with one problem.

2017-02-15 Thread Alan Gauld via Tutor
On 15/02/17 18:00, Adam Howlett wrote: > Write an if-else statement that > assigns 20 to the variable y if the variable x is greater than 100. > Otherwise, it should assign 0 to the variable y. > > Is there an easy way to solve this problem? Yes, just do what it says. Maybe if I reword the pro

Re: [Tutor] [Python 2.7] HELP: Serving HTTP on 0.0.0.0 port 80 not proceeding

2017-02-16 Thread Alan Gauld via Tutor
There are several issues here, I'll try to address them separately below... On 16/02/17 13:26, Allan Tanaka via Tutor wrote: > Not completely sure why it doesn't open the chart on the web browser You haven't shown us chart.html so we can't guess how your data in ticks.json is supposed to get int

Re: [Tutor] Select and deselect for multiple checkboxes in Tkinter

2017-02-17 Thread Alan Gauld via Tutor
On 17/02/17 18:31, Pooja Bhalode wrote: > I am writing to create two buttons, for selecting and de-selecting multiple > checkboxes that I have created previously. These checkboxes have different > variables that they are associated with for their values and thus cannot > create a loop for the same

Re: [Tutor] [Python 2.7] HELP: Serving HTTP on 0.0.0.0 port 80 not proceeding

2017-02-18 Thread Alan Gauld via Tutor
Please don't repeat post. We saw it the first time. Please do post again with the extra information requested. On 18/02/17 04:46, Allan Tanaka via Tutor wrote: > Not completely sure why it doesn't open the chart on the web browser when i > type this in the windows command prompt (cmd) python -m

Re: [Tutor] SciPy Optimize-like calling function as string

2017-02-18 Thread Alan Gauld via Tutor
On 18/02/17 21:52, Joseph Slater wrote: > I'm trying to use the scipy.optimize code ... > I've seen this done with dictionaries on some pages, > but it seems that this is intended to be faster There is a saying in programming that premature optimization is the root of all evil. If you don't know

Re: [Tutor] convert an integer number to string.

2017-02-20 Thread Alan Gauld via Tutor
On 20/02/17 09:36, Steven D'Aprano wrote: > Comma after "button" is not needed. > > cmds.button(label ="button" + srt(i+1)) > > may be better. and cmds.button(label ="button" + str(i+1)) better still :-) -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http

Re: [Tutor] Creating tables in Tkinter

2017-02-20 Thread Alan Gauld via Tutor
On 19/02/17 16:18, Pooja Bhalode wrote: > Hi, > > I am trying to create a simple table. But I was wondering how do I get the > title of the table to span over multiple columns in the first row. > Code: > > from Tkinter import * > > root = Tk() > root.geometry("700x500") > Label(root, text = "Tab

Re: [Tutor] Resources/Books for teaching OOP in Python and Tkinter

2017-02-20 Thread Alan Gauld via Tutor
On 19/02/17 16:34, Marie Shaw via Tutor wrote: > I am a teacher of 16-18 year olds. > I now need to teach them OOP using Python, > and GUI programming using Python. Those are two different topics, although most GUIs are easier if used with OOP. However, most tutorials (including mine) teach th

Re: [Tutor] Matplotlib in Tkinter

2017-02-20 Thread Alan Gauld via Tutor
On 20/02/17 14:54, Pooja Bhalode wrote: > Another issue, in this that is happening which is far more important from > the perspective that I am looking at, is that when I click the button > twice, two graphs get created one below the other. > > I tried adding a delete("all") statement as shown b

Re: [Tutor] Wedscraping Yahoo API

2017-02-20 Thread Alan Gauld via Tutor
Please post in plain text. Formatting is very important in Python and RTF or HTML tend to get scrambled in transit making your code and error hard to read. Thanks Alan G. On 20/02/17 14:32, Joe via Tutor wrote: > Hi, > I keep getting the following error as I am new to programming and I am > fol

Re: [Tutor] Class Inheritance

2017-02-21 Thread Alan Gauld via Tutor
On 21/02/17 09:49, Rafael Knuth wrote: > class FullPriceCustomer(object): > def __init__(self, customer, rate, hours): > > > class DiscountCustomer(FullPriceCustomer): > discount = 0.7 > def calculate_discount(self, rate, hours): > > customer_one = DiscountCustomer("Customer A", 75,

Re: [Tutor] Class Inheritance

2017-02-21 Thread Alan Gauld via Tutor
On 21/02/17 09:49, Rafael Knuth wrote: > class DiscountCustomer(FullPriceCustomer): > discount = 0.7 > def calculate_discount(self, rate, hours): > print ("Your customer %s made you %s USD at a 30% discount > rate this year." % (self.customer, self.rate * rate * discount)) I meant

Re: [Tutor] Trip Advisor Web Scraping

2017-02-22 Thread Alan Gauld via Tutor
On 22/02/17 02:55, Francis Pino wrote: > I need to recode my hotel ratings as 1-3 = Negative and 4-5 Positive. Can > you help point me in the direction to do this? I know I need to make a loop > using for and in and may statement like for rating in review if review >= 3 > print ('Negative') else

Re: [Tutor] How to access an instance variable of a superclass from an instance of the subclass?

2017-02-23 Thread Alan Gauld via Tutor
On 23/02/17 04:25, boB Stepp wrote: > I am trying to wrap my head around the mechanics of inheritance in > Python 3. I thought that all attributes of a superclass were > accessible to an instance of a subclass. For class attributes that happens automatically. >>> class A: a = 'A'

Re: [Tutor] Asking about Opening Teminal on Python

2017-02-23 Thread Alan Gauld via Tutor
On 23/02/17 22:16, Quang nguyen wrote: > Hi everyone, > I need to open a terminal on Raspberry Pi 2 in order to execute codesend of > 433Utils to send a signal to RF Receiver. Anyone know how to open a > terminal? Do you really need a terminal? Or do you only need to execute some commands? In eit

Re: [Tutor] Multiple muti-selection dropdown options

2017-02-23 Thread Alan Gauld via Tutor
On 23/02/17 22:25, Pooja Bhalode wrote: > I am working on GUI where I have two dropdown menus in a Toplevel of the > main root. That's not what your code shows. It shows scrolling listboxes, not menus. But it seems like a Frame with a set of checkboxes would be closer to what you actually want?

Re: [Tutor] Asking about Opening Teminal on Python

2017-02-24 Thread Alan Gauld via Tutor
On 24/02/17 02:04, Quang nguyen wrote: > Right now, I have school project for sending signal from Pi2 to > mutilple devices. And I am using 433Utils library for sending > and receiving signal. They provided file for do that but it only > execute on terminal, and i also have an UI. > > So I have an

Re: [Tutor] Multiple muti-selection dropdown options

2017-02-24 Thread Alan Gauld via Tutor
On 24/02/17 14:39, Pooja Bhalode wrote: > list, and then move to the next list, I loose the selections made on the > screen in the first list. I can however print it out and store it in the > code, but I would like to show it on the screen as well Peter has given you the answer: you need to speci

[Tutor] Fwd: Re: SciPy Optimize-like calling function as string

2017-02-25 Thread Alan Gauld via Tutor
Forwarding to list. Please always use reply-All or Reply-list when responding to the list. On Feb 18, 2017, at 6:21 PM, Alan Gauld via Tutor mailto:tutor@python.org>> wrote: > > On 18/02/17 21:52, Joseph Slater wrote: >> I'm trying to use the scipy.optimize code ... >

Re: [Tutor] counting number of loops

2017-02-25 Thread Alan Gauld via Tutor
On 25/02/17 17:12, Rafael Knuth wrote: > I want to compare two strings and count the number of identical letters: > > stringB = "ABCD" > stringA = "AABBCCDDEE" > for b in stringB: > if b in stringA: > r = 0 > r += 1 > print (r) > > How do I count the output (r) instead

Re: [Tutor] Invalid Syntax

2017-02-25 Thread Alan Gauld via Tutor
On 25/02/17 10:35, ehsan faraz wrote: > ... where “tip” is an invalid syntax. You need to assign a value to tip before trying to read it, otherwise tip is undefined. Similarly you should define price before trying to use it. But those would give you a NameError not a syntax error... Can you sen

Re: [Tutor] Fwd: Re: SciPy Optimize-like calling function as string

2017-02-25 Thread Alan Gauld via Tutor
On 25/02/17 17:24, Alan Gauld via Tutor wrote: >> If you don't know that you need to optimize then your >> time is usually better spent elsewhere. Dictionaries >> are pretty fast in Python and I'd suggest you try >> that first before shaving milliseconds in p

Re: [Tutor] UDP client

2017-02-26 Thread Alan Gauld via Tutor
On 26/02/17 06:44, Phil wrote: > s.connect((host, 1210)) > data = "GET_LIST" This is a string, you need to use bytes. data = bytes("GET_LIST",'utf8') > s.sendall(data) > #s.sendto(data, (host, 1210)) > s.shutdown(1) > Traceback (most recent call last): >File "/home/phil/Python/predict_clie

Re: [Tutor] [Python 2.7] HELP: Serving HTTP on 0.0.0.0 port 80 not proceeding

2017-02-27 Thread Alan Gauld via Tutor
On 27/02/17 02:44, Allan Tanaka via Tutor wrote: > I try to access it with http://0.0.0.0:8000/chart.html via Google Chrome, > On 18/02/17 04:46, Allan Tanaka via Tutor wrote: >> Not completely sure why it doesn't open the chart on the web browser >> when i type this in the windows command promp

Re: [Tutor] Checkbuttons Variables PY_VAR

2017-02-27 Thread Alan Gauld via Tutor
On 27/02/17 03:06, Pooja Bhalode wrote: > The following code creates a list of checkboxes It would really help uif you posted in plain text. The HTML/RTF is getting very hard to read with no indentation. > ones that user wants, I am trying to add the selected variables to another > list so that t

Re: [Tutor] [Python 2.7] HELP: Serving HTTP on 0.0.0.0 port 80 not proceeding

2017-02-27 Thread Alan Gauld via Tutor
On 27/02/17 10:13, Allan Tanaka via Tutor wrote: > I have changed the syntax to be python -m SimpleHTTPServer 8000 > to match my ml python script. Still it doesn't work? Define "doesn't work"? What happens? Do you see an error message - if so which one? What happens if you use the base url? ht

Re: [Tutor] Checkbuttons Variables PY_VAR

2017-02-27 Thread Alan Gauld via Tutor
On 27/02/17 03:06, Pooja Bhalode wrote: > for i in range(len(checkboxVars)): > if checkboxVars[i].get() == 1: >print checkboxVars[i] >selectedparam.append(checkboxVars[i]) As a point of Pythonic style this would be better written (and easier to read) as for var in checkboxVar

Re: [Tutor] [Python 2.7] HELP: Serving HTTP on 0.0.0.0 port 80 not proceeding

2017-02-27 Thread Alan Gauld via Tutor
On 27/02/17 10:24, Alan Gauld via Tutor wrote: > On 27/02/17 10:13, Allan Tanaka via Tutor wrote: >> I have changed the syntax to be python -m SimpleHTTPServer 8000 >> to match my ml python script. Still it doesn't work? A couple of other things to check: 1) does check.htm

Re: [Tutor] [Python 2.7] HELP: Serving HTTP on 0.0.0.0 port 80 not proceeding

2017-02-27 Thread Alan Gauld via Tutor
On 27/02/17 10:40, Allan Tanaka via Tutor wrote: > After typing python -m SimpleHTTPServer 8000 in CMD > then i proceed to my google chrome and type http://allan-pc:8000/ OK, But to be safe I'd probably stick to 0.0.0.0 rather than your PC name - it eliminates routing errors from the equation. >

Re: [Tutor] [Python 2.7] HELP: Serving HTTP on 0.0.0.0 port 80 not proceeding

2017-02-27 Thread Alan Gauld via Tutor
On 27/02/17 11:22, Allan Tanaka wrote: > - And did you see chart.html in that listing? > Yes it's there > > - How did you "proceed"? > Did you click the link in the directorty listing > or did you type it in by hand? > I click the link in directory listing OK, It looks like the server side is work

Re: [Tutor] Learning Objectives?

2017-02-27 Thread Alan Gauld via Tutor
On 27/02/17 10:44, Leam Hall wrote: > Is there a list of Python skill progression, like "Intermediates should > know and Advanced should know ?" Trying to map out > a well rounded study list. I'm not aware of such a list, and I'm not sure it's of much value. Better to just learn what you need a

Re: [Tutor] Problem with Spyder IDE in Anaconda3

2017-02-27 Thread Alan Gauld via Tutor
On 27/02/17 20:52, Stephen P. Molnar wrote: > To the best of my knowledge I am not running any anti-virus software. > This has always been a Linux computer and there has been no need. There are threats to Linux just fewer of them, plus you could be used as a host to pass on damaged files so you

Re: [Tutor] Learning Objectives?

2017-02-27 Thread Alan Gauld via Tutor
On 27/02/17 14:57, leam hall wrote: >> I'm not aware of such a list, and I'm not sure it's of much value. >> Better to just learn what you need and use it. ... > When I was coming up as a Linux guy I took the old SAGE guidelines and > studied each "level" in turn. It was useful for making me a we

Re: [Tutor] Help with this question

2017-02-27 Thread Alan Gauld via Tutor
On 27/02/17 22:00, Johnny Hh wrote: > write a python function called find_most_freq() that returns the element of > a given list that occurs the most frequently. If there are ties, take the > number found first. OK, You've shown us the exercise, now show us your attempt at a solution. Here is a s

Re: [Tutor] help with and

2017-03-01 Thread Alan Gauld via Tutor
On 01/03/17 06:21, darrickbled...@gmail.com wrote: > wage = eval(input("Enter in the employees hourly wage: ")) #get wage > hours_worked = eval(input("Enter in the number of hours worked: ")) Don't use eval() like this it is a security risk and is a very bad habit to get into. Instead use an expl

Re: [Tutor] Asking about sending signal to RF receiver through GPIO pins

2017-03-01 Thread Alan Gauld via Tutor
On 01/03/17 01:29, Quang nguyen wrote: > send the signal to RF receiver through pins in Pi2. I need to send the > signal from clicking a button in UI. > > Can anyone give me some hints? What bit do you need help on? Is it building a UI? Is it clicking a button? Is it sending the signal? For exa

Re: [Tutor] Understanding the error "method got multiple values for keyword argument "

2017-03-01 Thread Alan Gauld via Tutor
On 01/03/17 08:18, Pabitra Pati wrote: > def total(name, *args): > if args: > print("%s has total money of Rs %d/- " %(name, sum(args))) > else: > print("%s's piggy bank has no money" %name) > > I can call this method passing the extra arguments inside

Re: [Tutor] Understanding the error "method got multiple values for keyword argument "

2017-03-01 Thread Alan Gauld via Tutor
On 01/03/17 10:50, Peter Otten wrote: >> sees your call as something like: >> >> total(name = "John", 1, 2, 10 ) > > I think total(name="John", *(1, 2, 3)) > > is rather resolved as > > total(1, 2, 3, name="John") > Ah, yes that makes sense. Thanks for the clarification Peter (and Steven). T

Re: [Tutor] Learning Objectives?

2017-03-01 Thread Alan Gauld via Tutor
On 01/03/17 10:09, Leam Hall wrote: > I see computer science as a science that calls upon our creative nature > to produce excellence. Adding constraints like secure coding and TDD > push us to even greater artistic expression. Lack of constraints gives > us the current standard of non-performa

Re: [Tutor] Tables in Tkinter

2017-03-01 Thread Alan Gauld via Tutor
On 01/03/17 23:40, Pooja Bhalode wrote: > I am trying to create normal tables in Tkinter. First you need to define what a "normal table" is. There is no such thing in standard Tkinter, so any kind of table is not normal. Do you want a simple grid of values? Do you want a spreadsheet type grid w

Re: [Tutor] Spyder IDE Anaconda3: Problem with Plt.savefig

2017-03-01 Thread Alan Gauld via Tutor
On 01/03/17 20:20, Stephen P. Molnar wrote: > I have written a Python3 program to plot and save UV/VIS spectra from > the results of an Orca quantum mechanical calculation. Caveat: This forum is for help on the core Python language and its standard library. Asking about anything beyond that may r

Re: [Tutor] grb.select for multiple times

2017-03-01 Thread Alan Gauld via Tutor
On 01/03/17 18:23, Jason Snyder wrote: > I have a grib2 file with wind data at multiple taus as shown below: This list is for the core Python language and standard library. For anything outside that you are more likely to get answers on the specific library support forum or community. If that fai

Re: [Tutor] looping - beginner question

2017-03-02 Thread Alan Gauld via Tutor
On 02/03/17 13:42, Rafael Knuth wrote: > bar = ["beer", "coke", "wine"] > > customer_order = input("What would you like to drink, dear guest? ") > > for drink in bar: > if customer_order != drink: > print ("Sorry, we don't serve %s." % customer_order) > else: > print ("Su

Re: [Tutor] Tables in Tkinter

2017-03-02 Thread Alan Gauld via Tutor
On 02/03/17 14:25, Pooja Bhalode wrote: > when I tried to install tkintertable using pip: i got the following errors: > > OSError: [Errno 13] Permission denied: > '/Library/Python/2.7/site-packages/Pmw' Based on this I'm guessing you need to run pip with sudo? -- Alan G Author of the Learn to

Re: [Tutor] Asking about pi_switch

2017-03-02 Thread Alan Gauld via Tutor
On 02/03/17 22:20, Quang nguyen wrote: > Right now, I need to use pi_switch in order to send data through RF system > by Pi2. Until now, I installed everything it need from an article on the > internet. Those things are python-dev, libboost-python-dev, python-pip, and > I used pip to install pi_sw

Re: [Tutor] printing items form list

2017-03-03 Thread Alan Gauld via Tutor
On 03/03/17 18:52, Peter Otten wrote: > Antonio Zagheni via Tutor wrote: > >> suitcase = ["book, ", "towel, ", "shirt, ", "pants"] > > Hm, looks like you opened Rafael's suitcase while he wasn't looking, and > sneaked in some commas and spaces ;) > > That's cheating... Its also very difficul

Re: [Tutor] Tables in Tkinter

2017-03-03 Thread Alan Gauld via Tutor
On 03/03/17 16:07, Pooja Bhalode wrote: > The table that I am trying to get is a table with scrollable rows. I just > want to display the data in the table in the Tkinter window. I do not wish > to make it interactive, since just want to display the data. In that case you could just use a scroll

Re: [Tutor] Radiobuttons (two options out of 4)

2017-03-03 Thread Alan Gauld via Tutor
On 03/03/17 16:43, Pooja Bhalode wrote: > I am trying to create a GUI with four options out of which the user is > supposed to select two. But once the user selected two out of those four > options, the others need to get greyed out at that instant. > > I tried the following thing: > > *Label(lo

Re: [Tutor] Radiobuttons (two options out of 4)

2017-03-03 Thread Alan Gauld via Tutor
On 03/03/17 20:59, Pooja Bhalode wrote: > I tried putting in the event handlers for the checkbuttons as shown below. > > num = 0 > def selfcheck(event): > print "Self Check" > num = num + 1 > if num == 2: You need num to be inside the function since it needs to be reset to zero on

Re: [Tutor] pdf generation problem

2017-03-03 Thread Alan Gauld via Tutor
On 04/03/17 00:28, Jason Snyder wrote: > I have the following program where I am trying to generate a pdf: > 6 from matplotlib.backends.backend_pdf import PdfPages > 7 import numpy as np > 13 with PdfPages('wx_plot.pdf') as pdf: > When I run it I get the following error: > > Tr

Re: [Tutor] Tables in Tkinter

2017-03-03 Thread Alan Gauld via Tutor
On 03/03/17 21:15, Pooja Bhalode wrote: > Hi Alan, > > Can you please guide me to an example related to this problem? I do not > know how to use the scrollable frame, set backgrounds etc. > Sorry, I am new to tables in Tkinter. I could not find any examples as well WE are all new to tables in Tki

Re: [Tutor] Problems with matplotlib

2017-03-03 Thread Alan Gauld via Tutor
On 03/03/17 22:59, Jason Snyder wrote: > I installed the python module matplotlib on a computer and when I try to > run a program with the commands: > > import matplotlib.pyplot as plt I get the following errors: It could be an installation issue, but really this list is for the core language and

Re: [Tutor] QUESTION

2017-03-04 Thread Alan Gauld via Tutor
On 04/03/17 01:37, Tasha Burman wrote: > I am having difficulty with a power function; > what is another way I can do 4**9 without using **? You can use the pow() function. answer = pow(4,9) However, I'm not sure that really answers your question? Do you mean that you want to write your own pow

Re: [Tutor] Calculate 4**9 without using **

2017-03-04 Thread Alan Gauld via Tutor
On 04/03/17 16:17, Sri Kavi wrote: > I'm a beginner learning to program with Python. I'm trying to explain a > solution in plain English. Please correct me if I'm wrong. See the thread earlier today with the subject QUESTION for more on this topic. > Create a function that takes base and exponen

Re: [Tutor] Tables in Tkinter

2017-03-05 Thread Alan Gauld via Tutor
On 04/03/17 01:47, Alan Gauld via Tutor wrote: >> Can you please guide me to an example related to this problem? I had a play and here is a simple DisplayTable widget. Its still not a scrollable frame (although i might get round to that later...) But it takes a list of headings and a 2D l

Re: [Tutor] collections.Callable functionality

2017-03-06 Thread Alan Gauld via Tutor
On 06/03/17 03:07, ramakrishna reddy wrote: > Can you please explain the functionality of collections.Callable ? If > possible with a code snippet. First of all, do you understand the concept of callable in Python? Any object that can be used like a function is callable. You might have a mixed co

Re: [Tutor] Is this a scope issue?

2017-03-06 Thread Alan Gauld via Tutor
On 06/03/17 01:33, Rafael Skovron wrote: > This project compares two text files with parcel numbers. I think I'm > messing up the function call. I'm getting this error: > > Traceback (most recent call last): > File "amador.py", line 48, in > remaining_parcels(auctionlist,removedlist) > Name

Re: [Tutor] Socket error in class

2017-03-06 Thread Alan Gauld via Tutor
On 06/03/17 17:35, leam hall wrote: > What am I missing? I'd start by moving the import out of the class to its more normal position at the top of the file. > > class mysocket(): > import socket > def __init__(self, sock=None); > if sock is None: > self.sock = socket.socket(sock

Re: [Tutor] Calculate 4**9 without using **

2017-03-06 Thread Alan Gauld via Tutor
On 06/03/17 19:03, Sri Kavi wrote: > Wow, this works like a charm! > def power(base, exponent): > """ Returns base**exponent. """ > result = 1 > for _ in range(abs(exponent)): > result *= base > if exponent < 0: > return 1 / result > return result And just to ad

Re: [Tutor] Lists of duplicates

2017-03-08 Thread Alan Gauld via Tutor
On 08/03/17 19:56, Sri Kavi wrote: > It’s about making a function that returns a list of lists, with each list > being all of the elements that are the same as another element in the > original list. This is one of those problems where there is probably no definitive "correct" answer just differe

Re: [Tutor] Lists of duplicates

2017-03-09 Thread Alan Gauld via Tutor
On 09/03/17 04:29, Alex Kleider wrote: >> I'd probably opt for a dictionary: >> >> def f(lst): >> res = {} >> for item in lst: >> res.setdefault(item,[]).append(item) >> return list(res.values()) >> > The above works BUT > how setdefault returns the current value for the key

Re: [Tutor] Lists of duplicates

2017-03-09 Thread Alan Gauld via Tutor
On 09/03/17 06:06, Alex Kleider wrote: > It seems you are simply kicking the can down the road rather than > explaining how it it is that dot notation actually works. The dot notation is just a method access. Dictionaries are like any other object and have many methods. > To access a dictionary

Re: [Tutor] IMAP Login Error - raise self.error(dat[-1])

2017-03-09 Thread Alan Gauld via Tutor
On 09/03/17 06:05, Sreekul Nair wrote: > Running this simple program ends in following error - > File "C:\Python27\lib\imaplib.py", line 520, in login > raise self.error(dat[-1]) error: LOGIN failed. First thing to test with errors like this is can you login manually over telnet/ssh using the exa

Re: [Tutor] Help!! Code ridden with Bugs

2017-03-09 Thread Alan Gauld via Tutor
On 09/03/17 13:28, Eloka Chima via Tutor wrote: > My assignment below is ridden with bugs So tell us what they are don;t make us guess and don't expect us to run code which is by your own admission faulty! If you get error messages post them, in full. If it runs but misbehaves tell us what happen

Re: [Tutor] Help!! Code ridden with Bugs

2017-03-09 Thread Alan Gauld via Tutor
On 09/03/17 18:42, Eloka Chima via Tutor wrote: > Is my code okay. > > THERE IS AN ERROR/BUG IN YOUR CODE > Results: Traceback (most recent call last): File "python/nose2/bin/nose2", > line 8, Evidently not. But the error messages are unreadable, please send in plain text. -- Alan G Author o

Re: [Tutor] Tutor Digest, Vol 157, Issue 24

2017-03-10 Thread Alan Gauld via Tutor
On 10/03/17 10:50, Eloka Chima via Tutor wrote: Please post in plain text. Your email is unreadable... And please don't reply to the digest, and if you must, then at least delete the irrelevant bits. We've all seen these messages already and some people pay by the byte. > Thank you so much. Your

Re: [Tutor] Socket error in class, part the second

2017-03-10 Thread Alan Gauld via Tutor
On 10/03/17 12:38, leam hall wrote: > As noted, the fix was to put the "import socket" above the class > declaration. What confuses me is that in the calling program I'm importing > the class: > > from mysocket import mysocket > > In mysocket.py the "import socket" is above the class declarati

Re: [Tutor] Sklearn

2017-03-10 Thread Alan Gauld via Tutor
On 10/03/17 23:12, Daniel Bosah wrote: > Can someone explain sklearns to me? Not me, I've never heard of it till now. > I'm a novice at Python, and I would > like to use machine learning in my coding. Why? What do you know about machine learning? What other platforms support it? > But aren't

[Tutor] Fwd: Re: Sklearn

2017-03-10 Thread Alan Gauld via Tutor
Forwarding to list... Please use ReplyAll or ReplyList when responding to the tutor list. -- > I would like to carry statistical analyses of populations . > I've been that it's the best package for that sort of thing in Python, > but I'm new to machine learning, so I'm not quite

[Tutor] Fwd: RE: Fwd: Re: Sklearn

2017-03-10 Thread Alan Gauld via Tutor
-- Original message ---- From: Alan Gauld via Tutor Date: 3/10/17 8:13 PM (GMT-05:00) To: tutor Subject: [Tutor] Fwd: Re: Sklearn Forwarding to list... Please use ReplyAll or ReplyList when responding to the tutor list. -- > I would like to carry statistical analy

Re: [Tutor] Fwd: RE: Fwd: Re: Sklearn

2017-03-11 Thread Alan Gauld via Tutor
> I want libraries that contain algorithms to check for relationships > within a dataset. For example, I want to parse through a SES dataset to > see any possible connections between student achievement and > socioeconomic standing, and correlate that to neighborhood wealth. Ok, With that backgro

Re: [Tutor] cx_Oracle and Pyinstaller

2017-03-14 Thread Alan Gauld via Tutor
On 14/03/17 14:29, Madhu Venkat wrote: > try: > Conn = cx_Oracle.connect (self.dsn) > except cx_Oracle.DatabaseError as exception: > > dsn has all the required connection info. > > In this case, I believe I don't need TNSnames.ora file, please confirm. I don't know a

Re: [Tutor] Summing arrays

2017-03-16 Thread Alan Gauld via Tutor
On 16/03/17 05:11, Aaliyah Ebrahim wrote: > def sum2(N): > > b = np.arange(1,N+1,1) > mylist = [ ] > for i in b: > terms = 2*(1+3**(i-1)) > a = mylist.append[terms] > return np.sum(mylist) > terms = 2*(1+3**(i-1))> 9 mylist.append[terms] 10 > retur

Re: [Tutor] While condition

2017-03-17 Thread Alan Gauld via Tutor
On 17/03/17 14:46, Aaliyah Ebrahim wrote: > Hi, in my code below, why is it returning a value that is greater than 1200 > if my condition is that the value should be less than 1200? Your condition is that it be less than 1200 when it enters the loop body. That means it will *always* be 1200 or gre

Re: [Tutor] tiny, little issue with list

2017-03-19 Thread Alan Gauld via Tutor
On 19/03/17 12:17, Rafael Knuth wrote: > LogActivities = [] > prompt = ("What have you done today? ") > prompt += ("Enter 'quit' to exit. ") I'm not sure why you put that on two lines but thats just a nit pick... > while True: This will loop forever unless you explicitly break, return or hit an

Re: [Tutor] HTML module for Python

2017-03-22 Thread Alan Gauld via Tutor
On 20/03/17 22:09, ਪੰਜਾਬ ਪੰਜਾਬੀ wrote: > Looking for recommendations on Python module to use to generate HTML > pages/tables, other HTML content. Kindly help. While thee are some modules that help with this most Python programs I've seen just generate the HTML directly as strings. There is no di

Re: [Tutor] CSV file Reading in python

2017-03-22 Thread Alan Gauld via Tutor
On 20/03/17 19:37, Edzard de Vries wrote: > I have a CSV which I want to be able to read in Python. Are you using the csv module? Have you read the documentation for that? It gives several examples. If not already then use csv. If you are using it and still have problems send the code and errors

Re: [Tutor] Help with function scoping

2017-03-22 Thread Alan Gauld via Tutor
On 22/03/17 21:17, Richard Mcewan wrote: > I'm expecting two functions to be defined. Then called. And thats what you've got. But... > One returns a random number. The other user input (guessing the number). And thats also what you've got but you don't do anything with the returned value you

Re: [Tutor] Using Class Properly - early beginner question

2017-03-23 Thread Alan Gauld via Tutor
On 22/03/17 12:30, Rafael Knuth wrote: > I wrote a function that does exactly what I want, and that is: > Create a shopping list and then let the user decide which items (food) > are supposed to be instantly consumed and which ones stored. That's a good start, because it means you understand your

Re: [Tutor] Help with function scoping

2017-03-23 Thread Alan Gauld via Tutor
On 23/03/17 10:15, Richard Mcewan wrote: > #loop to check guess and report > while userGuess != computerGuess: > if userGuess < computerGuess: > print('Too low') > userGuess = getUser() > elif userGuess > computerGuess: > print('Too high') >

Re: [Tutor] Using Class Properly - early beginner question

2017-03-24 Thread Alan Gauld via Tutor
On 24/03/17 21:41, boB Stepp wrote: >> I have a question: When creating an instance of GroceryListMaker, you are >> using: >> >> if __name__ == "__main__": >> >> What is that specifically for? Its a common trick in Python that enables a single file to act as both a module and a program. When a s

Re: [Tutor] Using Class Properly - early beginner question

2017-03-24 Thread Alan Gauld via Tutor
On 24/03/17 21:42, boB Stepp wrote: >> I noticed that you split your class into three methods: Many real world classes have a lot more than 3 methods. >> def __init__(self): >> # initialize instances of class >> >> def make_shopping_list(self): >> # input >> >> def display_shopping_list(self): >

Re: [Tutor] Function question

2017-03-25 Thread Alan Gauld via Tutor
On 25/03/17 10:01, Peter O'Doherty wrote: > def myFunc(num): > for i in range(num): > print(i) > > print(myFunc(4)) > 0 > 1 > 2 > 3 > None #why None here? Because your function does not have an explicit return value so Python returns its default value - None. So the print() inside

Re: [Tutor] Retrieving DropDown List Values

2017-03-25 Thread Alan Gauld via Tutor
On 25/03/17 04:29, Braxton Jackson wrote: > Is there a simple command for retrieving the chosen value a user inputs > from a dropdown list? I am new to Python and cant seem to find a good > tutorials link on retreiving drop down values. That all depends on which GUI toolkit you are using. The stan

Re: [Tutor] Scrollbar

2017-03-27 Thread Alan Gauld via Tutor
On 27/03/17 17:22, Pooja Bhalode wrote: > The scrollbar goes not work in the window. Define 'not work'? You haven't connected it to anything and it doesn't respond to any events so what kind of work did you expect it to do? I assume it draws itself on screen and the scroll buttons operate OK wh

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