Re: [Tutor] Python Image Library

2017-05-18 Thread Alan Gauld via Tutor
On 18/05/17 16:43, Michael C wrote: > os.startfile('1.bmp') > > works like a charm! > > Now I need to figure out how to close this window once I finish with it! Sadly that is manual. Unless you care to write code to search for the process and use the Windows API to kill it off. If you really

Re: [Tutor] Python Image Library

2017-05-18 Thread Alan Gauld via Tutor
On 18/05/17 02:58, Michael C wrote: > when I run this, while it's called test.pyw, this pops up > > from PIL import Image > > im = Image.open('1.bmp') > im.show() One suggestion is to use Pillow instead of PIL. So far as I know PIL is frozen and all new development is on Pillow. It is

Re: [Tutor] Pyuthon 3 Combine 1 D Arrays

2017-05-17 Thread Alan Gauld via Tutor
On 17/05/17 20:50, Stephen P. Molnar wrote: > I'm beginning to think that I don't know how to ask the question as > Google and Stack Overflow have resulted in nothing. All of the results > seem to deal with integers. Have you tried asking on the scipy forum?

Re: [Tutor] How do I display a picture?

2017-05-17 Thread Alan Gauld via Tutor
On 18/05/17 00:24, Michael C wrote: > or to find another way to display the picture without using python image > library. There are lots of ways it depends on what you actually want to do with the image. For example you can run your favourite image viewer program(that looks like what PIL is

Re: [Tutor] Fwd: Re: How do I display a picture?

2017-05-17 Thread Alan Gauld via Tutor
On 18/05/17 00:38, Alan G via Tutor wrote: >Please always use reply all, or reply list when responding to list Oops, it seems like you did that already, my apologies. -- 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

Re: [Tutor] Help finishing a function

2017-05-17 Thread Alan Gauld via Tutor
Please use Reply-All or Reply-List when replying to the list, otherwise it only goes to me. On 17/05/17 17:21, Grace Sanford wrote: > Syntactically speaking, how can I check if an element in the list > "board" at position p equals "_" and then change that element to "0"? You can use the ==

Re: [Tutor] How do I display a picture?

2017-05-17 Thread Alan Gauld via Tutor
On 17/05/17 21:33, Michael C wrote: > How do I display a picture? What do you mean? What kind of picture? Where do you want it displayed (what kind of window/screen)? There are a dozen possible ways to "display a picture" depending on what you specifically want. -- Alan G Author of the Learn

Re: [Tutor] copy/paste/move files

2017-05-17 Thread Alan Gauld via Tutor
On 17/05/17 20:09, Michael C wrote: > How do I move files to a designated folder or copy/paste? copy/paste is a UI specific thing, you don't do that in Python code. What you do is either copy a file or move it. The shutil module provides easy functions for both. See the documentation for the

Re: [Tutor] Help - What is the best package to learn programming in Python?

2017-05-17 Thread Alan Gauld via Tutor
On 17/05/17 19:17, keith quach wrote: > I hope you could help. I am new to the Python community. I am looking > for your recommendation for a Windows 10 (64 bit) Python 3.6 > distribution package that covers all the necessary installtions/files. It depends on what you want to do. There is no

Re: [Tutor] Bug

2017-05-17 Thread Alan Gauld via Tutor
On 17/05/17 17:26, Grace Sanford wrote: > with "board" with elements 0-8). If one of these is the case, it is > suppose to print the "You won" string. Nevertheless, when I change list > variable to reflect one of these conditions, there is no printing > occurring. I cannot figure out why. You

Re: [Tutor] Matplotlib error with Python

2017-05-17 Thread Alan Gauld via Tutor
On 17/05/17 15:07, Pooja Bhalode wrote: > */Users/poojabhalode/.bash_profile: line 1: .bashrc: No such file or > directory* I'd start with this one. Where is the bash script error coming from? Is there really no .bashrc? If not what is the impact of not having it? I'm also not clear what is

Re: [Tutor] Help finishing a function

2017-05-17 Thread Alan Gauld via Tutor
On 17/05/17 14:31, Grace Sanford wrote: > I am wondering if someone can help/advise me on finishing the code for this > function: Please only send one email for a given i8ssue it gets confusing when people start responding to two different threads about the same question. Also please give us

Re: [Tutor] Given a string, call a function of that name

2017-05-17 Thread Alan Gauld via Tutor
On 17/05/17 03:49, boB Stepp wrote: > corresponding to one of his functions or methods, if he could use that > word to run a function of the same name. I said I had done something > once where I used the word as a dictionary key, which was then used to > call the function. That's the usual

Re: [Tutor] how do i open picture files without knowing the file name?

2017-05-16 Thread Alan Gauld via Tutor
On 16/05/17 19:49, Michael C wrote: > I am running this code so I can do some image manipulation with them. > The thing is, I have a lot of pictures to go through, so I can't type the > file names Do you know the folder where they live? If so os.listdir() will give you a list of filenames. If

Re: [Tutor] Tkinter + frame + grid question

2017-05-15 Thread Alan Gauld via Tutor
On 15/05/17 07:11, Phil wrote: > I'd like to place a red frame in the centre of the main window. What do you want surrounding it? You are going to have to use whichever layout manager fits the scenario. Remember you can use different layout managers in each frame in your app - and you will

Re: [Tutor] How to write the __str__ function

2017-05-14 Thread Alan Gauld via Tutor
On 14/05/17 19:03, Sydney Shall wrote: > The code that I have so far is as folows: > > def __str__(self): > return("\n" > " Output from __str__ of POCWP. " > "\n" > "\n After the first turnover, during the " >

Re: [Tutor] python 3 np.savetxt(name_s, I_z) produces IndexError: tuple index out of range

2017-05-11 Thread Alan Gauld via Tutor
On 11/05/17 20:46, Stephen P. Molnar wrote: >> script uses the np.savetxt() quite a few times, but one use generates >> the title error. The offending line is np.savetxt(name_s,I_z) where I_z >> is a single number of type float64 with a size of 1. I'm glad you found the problem but please, when

Re: [Tutor] Simple while loop question

2017-05-11 Thread Alan Gauld via Tutor
On 11/05/17 02:50, Rafael Skovron wrote: > I dont understand why j can have any value other than zero in this: > > for i in range(1, 5): j = 0 while j < i: print(j, end = " ") j += 1 Because i can go as high as 4 (from range(1,5)->1,2,3,4). So lets consider that

Re: [Tutor] Flowchart

2017-05-10 Thread Alan Gauld via Tutor
On 11/05/17 00:54, Mats Wichmann wrote: > and it turns out some people don't think flowcharts are really a useful > model... Yes, but as usual it depends. They are quite good for documenting human based processes, which is what they were originally designed for. They work very well for

Re: [Tutor] (no subject)

2017-05-10 Thread Alan Gauld via Tutor
On 11/05/17 01:02, Steven D'Aprano wrote: > Looks like spam to me. A link to a mystery URL with no context, by > somebody signing their email with a radically different name from the > email address used, And the address is not subscribed to the list so the message should have gone to

Re: [Tutor] Flowchart

2017-05-10 Thread Alan Gauld via Tutor
On 11/05/17 00:34, Steven D'Aprano wrote: > I didn't request anything. What is this? Do you have a question or are > you just sharing? It was me did the requesting. Adil originally posted his pdf's as attachments so I rejected the post, requesting he use a link instead. Unfortunately he left

Re: [Tutor] Flowchart

2017-05-10 Thread Alan Gauld via Tutor
On 10/05/17 00:25, adil gourinda wrote: > As you requested, I uploaded my flowcharts on a web storage link as: Thanks, although it would have helped if you included your original message since I am the only person to see it! It never got sent to the rest of the list. >

Re: [Tutor] urllib ... lost novice's question

2017-05-10 Thread Alan Gauld via Tutor
On 10/05/17 17:06, Rafael Knuth wrote: >>> Then, there is another package, along with a dozen other >>> urllib-related packages (such as aiourllib). >> >> Again, where are you finding these? They are not in >> the standard library. Have you been installing other >> packages that may have their own

Re: [Tutor] urllib ... lost novice's question

2017-05-08 Thread Alan Gauld via Tutor
On 08/05/17 16:23, Rafael Knuth wrote: > Which package should I use to fetch and open an URL? > I am using Python 3.5 and there are presently 4 versions: > > urllib2 > urllib3 > urllib4 > urllib5 I don't know where you are getting those from but the standard install of Python v3.6 only has

Re: [Tutor] best Python Web-Development Applications framework.

2017-05-07 Thread Alan Gauld via Tutor
On 07/05/17 16:23, Jojo Mwebaze wrote: > I am trying to figure out the best Python Web-Development Applications > framework. I trying to get started with building Web-Based Applications. > Kindly give advise which one is the best for a novice user It depends on several factors which you haven't

Re: [Tutor] General question rgrd. usage of libraries

2017-05-05 Thread Alan Gauld via Tutor
On 05/05/17 14:45, Rafael Knuth wrote: > How do I know which libraries I need to perform a certain task? Mostly youn learn by experience, but otherwise google (or other search engine) is your friend. It doesn't do any harm to read the Library Reference document on the python.org web site too, it

Re: [Tutor] selenium, automated testing and python

2017-05-04 Thread Alan Gauld via Tutor
On 04/05/17 22:09, Alan Gauld via Tutor wrote: > And the reasons above are only scratching the > surface, there are many more gains that apply to > testing in general but are only practical if > testing is automated. One thing I meant to add is that "automated" does not

Re: [Tutor] selenium, automated testing and python

2017-05-04 Thread Alan Gauld via Tutor
On 04/05/17 19:44, Palm Tree wrote: > Sorry i'm a bit new to automated testing. > > I have explored python wide and deep but can someone just tell me why as a > coder i need automated testing? You don't, you can test it all by hand. But it will take you much longer, especially after you've done,

Re: [Tutor] Index Out of Range?List

2017-05-04 Thread Alan Gauld via Tutor
On 04/05/17 13:50, Stephen P. Molnar wrote: >> I'll assume that's where the problem lies. >> Try checking if the string is not empty before using it: >> >> for line in f.readlines(): >> if line: >> atm_chg.append(float( line.split()[-1] )) > I have edited the code: >

Re: [Tutor] Index Out of Range?List

2017-05-04 Thread Alan Gauld via Tutor
On 04/05/17 13:21, Stephen P. Molnar wrote: > Here are the error messages: > > Enter Molecule ID: A > A.lac.dat > Traceback (most recent call last): > >File "", line 1, in > runfile('/home/comp/Apps/Python/Testing/ReadFile_1.py', > wdir='/home/comp/Apps/Python/Testing') There

Re: [Tutor] Python Bind DNS Zone config

2017-05-04 Thread Alan Gauld via Tutor
On 04/05/17 04:11, Nathan D'Elboux wrote: > when i run the above code it prompts me to enter the domain so i do, > then the out put is a "Value error: Unexpected '{' in field name Always, always, always post the full error message. Do not shorten it to the summary line. We can't see the location

Re: [Tutor] Index Out of Range?List

2017-05-03 Thread Alan Gauld via Tutor
On 04/05/17 00:32, Stephen P. Molnar wrote: > import numpy as np > > name = input("Enter Molecule ID: ") > name = str(name) You don't need the str(), input always returns a string. > name_in =name[:]+'.lac.dat' And you don't need the [:]. Just use name_in = name + '.lac.dat' >

Re: [Tutor] creating a cluster

2017-05-03 Thread Alan Gauld via Tutor
On 03/05/17 06:22, shubham goyal wrote: > Hello tutors, > > here i am trying to create a cluster on cloud using json data but its > giving some error > File "/usr/lib/python2.7/urllib2.py", line 1197, in do_open > raise URLError(err) > urllib2.URLError: It says connection refused. Do you

Re: [Tutor] Hi all: How do I save a file in a designated folder?

2017-05-03 Thread Alan Gauld via Tutor
On 03/05/17 00:28, Cameron Simpson wrote: >> And so forth? I assume you mean >> >> MMDD.png format? >> >> You should read about the strftime function in the time > > Further to this, I would also advocate that you consider writing the > timestamp > from largest unit to smallest unit, like

Re: [Tutor] Hi all: How do I save a file in a designated folder?

2017-05-02 Thread Alan Gauld via Tutor
On 02/05/17 19:09, Michael C wrote: > from PIL import Image > from PIL import ImageGrab > > screenshot = ImageGrab.grab() > screenshot.show() > screenshot.save("\test\missed.png") > > This is my current code, using Python Image Library! You should probably investigate Pillow, I believe

Re: [Tutor] Using Python to access .txt files stored behind a firewall as .exe files

2017-05-02 Thread Alan Gauld via Tutor
On 02/05/17 19:06, Ian Monat wrote: > I could give them reasons why .exe files won't work for me but they don't > really care if I take the data files on their site or not. But do they care about their reputation? The biggest issue here is not the technical one but the security one, they could

Re: [Tutor] Press ESC to exit()

2017-05-02 Thread Alan Gauld via Tutor
On 02/05/17 04:03, Michael C wrote: > holy cow I did warn you it was non trivial :-) Basically Eryksun has done what your scripting tool is doing in the background. -- 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

Re: [Tutor] Pycharm Edu Lesson 3, Task 7

2017-05-02 Thread Alan Gauld via Tutor
On 02/05/17 01:42, David Wolfe wrote: > I'm working through Pycharm Edu, and I'm stuck on the following: > > phrase = """ > It is a really long string > triple-quoted strings are used > to define multi-line strings > """ > first_half = phrase[:len(phrase)//2] > print(first_half) > > > The

Re: [Tutor] Using Python to access .txt files stored behind a firewall as .exe files

2017-05-01 Thread Alan Gauld via Tutor
On 02/05/17 01:12, Ian Monat wrote: > 1) Use Python to download the file from the web (but not by using a > webscraper, according to Alan) Things like BeautifulSoup will help you read the HTML and extract links etc but they won't help you actually fetch the file/documents from the web site. A

Re: [Tutor] Using Python to access .txt files stored behind a firewall as .exe files

2017-05-01 Thread Alan Gauld via Tutor
On 01/05/17 18:20, Ian Monat wrote: > ... I've written a script using the requests module but I > think a web scraper like Scrapy, Beautiful Soup or Selinium may be > required. I'm not sure what you are looking for. Scrapy, BS etc will help you read the HTML but not to fetch the file. Also do

Re: [Tutor] Press ESC to exit()

2017-05-01 Thread Alan Gauld via Tutor
On 01/05/17 19:28, Michael C wrote: > Hi all, I found out that one way to press ESC to kill the script was to > use my previous script language, AutoHotKey and this is how it works: > > ## When ESC is pressed, runs the function 'kill' > Esc::kill() > Is there a way to write it

Re: [Tutor] Fwd: Re: Python 3.6 Extract Floating Point Data from a Text File

2017-05-01 Thread Alan Gauld via Tutor
On 01/05/17 15:54, Stephen P. Molnar wrote: > Unfortunately, I'm still missing something. Here is my latest attempt > to incorporate your solution: > name = input("Enter Molecule ID: ") > name = str(name) you don't need the str() since input() always returns whatever string the user enters. >

[Tutor] Fwd: Re: Python 3.6 Extract Floating Point Data from a Text File

2017-04-30 Thread Alan Gauld via Tutor
How, embarrassing, I forgot to CC the list! :-) On 30/04/17 11:09, Stephen P. Molnar wrote: > I would have managed to extract input data from another calculation (not > a Python program) into the following text file. > > LOEWDIN ATOMIC CHARGES > -- > 0 C :

Re: [Tutor] Tkinter layout question

2017-04-30 Thread Alan Gauld via Tutor
On 26/04/17 07:56, Phil wrote: >> Your messages come into the moderation queue, I'm > > Thanks Alan, maybe the reason ...is because I'm > on the bounces list. I don;t know what bounces list you mean but it looks like your messages are going through directly now, I don't know what changed...

Re: [Tutor] Another set question

2017-04-30 Thread Alan Gauld via Tutor
On 30/04/17 00:58, Phil wrote: > Thank you Ben. A rethink of the problem during the 20 hours since > I posted my most recent question has led to a solution. You don;t say what so i'll go with what you say below... > The strings are the given numbers while the sets are > the likely candidates.

Re: [Tutor] How to display radiobutton window with no buttons selected?

2017-04-30 Thread Alan Gauld via Tutor
On 25/04/17 12:39, boB Stepp wrote: >>> I wish the displayed window to initially display with no button >>> selected. What am I missing here? >> >> It looks like the empty string is special. On my (linux) system all buttons >> appear grayed (while a selected button would be black). Any other

Re: [Tutor] Working with APIs - understanding the basics (Python 3.5)

2017-04-29 Thread Alan Gauld via Tutor
On 29/04/17 18:13, Rafael Knuth wrote: > can anyone recommend good resources? I am primarily in search of > simple, clean code examples & practical usecases (Google APIs for > example). An API is just a set of classes or functions. The Python standard library is an API. You already have lots of

Re: [Tutor] Tkinter layout question

2017-04-25 Thread Alan Gauld via Tutor
On 24/04/17 23:40, Phil wrote: By the way, I notice that my messages to this list, > and not other's, can take up to four hours Your messages come into the moderation queue, I'm not sure why because the moderation flag is not set on your account(it is automatically for new members). I'll

Re: [Tutor] Tkinter layout question

2017-04-24 Thread Alan Gauld via Tutor
On 24/04/17 20:02, Alan Gauld via Tutor wrote: And you could wrap that up as a pair of get/set functions if you so wished. def get_sudoku_grid(x,y): # code above return item def set_sudoku_grid(x,y,value): #code above item = value I should point out that to use my table code

Re: [Tutor] Tkinter layout question

2017-04-24 Thread Alan Gauld via Tutor
On 24/04/17 01:50, Phil wrote: On Mon, 24 Apr 2017 09:24:55 +1000 Phil <phil_...@bigpond.com> wrote: On Sun, 23 Apr 2017 09:39:54 +0200 Sibylle Koczian <nulla.epist...@web.de> wrote: Am 20.04.2017 um 14:43 schrieb Alan Gauld via Tutor: Its not too bad you can map the lar

Re: [Tutor] Tkinter layout question

2017-04-20 Thread Alan Gauld via Tutor
On 20/04/17 13:43, Alan Gauld via Tutor wrote: > So the 7th element becomes > divmod(7) -> 2,1 > > ie. element 7 maps to the 2nd cell, element 1 That should of course be the 3rd cell (0 based), oops. -- Alan G Author of the Learn to Program web site http://www.ala

Re: [Tutor] What are the few senarios of data science testing using Python

2017-04-20 Thread Alan Gauld via Tutor
On 20/04/17 11:48, John R wrote: > I am just trying to understand that how it is possible to > frame test cases on data science projcets using python! Can you clarify what you mean by "data science" projects? Do you mean projects built in Python and how to use, say, unittest with that code? Or

Re: [Tutor] Could anyone provide a complex data processing automation testing example

2017-04-20 Thread Alan Gauld via Tutor
On 20/04/17 11:56, John R wrote: > Most of the examples in google are looking simple in automation so I am not > getting an understanding of how a complex data processing application is > to be tested using python. Is this a different question to the other one you posted? If so in what way?

Re: [Tutor] Tkinter layout question

2017-04-20 Thread Alan Gauld via Tutor
On 20/04/17 10:33, Phil wrote: >> So, for a Suduko grid put 3x3 Entry boxes into a Frame. >> Then put 3x3 such frames into another frame. > > OK, so I'll go back to my original idea and use edit boxes. A grid of 9 x 9 > edit boxes does actually work and it makes it easy to keep track of the >

Re: [Tutor] Tkinter layout question

2017-04-20 Thread Alan Gauld via Tutor
On 19/04/17 23:48, Phil wrote: > I created a 9 x 9 grid on a canvas which looks much better. > I can display digits in the centre of the squares but > entering the digits from the keyboard seems to be beyond me. Eek! that's a recipe for premature baldness! Canvas is designed to display things

Re: [Tutor] Need help with code

2017-04-19 Thread Alan Gauld via Tutor
On 18/04/17 03:12, Tyler Seacrist wrote: > How do I avoid this error message everytime I utilize wordlist = > open("words.text") ? > wordlist = open("words.txt") > Traceback (most recent call last): > File "", line 1, in > wordlist = open("words.txt") >

Re: [Tutor] Write Data to Multiple Files

2017-04-19 Thread Alan Gauld via Tutor
On 19/04/17 11:35, Mohanad Ismail via Tutor wrote: > Read data from serial and write to file 1 for 15 sec, > after the 15 seconds continue writing the data on to > file 2 for 15 seconds >... each file should write for 15 seconds and stop for 15 seconds > Code: > #!/usr/bin/env python > from

Re: [Tutor] classproperty for Python 2.7 (read-only enough)

2017-04-19 Thread Alan Gauld via Tutor
On 19/04/17 08:43, Alan Gauld via Tutor wrote: > Probably because it is such a rare use case and because > its not that hard to do yourself if you really need it. Having read Steven's post I'll retract the bit about it being not that hard! :-) But I still think its a fairly rare scenario.

Re: [Tutor] sqlite3 making a spurious duplicate?

2017-04-19 Thread Alan Gauld via Tutor
On 19/04/17 03:21, Marilyn Davis wrote: > connection.execute("SELECT * FROM BRIGHTEST") > > returns a , not a regular python > sequence. Pretty much everything inn SQL land uses cursor objects. It's why best practice creates an explicit cursor for executing statements rather than the

Re: [Tutor] classproperty for Python 2.7 (read-only enough)

2017-04-19 Thread Alan Gauld via Tutor
On 19/04/17 08:28, Thomas Güttler wrote: > Nice, if it is that simple. > > Is there a reason why this is not in the standard library? Probably because it is such a rare use case and because its not that hard to do yourself if you really need it. But the standard library, like any open source

Re: [Tutor] Visual Studio Community 2017

2017-04-18 Thread Alan Gauld via Tutor
On 18/04/17 17:55, Rafael Knuth wrote: > I wanted to start my first project using matplotlib (I have never > worked with libraries before). Every time you do an import you are using a library. eg import sys import os etc It's no big deal. > I am trying to get started with VS Community 2017,

Re: [Tutor] classproperty for Python 2.7 (read-only enough)

2017-04-18 Thread Alan Gauld via Tutor
On 18/04/17 11:00, Thomas Güttler wrote: > I would like to have read-only class properties in Python. Is there a specific reason why? Do you think for example that users of the class will deliberately try to modify the attribute? Normally in Python we leave all attributes public and unprotected

Re: [Tutor] Tkinter and canvas question

2017-04-18 Thread Alan Gauld via Tutor
On 18/04/17 00:13, Phil wrote: > Thank you for reading this. > > How do I reference the_canvas from my solve() method? > class Sudoku(Frame): > def __init__(self, parent): > Frame.__init__(self, parent) > self.parent = parent > > parent.title("Sudoku solver") >

Re: [Tutor] sqlite3 making a spurious duplicate?

2017-04-17 Thread Alan Gauld via Tutor
On 18/04/17 00:36, Marilyn Davis wrote: > #!/usr/bin/env python3 > """ > Hello Tutors, > > I can't figure out why the FillWithStars() function puts Canopus in the db > twice. > > What am I missing? I don;t know but I converted your script into the more conventional form and it worked. it was

Re: [Tutor] Need help with code

2017-04-17 Thread Alan Gauld via Tutor
On 16/04/17 18:26, Tyler Seacrist wrote: > I need to draw a stack diagram for print_n > called with s = 'Hello' and n=2 and am unsure of how to do so. Me too. What is print_n? Which stack? One in your program or the interpreters internal stack? We need a lot more detail. -- Alan G Author

Re: [Tutor] Do not understand code snippet from "26.8. test — Regression tests package for Python"

2017-04-17 Thread Alan Gauld via Tutor
On 17/04/17 05:01, boB Stepp wrote: > Am I missing anything? If not, then why did the code snippet use the > (I believe to be misleading.) class variable approach with "func = > mySuperWhammyFunction" and "self.func(self.arg)"? I suspect it was a slightly broken attempt at reuse in that you can

Re: [Tutor] Do not understand code snippet from "26.8. test — Regression tests package for Python"

2017-04-16 Thread Alan Gauld via Tutor
On 16/04/17 16:21, boB Stepp wrote: > I did this and it indeed works. But how do I use this technique to > unittest the given function? I am just not seeing how to do it with > this with this mixin approach, and I have yet to study mixins, though > apparently I have just now started! I'm not

Re: [Tutor] understanding code testing

2017-04-16 Thread Alan Gauld via Tutor
On 16/04/17 03:18, Aaron Myatt via Tutor wrote: > My favourite book on testing. It is a pretty thorough walk through of > building a django app that helps you get a feel for the TDD work flow and > red, green, refactor cycle. A rather more practical and real world > applicable introduction to TDD,

Re: [Tutor] Do not understand code snippet from "26.8. test — Regression tests package for Python"

2017-04-15 Thread Alan Gauld via Tutor
On 16/04/17 00:17, boB Stepp wrote: > -- > #!/usr/bin/env python3 > > def mySuperWhammyFunction(any_input): > return any_input This is a simple function, its not bound to an object > > import unittest > >

Re: [Tutor] understanding code testing

2017-04-15 Thread Alan Gauld via Tutor
On 15/04/17 15:33, Rafael Knuth wrote: > can anyone point me to good learning resources on this subject? I'd recommend YouTube as your first port of call. There are a few python unit test videos but most of the best stuff is Java focused, but it translates to Python easily enough. Once you've

Re: [Tutor] Using Modules

2017-04-15 Thread Alan Gauld via Tutor
On 15/04/17 09:33, Aero Maxx D wrote: > With Python I'm not finding which modules I need Search for the functionality within the python.org site. The documentation tells you which module you are looking for. > ...I thought I'd connect to a MySQL database There is a standard DB interface in

Re: [Tutor] bracket issue

2017-04-15 Thread Alan Gauld via Tutor
On 15/04/17 03:17, Palm Tree wrote: > s="2*3+3(8-4(5+6+9))+2+3+3(4/4)" > > i want to find expression enclosed in brackets. > > i want outputs to be like: > (8-4(5+6+9)) > (5+6+9) > (4/4) > You probably could do it with some fancy regex but personally I'd investigate a proper text parser.

Re: [Tutor] How do we create a GUI to run a simple calculation program in Python?

2017-04-15 Thread Alan Gauld via Tutor
On 15/04/17 03:38, Alex Kleider wrote: >> Whatever he does he will need to separate his UI from his >> logic - a good programming skill regardless of UI. > > Can anyone suggest a good tutorial that explains exactly what this means > and how to achieve it? > (separate UI from logic I mean.) I

Re: [Tutor] sorted function

2017-04-14 Thread Alan Gauld via Tutor
On 14/04/17 19:29, shubham goyal wrote: > sorted function is not working when i am trying to sort the list of strings > but list.sort() is working. can you please help me understand. sort() sorts the list "in place". That is it sorts itself. sorted() returns a sorted copy of the list. It does

Re: [Tutor] Python 3.6 Multiply the elements of a 2D Array by the elements of a 1D Aeeay

2017-04-14 Thread Alan Gauld via Tutor
On 14/04/17 13:41, Stephen P. Molnar wrote: > The equation that I a want to evaluate (the one that I programmed in > FORTRAN) is equation (7) in the attached scan of one of the pages of > > Stephen P. Molnar and James W. King, Theory and Applications of the > Integrated Molecular Transform and

Re: [Tutor] creating .json files

2017-04-13 Thread Alan Gauld via Tutor
On 13/04/17 17:32, Rafael Knuth wrote: > Is there a way to split these two into separate steps: > a) creating a .json file > b) manipulating it (a, r, w ...) Of course. > What if I just wanted to create a .json file and do nothing with it? > > import json > file_name = "my_numbers.json" > >

Re: [Tutor] counting function calls

2017-04-13 Thread Alan Gauld via Tutor
On 13/04/17 17:10, marcus lütolf wrote: > Dear experts, Mats > I have found the solution, I put the counting variable at the wrong place: I don;t think so, what you have done now is count the times through the loop, but thats not (always) the same as the number of times the function gets called,

Re: [Tutor] python help

2017-04-13 Thread Alan Gauld via Tutor
On 13/04/17 15:33, Christina Hammer wrote: > I downloaded the newest version of Python on my windows computer and am > having some trouble using it. I need to save my work because I am using it > for an online class and am going to have to send it to my professor. But I > cannot access a tool bar

Re: [Tutor] Question to Phyton and XBee

2017-04-12 Thread Alan Gauld via Tutor
On 12/04/17 15:32, Daniel Berger wrote: >For me it is not clear what is going wrong and I would be happy to get >some help to solve the problem. This list is for the core language and library, so while we can help with installing third party packages that doesn't mean anyone here will

Re: [Tutor] Startup Python

2017-04-12 Thread Alan Gauld via Tutor
On 12/04/17 13:47, Wim Berrelkamp wrote: a=2 Here you assign the number 2 to 'a' d=a+4 print(d) > 6 > a=input('-->' ) Here you assign whatever character(s) the user types to 'a'. The fact that it looks like 2 doesn't change the fact that it is really the character '2'. So you

Re: [Tutor] Count for loops

2017-04-11 Thread Alan Gauld via Tutor
On 11/04/17 19:44, Mats Wichmann wrote: > import decimal > > Pi_Number = > str(decimal.Decimal(3.14159265358979323846264338327950288419716939)) > Unfortunately that doesn't work either: >>> " " + str(decimal.Decimal( ... 3.14159265358979323846264338327950288419716939)) '

Re: [Tutor] Count for loops

2017-04-11 Thread Alan Gauld via Tutor
On 11/04/17 17:48, Rafael Knuth wrote: > Pi_Number = str(3.14159265358979323846264338327950288419716939) > Pi_Number = "3" + Pi_Number[2:] > print(Pi_Number) > 3141592653589793 > > How come that not the entire string is being printed, but only the > first 16 digits? There are two problems

Re: [Tutor] Tkinter entry box text changed event

2017-04-10 Thread Alan Gauld via Tutor
On 10/04/17 10:18, Phil wrote: > def my_method(self.event): > print("method called") > > (self.event) is a syntax error and if I leave off "self", this is the result: You want two parameters self becaiuse its a method of a class so must have a self event which is the event passsed by the

Re: [Tutor] counting function calls

2017-04-10 Thread Alan Gauld via Tutor
On 10/04/17 08:55, marcus lütolf wrote: > Dear experts, > I have written the following code for motion detection with a PIR sensor > with a function and > I need to count how many times the funtion is called, but I get a traceback: > > #!/usr/bin/python3 > import sys, time > import RPi.GPIO as

Re: [Tutor] Tkinter entry box text changed event

2017-04-10 Thread Alan Gauld via Tutor
On 10/04/17 05:43, Phil wrote: > I would like a function to be called when I enter text > and then tab to the next entry box. One of the things about Entry boxes is that they are extremely flexible and have many event types associated with them. The consequence of this is that you as a

Re: [Tutor] (no subject)

2017-04-09 Thread Alan Gauld via Tutor
On 09/04/17 11:42, shubham goyal wrote: > Hello, I am a c++ programmer and wants to learn python for internship > purposes. How can i learn the advanced python fast mostly data science > packages, I know basic python. There are tutorials on most things. But it depends on what you mean by advanced

Re: [Tutor] What would be good use cases for the enum module?

2017-04-09 Thread Alan Gauld via Tutor
On 09/04/17 13:58, Mats Wichmann wrote: > All of these can of course be done without enums. So the extra benefit > of an enum is that the set is closed (immutable) and requires > uniqueness: picking some other value will be an error, Indeed, good catch. The value of an enum over an integer is

Re: [Tutor] What would be good use cases for the enum module?

2017-04-09 Thread Alan Gauld via Tutor
On 09/04/17 04:00, boB Stepp wrote: > understandable to me, but I am having difficulty imagining where I > might want to use these features. > Steven has given the basics, here are a few more real world examples: Any kind of status value: (open,closed,opening, closing,locked) - control valve

Re: [Tutor] Count for loops

2017-04-08 Thread Alan Gauld via Tutor
On 08/04/17 13:49, Rafael Knuth wrote: >> b = "3"+b[2:] #Removing the decimal point so that there are digits only in > > my_number = 3.14159 Here you assign a floating point number to mmy_number but the code Sama wrote was for working with strings read from a text file. You would need to

Re: [Tutor] Tkinter class question - solved

2017-04-08 Thread Alan Gauld via Tutor
On 07/04/17 20:21, Phil wrote: > After a bit more thought I now realise that I just > need to use self to reference e[][] in my check function. You need to use self any time you access any member of your class. So in your case: class TestGUI: def __init__(self, master): self.master

Re: [Tutor] Tkinter class question

2017-04-08 Thread Alan Gauld via Tutor
On 07/04/17 17:00, Phil wrote: > ...I'm now having a problem knowing when to use the "self" reference. self is needed every time you use an instance attribute or method. It is equivalent to 'this' in C++(or Java), but in Python it is never implicit you always have to explicitly specify self when

Re: [Tutor] want to set IDLE setting to default.

2017-04-07 Thread Alan Gauld via Tutor
On 07/04/17 23:01, Tianjiao Cui wrote: > Hi, all. I have met a very annoying issue that i messed up with IDlL > configuration. I changed "run" key in settings but i found it does not work > and then i tried to reset it to default but i failed. You need to give us more detailed descriptions of

Re: [Tutor] [Python 3.5] TypeError: a bytes-like object is required, not 'str' PICKLE

2017-04-07 Thread Alan Gauld via Tutor
Please always send the full error trace not just the last line. The message is full of useful details which we can't currently see. On 07/04/17 09:28, Allan Tanaka via Tutor wrote: > Hi > I have added b so that it translates into bytes object. save_cPickle part is > not problem... > But i

Re: [Tutor] Tkinter grid question

2017-04-07 Thread Alan Gauld via Tutor
On 07/04/17 11:08, Phil wrote: > ...In this case I become confused because had expected [][] > to be the same as a C two dimensional array. It is, sort of. If you set the data up correctly to start with :-) -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/

Re: [Tutor] Tkinter grid question

2017-04-07 Thread Alan Gauld via Tutor
On 07/04/17 03:09, Phil wrote: > Thank you for reading this. > > This is my first attempt at using Tkinter and I've quickly run into a problem. > Peter has already answered the problem but I'd like to point out how he used the interactive prompt >>> to demonstrate what was going wrong. You

Re: [Tutor] Network Sniffing on Windows with Python 3.6

2017-04-07 Thread Alan Gauld via Tutor
On 07/04/17 06:07, Some Developer wrote: > How would I go about writing a Python 3.6 script for Windows that would > sniff the network traffic and take the individual packets and then > reassemble them into something that is useful data? That is definitely possible using Python although it is

Re: [Tutor] Question about loop and assigning variables

2017-04-05 Thread Alan Gauld via Tutor
On 05/04/17 20:07, Fazal Khan wrote: > assign different variables with each loop You can't, but you can fake it... > def BeamInfo(x): > for Bnum in x: > if plan1.IonBeamSequence[Bnum].ScanMode == 'MODULATED': > TxTableAngle = >

Re: [Tutor] learning resources

2017-04-04 Thread Alan Gauld via Tutor
On 04/04/17 12:19, brian mituka wrote: > what are the best learning resources for a beginner in python... Look on Python.org and you will find a beginners page with many links. But... it will depend on whether you can already program in another language which beginners page you go to. I am, of

Re: [Tutor] Count for loops

2017-04-04 Thread Alan Gauld via Tutor
On 04/04/17 12:04, Rafael Knuth wrote: > Sarma: thank you so much, I checked your code, it works. However, can > you enlighten me what it exactly does? It just iterates over the PI string manually and compares the birth date with the first 4 PI string characters. It would probably be more

Re: [Tutor] How do we create a GUI to run a simple calculation program in Python?

2017-04-04 Thread Alan Gauld via Tutor
On 04/04/17 17:55, Lisa Hasler Waters wrote: > A middle school student of mine created a program to calculate simple and > compound interest. He built it in PyCharm EDU using a Mac running 10.11.6. > > He would like to create a GUI to run this program. Please, can you advise > on how he could

<    4   5   6   7   8   9   10   11   12   13   >