Re: [Tutor] If tuple cannot be sorted, then why sorted() on a tuple is fine?

2017-08-02 Thread Alan Gauld via Tutor
On 02/08/17 20:01, C W wrote: > I am a little confused about why Tuple can be sorted. > > Suppose I have the following, > >> aTuple = (9, 3, 7, 5) >> sorted(aTuple) > [3, 5, 7, 9] sorted() returns a new object. The original tuple has not been changed - print aTuple to confirm this. HTH -- Al

[Tutor] Loop problem (was: Re: Tutor Digest, Vol 161, Issue 42)

2017-08-02 Thread Alan Gauld via Tutor
On 02/08/17 20:53, Borisco Bizaro wrote: > I try this using loop but could not stop by pressing a key and could not > give total price please help me It would help if you showed us the code you wrote with the loop. Its difficult to guess what you did wrong when we can't see it. > print"\n welcome

Re: [Tutor] The results of your email commands

2017-08-03 Thread Alan Gauld via Tutor
On 03/08/17 11:05, Abdur-Rahmaan Janhangeer wrote: > me i cooked up :... Yes that works too, especially if you don;t need access to the individual prices later. There are a couple of things to make it more Pythonic... > x = True > sum = 0 > > while (x==True): > a = input("input:") > if

Re: [Tutor] how to make an lexical scope block?

2017-08-05 Thread Alan Gauld via Tutor
On 05/08/17 08:23, Xiaosong Chen wrote: > In C, it's a common pattern to use temporary variables in an lexical > scope to prevent the global scope from getting dirty. This was very common in the early days of C - around 1979-1985 - when compilers often only considered the first 4 (or 6) characters

Re: [Tutor] really basic question..

2017-08-05 Thread Alan Gauld via Tutor
On 05/08/17 16:48, bruce wrote: > redid a search just now. found a bunch of sites that said it's > doable.. embarrased Just because its doable doesn't mean you should though... Bare except clauses can hide a multitude of sins. Unless its at the top level of your program and you use it to log any

Re: [Tutor] unorderable types

2017-08-05 Thread Alan Gauld via Tutor
On 05/08/17 19:28, Howard Lawrence wrote: > if guess_value != number: > number = str(number) > print ('nope. the number i was thinking of was ' + number) There is the problem, you convert number to a str before printing it. so next iteration of the loop your if test fails. Yo

Re: [Tutor] how to make an lexical scope block?

2017-08-05 Thread Alan Gauld via Tutor
CCing the list. Always use ReplyAll or ReplyList when responding to the list. On 05/08/17 18:17, Xiaosong Chen wrote: > 2) Also we avoid importing with the >> from foo import * >> >> even if you import with >> >> import foo >> >> foo.temp can still be accessed. When you use autocomplete in an >> i

Re: [Tutor] Difference(s) betweenPython 3 static methods with and without @staticmethod?

2017-08-06 Thread Alan Gauld via Tutor
On 07/08/17 00:35, boB Stepp wrote: > = > Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 18:41:36) [MSC v.1900 64 > bit (AMD64)] on win32 > Type "help", "copyright", "credits" or "license" for more information. > p

Re: [Tutor] Difference(s) betweenPython 3 static methods with and without @staticmethod?

2017-08-08 Thread Alan Gauld via Tutor
On 08/08/17 02:22, boB Stepp wrote: > "@staticmethod" then there are two ways of calling the method, using > objects or using the class. Is there some reason not to use the > "ClassName.a_static_method()" syntax? Are there intended uses for > doing this? classes are objects too... You could ha

Re: [Tutor] setup.py "script" vs "console_scripts" Was: if __name__=='main' vs entry points: What to teach new comers?

2017-08-09 Thread Alan Gauld via Tutor
On 09/08/17 22:15, Steven D'Aprano wrote: > On Tue, Aug 08, 2017 at 12:56:56PM +0200, Chris Warrick wrote: > >> While setuptools is not officially part of the stdlib, > > This is the critical factor. How can you use *by default* something that > is *NOT* supplied by default? I have to agree wit

Re: [Tutor] What exactly does the three dots do? Why such as thing?

2017-08-10 Thread Alan Gauld via Tutor
On 10/08/17 14:39, C W wrote: > I suppose it's just a place holder, though I don't know when I would use it > in my every day life. Probably never. Like most programming languages Python has a load of rarely used, obscure features. Most Python programmers never use ellipses, metaclasses(*), the

Re: [Tutor] What exactly does the three dots do? Why such as thing?

2017-08-11 Thread Alan Gauld via Tutor
On 11/08/17 14:57, Mats Wichmann wrote: >> obscure features. Most Python programmers never use ellipses, > > I guess what this means is when I post code snippets with some lines > elided for greater readability of the point being made I should not use > ellipses for that, as they're actually a sy

Re: [Tutor] Percentage of installations without setuptools (Was if __name__=='__main__' ...)

2017-08-11 Thread Alan Gauld via Tutor
On 11/08/17 13:35, Thomas Güttler wrote: > I guess most python installations have setuptools. I guess so too, although I don't know. Those that don't are probably in one of two categories a) people who just downloaded Python and never installed anything else b) people working for large parano

Re: [Tutor] Percentage of installations without setuptools (Was if __name__=='__main__' ...)

2017-08-11 Thread Alan Gauld via Tutor
On 11/08/17 19:13, Chris Warrick wrote: >>> a) people who just downloaded Python and never installed >>>anything else > > False since Python 3.4/2.7.9. ensurepip installs Python on every new > Python install. Sorry Chris, that's not making sense? Do you mean ensurepip installs setuptools on

Re: [Tutor] conditional renaming folder and files in the tree

2017-08-12 Thread Alan Gauld via Tutor
On 11/08/17 16:10, banda gunda wrote: > for root, dirs, files in os.walk(".", topdown=False): > for name in files: > print(os.path.join(root, name)) > os.rename(name.replace("---", "changed")) Here you give the new name but not the original name. The function needs two values,

Re: [Tutor] Long post: Request comments on starting code and test code on chess rating project.

2017-08-13 Thread Alan Gauld via Tutor
On 13/08/17 06:22, boB Stepp wrote: > The intent of this project is more than just calculate chess ratings. > I also envision being able to store a record of all game results and > player information for my school chess players that I give lessons to. That's fair enough but OOP or no OOP the basi

Re: [Tutor] Long post: Request comments on starting code and test code on chess rating project.

2017-08-13 Thread Alan Gauld via Tutor
On 13/08/17 21:15, boB Stepp wrote: I return to the point I made about focusing on the objects not the functionality. > It is not very well-written in my opinion. But anyway ... The basic formula > is: > > new_rating = old_rating + K_MULTIPLIER * (opponent_rating - > old_rating) + K_ADDER * (y

Re: [Tutor] "Path tree"

2017-08-14 Thread Alan Gauld via Tutor
On 13/08/17 21:07, Michael C wrote: > Please look at the picture attached: This is a text mailing list, no binary attachments allowed. The server strips them off. You need to put it on a web site and provide a link. > consisting of (x,y). Now I am trying to make a function go through this >

[Tutor] Fwd: Re: "Path tree"

2017-08-14 Thread Alan Gauld via Tutor
Forwarding to the list. Forwarded Message pic http://imgur.com/a/CwA2G On Mon, Aug 14, 2017 at 8:55 AM, Alan Gauld via Tutor mailto:tutor@python.org>> wrote: On 13/08/17 21:07, Michael C wrote: > Please look at the picture attached: This is a tex

Re: [Tutor] Long post: Request comments on starting code and test code on chess rating project.

2017-08-15 Thread Alan Gauld via Tutor
On 15/08/17 15:09, Neil Cerutti wrote: >> There are a variety of reports that I would like to be able to >> print to screen or paper. Things such as a "Top x List" of >> rated players, full rating list sorted from highest rating to >> lowest, rating lists for the current school year only or a >>

Re: [Tutor] Long post: Request comments on starting code and test code on chess rating project.

2017-08-16 Thread Alan Gauld via Tutor
On 16/08/17 04:06, boB Stepp wrote: >> I agree with Neil, this is exactly what SQL is good for and >> would make this part of the project much easier and would have >> the added benefit of introducing you to one of the trickiest, >> but most common, bits of OOP - object persistence... > > Would y

Re: [Tutor] "Path tree"

2017-08-16 Thread Alan Gauld via Tutor
On 16/08/17 02:02, Cameron Simpson wrote: > Ok. So you have a graph like this: > 1 -- 2 -- 3 -- 4 >| > 7 -- 5 -- 6 -- 8 > > graph = { > 1: [2], > 2: [1, 3], 2: [1, 3, 5], > 3: [2, 4], > 4: [3], > 5: [7, 6], 5: [2, 6, 7], > 6: [5, 8], > 7:

Re: [Tutor] pygame not working

2017-08-16 Thread Alan Gauld via Tutor
On 16/08/17 17:33, Quantz Jeremy wrote: > I’m not sure if I should be asking here about this, Strictly speaking no, this list is for questions about Python and its standard library. So PyGame issues should really go to the PyGame support fora, and that's still the best place for detailed support.

Re: [Tutor] Object takes no parameters

2017-08-16 Thread Alan Gauld via Tutor
On 17/08/17 01:08, Howard Lawrence wrote: > class Human: > def _init_(self, n, o) > self.name = n > self.occupation = o > > > tom = Human('tom cruise', 'actor') > > Traceback most recent call last > File "c:\users\shaun\python\python35\human_class.py"line 16 in module >

Re: [Tutor] (no subject)

2017-08-16 Thread Alan Gauld via Tutor
On 16/08/17 23:36, Howard Lawrence wrote: > class Address: > def _init_(self,Hs,St,Town,Zip): > self.HsNunber=Hs > self.Street=St > self.Town=Town > self.Zip=Zip > Addr=Address (7, ' high st', 'anytown',

Re: [Tutor] Tutor Digest, Vol 162, Issue 42

2017-08-17 Thread Alan Gauld via Tutor
On 17/08/17 12:43, Howard Lawrence wrote: > On Aug 17, 2017 3:17 AM, wrote: ... > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Tutor digest..." Please follow the instructions. Change the subject line. And don't post the entire digest, it's hard to fi

Re: [Tutor] Help....

2017-08-17 Thread Alan Gauld via Tutor
On 17/08/17 14:17, edmundo pierre via Tutor wrote: > I am trying to write a code to solve a system of equation at 2 variables. > I used Tkinter to do it. More significantly you used numpy to do it and that seems to be where the issues lie, not in Tkinter. Numpy is part of SciPy which has a ded

Re: [Tutor] When to use classes

2017-08-19 Thread Alan Gauld via Tutor
On 19/08/17 05:26, boB Stepp wrote: > related methods needs to share the same values and a class would tidy > this up nicely without the need for any globals or needless passing of > the exact same values around as parameters/arguments. Indeed, but its important to remember that class attributes

Re: [Tutor] When to use classes

2017-08-19 Thread Alan Gauld via Tutor
On 19/08/17 08:52, Alan Gauld via Tutor wrote: Following up my own post - a sure sign of failure to communicate :-( > On 19/08/17 05:26, boB Stepp wrote: > >> related methods needs to share the same values and a class would tidy >> this up nicely without the need for any globa

Re: [Tutor] When to use classes

2017-08-19 Thread Alan Gauld via Tutor
On 19/08/17 10:04, Peter Otten wrote: > nicer interface. Nobody would want to write > > a + b * c > > as > > add(a, mul(b, c)) Unless they program in Lisp perhaps :-) -- 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] When to use classes

2017-08-19 Thread Alan Gauld via Tutor
On 19/08/17 17:00, boB Stepp wrote: > I try to keep this in mind. Another thing I'm currently struggling > with is when to use inheritance vs. separate, independent classes. The golden rule is if the child is not a kind-of the parent then it should be delegation not inheritance. Never use inheri

Re: [Tutor] help with subprocess module

2017-08-19 Thread Alan Gauld via Tutor
On 19/08/17 11:13, kay Cee wrote: > import subprocess > import time > import datetime > > class UpdateError(Exception): > pass In defining your own type of Exception you implicitly say that you will be raising it somewhere. But you never raise this exception in your code... > def update():

Re: [Tutor] When to use classes

2017-08-20 Thread Alan Gauld via Tutor
On 20/08/17 02:47, Steven D'Aprano wrote: > since then feels like going back to the Dark Ages. Having to care about > low-level details like creating buttons, installing callbacks and so > forth just feels wrong. To be fair most GUI frameworks come with a GUI builder that remove the manual codi

Re: [Tutor] When to use classes

2017-08-22 Thread Alan Gauld via Tutor
On 20/08/17 02:08, Steven D'Aprano wrote: > Raymond Hettinger has a good video presentation about the use of classes > and inheritance for delegating work. (That is not to be confused with > delegation as an alternative to inheritance.) No, but I think it would have been useful if he had made t

Re: [Tutor] Does matplotlib.finance still work?

2017-08-24 Thread Alan Gauld via Tutor
On 24/08/17 14:51, C W wrote: > I have the following code, I get an error at the first line. So don't make us guess. What is the error(full text please)? > from matplotlib.finance import quotes_historical_yahoo_ochl And what does a dir() show for matplotlib.finance? Are you sure the name is spe

Re: [Tutor] Does matplotlib.finance still work?

2017-08-25 Thread Alan Gauld via Tutor
On 25/08/17 15:19, C W wrote: > I did not mean to leave out the error message, it was very long. That just means it has a lot of information in it :-) > I think the package has been removed. I don;t think so based on the traceback... quotes = quotes_historical_yahoo_ochl('APX', start, ...

Re: [Tutor] How to use subprocess module to get current logged in user?

2017-08-26 Thread Alan Gauld via Tutor
> My objective: Determine who the currently logged in user is and > determine if that user is in my list of users that I have authorized > to use my programs. In addition to Steve and Mats answers: import os os.getlogin() #-> 'alan' os.getuid() #-> 1001 import pwd pwd.getpwuid(os.getuid()) #

Re: [Tutor] easygui

2017-08-27 Thread Alan Gauld via Tutor
On 27/08/17 03:07, George Sconyers via Tutor wrote: > Hello all. Need some help with easygui which my son is trying to run for a > book he is working in. I'm not sure what the current status of easygui is, I read somewhere that it had been discontinued. But if you are still finding a download for

Re: [Tutor] Problems Plotting in 3D

2017-08-31 Thread Alan Gauld via Tutor
On 31/08/17 07:18, Kendall Evans wrote: > I am calculating the youngs modulus for a crystal > Find S=inv(C) > Modulus = S(1,1)^-1 I assume you will be using SciPy for this? There are dedicated fora for SciPy stuff where you might find someone who has been down this

Re: [Tutor] Python 3 for Beginners was: (Re: intro book for python)

2017-09-03 Thread Alan Gauld via Tutor
On 03/09/17 11:02, Leam Hall wrote: > Anyone that uses python on Linux has to use Python 2. Errr, nope. I use python 3 on Linux all the time. My last significant Python 2 program was about 4 years ago. It may be true that the distro maintainers are still using python 2 for historical reasons but

Re: [Tutor] Executing "if :" function on terminal

2017-09-05 Thread Alan Gauld via Tutor
On 05/09/17 08:56, Nathan Kckaiyer wrote: > i have just started learning python. I have repeatedly hit a road > block on my mac os terminal . Everytime i use the "if :" command i > get syntax errors. The problem is that you are somehow executing the Python interpreter prompt in the interpreter.

Re: [Tutor] I want to display Integral symbols

2017-09-05 Thread Alan Gauld via Tutor
On 05/09/17 14:29, edmundo pierre via Tutor wrote: > I have been trying to display mathematics symbols on my Tkinter (using > Python) project, > but was not successful So show us what you did. Its hard to figure out what's gone wrong when we can't see your code. And that includes telling us wh

Re: [Tutor] Help With Python Tasks

2017-09-05 Thread Alan Gauld via Tutor
On 05/09/17 19:25, Ruth Hardy wrote: > I was wondering if you can help me please with these computer science tasks We can help, but we won;t do them for you. > First Task > > Write code do the following things involving strings. Wherever possible, > you should try to incorporate functions/pro

Re: [Tutor] Select a string

2017-09-06 Thread Alan Gauld via Tutor
On 06/09/17 06:34, Pat Martin wrote: > but my script returns 0. Since they want it to find 2 from the bobob in the > string using "bob in s" doesn't work (it only returns 1). Your code has bugs and Cameron has addressed those along with general advice on how to debug your code in future. However

Re: [Tutor] Fw: I want to display Integral symbols

2017-09-06 Thread Alan Gauld via Tutor
On 06/09/17 08:09, edmundo pierre via Tutor wrote: > So show us what you did. Its hard to figure out what's > gone wrong when we can't see your code:That is what I did: > from sympy import*from tkinter import*from sympy import init_printing > root = > Tk()root.geometry("450x350+500+500")root.titl

Re: [Tutor] New to Python

2017-09-08 Thread Alan Gauld via Tutor
On 08/09/17 08:35, George Fischhof wrote: > As this is a really frequent question, maybe it would be good to put a > short list (the answers cumulated no more than about 10 websites) into the > welcome message of the Tutor mailing list. The welcome message should be a very short (ideally one "scr

Re: [Tutor] How is database creation normally handled?

2017-09-10 Thread Alan Gauld via Tutor
On 10/09/17 01:29, boB Stepp wrote: > While reading about SQL, SQLite and the Python module sqlite3, it > appears that I could (1) have a program check for the existence of the > program's database, and if not found, create it, make the tables, > etc.; or, (2) create the database separately and inc

Re: [Tutor] Standard module sqlite3 or APSW?

2017-09-10 Thread Alan Gauld via Tutor
On 10/09/17 01:56, boB Stepp wrote: > So if all of this is correct, does the documentation at > https://rogerbinns.github.io/apsw/pysqlite.html#pysqlitediffs give an > objective assessment of the differences between pysqlite and APSW? I believe so. I've never used APSW, only read a single web art

Re: [Tutor] beginning to code

2017-09-10 Thread Alan Gauld via Tutor
For some reaspon I'm missing the original post so apologies to replying to Senthil instead of the OP directly... >> The code i should try is as following: >> >> while True: >> print ('who are you') >> name = input () >> if name != 'bert': >> continue >> pri

Re: [Tutor] How to create an object in database only if the object is not already there?

2017-09-11 Thread Alan Gauld via Tutor
On 11/09/17 10:38, GMX wrote: > I am using `pony` orm to write a simple class as my model. pony is not a standard module (indeed I only heard about it from your email) so you are probably best asking on the pony support forum if such exists or via the author. > from pony.orm import Database > fr

Re: [Tutor] question about calendar module in standard libriary

2017-09-11 Thread Alan Gauld via Tutor
On 11/09/17 11:58, Айнур Зулькарнаев wrote: > So, the question is why not explicitly raise ValueError if > user enters the firstweekday parameter bigger that 6 Its a valid question but you probably need to find the original PEP document to find the answer and that module has been around for a *

Re: [Tutor] How to write database-agnostic python code? (Is this even possible?)

2017-09-13 Thread Alan Gauld via Tutor
On 12/09/17 20:05, boB Stepp wrote: As I continue to read about SQL, one thing jumps out: There are many differences between how SQL statements are implemented usage of SQL. So how does one write one's python program to be DB-agnostic? And if this is impossible, then what is the best way t

Re: [Tutor] How is database creation normally handled?

2017-09-13 Thread Alan Gauld via Tutor
On 10/09/17 18:41, Mats Wichmann wrote: > restore" and a local copy of the (mysql) db will be built. So that's > what I just agreed with: the setup process happens outside the code app ... > maybe it's not that unusual - any time you need to start with a > reproducible known state of the DB, that

Re: [Tutor] Create CDF using Python

2017-09-13 Thread Alan Gauld via Tutor
On 13/09/17 01:28, Pareshkumar Panchal wrote: > I have set of data in excel file. i would like to create the CDF plots & > find 40th & 70th Percentile using python with functionality of refresh > whenever the data sets update. There may be a good reason for this but frankly that's what spreadshee

Re: [Tutor] How to write database-agnostic python code? (Is this even possible?)

2017-09-14 Thread Alan Gauld via Tutor
On 14/09/17 04:11, boB Stepp wrote: >> SELECT some, fields (never *) > > Why no "*"? Does this open up a security vulnerability? Not so much security as resilience to change. If you use * and the data schema changes to include extra fields then your * query returns the extra fields and all the

Re: [Tutor] How to write database-agnostic python code? (Is this even possible?)

2017-09-14 Thread Alan Gauld via Tutor
On 14/09/17 04:40, boB Stepp wrote: >> mapping your logic layer object models to underlying >> data tables. > > My initial thoughts here are that typically a particular class would > map to a particular table and that each object instance would > correspond to a row in said table. Is this typica

Re: [Tutor] Python Help

2017-09-15 Thread Alan Gauld via Tutor
On 15/09/17 04:08, Pratyusha Thundena wrote: > How do check to see if string ‘garden’ contains a > vowel(a, e , i , o, u , or y) using a for loop? Hi, this sounds like homework and we won't do your homework for you, but we do give hints. How would you do this without a computer? There are (at l

Re: [Tutor] array input from keyboard

2017-09-15 Thread Alan Gauld via Tutor
On 15/09/17 21:50, Derek Smith wrote: > if nput1 == "file" : > nput2 = input("Please provide your input file? ") > nput2 = nput2.lower() Are you sure the filenames will always be lower case? > print (nput2) > fh = open(nput2,"r") You should wrap that in a try/except in case ther

Re: [Tutor] Python + Irc

2017-09-15 Thread Alan Gauld via Tutor
On 15/09/17 21:16, Fernando Gualberto wrote: > How i can integrate Python program with IRC to send Messages from program > to the IRC? If you google "python irc module" you should get several hits. Try looking at the documentation and pick the one that seems easiest for your needs. -- Alan G Aut

Re: [Tutor] Python HW question

2017-09-16 Thread Alan Gauld via Tutor
On 16/09/17 01:32, mikn...@gmail.com wrote: > I really need some Python help. I’m a beginner and have some hw for class: OK, Usual caveat: we don;t do your homework, just give hints. > Write a program that calculates longest substring of increasing letters in > st, say st=‘Supercalifragilistice

Re: [Tutor] pip install of subprocess module

2017-09-18 Thread Alan Gauld via Tutor
On 18/09/17 18:59, Derek Smith wrote: > I want to use the subprocess.run module b/c per the> docs os.system is > antiquated Its not so much antiquated but it is deprecated because it is severely limited, all you get back is an error code. > Why am I doing wrong below? You are trying to insta

Re: [Tutor] Require help for a script

2017-09-19 Thread Alan Gauld via Tutor
On 19/09/17 08:48, Clara Chua wrote: > Hi Python tutor, I require help for a script that asks user for number of > rows, r and number of columns c, and generates a r x c matrix with the > following values: What help do you need? Which part of the above do you not know how to do? Can you ask the u

Re: [Tutor] (no subject)

2017-09-19 Thread Alan Gauld via Tutor
On 19/09/17 15:11, C wrote: > Hi Python tutor, I require help for a script that asks user for number of > rows, r and number of columns c, and generates a r x c matrix with the > following values: You already posted this in another thread, please do not multi-post it just clutters up the archive a

Re: [Tutor] Tutor Digest, Vol 163, Issue 28

2017-09-19 Thread Alan Gauld via Tutor
On 19/09/17 15:45, Saahndong Ransom wrote: > What are the uses of python? > What are easy way to learn python? Python is a general purpose programming language that can be used to build many kinds of software applications from computer administration to web servers to desktop GUI applications. Th

Re: [Tutor] Need Help with install of Python!

2017-09-19 Thread Alan Gauld via Tutor
On 19/09/17 21:13, Larry Staley wrote: > Hello I am very new to Python just having installed Python Version 2.7 onto > my windows 8.1 laptop. I thought the install was successful and was > entering information for my first assignment when I received an unexpected > error. Where did you get your v

Re: [Tutor] subprocess check_output

2017-09-20 Thread Alan Gauld via Tutor
On 20/09/17 22:09, Derek Smith wrote: > Why does python output this b and newline characters Because that's what the command is returning. The b indicates its an array of bytes (as opposed to a unicode string) Note the module dpocumentation for check_output() says: "By default, this function wil

Re: [Tutor] running or calling a module from the desktop

2017-09-21 Thread Alan Gauld via Tutor
On 20/09/17 22:06, orpha.pen...@outlook.com wrote: > I would like to import, run or set path to desktop. OK, On Windows go to Windows Exploder and type in the address %HOMEPATH%\Desktop Go there and you should be able to see/figure out the full path to your personal desktop folder. Then add t

Re: [Tutor] How to sort float number from big numbers to small numbers?

2017-09-25 Thread Alan Gauld via Tutor
On 25/09/17 04:34, edmundo pierre via Tutor wrote: I am trying to sort float numbers input by an user from the bigger to smaller number. I do not know how to compare float numbers. Any ideas? Thank you! The same way you sort anything else. Using the comparison operations ==, <, >, <=, >= Ther

Re: [Tutor] Python programming for the absolute beginner

2017-09-29 Thread Alan Gauld via Tutor
On 29/09/17 08:51, Peter Collidge wrote: > I have borrowed the above book from my local library but I believe it was > written in 2010 and as a result I am having difficulty in deciding which > version of Python to download. > Can anyone help? If you want to follow the book use the version the boo

Re: [Tutor] Directory Structure

2017-09-29 Thread Alan Gauld via Tutor
On 29/09/17 18:02, Chris wrote: > I'd like to store a directory tree in a python script. That doesn't make much sense. A directory tree is stored on the hard disk. A python script is the source code to a program you execute What do you mean by "store the directory tree in the script"? Do you mea

Re: [Tutor] problem with python3.5 headfirst python 2nd ed chpt 10 test drive example decorator issues

2017-09-29 Thread Alan Gauld via Tutor
On 28/09/17 23:35, peter wrote: > I am on chapter 10 of headfirst python second edition. got most of the > prior codes to work but am stuck on this one. I don;t know the book and only vaguely know Flask, but I'd start by adding some debug print statements to the functions. Something like def ..

Re: [Tutor] Directory Structure

2017-09-29 Thread Alan Gauld via Tutor
On 29/09/17 20:34, Chris wrote: > I want to store some kind of representation of the tree in memory when > the code runs. Then I could not only move the mails but also create > lists, e.g. a table with mail headers. Thanks for the extra detail but... Probably the reason you can't find any module

Re: [Tutor] I want to learn how memory works!

2017-09-29 Thread Alan Gauld via Tutor
On 29/09/17 19:47, Michael C wrote: > Could you point me to a source of information about all the things someone > should know before he starts writing a memory scanner? Not a single source but wikipedia is a good start for anything technical. In particular you need to understand the difference

Re: [Tutor] Am I missing something obvious about "FizzBuzz"?

2017-10-01 Thread Alan Gauld via Tutor
On 01/10/17 06:56, boB Stepp wrote: > I definitely was *not* looking for a pat on the back. I just could > not believe that "FizzBuzz" (Or similar questions.) would ever be > needed in a job interview for programming/software engineering. The fizzbuzz one is definitely a bit too simplistic, b

Re: [Tutor] Beginner's guessing game

2017-10-01 Thread Alan Gauld via Tutor
On 01/10/17 09:38, Steve Lett wrote: > Can u please tell me why this program does not work in line 28? That is > guessesTaken. It reads 0 when it should be a larger number. > > I am a beginner having another try to get it! > > Thank you, Steve Welcome Steve, but I can't see any program? Did you

Re: [Tutor] Most common words in a text file

2017-10-01 Thread Alan Gauld via Tutor
On 30/09/17 18:12, Sri G. wrote: > import sysimport collections I assume that should be two lines? But you can also import multiple modules on a single line. import sys, collections Although some folks don't like that style. > def find_most_common_words(textfile, top=10): > ''' Returns th

Re: [Tutor] Am I missing something obvious about "FizzBuzz"?

2017-10-01 Thread Alan Gauld via Tutor
On 01/10/17 16:09, Steven D'Aprano wrote: >> The fizzbuzz one is definitely a bit too simplistic, but the one >> cited by McConnel (reverse a linked list in C) is typical of >> the kind of question we used. And yes, most candidates failed. > > I would have *no idea* how to traverse a singly-link

Re: [Tutor] Am I missing something obvious about "FizzBuzz"?

2017-10-01 Thread Alan Gauld via Tutor
On 01/10/17 22:39, Marc Tompkins wrote: >>> Probably the best programming test there is look at code >>> that's already been developed, >> >> It is what we did with the bug finding test. > My test was, fortunately for me, not a start-from-scratch FizzBuzz problem, > but debugging a report module

Re: [Tutor] closing the window through code

2017-10-01 Thread Alan Gauld via Tutor
On 01/10/17 19:36, Max Patient wrote: > my task is to create a password checker and one of the > criteria is to have a quit option. What does the quit do? Quit the login? or quit the application? Based on your subject line I'm assuming just quit the login - but then how would you do anything in

Re: [Tutor] script guidelines

2017-10-03 Thread Alan Gauld via Tutor
On 03/10/17 09:48, renukesh nk wrote: > requirement: > i have a directory , that contains multiple sub directories, each sub > directory has multiple text and log files, my script fetches the required > lines from all the sub directories and stores it in one text file. > I'm not too sure what yo

Re: [Tutor] ctypes wintypes

2017-10-03 Thread Alan Gauld via Tutor
On 03/10/17 22:30, Michael C wrote: > I am trying to create SYSTEM_INFO structure and MEMORY_BASIC_INFORMATION > structure > > I think there are modules for this purpose? Is it the ctypes.wintypes? wintypes does define many of the standard Win32 API types but sadly neither of the two you mentio

Re: [Tutor] (no subject)

2017-10-03 Thread Alan Gauld via Tutor
On 03/10/17 22:49, steve.lett...@gmail.com wrote: > That is guessesTaken. It reads 0 when it should be a larger number. What makes you think so? You never increase it from its initial value so, quite correctly it stays at zero. > I am a beginner having another try to get it! Remember the comput

Re: [Tutor] ctypes wintypes

2017-10-04 Thread Alan Gauld via Tutor
On 04/10/17 04:12, Michael C wrote: > Is there a module that does this for me? > If it exists, how do I find it? Google is your friend. What you need to remember is that modules only get created if someone else has the same need as you. And usually if its a repeated need since it takes time and e

Re: [Tutor] I am trying to create a list of object and want to display that list on the screen on my Tkinter screen

2017-10-04 Thread Alan Gauld via Tutor
On 04/10/17 14:40, edmundo pierre via Tutor wrote: > Hello, > I am writing a code When posting code please use plain text. HTML gets mangled so we can't see what your code looks like.(see below) > where I am using a empty list and I will fill up that > list with object. Then  I will show those

Re: [Tutor] Tkinter's Documentation

2017-10-06 Thread Alan Gauld via Tutor
On 05/10/17 17:38, adil gourinda wrote: > Where can i find the reference documentation of "Tkinter" Tkinter is a module, not part of the language, so it is documented in the modules section. But the documentation is not 100% complete and for details you often need to look at the Tk/Tcl documentat

Re: [Tutor] script guidelines

2017-10-06 Thread Alan Gauld via Tutor
On 06/10/17 11:07, renukesh nk wrote: > currently m using pycharm , interpreter = python 3.6 > i am getting th error as below, what might be the reason for this. > > UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 159: > character maps to It looks like you have a character

Re: [Tutor] Tkinter's Documentation

2017-10-06 Thread Alan Gauld via Tutor
I asked for an alternative. Sorry if my first message was not so clear -- From: Tutor on behalf of Alan Gauld via Tutor Sent: Friday, October 6, 2017 10:05:27 AM To: tutor@python.org

Re: [Tutor] Tkinter's Documentation

2017-10-06 Thread Alan Gauld via Tutor
estions) I didn't get any response, So I thought that it is like a dead project, for this reason why I asked for an alternative. Sorry if my first message was not so clear -- From: Tutor on

Re: [Tutor] using while loop for read process memory

2017-10-08 Thread Alan Gauld via Tutor
On 08/10/17 20:18, Michael C wrote: > This is the red part  >   index = current_address >         end = current_address + mbi.RegionSize > >         while index < end: >             if ReadProcessMemory(Process, index, ctypes.byref(buffer), \ >                                  ctypes.sizeof(buffer

Re: [Tutor] sibling import

2017-10-12 Thread Alan Gauld via Tutor
On 12/10/17 12:15, Atar new wrote: > Here is my problem. I want to use sibling import but it is not working . I > know taht if we add the directory in sys.path ,it will work. > Why not put the package in the same folder as your top level script? I think that should work. > But I have to package

Re: [Tutor] coding help with maxwell-boltzmann distribution

2017-10-12 Thread Alan Gauld via Tutor
On 12/10/17 21:22, Cameron McKay wrote: > I've never used python trying to plot a graph. Thus I am having > difficulties trying to plot the maxwell-boltzmann distribution. Bear in mind that this list is for people learning the Python language and its standard library(as defined on python.org). A

Re: [Tutor] Variable list problem

2017-10-12 Thread Alan Gauld via Tutor
On 12/10/17 22:29, Le Mar wrote: > hi i'm wondering if anyone could help me with this exercise: > We can give you tips but we don;t do your homework for you. > 1. Read an integer number from the console, store the result in a variable > n > 2. Read ‘n’ integers from the console and store

Re: [Tutor] using while loop for read process memory

2017-10-13 Thread Alan Gauld via Tutor
On 13/10/17 02:58, Michael C wrote: >         end = current_address + mbi.RegionSize - 7 > > then it doesn't complain anymore. I think it's because I ran this in a > while loop with start += 1 > so in the last 7 bytes, I'd be reading past the end of this memory chunk. > > Is this right? Yes, al

Re: [Tutor] problem with program

2017-10-13 Thread Alan Gauld via Tutor
On 13/10/17 13:04, Chris Coleman wrote: > def_init_(self,chat): > File "scripts/bird.py", line 4 > def_init_(self,chat): > ^ > SyntaxError: invalid syntax There are two problems here. The first is that you need a space after the def. The second is that ther

Re: [Tutor] problem with program

2017-10-13 Thread Alan Gauld via Tutor
On 13/10/17 18:53, Alan Gauld via Tutor wrote: > On 13/10/17 13:04, Chris Coleman wrote: > >> def_init_(self,chat): > >> File "scripts/bird.py", line 4 >> def_init_(self,chat): >> ^ >> SyntaxError: invalid syn

Re: [Tutor] How to test for the existence of a table in a sqlite3 db?

2017-10-14 Thread Alan Gauld via Tutor
On 14/10/17 06:43, boB Stepp wrote: > table if that table does not exist. Alan suggested using > executescript() to do this. I misunderstood Alan and thought that > this would take a filename and execute it. c.executescript(sqlFile.read()) -- Alan G Author of the Learn to Program web site

Re: [Tutor] Tree again: iterator, yield, increase (treelib)

2017-10-14 Thread Alan Gauld via Tutor
On 14/10/17 16:44, Chris wrote: > I've a question about treelib library from pip. The list focus is the language and standard library so if you want to ask about other code you need to give us more context. treelib is not a commonly discussed module, in fact this the first mention I've seen. > T

Re: [Tutor] Windows Memory Basics

2017-10-16 Thread Alan Gauld via Tutor
On 16/10/17 21:04, Michael C wrote: > I don't understand this part about the memory: And I'm not sure I understand your question but... > if I used VirtualQueryEx to find out if a region of memory is ok to scan, > and it > says it's ok, are the values in the region arranged like this: > > short

Re: [Tutor] Windows Memory Basics

2017-10-17 Thread Alan Gauld via Tutor
On 17/10/17 00:53, Michael C wrote: > ah, i am bummed completely haha. > > Is there a way to tell which parts a variables so I can scan it? > Maybe you could point me to some reading materials? There are some rules about where programs store data within their memory space, but typically that will

Re: [Tutor] Windows Memory Basics

2017-10-17 Thread Alan Gauld via Tutor
On 17/10/17 01:02, Michael C wrote: > that is, one number, can be truncated and exist in multiple locations like > this > > double = 12345678 > > 123 is at x001 > 45 is at x005 > 678 is at x010 That won't happen, a single variable will always be in a a single area. But the representation won't

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