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

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

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

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] 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] 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] 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] Accessing an entry value input by the user

2017-02-12 Thread Alan Gauld via Tutor
On 12/02/17 20:01, Pooja Bhalode wrote: > Thank you so much. I got stuck in another section: It would be helpful if you gave more details of exactly how you get stuck. What is happening(or not) that puzzles you. Otherwise we just have to guess at what you mean. Anyway, here goes... > root=Tk()

Re: [Tutor] ISSUE WITH PYTHON 3,5 API RUNTIME

2017-02-12 Thread Alan Gauld via Tutor
On 12/02/17 19:10, ViRuZ Fx . wrote: > Hello fellow programmers of Python, Im here writing you this because, since > I got a virus and my computer reseted to 0, I have no idea what reset to 0 means. Did you reinsatall Windows and all your applications? Did you use the Windows repair tool? > I ca

Re: [Tutor] Accessing an entry value input by the user

2017-02-11 Thread Alan Gauld via Tutor
; print i > textvar = "\t Conc"+str(i+1) > Label(frame1, text=textvar).grid(row=(9+i), column=0,sticky=W) > conclowerentry = Entry(frame1) > conclowerentry.grid(row= (9+i), column = 1, sticky = W) > concupperentry = Entry(frame1) &

Re: [Tutor] Accessing an entry value input by the user

2017-02-11 Thread Alan Gauld via Tutor
On 11/02/17 15:28, Pooja Bhalode wrote: > I am trying to create a label and an entry widget. I am not able to > understand as to how to access the value input by the user in the entry > widget. > > Label(frame1, text = "Number of species:").grid(row=0, column = 1, sticky=W) > entrynumberspecies =

Re: [Tutor] Climata package

2017-02-10 Thread Alan Gauld via Tutor
On 10/02/17 20:07, fei fan wrote: > Hi tutor, > > Do you know of any good resources to extract data using the climata > package and to convert these data in .geojson format? This forum is for the core language and standard library so this is a bit off topic, you might get a better response on th

Re: [Tutor] CheckButtons reset to default values

2017-02-10 Thread Alan Gauld via Tutor
On 10/02/17 15:56, Pooja Bhalode wrote: > root = Tk() > root.title("Design of Experiments with Parameter Estimation") > root.geometry("1000x1000") > > def DesignPoint(): > rootdesign=Tk() You should o0nly have one root. This create a new root everytime you xcall Designpoint and even if thats

Re: [Tutor] Can I can use subprocess module for connecting to linux from windows

2017-02-10 Thread Alan Gauld via Tutor
On 10/02/17 06:48, Basavaraj Lamani wrote: > putty, I will do SSH connection to Linux machine(VM). I enter username and > password to access Linux machine(VM) then I enter different commands to > install application in Linux machine. > > Automation: I want to automate above manual task by using p

Re: [Tutor] Help

2017-02-10 Thread Alan Gauld via Tutor
On 10/02/17 02:05, Sasiliyu Adetunji wrote: > Please assist with this assignment > > Write a function my_sort which takes in a list of numbers (positive > integers). > > The function should return a list of sorted numbers such that odd numbers > come first and even numbers come last. def my_sort

Re: [Tutor] Find (list) strings in large textfile

2017-02-09 Thread Alan Gauld via Tutor
On 09/02/17 19:15, Sylwester Graczyk wrote: > Hi all, > I'm try to write a code to search strings (from one textfile with lists > of strings) in second large text file. > but script doesn't search my lists in entire file (not complete output file) The problem is that you open the data file once,

Re: [Tutor] Help with Multiple Inheritance in Classes

2017-02-09 Thread Alan Gauld via Tutor
On 09/02/17 10:42, Vusa Moyo wrote: > Thanks so much. You've been a great help. > > You have confirmed that the lecture's question is flawed. It is not, it is exactly right. (Albeit unusual in its use of class attributes) but there is nothing wrong with the code, only the way you were trying to u

Re: [Tutor] Help with Multiple Inheritance in Classes

2017-02-09 Thread Alan Gauld via Tutor
On 09/02/17 09:25, Vusa Moyo wrote: > class Cat: > name = "" > kind = "cat" > color = "" > value = 100.00 > > def description(self): > desc_str = "%s is a %s %s cat worth R%.2f." % (self.name, > self.color, self.kind, self.value) > return desc_str > > The abov

Re: [Tutor] Help on this assignment

2017-02-09 Thread Alan Gauld via Tutor
On 09/02/17 08:10, Sasiliyu Adetunji wrote: > Write a function called remove_duplicates which will take one argument > called string. This string input will only have characters between a-z. > > The function should remove all repeated characters in the string and return > a tuple with two values:

Re: [Tutor] Explorer bar window(wxpython) combined to Tkinter

2017-02-08 Thread Alan Gauld via Tutor
On 08/02/17 23:09, Pooja Bhalode wrote: > But, I want to create this in the original GUI window that I am working in > using Tkinter. However, when I tried importing it, I am not able to > understand how to deal with different roots, Unfortunately you cannot mix toolkits. You either use Tkinter o

Re: [Tutor] Help on shoppingcart

2017-02-08 Thread Alan Gauld via Tutor
On 08/02/17 10:04, Sasiliyu Adetunji wrote: > Pls help me on this shoppingcart assignment Sure. You have a very specific set of tasks. Which bit are you stuck on? What have you tried? Show us your code and we can help get it working. > Create a class called ShoppingCart > Create a constructo

[Tutor] Rock,Paper Scissors (was no subject)

2017-02-08 Thread Alan Gauld via Tutor
On 08/02/17 10:02, တာန္ခတ္သန္ wrote: > Thanks for your answers. Your explanation makes me understand what I > didn't understand and it discourages me to go on Python in other way > as I feel like this doesn't suit to me. :'( Don't be discouraged. Your central program was very nearly right and your

Re: [Tutor] Help with Multiple Inheritance in Classes

2017-02-08 Thread Alan Gauld via Tutor
On 08/02/17 07:11, Vusa Moyo wrote: > I have a suspicion my lecturer's question is flawed, so I'd like to pose it > to you guys to confirm my suspicions. I think your interpretation of the question is flawed. See Peter's reply for why. However another point is > class Cat: > name = ""

Re: [Tutor] (no subject)

2017-02-08 Thread Alan Gauld via Tutor
On 07/02/17 21:09, တာန္ခတ္သန္ wrote: > RockPaperScissors game using dictionary. I have written my code and it > doesn't work at all. So what does it do? Crash your PC? Give an error? Run silently and stop? You need to be precise when telling us these things. If you get an error message send us th

Re: [Tutor] Multiple tabs using tkinter

2017-02-07 Thread Alan Gauld via Tutor
On 07/02/17 19:51, Zachary Ware wrote: >> But Tix has over 40 extra widgets including a tabbed notepad, >> balloon, meter, shell and and a very powerful (but undocumented!) >> grid control. > > Very little of tkinter is actually documented outside of the official > Tcl/Tk docs, unfortunately.

Re: [Tutor] Multiple tabs using tkinter

2017-02-07 Thread Alan Gauld via Tutor
On 07/02/17 18:59, Alan Gauld via Tutor wrote: > It should be easy since its just native Tcl code, there's no C Scratch that, I just found a C API for Tix so I guess it has some C after all. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.am

Re: [Tutor] Tkinter Calendar to receive user entry.

2017-02-07 Thread Alan Gauld via Tutor
On 07/02/17 19:40, Peter Otten wrote: >>> from ttkcalendar import Calendar >> >> Doesn't work for me in either Python 3.6.0 or in Python 2.7.6 >> >> Which version of 2.7 are you using? > > The distribution's Python 2.7.6 on Linux Mint 17. After fixing the import > statements... OK, I went back

Re: [Tutor] Tkinter Calendar to receive user entry.

2017-02-07 Thread Alan Gauld via Tutor
On 07/02/17 10:18, Peter Otten wrote: > $ cat demo.py > #!/usr/bin/env python > import calendar > import ttk > import Tkinter > from ttkcalendar import Calendar Doesn't work for me in either Python 3.6.0 or in Python 2.7.6 Which version of 2.7 are you using? -- Alan G Author of the Learn to Pr

Re: [Tutor] Error when trying to use classes

2017-02-07 Thread Alan Gauld via Tutor
On 07/02/17 15:34, Rafael Skovron wrote: > My general workflow is I edit in vim, then invoke python3 interpreter, > import the module and try to use the Class and methods from the class. > > For example, importing customer.py and assigning this object yields: > rafael = Customer('rafael',10

Re: [Tutor] Multiple tabs using tkinter

2017-02-07 Thread Alan Gauld via Tutor
On 07/02/17 16:41, Zachary Ware wrote: > Full disclosure, I've never actually used Tix beyond making it build > with the rest of CPython on Windows and making sure it actually worked > on one of my Linux buildbot workers. I have only ever seen it as a > maintenance headache :) The beauty of Tix

Re: [Tutor] Multiple tabs using tkinter

2017-02-07 Thread Alan Gauld via Tutor
On 07/02/17 03:56, Pooja Bhalode wrote: > you mentioned that there are multiple toolkits which can be used instead of > tkinter. I was also looking into wxpython for building a explorer bar. > Mainly, I have to build a software entirely using python and thus, needed > all these things put in place

Re: [Tutor] Help with this work

2017-02-07 Thread Alan Gauld via Tutor
On 07/02/17 04:08, Sasiliyu Adetunji wrote: > I have been working on yhis assignment You are asking for help but in what regard? There is no question or problem statement in your post? I've put some general comments below... > class ShoppingCart(object): > > def __init__(self): > self.tot

Re: [Tutor] Multiple tabs using tkinter

2017-02-07 Thread Alan Gauld via Tutor
On 07/02/17 03:31, Zachary Ware wrote: > ttk rather than Tix; Tix is unmaintained and soft-deprecated in 3.6+. Really? Thats a pity. Tix was supposed to be the module with the extra widgets and ttk was purely the themed versions of same. Its a shame to confuse their purposes. OTOH it does mean t

Re: [Tutor] Help Please on python

2017-02-07 Thread Alan Gauld via Tutor
On 07/02/17 02:12, Laura Garcia wrote: > I need to create a python code that should simulate throwing darts by > random landing between (a random x and a random y)0 and 1. and the program > should print out number of darts that land within a rectangle. Look in the random module. There are a bunc

Re: [Tutor] Tkinter Calendar to receive user entry.

2017-02-07 Thread Alan Gauld via Tutor
On 07/02/17 00:24, Pooja Bhalode wrote: > I am trying to create a calendar using tkinter GUI such that when the user > opens the GUI, So far as I'm aware there is no such Calendar widget in the standard modules, you would need to find a third party module. > Can some one please help me with thi

Re: [Tutor] Basic Tutorial for Python

2017-02-06 Thread Alan Gauld via Tutor
On 06/02/17 16:13, Hüseyin Ertuğrul wrote: > Hello all, > I am a system engineer and I want to learn python language. > I don't know any program language That's a common request and the python.org site has a whole page dedicated to folks like you. https://wiki.python.org/moin/BeginnersGuide/NonP

Re: [Tutor] Multiple tabs using tkinter

2017-02-06 Thread Alan Gauld via Tutor
On 06/02/17 16:40, Pooja Bhalode wrote: > I was wondering if someone could help me regarding multiple tabs in > tkinter. Look at the tabbed notebook in the Tix module. It should do what you want. I give a tutorial on its use in my recent book but you can also find online tutorials, especially in

Re: [Tutor] sort() method and non-ASCII

2017-02-06 Thread Alan Gauld via Tutor
On 06/02/17 12:13, boB Stepp wrote: py> 'pi = \N{GREEK SMALL LETTER PI}' 'pi = π' >>> >>> >>> You have surprised me here by using single quotes to enclose the >>> entire assignment statements. I thought this would throw a syntax >>> error, but it works just like you show. What is going

Re: [Tutor] Syntax error while attempting to type in multiline statements in the interactive interpreter

2017-02-05 Thread Alan Gauld via Tutor
On 05/02/17 01:29, boB Stepp wrote: > But it seems to me on further thought that both REPL and what seems > most consistent to me, "...wait until all the input has been read, > then evaluate it all..." amounts to the same thing in the case of > entering function definitions into the interpreter.

Re: [Tutor] Syntax error while attempting to type in multiline statements in the interactive interpreter

2017-02-04 Thread Alan Gauld via Tutor
On 04/02/17 22:56, boB Stepp wrote: > On Sat, Feb 4, 2017 at 4:40 PM, David wrote: >> On 5 February 2017 at 09:02, boB Stepp wrote: >>> py3: a >>> ['Mary', 'had', 'a', 'little', 'lamb', 'break'] >>> py3: for w in a: >>> ... print(w) >>> ... print('Huh?') >>> File "", line 3 >>> print('H

Re: [Tutor] Copy/Paste in Tkinter

2017-02-04 Thread Alan Gauld via Tutor
On 04/02/17 16:09, Pooja Bhalode wrote: > I do not have a text box, but a GUI similar to a word editor. That sounds like a text box to me!? What are you using to enter the text if not a Text widget? > I was learning from youtube videos about this. You can start with the GUI topic in my tutorial

Re: [Tutor] Tkinter Copy/Paste/Cut functionalities

2017-02-04 Thread Alan Gauld via Tutor
On 04/02/17 02:34, Pooja Bhalode wrote: > I came across some snippets of the code to do this but using a self class. I'm not sure what you mean by a "self class"? > I was wondering if some one could help me create these functionalities in a > manner similar to the following code. (similar to the

Re: [Tutor] Copy/Paste in Tkinter

2017-02-04 Thread Alan Gauld via Tutor
On 04/02/17 00:24, Pooja Bhalode wrote: > I am trying to write a simple Tkinter code in Python in order to > demonstrate select/copy/paste/cut functionalities using keyboard keys and > menu options. You are going a fairly long winded way about it. Rather than generating events use the Text/Entry

Re: [Tutor] Best Python 3 module to create simple text editor in Windows command prompt?

2017-02-03 Thread Alan Gauld via Tutor
On 03/02/17 04:42, boB Stepp wrote: > On Thu, Feb 2, 2017 at 8:35 PM, eryk sun wrote: >>> >> Try using curses [1]. Christoph Gohlke has a port for Windows Python >> based on the PDCurses library [2]. > > Thanks, Eryk. I did not realize that curses had been ported to > Windows. I thought it was

Re: [Tutor] Lock File Usage

2017-01-30 Thread Alan Gauld via Tutor
On 30/01/17 14:45, ad^2 wrote: > So, IF: no lock file, create a lock file, execute, delete lock file when > finished successfully. ElSE: the script is running, exit. Then, cron will > try again an hour later. That's probably the most common way of doing what you want. But you need to make absolu

Re: [Tutor] cannot open idle in 3.6 version but can in 2.7

2017-01-26 Thread Alan Gauld via Tutor
On 25/01/17 20:56, Wiley, Brian wrote: > I would like to learn and utilize both python versions. > For some reason when access shell for 3.6 I get this message: > > "Your Python may not be configured for Tk. **", file=sys.__stderr__) That usually means you've installed a Python that has not be

Re: [Tutor] Feature or ... after python 2.7

2017-01-25 Thread Alan Gauld via Tutor
On 25/01/17 17:32, source liu wrote: >>> $cat test.py >>> #!/bin/env python >>> print "I am python" >>> >>> $perl test.py >>> I am python >>> >> >> That is just because this particular print statement >> is compatible with Perl. If you had tried anything >> more complex then it would have bombed.

Re: [Tutor] Feature or ... after python 2.7

2017-01-25 Thread Alan Gauld via Tutor
On 25/01/17 02:55, source liu wrote: > 2.7. (2.7.16 if I remembered it correctly), one could run python script > with perl > > $cat test.py > #!/bin/env python > print "I am python" > > > $perl test.py > I am python > That is just because this particular print statement is compatible with Pe

Re: [Tutor] Another way to strip?

2017-01-19 Thread Alan Gauld via Tutor
On 19/01/17 21:29, ad^2 wrote: > I'm looking for a cleaner more elegant way to achieve stripping out a file > name from a list which contains a path and file extension. > > Ex. > > my_list = ['/var/tmp/02_80_5306__2017_01_19_08-36-57_4918_0.zip', > '/var/tmp/02_80_5309__2017_01_19_08-40-

Re: [Tutor] How can I run this test script using selenium while making connection and running the code I am facing issue Please see my code below

2017-01-19 Thread Alan Gauld via Tutor
On 19/01/17 02:29, Sarika Shrivastava wrote: > Yes I dont have issue with unittest framework but i dont have to reconized > my issue How can I resolve this issue ?? What is the issue? You haven't told us what is wrong. What happens? What did you expect to happen? Are there any error messages? If s

Re: [Tutor] How can we learn to use Python

2017-01-18 Thread Alan Gauld via Tutor
On 18/01/17 02:36, Laura Meldrum wrote: > www.sololearn.com/Play/Python/hoc says to "download the Python 3.x version > that is compatible with your operating system" So the first question is - what is your operating system? Assuming it is a version of Windows then you next need to find out whethe

Re: [Tutor] Searching db while typing on Entry widget

2017-01-16 Thread Alan Gauld via Tutor
On 16/01/17 15:11, Ali Moradi wrote: > Hi. i want to search one field of my db while i type text in my Entry > widget. how can i do that? Assuming you mean a live search type of thing, like Google etc do then you need to bind the keypress (or maybe the key-up) event to a function that does the se

Re: [Tutor] problem with scroll in Tkinter

2017-01-13 Thread Alan Gauld via Tutor
On 13/01/17 06:55, Ali Moradi wrote: > https://paste.pound-python.org/show/CIKA8eOFbdq18r3nFUBv/ > > On Fri, Jan 13, 2017 at 10:25 AM, Ali Moradi wrote: > >> hi. I've written this code and i can't fix the scrollbar error. i am a >> beginner in Python plz help. this is python3 code. You've poste

Re: [Tutor] Convert tuple within tuple into single tuple

2017-01-11 Thread Alan Gauld via Tutor
On 11/01/17 06:31, ramakrishna reddy wrote: > Hi All, > > Is there any way to convert x = (1, 2, 3, (4, 5)) to x = (1, 2, 3, 4, 5) in > python 2.7 You can write a function(*) to flatten the data structure, but you need to be careful and think through how you expect it to handle strings, say... or

Re: [Tutor] Importing classes

2017-01-11 Thread Alan Gauld via Tutor
On 11/01/17 02:53, kay Cee wrote: > Is there a proper way to import a class from a module? If so, please tell. The most common way is probably: >>> from mymodule import Myclass >>> myobject = Myclass() but its just as good to do >>> import mymodule >>> myobject = mymodule.Myclass() -- Al

Re: [Tutor] small remark

2017-01-11 Thread Alan Gauld via Tutor
On 10/01/17 17:56, adil gourinda wrote: >When I was surfing in “Python Library” I made some observations and I want > to share them That's good and as a place to discuss those observations the tutor list is a suitable forum. However, if you want the proposals considered for actual implementa

Re: [Tutor] Challenges with psycopg2 on Python 3.2

2017-01-06 Thread Alan Gauld via Tutor
On 06/01/17 12:55, Admire Mutsikiwa wrote: > it screams on the Python3.2 prompt, it gives Hardly screaming, rather a polite complaint that you've messed up your indentation. import psycopg2 > File "", line 1 > import psycopg2 > ^ > IndentationError: unexpected indent I'll guess

Re: [Tutor] Help with a Conversion

2017-01-05 Thread Alan Gauld via Tutor
On 05/01/17 13:29, S. P. Molnar wrote: > Fortran II using punched paper tape. Yes, am a rather elderly . . .). You are not the only one, there are at least 2 more of us on this list that started in that era... > short program to change frequency to wavelength for a plot of > ultraviolet spect

Re: [Tutor] prenting a line form appearing in log file

2017-01-05 Thread Alan Gauld via Tutor
On 05/01/17 13:01, anatta anatta wrote: > I have created a log file, using 'logging' module, > name = raw_input ("Please enter your name.") > print 'Hi ', name, 'Please go ahead and press enter to transfer files' > > The log file records the variable 'name' in the log file at the > right locat

Re: [Tutor] Total newbie question

2017-01-04 Thread Alan Gauld via Tutor
On 04/01/17 06:51, MR ZenWiz wrote: > It appears that while python is installed in /usr/bin, idle is in > /usr/local/bin and expects the python interpreter to be also under > /usr/local, which does not seem to be the default. > > I created a symlink 'ln -s /usr/bin/python3.5 > /usr/local/bin/pyth

Re: [Tutor] Fw: path string

2017-01-04 Thread Alan Gauld via Tutor
On 03/01/17 15:59, anatta anatta wrote: > Please disregard my request below. > > I know the problem! > > I have not defined the variable in question as a global variable. That's one solution but its not a very good one. Global variables are not considered good practice for many reasons. In par

Re: [Tutor] Total newbie question

2017-01-03 Thread Alan Gauld via Tutor
On 03/01/17 01:21, MR ZenWiz wrote: > I'm trying to install python 4.6 on my Xubuntu 16.04 desktop, I assume you mean Python 3.6? And my first question is why? Do you have some specific features in 3.6 that you need? Otherwise just go with the latest version in your package manager which will prob

Re: [Tutor] path string

2017-01-02 Thread Alan Gauld via Tutor
On 02/01/17 17:01, anatta anatta wrote: > I am trying to create unsuccessfully source path as > a string 'str7' in part_1 of the code below, When you say unsuccessfully what do you mean? What do you expect? What do you get? > to be used in part_2 of the code. For that you need to expose it out

Re: [Tutor] help :making window

2016-12-31 Thread Alan Gauld via Tutor
On 31/12/16 16:05, syafiqah amir via Tutor wrote: > Hello,Im trying to execute the code but the window does not come out. Please always post python code in plain text, otherwise the html gets wrapped and it becomes illegible. > (script from Maya python for games and film) This group is for cor

Re: [Tutor] formatting xml (again)

2016-12-27 Thread Alan Gauld via Tutor
On 27/12/16 19:44, richard kappler wrote: > Using python 2.7 - I have a large log file we recorded of streamed xml data > that I now need to feed into another app for stress testing. The problem is > the data comes in 2 formats. > > 1. each 'event' is a full set of xml data with opening and closin

Re: [Tutor] IndexError: list index out of range

2016-12-27 Thread Alan Gauld via Tutor
On 27/12/16 15:22, Mysore Ventaka Rama Kumar wrote: > Please review and comment/correct my error! Rather than expect us to read through many lines of code it would help id you posted the entire error message which will tell us exactly where the problem lies. Also tell us for completeness which P

Re: [Tutor] How to interact with the result of subprocess.call()

2016-12-26 Thread Alan Gauld via Tutor
On 25/12/16 16:33, Jim Byrnes wrote: >> (*)LO remembers its last screen setting and opens with them, >> if those screen settings are different than the ones you >> programmed for then navigation will be different and so on. > > I don't think I need to "know where stuff is" to manipulate LO. It

Re: [Tutor] Manipulating Dictionary values

2016-12-26 Thread Alan Gauld via Tutor
On 26/12/16 08:03, Sunil Tech wrote: > Hi Team, > > Dictionary is like > > a = {'a': 'New', 'b': 'Two', 'l': [{'k': 'test', 'm': 'again'}, {'k': > 'test', 'm': 'again'}]} > > I am trying to modify a value in the dictionary value at a['l'] So make life easy for yourself and get rid of the outer

Re: [Tutor] accessing attribute from python programming for absolute beginner

2016-12-26 Thread Alan Gauld via Tutor
On 26/12/16 04:08, syafiqah amir via Tutor wrote: > i did not achieve the desired outcome which is the name of the critters did > not print > #attribute Critter#Demonstrates creating and accessing object attributes > class Critter(object):"""A virtual pet"""def __init__(self,name):

Re: [Tutor] How to interact with the result of subprocess.call()

2016-12-25 Thread Alan Gauld via Tutor
On 25/12/16 17:08, boB Stepp wrote: > Then I see that I have a GCE (Gross Conceptual Error) floating around. > I thought that event loops are just intercepting the redirected stdin > from the keyboard. This is not true? If not, then how is this > working? No event loops don't use stdin. They ar

Re: [Tutor] How to interact with the result of subprocess.call()

2016-12-25 Thread Alan Gauld via Tutor
On 25/12/16 01:58, boB Stepp wrote: > the stdin option of call()might be used to direct the desired > keystrokes to LO? After looking at The problem is that keystrokes in a GUI are not read from stdin, they are read as events from the GUI event loop. So, if LO was a CLI tool (like vim or top, sa

Re: [Tutor] How to interact with the result of subprocess.call()

2016-12-24 Thread Alan Gauld via Tutor
On 25/12/16 01:21, Jim Byrnes wrote: > I am not trying to automate libreoffice using subprocess. No, but you are trying to automate LO from within Python by sending it keystrokes and that's not easy. That's why I previously asked whether you really wanted to open the LO file directly and manipul

Re: [Tutor] I download package and it says computer is missing this file, how do I fix?

2016-12-23 Thread Alan Gauld via Tutor
On 23/12/16 01:47, Don Pryor wrote: > [image: Inline image 1] > This is a text mailing list so the server strips out most attachments. You need to tell us a lot more. 1) What package are you trying to install 2) How are you downloading/installing it(pip/ftp/binary installer?) 3) Which OS and Pytho

Re: [Tutor] Trouble Launching Python

2016-12-22 Thread Alan Gauld via Tutor
On 19/12/16 22:38, Joseph Olugbohunmi via Tutor wrote: > Hello,Good day, I installed Python 3.5.2 on my Windows 8.1 PC Are you sure you used the right Python version. There are separate downloads for 32 and 64 bit machines. It may be that you downloaded the 64 bit version and have a 32bit OS ru

Re: [Tutor] Open a libreoffice calc file in Python

2016-12-22 Thread Alan Gauld via Tutor
On 22/12/16 03:37, Jim Byrnes wrote: > Python 3.4 on Ubuntu > > If I was going to open a libreoffice calc file from the terminal I would > go: libreoffice --calc /home/path/to/myfile.ods. > > How would I do this from Python? Others have advised how to run the Libreoffice app from within Python.

Re: [Tutor] Using Python to solve factoria

2016-12-22 Thread Alan Gauld via Tutor
On 21/12/16 07:50, Hedgar wrote: > I really happy to be accepted to the list! You're welcome, but one very important thing to note is that you should always post to this list in plain text, not HTML. That's because HTML loses the formatting of the code (see below) and in Python formatting is very

Re: [Tutor] Fwd: Question about selenium with python

2016-12-22 Thread Alan Gauld via Tutor
On 21/12/16 01:29, Fazal Khan wrote: > Im a new programmer and this is my first time posting here. I have a > question about using selenium with python. I notice you haven't had an answer yet. That may be because Selenium is not part of the standard Python library and this list is for questions

Re: [Tutor] function argument unpacking

2016-12-08 Thread Alan Gauld via Tutor
On 08/12/16 06:04, Palanikumar wrote: > #Function Argument unpacking > def myfunc(x, y, z): > print(x. v. z) > Please always send the actual code that generates the error, do not retype as it causes us to chase phantom bugs. In this case the fact that the v in the print statement should be a

Re: [Tutor] copy files selectively from source to destination

2016-12-05 Thread Alan Gauld via Tutor
On 05/12/16 16:20, anatta anatta wrote: > I however want to copy selective files. > For example I like to copy only .txt files only > How could I do this selective copying? By applying an if test just before you copy filetype = '.txt' # or read it as an input ... if sourcefile extension =

Re: [Tutor] Ran into a problem: Tried many different methods

2016-11-30 Thread Alan Gauld via Tutor
On 30/11/16 02:29, Parish Watteau wrote: > A program that will read each player’s name and golf score as > keyboard input, and then save these as records in a file named golf.txt. > (Each record will have a field for the player’s name and a field for the > player’s score.) > > I attempted

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