Re: [Tutor] which of these is more efficient?

2019-08-19 Thread Alan Gauld via Tutor
On 19/08/2019 00:55, nathan tech wrote: > Is this an efficient method compared to 1? Efficient in what sense? The amount of code to write? The amount of computing resources used? The speed - and does that matter in an interactive game like this? -- Alan G Author of the Learn to Program web

Re: [Tutor] python question

2019-08-18 Thread Alan Gauld via Tutor
On 18/08/2019 05:35, Thejal Ramesh wrote: > Hi, i have a question regarding this question. I'm not quite sure what the > question is asking. > Part A: Popular (1.5 Marks) > Write a function popular(graph list, n) that returns a list of people who > have at least n friends. Each person is

Re: [Tutor] What is Tuple in the typing module?

2019-08-17 Thread Alan Gauld via Tutor
On 17/08/2019 00:46, C W wrote: The formatting seems messed up I'll try to straighten it out. I hope I get it right! Caveat: I'm no expert in the typing module, I've read the docs but never found any use for it. > What exactly is Tuple in the typing module? What does it do? It specifies a

Re: [Tutor] Search for Text in File

2019-08-15 Thread Alan Gauld via Tutor
On 15/08/2019 15:10, Stephen P. Molnar wrote: > I need to find a phrase in i text file in order to read a unique text > string into a python3 application. > > I have become stuck and Google has not been of any use. I'm sorry but there is so much wrong here it is difficult to know where to

Re: [Tutor] HELP PLEASE

2019-08-13 Thread Alan Gauld via Tutor
On 13/08/2019 12:09, Sithembewena L. Dube wrote: > Hi Marissa, > > I really think that you could consider doing an introductory Python > tutorial and then venture back into solving this problem. >>> This is the output of my updated code: >>> Traceback (most recent call last): >>> File

Re: [Tutor] Fwd: Re: HELP PLEASE

2019-08-12 Thread Alan Gauld via Tutor
On 12/08/2019 19:35, Alan Gauld via Tutor wrote: > To save some typing convert the?? int conversion loop into a function: > > > def?? to_ints(strings): > ?? num_copy = [] > ?? for num in nums: > num_copy.append(float(num)) > > ?? retur

[Tutor] Fwd: Re: HELP PLEASE

2019-08-12 Thread Alan Gauld via Tutor
Forwarding to tutorblist for info... Forwarded Message Subject:Re: [Tutor] HELP PLEASE Date: Mon, 12 Aug 2019 19:34:48 +0100 From: Alan Gauld Reply-To: alan.ga...@yahoo.co.uk To: Marissa Russo On 12/08/2019 19:17, Marissa Russo wrote: > I fixed some

Re: [Tutor] HELP PLEASE

2019-08-12 Thread Alan Gauld via Tutor
On 12/08/2019 17:54, Marissa Russo wrote: > def mean(nums): > for num in nums: > _sum += num > return _sum / len(nums) > > def mean2(nums2): > for num in nums2: > _sum += nums2 > return _sum / len(nums2) > > def main(): > data = get_numbers() > >

Re: [Tutor] Object creation query

2019-08-10 Thread Alan Gauld via Tutor
On 10/08/2019 09:48, mhysnm1...@gmail.com wrote: > HI all, > > I have multiple different accounts that I am creating reports for. Thus I > cannot have a centralised transaction table that contains all the records. > These different accounts are for different organisations or for other > members in

Re: [Tutor] Object creation query

2019-08-09 Thread Alan Gauld via Tutor
On 09/08/2019 09:54, mhysnm1...@gmail.com wrote: > updates and insertions. I have multiple tables with the same structure with > different names. Umm, why? Assuming by structure you mean they have the same fields then that's usually a bad design decision. Why not have one table with an attribute

Re: [Tutor] Name for this type of class?

2019-08-04 Thread Alan Gauld via Tutor
On 04/08/2019 09:15, Alan Gauld via Tutor wrote: >>> Classes should never be named for their data but for their function. > I was not suggesting that a class name should be a verb, I think my biggest mistake here was the use of the word "function" which, in a programming

Re: [Tutor] Name for this type of class?

2019-08-04 Thread Alan Gauld via Tutor
On 04/08/2019 04:44, David L Neil wrote: >> Classes should never be named for their data but for their function. >> What does this class do? What operations does it support. > > > This statement caused me to double-take. Do I misunderstand? I suspect so, thats why I wrote my follow up. I was

Re: [Tutor] Name for this type of class?

2019-08-03 Thread Alan Gauld via Tutor
On 03/08/2019 17:56, Malcolm Greene wrote: >... interesting thoughts including Alan's "classes should never be named > for their data but for their function" feedback. I'm going to have to > noodle on that one. Let me expand slightly. Go back to the fundamentals of OOP. OOP is about programs

Re: [Tutor] Name for this type of class?

2019-08-02 Thread Alan Gauld via Tutor
On 03/08/2019 00:47, Malcolm Greene wrote: > Anyways, I'm looking for help coming up for the proper name for a class that > collects the following type of telemetry data Classes should never be named for their data but for their function. What does this class do? What operations does it

Re: [Tutor] just a quick logic check if someone has two seconds

2019-08-01 Thread Alan Gauld via Tutor
On 01/08/2019 23:10, nathan tech wrote: > > import speedtest This is not a standard library module so I have no idea what it does so obviously there could be magic afoot of which I am unaware. But assuming it behaves like most Python code... > def do-test(): > test=speedtest.Speedtest() >

Re: [Tutor] Create Logging module

2019-08-01 Thread Alan Gauld via Tutor
On 01/08/2019 10:11, Sinardy Xing wrote: > start here--- > > import logging > > ..snip... > from functools import wraps > > def logme(func_to_log): > import logging You don't need the import, it's already done in the first line. > #Check log level within understanable

Re: [Tutor] Difference between decorator and inheritance

2019-08-01 Thread Alan Gauld via Tutor
On 31/07/2019 18:57, Gursimran Maken wrote: > Anyone could please let me know the difference between decorators and > inheritance in python. > > Both are required to add additional functionality to a method then why are > we having 2 separate things in python for doing same kind of work.

Re: [Tutor] Which is better in principle: to store (in file) calculated data or to re-calculate it upon restarting program?

2019-07-31 Thread Alan Gauld via Tutor
On 31/07/2019 03:02, boB Stepp wrote: > preceding scores plus the current one. If the data in the file > somehow got mangled, it would be an extraordinary coincidence for > every row to yield a correct total score if that total score was > recalculated from the corrupted data. True but the

Re: [Tutor] Which is better in principle: to store (in file) calculated data or to re-calculate it upon restarting program?

2019-07-30 Thread Alan Gauld via Tutor
On 30/07/2019 18:20, boB Stepp wrote: > What is the likelihood of file storage corruption? I have a vague > sense that in earlier days of computing this was more likely to > happen, but nowadays? Storing and recalculating does act as a good > data integrity check of the file data. No it

Re: [Tutor] Which is better in principle: to store (in file) calculated data or to re-calculate it upon restarting program?

2019-07-30 Thread Alan Gauld via Tutor
On 30/07/2019 17:21, boB Stepp wrote: > musings I am wondering about -- in general -- whether it is best to > store calculated data values in a file and reload these values, or > whether to recalculate such data upon each new run of a program. It depends on the use case. For example a long

Re: [Tutor] REQUIRED SUPPORT FOR CODE

2019-07-25 Thread Alan Gauld via Tutor
On 25/07/2019 16:58, NITESH KUMAR wrote: > I want to make Autocomplete searchbox using database .Please suggest me the > code for this. Since you tell us next to noting we can only make wild suggestions. Try to find a project that does the same thing - ideally one written in Python (assuming that

Re: [Tutor] Fw: CSC1010H 4th assignment

2019-07-25 Thread Alan Gauld via Tutor
On 25/07/2019 20:04, Mahima Daya wrote: > hi there, please could you assist. With what? Your subject tells us absolutely nothing. Your message gives us no clues. The fact that you are posting to the Python tutor list suggests you might have a question about Python programming. But what that is

Re: [Tutor] pass arg to list

2019-07-18 Thread Alan Gauld via Tutor
On 18/07/2019 19:34, Anirudh Tamsekar wrote: > # User Args > > version = sys.argv[1] > build = sys.argv[2] > > add_file = (... > ) > Traceback (most recent call last): > > File "/Users/atamsekar/Projects/PulseSO/trunk/swrelease/samplexls.py", > line 5, in > > version = sys.argv[1] >

Re: [Tutor] Calling a C shared library with PyObject

2019-07-17 Thread Alan Gauld via Tutor
On 17/07/2019 18:03, Jesse Ibarra wrote: > I am using Python3.6 > > Working with C/Python embedding: > https://docs.python.org/3.6/extending/embedding.html#beyond-very-high-level-embedding-an-overview > > I have to call a shared library (.so) that I created using PyObjects. To be honest

Re: [Tutor] Lengthy copyright notices?

2019-07-17 Thread Alan Gauld via Tutor
On 17/07/2019 21:01, David L Neil wrote: > One line offers plenty of space to exert a claim (such can be very > simple and does not need to be lawyer-speak!) which should also refer to > the template's/package's external file or web-page. Yes, I've seen that and if the lawyer speak is very

Re: [Tutor] Unit testing: Just the API or internal use only methods, too?

2019-07-16 Thread Alan Gauld via Tutor
On 16/07/2019 23:41, boB Stepp wrote: > essentially said that I should be testing the public interface to my > classes, but not the methods only used internally by the class and not > meant to be publicly accessible. I suspect he meant that you should publish the tests for the API but not

Re: [Tutor] raising exceptions in constructor code?

2019-07-16 Thread Alan Gauld via Tutor
On 16/07/2019 22:56, Mats Wichmann wrote: >> thrown. This gets watered down to the mantra "Don't throw exceptions from >> within constructors." Does this carry over to Python? > > If you mean __init__, that's not a constructor, so you should set your > mind at rest :) It's more properly

Re: [Tutor] Reading .csv data vs. reading an array

2019-07-16 Thread Alan Gauld via Tutor
On 16/07/2019 09:59, Oscar Benjamin wrote: >> All true, but sed - once you get used to it! - is easier IMHO >> and usually faster than Python - it's written in C... > > I always think I'll like sed but whenever I actually try to use it I > just can't get the syntax together. Id been using awk

Re: [Tutor] Lengthy copyright notices?

2019-07-15 Thread Alan Gauld via Tutor
On 15/07/2019 23:34, Mats Wichmann wrote: > Rule #1: it's all opinion in the end... ditto... > The common practice is that licence/copyright text is included as a > comment in the code, not in a docstring. I'd second that opinion. I don't like losing the copyright stuff to a separate file -

Re: [Tutor] Reading .csv data vs. reading an array

2019-07-15 Thread Alan Gauld via Tutor
On 15/07/2019 21:28, Mats Wichmann wrote: >> a float of s.  Of course I can't edit a 4G file in any editor that I >> have installed, so I have to work with the fact that there is a bit of >> text in there that isn't quoted. Try sed, it's on most Unix like OS. It doesn't read the entire file into

[Tutor] Fwd: RE: pointers or references to variables or sub-sets of variables query.

2019-07-15 Thread Alan Gauld via Tutor
to know. I have used just about every type of PC since the early 80's. Even used DEC VAX, IBM 3270's as well. Yes, been around for a while now. -Original Message- From: Tutor On Behalf Of Alan Gauld via Tutor Sent: Monday, 8 July 2019 8:55 AM To: tutor@python.org Subject: Re

Re: [Tutor] Web framework module for Python.

2019-07-15 Thread Alan Gauld via Tutor
On 15/07/2019 07:56, mhysnm1...@gmail.com wrote: > like apache. If there is a simple python module that can run a web server, > this would be great. If there is a python module that can assist in building > the HTMl, this would be great as well. I am not sure how to link python and > the web HTML

Re: [Tutor] How to store output of Python program in XML

2019-07-13 Thread Alan Gauld via Tutor
On 13/07/2019 07:40, Asad wrote: > want to print the output of the script in a xml file so that I can add some > tags . How can it be done ? XML is just text dso you can just use the normal Python string operations to format an XML string with your data. However there are XML libraries aplenty

Re: [Tutor] Output reason

2019-07-12 Thread Alan Gauld via Tutor
On 12/07/2019 15:24, Gursimran Maken wrote: > Can someone please explain me the reason for below output. You've been bitten by one of the most common gotchas in Python :-) > def fun(n,li = []): > a = list(range(5)) > li.append(a) > print(li) > > fun(4) > fun(5,[7,8,9]) >

Re: [Tutor] Multiprocessing with many input input parameters

2019-07-12 Thread Alan Gauld via Tutor
On 12/07/2019 01:51, DL Neil wrote: > older articles! We haven't discussed hardware. Most modern PC CPUs offer > multiple "cores". Assuming (say) four cores, asyncio is capable of > running up to four processes concurrently - realising attendant > acceleration of the entirety. Just to pick up

Re: [Tutor] RE Embedding Python in C

2019-07-09 Thread Alan Gauld via Tutor
On 09/07/2019 15:13, Ibarra, Jesse wrote: Caveat: I'm no expert on embedding and indeed have only done it once using the examples in the docs. However, based on my general Python experience... > I then embedded the example using C/Python API: >

Re: [Tutor] Fw: [docs] Python Embedding PyImport_ImportModule

2019-07-08 Thread Alan Gauld via Tutor
On 08/07/2019 15:14, Ibarra, Jesse wrote: > I cannot seem to figure this potential bug out. Neither can we since we cannot see any code. You need to give us some context. What are you trying to do? What libraries are you using? Which OS and Python versions? Did you get ay errors? If so post

Re: [Tutor] pointers or references to variables or sub-sets of variables query.

2019-07-07 Thread Alan Gauld via Tutor
On 07/07/2019 20:54, David L Neil wrote: > (However, some of us grew-up at a time when RAM was expensive and even > in our relaxed state, such 'costs' still impinge on our consciousness - Indeed, my first computer was at the local university and had 64KB. My second computer was a Sinclair

Re: [Tutor] pointers or references to variables or sub-sets of variables query.

2019-07-07 Thread Alan Gauld via Tutor
On 07/07/2019 09:19, David L Neil wrote: > First-off, it has to be said that "100's of elements" suggests using an > RDBMS - particularly if 'age' (eg 23 and 99) is not the only likely > selection mechanism. Multiple selection mechanisms might suggest an RDBMS but hundreds of items is

Re: [Tutor] Neutral Networks

2019-07-07 Thread Alan Gauld via Tutor
On 07/07/2019 03:49, Rashmi Vimalendran wrote: > I have a python program for the project which is about developing an AI > program to identify persons. The program I have identities the first > person. It is not able to identify the 2nd person. When we run it, it is > not even showing an error. I

Re: [Tutor] pointers or references to variables or sub-sets of variables query.

2019-07-07 Thread Alan Gauld via Tutor
On 07/07/2019 03:39, mhysnm1...@gmail.com wrote: > In C, you can use pointers to reference variables, arrays, ETC. In python, I > do not recall anything specifically that refers to such a capability. In Python a variable is a name that refers to an object. Many names can refer to the same

Re: [Tutor] enumerate over Dictionaries

2019-07-06 Thread Alan Gauld via Tutor
On 06/07/2019 05:28, Suhit Kumar wrote: > I have made the complete program but when I am compiling the program it is > showing errors. Can you please help to resolve this? > The code is in the file attached with this mail. And where are the errors? Do not expect us to run unknown code received

Re: [Tutor] Regarding help in python algorithm

2019-07-05 Thread Alan Gauld via Tutor
On 05/07/2019 07:25, Suhit Kumar wrote: > I am a student at an university. Currently I was working on an algorithm > using python. It is based on scheduling the teachers to their nearest > venues. And at the venues there can be atmost 400 teachers and these are to > be divided into the Batches of

Re: [Tutor] enumerate over Dictionaries

2019-07-04 Thread Alan Gauld via Tutor
On 04/07/2019 18:02, Animesh Bhadra wrote: > Hi All, > My python version is 3.6.7 > I need help to understand this piece of code? > > rainbow ={"Green": "G", "Red": "R", "Blue": "B"} > # ennumerate with index, and key value > for i, (key, value) in enumerate(rainbow.items()): Lets unpick t from

Re: [Tutor] double nodes being enter into tree structure

2019-06-28 Thread Alan Gauld via Tutor
On 28/06/2019 07:10, mhysnm1...@gmail.com wrote: > > Anyway, my issue is I am getting the same node being added to the parent node > of my tree below. I'm not sure about that part but > def addNode(words, tree): > if words: > wordExists = False > for child in

Re: [Tutor] Environment variables and Flask

2019-06-28 Thread Alan Gauld via Tutor
On 28/06/2019 06:24, Mayo Adams wrote: > What are these environment variables, exactly, and why is it necessary to > set them? When you run a program under an operating system the OS sets up an "environment" (or context) for the program to run in. (This includes the OS shell that the user

Re: [Tutor] Python and DB

2019-06-27 Thread Alan Gauld via Tutor
On 27/06/2019 22:20, Brave Heart via Tutor wrote: > I would like python to write to DB so I can from DB write on a webpage with > PHP... Yes, that's easy enough. Python supports access to many databases, do you have one in mind? If not the SQLite module that comes in the standard library is

Re: [Tutor] Range command

2019-06-26 Thread Alan Gauld via Tutor
On 27/06/2019 00:07, Brick Howse via Tutor wrote: > Hello all, > > New to programming and I noticed the range command did not function like it > does in the tutorial. > For example, > I type > range(5, 10) > And the output is > range(5, 10) You have a Python 2 tutorial but are using

Re: [Tutor] data structures general query

2019-06-26 Thread Alan Gauld via Tutor
On 26/06/2019 19:46, Mats Wichmann wrote: > I forgot to add the snide-comment part of "what are these good for": > > (a) binary search trees are excellent for Computer Science professors > who want to introduce recursion into their classes. > > (b) all the classic data structures are candidates

Re: [Tutor] data structures general query

2019-06-26 Thread Alan Gauld via Tutor
On 26/06/2019 11:40, mhysnm1...@gmail.com wrote: > When would you use the below structures and why? If you can provide a real > life example on when they would be used in a program This would be great. > Link lists Link lists are very flexible and ideal for when you have a varying amount of

Re: [Tutor] tree or link-list questions.

2019-06-26 Thread Alan Gauld via Tutor
On 26/06/2019 11:34, mhysnm1...@gmail.com wrote: > The reason why I am using the tree structure like a file system. Is I am > going to attempt to write some code to walk down the tree based upon certain > conditions which I am still working on. Based upon the test conditions will > determine how

Re: [Tutor] Training, Was: Basic Question about Visualization for enduser

2019-06-25 Thread Alan Gauld via Tutor
Caveat: This is a long term bug bear of mine and I spent many, many hours over the last 20 years in discussion with our local universities discussing how software-engineering training could be made more relevant to the real world. I'll try to keep it focused :-) On 25/06/2019 21:00, David L Neil

Re: [Tutor] Python Imported Code

2019-06-25 Thread Alan Gauld via Tutor
On 25/06/2019 14:50, stephen.m.sm...@comcast.net wrote: > using global, but that fails. I also can't seem to use arguments because the > module that tkinter fires up with this command: > > self.process_button = tk.Button(master, text='Process Request', \ >

Re: [Tutor] Basic Question about Visualization for enduser

2019-06-25 Thread Alan Gauld via Tutor
On 25/06/2019 15:52, Sinardy Xing wrote: > My question is, how currently all of this great technology glue together > and as a final product for the enduser. Because I cant imagine that we > install Anaconda Jupyter Notebook at frontend for the enduser to use it, > and give end user bunch of *.py

Re: [Tutor] tree or link-list questions.

2019-06-25 Thread Alan Gauld via Tutor
On 25/06/2019 13:24, mhysnm1...@gmail.com wrote: ... the tree I am trying to create is: > > * A single root node > * A node can only have a single parent. > * A parent can have multiple children. > * Each node is unique. A tree with multiple children (where multiple is more than

Re: [Tutor] tree or link-list questions.

2019-06-25 Thread Alan Gauld via Tutor
On 25/06/2019 13:24, mhysnm1...@gmail.com wrote: A much less open ended question :-) > class Node: > > def __init__(self, name, value): > self.parent = None > self.child = [] This should be plural if its a list. So call it children... However I'm not really sure it should

Re: [Tutor] Basic Question about Visualization for enduser

2019-06-25 Thread Alan Gauld via Tutor
On 25/06/2019 13:39, Sinardy Xing wrote: > All of the example that I learned from internet currently are using the > Anaconda Jupyter Notebook. > I know there are API where we can output the result of the graph to png, > will that be possible all these done automatically and dynamically via an >

Re: [Tutor] replacing a loop

2019-06-25 Thread Alan Gauld via Tutor
On 24/06/2019 17:15, johnf wrote: > def locChoices(self): >     locDS = self.eslocation.getDataSet() >     loc_Choices=[''] >     locKeys=[0] >     for row in locDS: >     loc_Choices.append(row['facility']) >     locKeys.append(row['pkid']) > >

Re: [Tutor] collections and mappings

2019-06-21 Thread Alan Gauld via Tutor
On 21/06/2019 11:39, mhysnm1...@gmail.com wrote: > I think I understand, but that type of maths I have not touched in 40 years. The real point is that in Python terms a mapping is nearly always just another name for a dictionary. Either a set of key/value pairs or a set of key/function pairs.

Re: [Tutor] Fwd: Re: Hii

2019-06-21 Thread Alan Gauld via Tutor
On 21/06/2019 14:59, Antonio Arizpe wrote: > i just need help with a script thats registers keystrikes and adds up all > the times you've struck a key and gives a number of the total amount of > times the keyboard was struck. nothing specific about characters. just how > many times it was struck

Re: [Tutor] collections and mappings

2019-06-21 Thread Alan Gauld via Tutor
On 21/06/2019 01:01, mhysnm1...@gmail.com wrote: > I have reviewed the collection module and do not understand mappings. I have > seen this in other languages and have never got the concept. Can someone > explain this at a very high level. OK. You are a master of the open ended question so I'm

[Tutor] Fwd: Re: Hii

2019-06-20 Thread Alan Gauld via Tutor
x=1 while x<1080: pyautogui.screenshot('/Program Files/Python37/tll/'+str(today)+'/image'+str(x)+'.png') x+=1 time.sleep(30) On Thu, Jun 20, 2019 at 3:30 AM Alan Gauld via Tutor mailto:tutor@python.org>> wrote: On 19/06/2019 23:30, Anton

Re: [Tutor] word printing issue

2019-06-20 Thread Alan Gauld via Tutor
On 20/06/2019 11:44, mhysnm1...@gmail.com wrote: > I have a list of strings that I want to break them into separate words, and > a combination of words then store them into a list. Example below of a > string: > "Hello Python team". > The data structure: > [ ['Hello'], > ['Hello', 'Python'], >

Re: [Tutor] Hii

2019-06-20 Thread Alan Gauld via Tutor
On 19/06/2019 23:30, Antonio Arizpe wrote: > i just need help with a script thats registers keystrikes and adds up all > the times youve struck a key and gives a number of the total amount of > times the keyboard was struck. nothing specific about characters. just how > many times it was struck

Re: [Tutor] Unexpected result when running flask application.

2019-06-19 Thread Alan Gauld via Tutor
On 19/06/2019 05:18, Cravan wrote: > Hi all, > > I am experiencing an unexpected result when I try to run my > flask application. > The movie.html page prints out nothing except those in the . This appears > on my webpage: Note that the mail server does not allow (for security

Re: [Tutor] Installing Python on Server

2019-06-18 Thread Alan Gauld via Tutor
On 18/06/2019 14:28, Ben Wadsworth wrote: > Hi, > When installing Python on a windows server, will the server require a > restart? I've never tried so can't be sure. But it shouldn't. Python doesn't require any special access. But then again, it is Windows, so you can never tell. -- Alan G

Re: [Tutor] How to Scrape Text from PDFs

2019-06-17 Thread Alan Gauld via Tutor
On 17/06/2019 06:30, Cem Vardar wrote: > some PDF files that have links for some websites and I need to extract these > links There is a module that may help: PyPDF2 Here is a post showing how to extract the text from a PDF which should include the links.

Re: [Tutor] Installing Python v3 on a laptop Windows 10

2019-06-15 Thread Alan Gauld via Tutor
On 15/06/2019 22:23, Ken Green wrote: > I understood there is a preferable method > of installing Python into Windows. I pray > tell on how about to do it, gentlemen. It depends a bit on which python distribution you use, there are several. Personally for Windows I always recommend the

Re: [Tutor] deleting elements out of a list.

2019-06-15 Thread Alan Gauld via Tutor
On 15/06/2019 05:51, mhysnm1...@gmail.com wrote: Caveat: I'm picking this up late in the day and only had a cursory look at it, so may be missing some critical insight... > I have a list of x number of elements. Some of the elements are have similar > words in them. For example: Define

Re: [Tutor] Differences between while and for

2019-06-15 Thread Alan Gauld via Tutor
On 15/06/2019 05:53, mhysnm1...@gmail.com wrote: > In C, Perl and other languages. As a point of interest not all languages have these constructs. Oberon, for example, only has a while loop because it can be used to simulate all other loop types. Some Lisp dialects don't even have a loop

Re: [Tutor] os.is_file and os.is_dir missing from CPython 3.8.0b?

2019-06-14 Thread Alan Gauld via Tutor
On 14/06/2019 15:53, Tom Hale wrote: > I'm trying to use os.is_dir, but I'm not finding it or os.is_file. I've never heard of these functions, but I'm still on v3.6, never having found a reason to upgrade. So I assume... > Python 3.8.0b1 (tags/v3.8.0b1:3b5deb01, Jun 13 2019, 22:28:20) ...these

Re: [Tutor] Download audios & videos using web scraping from news website or facebook

2019-06-14 Thread Alan Gauld via Tutor
On 14/06/2019 07:35, Sijin John wrote: > I am trying to Download audios & videos using web scraping from news website > (eg: https://www.bbc.com/news/video_and_audio/headlines) or Facebook & I > could't. > So in real scenario is it really possible to download audios/videos using > python code

Re: [Tutor] Installing Python

2019-06-10 Thread Alan Gauld via Tutor
On 10/06/2019 22:20, Avi Chein wrote: > I'm trying to install Python 3.6 on my MacOS Mojave but it isn't installing > properly. When asking for help, on any forum, it's never a good idea to say that something "doesn't work" or "isn't installing properly". That gives us nothing to work on. What

Re: [Tutor] Python printing parentheses and quotes

2019-06-10 Thread Alan Gauld via Tutor
On 10/06/2019 17:50, Sai Allu wrote: > Basically what happened was that I had a few lines in the script like this > ip = "10.41.17.237" > print(" Welcome to Squid Monitoring for ", ip) > print("") > > and the output was like this > > (" Welcome to Squid Monitoring for

Re: [Tutor] Pickles and Shelves Concept

2019-06-08 Thread Alan Gauld via Tutor
On 08/06/2019 01:02, Alan Gauld via Tutor wrote: > keys to your data and then restore it in any sequence, or > only restore some of it, you can. Apologies for the Yoda-speak at the end! A bit of editing that didn't quite work out as intended... -- Alan G Author of the Learn to Program we

Re: [Tutor] Pickles and Shelves Concept

2019-06-07 Thread Alan Gauld via Tutor
On 07/06/2019 18:42, Gursimran Maken wrote: > I am not getting the concept of pickle and shelves in python, I mean what's > the use of both the concepts, when to use them in code instead of using > file read and write operations. You are right in that you could save all your data to a file using

Re: [Tutor] Fwd: Re: would someone please explain this concept to me

2019-06-06 Thread Alan Gauld via Tutor
On 06/06/2019 00:57, Alan Gauld via Tutor wrote: > But in the second example you actially change the object > that checklimit refers to. > > checklimit = 22 # immutable value assigned > feeds['bar'] = checklimit # both refer to same immutable value > base_var = 66

Re: [Tutor] Fwd: Re: would someone please explain this concept to me

2019-06-05 Thread Alan Gauld via Tutor
On 05/06/2019 20:47, nathan tech wrote: > so for example if I do: > > feeds[feed1]["limit"]=g.checklimit > > And later did g.checklimit=7000 > > Would it change feeds[feed1]["limit"] too? No, because the feeds value is still referencing the original value object. The issue arises when you

Re: [Tutor] Fwd: Re: would someone please explain this concept to me

2019-06-05 Thread Alan Gauld via Tutor
> That is why I was going to use g.blank-feed as the template, > assign that to d["feed 1's link"] then just update the feed part. The simplest way is just to assign a new blank dictionary. Don;t assign the same dictionary to each feed. (Incidentally your description above is much clearer than

Re: [Tutor] would someone please explain this concept to me

2019-06-04 Thread Alan Gauld via Tutor
On 05/06/2019 00:37, nathan tech wrote: > Hi there, > > So I have just fixed a huge bug in my program, but don't understand > exactly... How it bugged. Neither do I, your explanation raises more questions than answers. > globals.py: > feeds={} > blank_feed={} > blank_feed["checked"]=1 >

Re: [Tutor] Interactive editing of variables.

2019-06-02 Thread Alan Gauld via Tutor
On 02/06/2019 01:10, mhysnm1...@gmail.com wrote: > What I do not know, how this applies to open source. If there is no > commercial transaction. Then this is the area I am unsure if any of the laws > I am indirectly referring to impact. Caveat: I am not a lawyer... I know it has a big impact

Re: [Tutor] Interactive editing of variables.

2019-06-01 Thread Alan Gauld via Tutor
On 01/06/2019 09:52, mhysnm1...@gmail.com wrote: > the underlying graphic library. Win32 could work if I could load it. Since > then I could use standard windows objects. If you are running windows then you can access the Win32 DLLs via ctypes. The win32 package should also be easily

Re: [Tutor] Interactive editing of variables.

2019-06-01 Thread Alan Gauld via Tutor
On 01/06/2019 08:55, mhysnm1...@gmail.com wrote: > As I am using Python 3.7 under windows. I have tried to use the win32gui, > and Tkinter. Both generate the below errors and I cannot identify a module > release to support the version of Python I am using. Tkinter should be included in the

Re: [Tutor] is this doable

2019-06-01 Thread Alan Gauld via Tutor
On 01/06/2019 00:13, Alan Gauld via Tutor wrote: > Is the language C/C++? If so you may know the OS API calls needed > and you could access those directly from Python using ctypes > That might make your job more familiar and easier. I meant to add a nod to Mark Hammond's win32 pa

Re: [Tutor] Interactive editing of variables.

2019-06-01 Thread Alan Gauld via Tutor
On 01/06/2019 03:53, mhysnm1...@gmail.com wrote: > I have no clue on how to achieve what I want to do and the code I have > creates an hash. As shown below: Thats because what you want is not a standard feature of CLI apps. You will need to do one of the following(in order of easiness): 1) Use a

Re: [Tutor] is this doable

2019-05-31 Thread Alan Gauld via Tutor
On 31/05/2019 20:41, nathan tech wrote: > Is it possible, in python, to store a running task id in the registry? >From mention of the registry I assume you are running Windows? There is no registry on Unixlike systems. The answer in either case is yes since a task ID is just a number. However

Re: [Tutor] File extension against File content

2019-05-31 Thread Alan Gauld via Tutor
On 31/05/2019 11:03, Sunil Tech wrote: > Hi Tutor, > > Is there any way that I can actually programmatically compare the file > extension with its content? For images the standard library offers imghdr I'm not sure how reliable or accurate it is but it claims to identify a dozen or so of the

Re: [Tutor] Query about python recipies for practices

2019-05-27 Thread Alan Gauld via Tutor
On 27/05/2019 23:44, Mats Wichmann wrote: > and, if you meant problems for practicing... there are a lot of those > around. Most courses have problems for you to solve, naturally, and a > brief hunt around turned up some sites like these that are not courseware: And don't forget the wonderful

[Tutor] Fwd: Re: Setting Command Line Arguments in IDLE

2019-05-26 Thread Alan Gauld via Tutor
Oops, Forgot to include the list! Forwarded Message Subject:Re: Setting Command Line Arguments in IDLE Date: Sun, 26 May 2019 09:03:36 +0100 From: Alan Gauld To: Richard Damon On 26/05/2019 02:55, Richard Damon wrote: > I am working on a python script

[Tutor] Fwd: RE: regular expressions query

2019-05-24 Thread Alan Gauld via Tutor
different places and still don't understand why, how and when you would use them. Something else I have been wondering. Goal here is to grow my knowledge in programming. # end if # end for print (count) # end for input () # end for -Original Message- From: Tutor On Behalf Of Alan Gaul

Re: [Tutor] I'm having a small problem with my code

2019-05-24 Thread Alan Gauld via Tutor
manually. > > On Fri, May 24, 2019 at 3:00 AM Alan Gauld via Tutor <mailto:tutor@python.org>> wrote: > > On 23/05/2019 13:16, David Lifschitz wrote: > > > The next job of the code is to sort the list of numbers that > were inputted > > in an asce

Re: [Tutor] regular expressions query

2019-05-24 Thread Alan Gauld via Tutor
On 24/05/2019 01:15, mhysnm1...@gmail.com wrote: > Below I am just providing the example of what I want to achieve, not the > original strings that I will be using the regular expression against. While I'm sure you understand what you want I'm not sure I do. Can you be more precise? > The

Re: [Tutor] I'm having a small problem with my code

2019-05-23 Thread Alan Gauld via Tutor
On 23/05/2019 13:16, David Lifschitz wrote: > The next job of the code is to sort the list of numbers that were inputted > in an ascending fashion. You are aware that Python lists have a built in sort method? It will be more efficient than anything you can create yourself in Python. Assuming you

Re: [Tutor] Learning something new.

2019-05-23 Thread Alan Gauld via Tutor
On 23/05/2019 08:38, Jessica Rabbit wrote: > Hello, my name is Jessica and I hope I found the right e mail to help me > learn of to write in code and eventually learn to hack. Hi Jessica and welcome to the tutor list. > know how to do something that my father can. If this email is read by >

Re: [Tutor] A Python Newbie Requesting help with Lambdas, Filters, Maps, and Built-in Functions to solve problems for a List of Songs

2019-05-21 Thread Alan Gauld via Tutor
On 21/05/2019 14:30, Rahul Alawani wrote: > # 4. The longest song title in the entire songs list > def longest_title (songmix): > temp = max(songmix, key=lambda num: len(max(num['titles']))) > return list(map(lambda x: max(songmix, key=lambda num: > len(max(num['titles'])))['artist'], >

Re: [Tutor] Case Insensitive Globing

2019-05-20 Thread Alan Gauld via Tutor
On 20/05/2019 09:49, Alan Gauld via Tutor wrote: > On 19/05/2019 19:19, Alan Gauld via Tutor wrote: > ... >> So I always end up with two copies - the original file and the >> edited version. > I forgot I had moved all my photos onto my NAS box > and then mounted that in m

Re: [Tutor] Case Insensitive Globing

2019-05-20 Thread Alan Gauld via Tutor
On 19/05/2019 19:19, Alan Gauld via Tutor wrote: > Hmm, odd. My NTFS filesystems on Windows all appear to be case > sensitive. For example I have a photo editor that saves its files > with a jpg extension but the files from my camera all end in JPG. > So I always end up wit

Re: [Tutor] Case Insensitive Globing

2019-05-19 Thread Alan Gauld via Tutor
On 19/05/2019 01:37, Steven D'Aprano wrote: > That's not quite right -- case sensitivity of the OS isn't important, > case sensitivity of the *file system* is. And the standard file system > on Mac OS, HFS+, defaults to case-preserving but case-insensitive. > > (There is an option to turn

Re: [Tutor] Two Scripts, Same Commands, One Works, One Doesn't

2019-05-19 Thread Alan Gauld via Tutor
On 19/05/2019 04:58, DL Neil wrote: > last time I used the term "bomb", I'm guessing that "abend" wouldn't > pass muster either... Gosh, I haven't seen a reference to abend in 20 years. I'd almost managed to erase the memory... :-) -- Alan G Author of the Learn to Program web site

Re: [Tutor] How arguments to the super() function works?

2019-05-18 Thread Alan Gauld via Tutor
On 18/05/2019 17:21, Arup Rakshit wrote: > class Role(db.Model): > > def __init__(self, **kwargs): > super(Role, self).__init__(**kwargs) > > Here, why super(Role, self).__init__(**kwargs) is used instead > of super().__init__(**kwargs) ? I suspect you are reading an older

  1   2   3   4   5   6   7   8   9   10   >