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 *

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

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

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

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

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

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

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

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

2017-08-06 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 >>

Re: [Tutor] unorderable types

2017-08-06 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.

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

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)

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] The results of your email commands

2017-08-02 Thread Alan Gauld
I'[ve CCd the list, please use ReplyAll when responding to the list. On 02/08/17 22:13, Borisco Bizaro wrote: > Hi,am try to write a code that take input from user continuently > until key press it stop and give total amount user enter. > while True: > input ("enter another

[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

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

Re: [Tutor] if __name__=='main' vs entry points: What to teach new comers?

2017-08-02 Thread Alan Gauld via Tutor
On 02/08/17 04:35, Abdur-Rahmaan Janhangeer wrote: > what difference do you make between python scripts and python code files? > Not much. Scripts are a concept more than a defined term, they often refer to executable programs written in a "scripting language" - which is usually an interpreted

Re: [Tutor] if __name__=='main' vs entry points: What to teach new comers?

2017-08-01 Thread Alan Gauld via Tutor
On 01/08/17 15:54, Thomas Güttler wrote: > He asked me if "if __name__=='main':" is state of the art if you want > to translate a shell script to python. It all depends what you plan to do with the script. If you literally just want to translate a shell script such that it will always be

Re: [Tutor] Error with sqlalchemy

2017-08-01 Thread Alan Gauld via Tutor
On 01/08/17 12:13, rakesh sharma wrote: > I am getting the error > > TypeError: utf_8_decode() argument 1 must be string or buffer, not long That's not too helpful out of context, can you show us more of the error trace? Can you show us the method that generates it? Do you have any indication

Re: [Tutor] How sum() works in python

2017-08-01 Thread Alan Gauld via Tutor
On 01/08/17 07:06, ramakrishna reddy wrote: >> sum([1,2,3]) returns 6. > > But sum with [] 'empty list' as second parameter returns as below. > >> sum([[1,2,3], [3,4,5]], []) returns [1, 2, 3, 3, 4, 5] An interesting question, I wasn't aware that you could add lists with sum. However, the

Re: [Tutor] Recommended Python Compiler

2017-07-31 Thread Alan Gauld via Tutor
On 31/07/17 13:45, Wolfgang Maier wrote: > here. There may be more powerful IDEs than IDLE, but it takes you a long > way (far beyond beginner/scripting level) And IdleX is a vastly superior, drop-in replacement, superset of IDLE. The extra features, for those interested, are described here:

Re: [Tutor] Recommended Python Compiler

2017-07-30 Thread Alan Gauld via Tutor
On 30/07/17 23:22, George Sconyers via Tutor wrote: > ...looking for a recommended compiler for an Ubuntu environment. In programming precision is everything. You are not in fact looking for a compiler, you are looking for a development environment or IDE. A compiler takes source code and

[Tutor] While loop homework: was Re: Tutor Digest, Vol 161, Issue 33

2017-07-30 Thread Alan Gauld via Tutor
On 30/07/17 23:36, Borisco Bizaro wrote: > a=1 > b=2 > while a input ("enter another price :") Do 'a' or 'b' ever change? Does 'a print"\n\n press 0 key to stop" Does the user

Re: [Tutor] Tutor Digest, Vol 161, Issue 41

2017-07-30 Thread Alan Gauld via Tutor
On 30/07/17 19:50, Borisco Bizaro wrote: > Please I have been ask to write python code that ask user to enter a price > continuetly until key press to and give the total amount of price I have > enter using while loop I don't know how to go about it First of all, please do not send the whole

Re: [Tutor] What's the difference between sort(aList) and aList.sorted()

2017-07-27 Thread Alan Gauld via Tutor
On 27/07/17 03:22, C W wrote: > Thank you very much, Steve! > > I think I got it. To get help() on a method, you have to somehow invoke an > object first. Or just use the class. In Steven's examples he included list.sort. 'list' is the class name for a list. -- Alan G Author of the Learn to

Re: [Tutor] basic decorator question

2017-07-27 Thread Alan Gauld via Tutor
On 27/07/17 03:22, boB Stepp wrote: > use them. The idea of replacing a function with its decorated version > sounds cool, but what types of problems would I want to use this > approach on? I'm sure others will have their own take on this but personally I view them as primarily for building

Re: [Tutor] What's the difference between sort(aList) and aList.sorted()

2017-07-26 Thread Alan Gauld via Tutor
On 26/07/17 19:40, C W wrote: > My understanding of each is: > 1) function(variable) is manipulating a vector, I can do bList = > sorted(aList) > 2) object.method() is permanently changing it, I don't even need to assign > it in #1. > > Why is there both? They do the same thing. As you have

Re: [Tutor] new to python

2017-07-25 Thread Alan Gauld via Tutor
On 25/07/17 04:58, N6Ghost wrote: > this code works > f = open("C:/coderoot/python3/level1/inputfile.txt", 'r') > for line in f: > for line in f: > #print(line.rstrip()) > print(line) > > f.close() > the out put skips the first line of the inputfile and puts a blank line

[Tutor] Study Python was: Re: Tutor Digest, Vol 161, Issue 36

2017-07-25 Thread Alan Gauld via Tutor
On 24/07/17 18:41, Borisco Bizaro wrote: > Please what is the best way to study python programming well. One important skill is to read and follow instructions. For example... > On Jul 24, 2017 17:00, wrote: > >> Send Tutor mailing list submissions to >>

[Tutor] Fwd: Re: basic decorator question

2017-07-24 Thread Alan Gauld
Bah, Forgot to ReplyAll... Forwarded Message On 24/07/17 15:33, bruce wrote: > But, I'm sooo confuzed! My real question though, can a decorator have > multiple internal functions? Yes and classes too if you want. A decorator is just a standard function in all respects. The

Re: [Tutor] Python3 Help

2017-07-24 Thread Alan Gauld via Tutor
On 24/07/17 01:58, Alan Gauld via Tutor wrote: > $ which python3 > >> -bash: $: command not found > > The $ is the OS prompt you are not supposed to type it in. While on the subject you might also see something like # Which can mean one of two things 1) It's a comm

Re: [Tutor] Python3 Help

2017-07-23 Thread Alan Gauld via Tutor
On 24/07/17 00:19, Brandon Anderson wrote: > 2. I’m trying to locate the directory path to where Python3 is located on my > system, but when I enter > the following command: > $ type -a python3 You could also try $ which python3 > -bash: $: command not found The $ is

[Tutor] Fwd: Re: Python Help

2017-07-23 Thread Alan Gauld via Tutor
be the right command for the shell. Winonah On Sat, Jul 22, 2017 at 9:34 PM, Cameron Simpson <c...@zip.com.au <mailto:c...@zip.com.au>> wrote: On 23Jul2017 00:20, Alan Gauld <alan.ga...@yahoo.co.uk <mailto:alan.ga...@yahoo.co.uk>> wrote: On 22/07/17 19:

[Tutor] Fwd: Re: Python Help

2017-07-23 Thread Alan Gauld via Tutor
.com.au <mailto:c...@zip.com.au>> wrote: On 23Jul2017 00:20, Alan Gauld <alan.ga...@yahoo.co.uk <mailto:alan.ga...@yahoo.co.uk>> wrote: On 22/07/17 19:14, Winonah Ojanen wrote: using python with anaconda in jupiter notebook.

Re: [Tutor] new to python

2017-07-23 Thread Alan Gauld via Tutor
On 23/07/17 07:26, N6Ghost wrote: > > f = open("C:\coderoot\python3\level1\inputfile.txt", 'r') > for line in file: Note that you have no variable called 'file'. So this line doesn't make sense. > for line in f: > print(line.rstripe()) This bit will work if you omit the line

Re: [Tutor] Python Help

2017-07-22 Thread Alan Gauld via Tutor
On 22/07/17 19:14, Winonah Ojanen wrote: > using python with anaconda in jupiter notebook. However, I am having Usual caveat: The tutor list is targeted at the standard library so any help for non standard library modules is best sought from the library support fora. In this case that includes

Re: [Tutor] Quick Pythonic Style Tips

2017-07-22 Thread Alan Gauld via Tutor
On 22/07/17 12:20, Abdur-Rahmaan Janhangeer wrote: > As a user switching between some languages, it took sometimes before i > discovered that there was a styling guide in python There are style idioms in most languages although not always written down as clearly as in PEP8. That having been said

Re: [Tutor] PYTZ Package not working.

2017-07-20 Thread Alan Gauld via Tutor
On 20/07/17 18:41, Daniel Bosah wrote: > I'm trying to get my function to work: Did you read any of the replies to your previous message? You do not appear to have applied any of the suggestions. > def deposit(self,amount): > if amount > 0: > self.balance += amount >

Re: [Tutor] Problems with pytz module

2017-07-19 Thread Alan Gauld via Tutor
On 19/07/17 20:58, Daniel Bosah wrote: > class Account: > def deposit(self,amount): > if amount > 0: > self.balance += amount > self.show_balance() > > self.transaction_list.append( > def withdrawl(self,amount): > if 0 < amount <=

Re: [Tutor] unitest with random inputs

2017-07-19 Thread Alan Gauld via Tutor
On 19/07/17 16:01, Sydney Shall wrote: > I am learning to use unittest. > > def test_zero_in_capitalsadvanced(self): > self.assertIn(self.capitalsadvanced, 0.0) Remember the interpreter... >>> help(unittest.case.assertIn) Help on function assertIn in module unittest.case:

Re: [Tutor] if/else statement

2017-07-18 Thread Alan Gauld via Tutor
On 18/07/17 18:31, Shane Johnson (shanejoh) wrote: > def greater_less_equal_5(answer): >if answer is '>' 5 >return 1 >elif answer is < 5: >return 0 >else: >return 4 > I’m getting a invalid syntax line 2 error. Any assistance is greatly >

Re: [Tutor] Python Questions

2017-07-18 Thread Alan Gauld via Tutor
On 18/07/17 11:41, Max Smith wrote: > What's the easiest way to learn python currently Write a lot of code. As to which tutorial to follow, that's a very personal choice and depends on your previous knowledge and learning style. If you can already program in a similar language(say Perl, PHP or

Re: [Tutor] Image i/o in python

2017-07-16 Thread Alan Gauld via Tutor
On 16/07/17 17:13, D.V.N.Sarma డి.వి.ఎన్.శర్మ wrote: > In python we have a set of imread and imshow in skimage. In matplotlib.image > we again have imreadand imshow functions. In scipy.misc we again have > another set imread and imshow. Are there anyfunctional differences between > these multiple

Re: [Tutor] Python __del__ method

2017-07-11 Thread Alan Gauld via Tutor
On 11/07/17 15:47, Jia Yue Kee wrote: > I am new to Python and I came across the Python __del__ method The __del__() method is a bit of an oddity and often not used in industrial strength Python code. > if __name__ == "__main__": > x = Robot("Tik-Tok") > y = Robot("Jenkins") > z = x

Re: [Tutor] Fwd: Re: call key on_press event multiple times when key is held down

2017-07-10 Thread Alan Gauld via Tutor
On 04/07/17 13:45, Carlton Banks wrote: > Any suggestion on any GUI solutions? Here is a Tkinter solution that increments a counter while the mouse button is pressed. It should give you the idea... Obviously you need to replace the counter increment with your desired processing. And the print

Re: [Tutor] @property vs @classmethod

2017-07-09 Thread Alan Gauld via Tutor
On 09/07/17 02:56, Mats Wichmann wrote: > From OO people, though, we get the sputtering But... But... what about > encapsulation, data hiding, etc? Encapsulation isn't really an issue here since Pythons classes fully encapsulate their data and methods. They just make them both public. Data

Re: [Tutor] @property vs @classmethod

2017-07-08 Thread Alan Gauld via Tutor
On 09/07/17 00:03, Evuraan wrote: > I was hoping to learn when to use classmethod and when to use property. > They both seem similar (to me at least..), what's the pythonic way to > choose between them? In fact they do completely different things. A property is a field of an object that you

Re: [Tutor] principal question

2017-07-08 Thread Alan Gauld via Tutor
On 08/07/17 09:05, marcus lütolf wrote: > Is it possible to have python compare 2 subsequent *.jpg images > in subtracting the pixel values of the second from the first image. Yes > If the images and are identical the result should be 0 and the first > image could be deletet. That's

Re: [Tutor] Which DB use with standalone desktop app

2017-07-06 Thread Alan Gauld via Tutor
On 06/07/17 18:32, zhenghao li wrote: > 100 records are not a lot, so sqlite is sufficient. Its database engine > is included in python and it doesn't need to be run as a stand-alone > server so that saves you a lot of time for setting things up. If you > have a lots of tables and data say like

Re: [Tutor] Which DB use with standalone desktop app

2017-07-06 Thread Alan Gauld
Oops, I forgot the list! Blush... On 06/07/17 18:30, Alan Gauld wrote: > On 06/07/17 09:57, Freedom Peacemaker wrote: > >> own but google cant help me. There are some with SQL in name (eg. sqlite3, >> MySql), but there are some other NoSql like MongoDB or Redis. > NoS

Re: [Tutor] Why use main() ?

2017-07-05 Thread Alan Gauld via Tutor
On 05/07/17 16:37, David Rock wrote: > This is a question about the benefits of using a main() function vs not. Others have answered for the pros, but I confess that I don't always use a main(), but only if all I'm doing is, say, instantiating a class and running a method. For anything more

Re: [Tutor] Fwd: Re: call key on_press event multiple times when key is held down

2017-07-04 Thread Alan Gauld via Tutor
On 04/07/17 12:00, Alan Gauld via Tutor wrote: >> the library you are using, I normally just use the standard >> library for such things, or build a simple GUI… > > Standard library being?.. The Python standard library that ships with Python and is docume

[Tutor] Fwd: Re: call key on_press event multiple times when key is held down

2017-07-04 Thread Alan Gauld via Tutor
Forwarding to Tutor list Please always use reply-All or reply-List to respond to tutor posts. Forwarded Message > Den 4. jul. 2017 kl. 11.35 skrev Alan Gauld via Tutor <tutor@python.org>: > > On 04/07/17 09:50, Carlton Banks wrote: >> I am try

Re: [Tutor] call key on_press event multiple times when key is held down

2017-07-04 Thread Alan Gauld via Tutor
On 04/07/17 09:50, Carlton Banks wrote: > I am trying to record from my microphone while i press down a button, First question is which OS? That makes a big difference in this kind of scenario. > the library I am using is not able to detect on hold event. There isn't really any concept of a

Re: [Tutor] [Python2.7] Convert (2,188,1) into (188,1)

2017-07-04 Thread Alan Gauld via Tutor
On 28/06/17 16:48, Allan Tanaka via Tutor wrote: > Hi. I have array shape like: (2,188,1). I assume this is a numpy array rather than the standard library array? If so consider asking on the scipy/numpy support forum for more specialised help. > I want to make it like this: (188,1). I try that

Re: [Tutor] Not returning out the series

2017-07-04 Thread Alan Gauld via Tutor
On 04/07/17 03:40, Rafael Skovron wrote: > def m(i): > total = 0 > for i in range(1,i+1,1): > total+=(i/(i+1)) > return total convert the numerator to a float. Otherwise you are using integer division. (I'm guessing you are running Python 2.7?) You could also import division

[Tutor] Fwd: Re: Ubuntu install [was: Re: Fwd: Re: program code for Python Programming for the Absolute Beginner, 3rd ed.?]

2017-07-03 Thread Alan Gauld via Tutor
Forwarding to group. Please always use ReplyAll (or ReplyList) when responding to list emails. Forwarded Message I have a fresh install of Ubuntu 16.04.2, on which I try to install Python 3.6.1. I have done this multiple times in the past, but for some reason I tried it 3

[Tutor] Ubuntu install [was: Re: Fwd: Re: program code for Python Programming for the Absolute Beginner, 3rd ed.?]

2017-07-03 Thread Alan Gauld via Tutor
On 03/07/17 09:13, Alan Gauld via Tutor wrote: > forwarding to list. > > Sorry, > I still have no idea what you are trying to do and what you want help with? OK, I just realized that you replied to the wrong post and this is actually about the thread on installing 3

Re: [Tutor] program code for Python Programming for the Absolute Beginner, 3rd ed.?

2017-07-02 Thread Alan Gauld via Tutor
On 02/07/17 11:03, Richard Grose wrote: > https://www.google.co.uk/url?sa=t=j==s=web=1=0ahUKEwiw1tD3qurUAhULKlAKHWMOAPMQFggkMAA=https%3A%2F%2Fgithub.com%2FCWade3051%2FPy%2Ftree%2Fmaster%2FAbsolute%2520Book%2Fpy3e_source=AFQjCNG36WhZfh5ftqWncjtgZy3z6xgh6g=rjt > > Py/Absolute Book/py3e_source at

Re: [Tutor] Query regarding output

2017-06-29 Thread Alan Gauld via Tutor
On 29/06/17 03:14, shubham goyal wrote: > This Question is asked in some exam. i am not able to figure it out. > > a = [0, 1, 2, 3] > for a[-1] in a: > print(a[-1]) > > its giving output 0 1 2 2 > > it should be 3 3 3 3 as a[-1] belongs to 3. > can anyone help me figuring it out. This is

Re: [Tutor] Query regarding Regular Expression

2017-06-28 Thread Alan Gauld via Tutor
On 28/06/17 21:27, cookiestar227 - Cookie Productions wrote: > So far have understood everything except for the following example: > t = "A fat cat doesn't eat oat but a rat eats bats." mo = re.findall("[force]at", t) > What I don't understand is the [force] part of the Regular

Re: [Tutor] Choosing between dictionary or external file

2017-06-28 Thread Alan Gauld via Tutor
On 28/06/17 17:44, Henrique C. S. Junior wrote: > using dictionaries to store information. Here is an example: > > > basis_sets = { > "Pople-style basis sets": { > "3-21G": "Pople 3-21G (H-Cs)", > "STO-3G": "Minimal basis set(H-I)", >

[Tutor] Fwd: Re: Using files to read data

2017-06-27 Thread Alan Gauld via Tutor
34 2017" ] [ 0.03, 0.9777, "Mon Jun 26 20:37:34 2017" ] [ 0.02, 0.9889, "Mon Jun 26 20:37:34 2017” *with this code* filename = "xyz_save.json" with open(filename) as f_obj: lines = f_obj.read() print(lines)

Re: [Tutor] Using files to read data

2017-06-27 Thread Alan Gauld via Tutor
On 27/06/17 06:32, Micheal Dale Peterson wrote: > I am trying to write something that stores x and y data > with a time reference and then use it later ... Lets stick to one thing at a time. How far did you get writing the data to a file? Did the file get created? Can you edit in the text editor?

[Tutor] Fwd: Re: bottle: request.form.get()

2017-06-23 Thread Alan Gauld
Please always use ReplyAll when responding to the tutor list. (Or ReplyList if your mail client supports it) (Having said that I forgot to add the list - oops! :) On 22/06/17 19:48, adil gourinda wrote: > 1) I expected a well made documentaion that your The Python web site provides

Re: [Tutor] how-to generate specific lines of text from two python lists

2017-06-22 Thread Alan Gauld via Tutor
On 21/06/17 21:26, Tahir Hafiz wrote: > My python skills are limited but I have managed to generate a couple > of lists using python and the psycopg2 library by querying a postgress > table and it's columns. You say your python skills are limited but how about your SQL skills? The reason I ask

Re: [Tutor] bottle: request.form.get()

2017-06-22 Thread Alan Gauld via Tutor
On 21/06/17 15:54, adil gourinda wrote: >I was looking for the "request.form.get()" method in "Python Library"> but > I didn't find it, I looked also in "Requests 2.18.1 Documentation" You don't say which requests package you are using. You reference bottle in the subject line and Requests

Re: [Tutor] Class

2017-06-21 Thread Alan Gauld via Tutor
On 20/06/17 23:39, Rex Florian via Tutor wrote: > Can someone explain how Python achieves the vector addition of more than 2 > vectors > without some kind of looping? > > class Vector: >def __init__(self, a, b): >def __str__(): >def __add__(self,other): > return Vector(self.a

Re: [Tutor] __str__ on a subclass

2017-06-19 Thread Alan Gauld via Tutor
On 19/06/17 20:32, Evuraan wrote: > class Employee: > """Class with FirstName, LastName, Salary""" > def __init__(self, FirstName,LastName, Salary): > def __str__(self): > return '("{}" "{}" "{}")'.format(self.FirstName, >

Re: [Tutor] Fahrenheit to Celsius Conversion another problem and Programming Paradigm

2017-06-14 Thread Alan Gauld via Tutor
On 14/06/17 15:20, William Gan wrote: > print('Enter C for Celsius to Fahrenheit or F for Fahrenheit to Celsius.') > > if unit == 'C' or 'c': You have hit a common error for beginners. reading this as a human it is quite clear what is meant but the computer sees it differently. It sees: if

Re: [Tutor] Raspberry pi 2 python help

2017-06-13 Thread Alan Gauld via Tutor
On 13/06/17 15:08, DJ VIN Lom wrote: > Can i create a script to have my pi change to a certian directory > automaticlly after booting. You have some serious misconceptions about how the Pi works. The Pi does not have any idea of a "directory" when it boots up. The whole concept of a home

Re: [Tutor] Query

2017-06-13 Thread Alan Gauld via Tutor
On 13/06/17 10:09, Muddunuri Mahesh wrote: > Where can i get the perfect tutorials for black scripting using python I'm not sure what you mean by black scripting - and neither does google apparently... Other than that it is a gothic style of typescript font... But the perfect tutorial for

Re: [Tutor] string reversal using [::-1]

2017-06-12 Thread Alan Gauld via Tutor
On 12/06/17 15:57, Vikas YADAV wrote: > for i in range(len(s)-1, 1, -2): > print s[i] > - > > So my question is: how would you write "s[::-1]" in terms of a for loop for > illustration purpose? Exactly as above but replace -2 with -1 for i in

Re: [Tutor] Creating 2 Subarrays for large dataset

2017-06-12 Thread Alan Gauld via Tutor
On 12/06/17 16:52, Peter Gibson wrote: > I have a large, 4 column data set that is in the form of an array. Do you mean 4 separate arrays or a single 4xN array? Or do you mean an N size array of 4 item tuples? Or are the 4 colums part of a class? There are lots of ways to interpret that

Re: [Tutor] Fahrenheit to Celsius Conversion with if else statements

2017-06-12 Thread Alan Gauld via Tutor
On 12/06/17 15:17, William Gan wrote: > print('Enter C for Celsius to Fahrenheit or F for Fahrenheit to Celsius.') > unit = input('Enter C or F:') > temp = int(input('Enter temperature:')) > > if unit == 'C': Note this only t5ests for 'C' - ie capital C. You might want to force the input to be

Re: [Tutor] Huge list comprehension

2017-06-12 Thread Alan Gauld via Tutor
On 12/06/17 05:54, syed zaidi wrote: > One reason fornsharing the code was that I have to manually create over 100 > variables > Is there a way i can automate thst process? I doubt very much that you *have* to create 100 varables, that's an implementation choice as part of your design. If you

Re: [Tutor] tkinter actively maintained?

2017-06-12 Thread Alan Gauld via Tutor
On 12/06/17 03:54, Michael C wrote: > Hi all: > > is tkinter still being actively maintained? I only had to ask about this > because I have never looked stuff like this up before. Yes, Tkinter tracks the Tk releases so that most of the activity at present is in the ttk sub package. There is a

Re: [Tutor] string reversal using [::-1]

2017-06-10 Thread Alan Gauld via Tutor
On 10/06/17 17:39, Vikas YADAV wrote: > Question: Why does "123"[::-1] result in "321"? > > MY thinking is [::-1] is same as [0:3:-1], that the empty places defaults to > start and end index of the string object. Did you try that? You may be surprised. The wonderful thing about the >>> prompt is

Re: [Tutor] Huge list comprehension

2017-06-10 Thread Alan Gauld via Tutor
On 10/06/17 08:35, Abdur-Rahmaan Janhangeer wrote: > take a look at numpy It seems he already has, np.array is in his code. It's just the imports that are missing I suspect. > and don't necessarily give us the whole code. it becomes too long without > purpose Yes although in this case it does

Re: [Tutor] Coming from R, what's a good IDE editor? I've tried PyCharm and Spyder

2017-06-08 Thread Alan Gauld via Tutor
On 08/06/17 19:24, C W wrote: > IPython is great for presentation, but you need to start it up in Terminal, > Spyder does not have an icon in Application, you again need to start it up > in Terminal with a few commands. It is slow to start up. (I have it) You should be able to create your own

Re: [Tutor] Coming from R, what's a good IDE editor? I've tried PyCharm and Spyder

2017-06-03 Thread Alan Gauld via Tutor
On 03/06/17 07:20, Mike C wrote: > There is a high demand for Python in the > industry, but there has not been a good IDE. There are a ton of IDEs for Python including the generic ones like VS, Eclipse and Netbeans. But... I've tried many of these and find I keep coming back to the simpler

Re: [Tutor] Pasting an image with transparency

2017-06-02 Thread Alan Gauld via Tutor
On 01/06/17 20:34, Terry wrote: > Slackware 14.2 64-bit > Python 2.7.13 > > I am trying to automate some photo processing by pasting a > sig or watermark. The sig image is a .png with transparency > but when it pastes it does so with a black background. Is there > a way to paste with

Re: [Tutor] Issue with wsgi_ref.simple_server - sometimes very slow!

2017-06-02 Thread Alan Gauld via Tutor
This appears to be a duplicate of the message you sent on 31st May. Please don not send multiple copies of the same message, it fragments the threads and messes up the archives for searching. One message is sufficient, if you don't get a response it probably means nobody knows the answer (or maybe

Re: [Tutor] threading tutorial

2017-06-01 Thread Alan Gauld via Tutor
On 01/06/17 16:30, Michael C wrote: > Oh i get it alright, however in my code I have to push the W button like > this: > > import pyautogui > import time > > pyautogui.keyDown('w') > time.sleep(2) > pyautogui.keyUp('w') So this emulates a user pressing the w key for 2 seconds. What's not clear

Re: [Tutor] 3D plotting

2017-05-29 Thread Alan Gauld via Tutor
On 29/05/17 21:40, Jack Lambert wrote: > I am very new to python and am using it for some astronomy data analysis. > What I am trying to is plot a 3D scatter plot of three variables that are > being read from a file. I've tried using code from other examples of 3d > plots but, having little idea

Re: [Tutor] Problem with if statements and else statements

2017-05-28 Thread Alan Gauld via Tutor
On 29/05/17 00:12, Alex Kleider wrote: > On 2017-05-28 13:13, Mats Wichmann wrote: > >> FWIW, if checking for multiples, you could also write: >> >> if Month in ['January', '1']: > > Would > if Month in {'January', '1'}: > > be even better? (regarding efficiency perhaps? Trivial point, I

Re: [Tutor] Counting a string backwards

2017-05-28 Thread Alan Gauld via Tutor
On 28/05/17 18:58, C W wrote: > Now if I do case 2, >> print(great[-3:-1]) >> me > > Where did the exclamation mark go in case 2? > > I was told the count begins at zero, that's true going forward, but not > backwards. Its not about where the count starts its about where it finishes. It

Re: [Tutor] airflow dag

2017-05-28 Thread Alan Gauld via Tutor
On 28/05/17 04:37, shubham goyal wrote: > Does anybody have answer? You received two answers, both of which asked you to try something and get back to us for more information. Did you try printing sys.argv? What was the result? And did you try Peter's argparse code? You still haven't explained

Re: [Tutor] How to deploy seamless script updates to your "clients"?

2017-05-26 Thread Alan Gauld via Tutor
On 26/05/17 22:56, Juan C. wrote: >> a basic idea would be to get a webpage and put your code there. This is >> where you edit your codes > > What does a webpage have to do with this, I really can't picture that. I think it just means host the files on a web server so you can access them using

Re: [Tutor] airflow dag

2017-05-25 Thread Alan Gauld via Tutor
On 25/05/17 13:15, shubham goyal wrote: > He guys, > > I want to ask that can we pass the parameters as commandline arguments in > airflow when we are triggering the dag and access them inside the dag's > python script/file. I've no idea what a dag is. This list is for people learning Python as

Re: [Tutor] real time response

2017-05-24 Thread Alan Gauld via Tutor
On 23/05/17 21:07, Michael C wrote: > def do_stuff: > blah > check() > blah > check() > blah > check() > blah > > and then either break or return if condition is met? > > But that just isn't responsive enough. Is there a way to make function > check for the

Re: [Tutor] Looping through Dictionaries

2017-05-23 Thread Alan Gauld via Tutor
On 23/05/17 18:38, Rafael Knuth wrote: > Now, I want to print the item next to the stock update, and I am > receiving an error message. I couldn't figure out how to fix that: So show us the error message, all of it. I can't begin to guess what it might be. UI also don't understand what "print

Re: [Tutor] recursion

2017-05-23 Thread Alan Gauld via Tutor
On 23/05/17 06:18, Peter Otten wrote: > Michael C wrote: > >> oh ya, my function does in fact take no input and doesn't change anything, >> and all i wanted to was to call itself a 2nd time, yes, so I solved it a >> few hours back ,and it's good enough for me for now :) > > Would you mind

Re: [Tutor] recursion

2017-05-22 Thread Alan Gauld via Tutor
On 22/05/17 17:11, Michael C wrote: > I have a function to return (x,y) value, but sometimes it would naturally > unable to return those 2 values properly. I know what recursion is, and I > think all I got to do is to call this function a 2nd time and the problem > would go away. Sorry, but that

Re: [Tutor] deleting elements of a dictionary

2017-05-19 Thread Alan Gauld via Tutor
On 19/05/17 15:23, Michael C wrote: > list(read_dictionary) converts the dictionary into a list right? How can > you save the list as a dictionary? Nope, list() produces a new list object containing the keys of the dictionary. In the old day(of python 2) you used to get the same effect using for

Re: [Tutor] Python Image Library

2017-05-19 Thread Alan Gauld via Tutor
On 19/05/17 15:15, Peter Otten wrote: > call the destroy() rather than the quit() method. Nice! > > However, as your code gets away without calling destroy() I'm still > puzzled... withdraw hides the window then quit ends the mainloop so the procedure falls through to the end and everything

Re: [Tutor] Python Image Library

2017-05-19 Thread Alan Gauld via Tutor
On 19/05/17 10:29, Alan Gauld via Tutor wrote: > is something that seems to work for jpegs. I hope bmp files > will too, I didn't have any to test... I converted a few jpg to bmp. It does work but it turns out Pillow is quite fussy about the BMP format. I had to turn off colour space heade

Re: [Tutor] Python Image Library

2017-05-19 Thread Alan Gauld via Tutor
On 18/05/17 18:06, Alan Gauld via Tutor wrote: > Here is some untested Tkinter code to display an image > for 2 seconds: I tried this last night and it turned out to be harder than I expected. Eventually I got to bed at 3am! But here is something that seems to work for jpegs. I hope bmp

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