Re: The "loop and a half"

2017-10-03 Thread Larry Hudson via Python-list
On 10/03/2017 10:29 AM, Stefan Ram wrote: Is this the best way to write a "loop and a half" in Python? x = 1 while x: x = int( input( "Number (enter 0 to terminate)? " )) if x: print( f'Square = { x**2 }' ) In a C-like language, one could write: while x = int( input( "

Re: newb question about @property

2017-10-02 Thread Larry Hudson via Python-list
On 10/01/2017 03:52 PM, Bill wrote: Steve D'Aprano wrote: The definitive explanation of descriptors is here: https://docs.python.org/3/howto/descriptor.html Thank you!  It is next on my list.   Then I'll try that Circle problem you mentioned as an exercise last night!  I don't expect run into

Re: Beginners and experts (Batchelder blog post)

2017-09-27 Thread Larry Hudson via Python-list
On 09/27/2017 09:41 AM, leam hall wrote: On Sat, Sep 23, 2017 at 5:26 PM, Ned Batchelder wrote: [snip] The question is, what should a person "know" when hiring out as a programmer? What is 'know" and what should be "known"? Specifically with Python. Hopefully NOT like this person... (Sourc

Re: "tkinter"

2017-09-13 Thread Larry Hudson via Python-list
On 09/13/2017 05:33 AM, leam hall wrote: On Wed, Sep 13, 2017 at 8:28 AM, Stefan Ram wrote: I presume that "tkinter" is intended to be pronounced "logically": T K inter (tee kay inter /ti keI In t%/) . But it would be faster to pronounce it T kinter (tee kinter /ti kIn t%/) . S

Re: [Tutor] beginning to code

2017-09-13 Thread Larry Hudson via Python-list
On 09/13/2017 09:18 AM, ROGER GRAYDON CHRISTMAN wrote: I have not yet mastered how to respond to a particular note in a threadwith the mailer that I use, so this is not in response to anyone in particular,but just to some of the sentiments as a whole. if x:> # do something Completely out

Re: A question on modification of a list via a function invocation

2017-08-17 Thread Larry Hudson via Python-list
On 08/17/2017 12:18 AM, Larry Hudson wrote: On 08/16/2017 03:39 PM, Chris Angelico wrote: On Thu, Aug 17, 2017 at 8:29 AM, Mok-Kong Shen ... Oops, I replied to Chris's post, but it was meant for the OP. I should have replied to Mok-Kong Shen's post instead. My bad. Sorry for the

Re: A question on modification of a list via a function invocation

2017-08-17 Thread Larry Hudson via Python-list
On 08/16/2017 03:39 PM, Chris Angelico wrote: On Thu, Aug 17, 2017 at 8:29 AM, Mok-Kong Shen wrote: I have earlier learned some other (older) programming languages. For these the formal parameters are either "by reference" or "by value". In the first case, any modification of the formal paramet

Re: A question on modification of a list via a function invocation

2017-08-15 Thread Larry Hudson via Python-list
On 08/14/2017 08:25 PM, Larry Hudson wrote: [snip] Here is my attempt to clarify the situation with some ascii graphics. (Well, not ascii, but utf-8 box-drawing characters — I hope they come through ok. And, of curse, it won't display properly with a proportional font.) The left side i

Re: A question on modification of a list via a function invocation

2017-08-14 Thread Larry Hudson via Python-list
On 08/14/2017 01:02 PM, Mok-Kong Shen wrote: Am 14.08.2017 um 21:53 schrieb Ned Batchelder: [snip] def test(alist): alist=[3,6,9] return def test1(alist): alist[0],alist[1],alist[2]=3,6,9 return def test2(alist): alist[0],alist[1],alist[2]=3,6,9 alist=[30,60,90] return

Re: Is An Element of a Sequence an Object?

2017-06-04 Thread Larry Hudson via Python-list
On 06/03/2017 09:39 PM, Chris Angelico wrote: That's a tricky thing to pin down. Since it's possible for a sequence to contain itself, or to contain something which contains it, Like a Tardis? [Sorry, couldn't resist...] ;-) OTOH, On-Topic... It might be worth while to point out that a 'ch

Re: Verifiably better, validated Enum for Python

2017-05-26 Thread Larry Hudson via Python-list
On 05/26/2017 04:46 AM, Steve D'Aprano wrote: [snip..]> That's not how the C standard defines "undefined behaviour", or the implication of such. A little OT here, but... This brings to mind this entry in the Jargon File: http://catb.org/jargon/html/N/nasal-demons.html -- -=- Larry -=- -

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Larry Hudson via Python-list
On 03/26/2017 01:21 AM, Νίκος Βέργος wrote: print('''UPDATE visitors SET (pagesID, host, ref, location, useros, browser, visits) VALUES (%s, %s, %s, %s, %s, %s, %s) WHERE host LIKE "%s"''', (pID, domain, ref, location, useros, browser, lastvisit, domain) ) prints out: UPDATE visitors SET (pag

Re: Who are the "spacists"?

2017-03-19 Thread Larry Hudson via Python-list
On 03/18/2017 05:01 PM, Nathan Ernst wrote: [...] Personally, I dislike any editor that, by default, changes my input to something else. If I hit tab, I want a tab to be inserted, by default. If I want something else, I'll change the configuration. A trivial point (and irrelevant)... The thing

Re: The hardest problem in computer science...

2017-01-06 Thread Larry Hudson via Python-list
On 01/06/2017 05:03 AM, Steve D'Aprano wrote: The second hardest problem in computer science is cache invalidation. The *hardest* problem is naming things. In a hierarchical tree view widget that displays items like this: Fiction ├─ Fantasy │ ├─ Terry Pratchett │ │ ├─ Discw

Re: Hey, I'm new to python so don't judge.

2017-01-06 Thread Larry Hudson via Python-list
On 01/03/2017 04:27 PM, Callum Robinson wrote: > On Wednesday, January 4, 2017 at 1:17:11 PM UTC+13, Chris Angelico wrote: >> On Wed, Jan 4, 2017 at 11:03 AM, Erik wrote: >>> I doubt it's getting that far (I can see at least one syntax error in the >>> code pasted). >> >> True true. In any case, t

Re: Hey, I'm new to python so don't judge.

2017-01-03 Thread Larry Hudson via Python-list
On 01/03/2017 04:27 PM, Callum Robinson wrote: On Wednesday, January 4, 2017 at 1:17:11 PM UTC+13, Chris Angelico wrote: On Wed, Jan 4, 2017 at 11:03 AM, Erik wrote: I doubt it's getting that far (I can see at least one syntax error in the code pasted). True true. In any case, the point is t

Re: python 2.7.12 on Linux behaving differently than on Windows

2016-12-06 Thread Larry Hudson via Python-list
On 12/06/2016 03:21 AM, BartC wrote: On 06/12/2016 07:37, Larry Hudson wrote: Now you're suggesting the _shell_ is going to read and process a CVS file??? What follows a shell command is a set of values a,b,c,d,e. What is encountered in a CSV is a set of values a,b,c,d,e. You really

Re: python 2.7.12 on Linux behaving differently than on Windows

2016-12-05 Thread Larry Hudson via Python-list
On 12/05/2016 10:50 AM, BartC wrote: And just what ARE A, C, and D? It doesn't matter, and is not the concern of the shell. It should restrict itself to the basic parsing that may be necessary when parameters are separated by white-space and commas, if a parameter can contain white-space

Re: python 2.7.12 on Linux behaving differently than on Windows

2016-12-05 Thread Larry Hudson via Python-list
On 12/05/2016 06:51 PM, Nathan Ernst wrote: IIRC, command.com was a relic of Win9x running on top of DOS and was a 16-bit executable, so inherently crippled (and probably never support by the NT kernel). Whereby cmd.exe coexisted but ran in a 32-bit context. I know my 79-year-old memory is defi

Re: Help with two issues, buttons and second class object

2016-11-24 Thread Larry Hudson via Python-list
On 11/24/2016 06:53 AM, Peter Otten wrote: Thomas Grops via Python-list wrote: [snip...] Instead of repeating your code with copy-and-past make a helper function like the randx() posted by Larry Hudson. By the way, randint(min, max) may return max so there are 9 possible outcomes while you

Re: Random number help

2016-11-23 Thread Larry Hudson via Python-list
On 11/23/2016 11:17 AM, Thomas Grops wrote: I need a way of generating a random number but there is a catch: I don't want to include certain numbers, is this possible? random.randint(1,100) works as it will randomly pick numbers between 1 and 100 but say i don't want 48 to come out is there a

Re: How to you convert list of tuples to string

2016-11-23 Thread Larry Hudson via Python-list
On 11/23/2016 03:09 AM, Ned Batchelder wrote: [snip...] Or using the new string formatting syntax: msg = '{},{},{}:{}'.format(*item) The *item in the format() unpacks the tuple. "new" == "Introduced in 2.6, available since 2008" :) --Ned. Of course. I probably should have said "newer" o

Re: How to you convert list of tuples to string

2016-11-23 Thread Larry Hudson via Python-list
On 11/22/2016 08:51 AM, Michiel Overtoom wrote: Hi Ganesh, Any better suggestion to improve this piece of code and make it look more pythonic? import random # A list of tuples. Note that the L behind a number means that the number is a 'long'. data = [(1, 1, 373891072L, 8192), (1, 3, 390

Re: Can somebody tell me what's wrong wrong with my code? I don't understand

2016-11-23 Thread Larry Hudson via Python-list
On 11/21/2016 07:10 PM, rmjbr...@gmail.com wrote: Hi! This is my first post! I'm having trouble understanding my code. I get "SyntaxError:invalid syntax" on line 49. I'm trying to code a simple text-based rpg on repl.it. Thank you for reading. print("Welcome to Gladiator Game! Choose your ch

Re: A question about sprite rendering in game development

2016-11-16 Thread Larry Hudson via Python-list
On 11/16/2016 12:16 AM, shadecelebi wrote: thanx a lot you guys. I'm slightly familiar with pygame from before so I'll make sure to utilize it. and no I don't have any of the characters yet as I've yet to start. I just wanted to know if I should keep learning python or if it would be trivial t

Re: Need help with coding a function in Python

2016-10-31 Thread Larry Hudson via Python-list
On 10/31/2016 03:09 PM, devers.meetthebadger.ja...@gmail.com wrote: http://imgur.com/a/rfGhK#iVLQKSW How do I code a function that returns a list of the first n elements of the sequence defined in the link? I have no idea! So far this is my best shot at it (the problem with it is that the

Re: Function to take the minimum of 3 numbers

2016-10-09 Thread Larry Hudson via Python-list
On 10/09/2016 05:01 AM, Cai Gengyang wrote: def min3(a, b, c): min3 = a if b < min3: min3 = b if c < min3: min3 = c if b < c: min3 = b return min3 print(min3(4, 7, 5)) 4 This is NOT a recommendation here, just a different way of looking a

Re: Nested for loops and print statements

2016-09-28 Thread Larry Hudson via Python-list
On 09/27/2016 09:20 PM, Steven D'Aprano wrote: On Wednesday 28 September 2016 12:48, Larry Hudson wrote: As they came through in the newsgroup, BOTH run correctly, because both versions had leading spaces only. (I did a careful copy/paste to check this.) Copying and pasting from the

Re: Nested for loops and print statements

2016-09-27 Thread Larry Hudson via Python-list
On 09/26/2016 01:57 PM, Cai Gengyang wrote: Ok it works now: for row in range(10): for column in range(10): print("*",end="") but how is it different from --- for row in range

Re: Nested for loops and print statements

2016-09-26 Thread Larry Hudson via Python-list
On 09/26/2016 08:25 AM, Cai Gengyang wrote: I just wanted to note that sometimes the code works, sometimes it doesn't. (even though both are exactly the same code) ... Weird , dum dum dum It is NOT weird. Python is being consistent, YOU are not. These examples are NOT "exactly the same code

Re: strings and ints consistency - isinstance

2016-09-22 Thread Larry Hudson via Python-list
On 09/22/2016 06:40 AM, Sayth Renshaw wrote: [snip...] True it failed, just actually happy to get it to fail or pass successfully on int input. Just felt it was a clearer and more consistent approach to verifying input, then most of the varied and rather inconsistent approaches I have seen in

Re: Data Types

2016-09-22 Thread Larry Hudson via Python-list
On 09/20/2016 09:03 PM, Cai Gengyang wrote: [snip...] So for example for "bool" , it only applies to True/False and nothing else? (2 data types), i.e. : Not exactly... bool is the data type (or class), True and False are the only two _values_ (not types). type(True) type(False) [

Re: How to split value where is comma ?

2016-09-08 Thread Larry Hudson via Python-list
On 09/08/2016 07:57 AM, John Gordon wrote: In Joaquin Alzola writes: Use the split a.split(",") for x in a: print(x) This won't work. split() returns a list of split elements but the original string remains unchanged. You want something like this instead: newlist = a.split(",")

Re: Extend unicodedata with a name/pattern/regex search for character entity references?

2016-09-04 Thread Larry Hudson via Python-list
On 09/04/2016 09:00 AM, Veek. M wrote: Steve D'Aprano wrote: On Sun, 4 Sep 2016 06:53 pm, Thomas 'PointedEars' Lahn wrote: Regarding the name (From field), my name *is* Veek.M […] Liar. *plonk* You have crossed a line now Thomas. That is absolutely uncalled for. You have absolutely no l

Re: Multimeter USB output

2016-08-30 Thread Larry Hudson via Python-list
On 08/29/2016 09:24 PM, Paul Rubin wrote: Larry Hudson writes: with BDS-C under CP/M. Somebody remenbering this no-fp compiler from the dark age before PC und Linux? I remember it well. It's what I used to initially learn C. Source code is online here: http://www.bdsoft.com/reso

Re: [OT] Altair

2016-08-30 Thread Larry Hudson via Python-list
On 08/30/2016 11:51 AM, Joe wrote: Am 30.08.2016 um 17:52 schrieb D'Arcy J.M. Cain: On Tue, 30 Aug 2016 15:56:07 +0200 Joe wrote: Am 30.08.2016 um 13:01 schrieb D'Arcy J.M. Cain: On Mon, 29 Aug 2016 21:21:05 -0700 Larry Hudson via Python-list wrote: I remember it well. It's

Re: Multimeter USB output

2016-08-30 Thread Larry Hudson via Python-list
On 08/30/2016 04:01 AM, D'Arcy J.M. Cain wrote: On Mon, 29 Aug 2016 21:21:05 -0700 Larry Hudson via Python-list wrote: I remember it well. It's what I used to initially learn C. I'm a completely self-taught, hobby programmer. Been around since the MITS Altair. How many reme

Re: Multimeter USB output

2016-08-29 Thread Larry Hudson via Python-list
On 08/29/2016 01:54 AM, Joe wrote: [snip...] Interesting, but... The last time I did something with c, it was with BDS-C under CM/M. Somebody remenbering this no-fp compiler from the dark age before PC und Linux? I remember it well. It's what I used to initially learn C. I'm a completely sel

Re: I am new to python. I have a few questions coming from an armature!

2016-08-17 Thread Larry Hudson via Python-list
On 08/17/2016 04:24 AM, Jussi Piitulainen wrote: ... http://www-formal.stanford.edu/jmc/recursive/node2.html (the paper famously titled "Part I" without any Part II, unless I mistake much.) Totally OT here, but... This reminds me of a old record I have with the (deliberately tongue-in-cheek)

Re: Appending an asterisk to the end of each line

2016-07-05 Thread Larry Hudson via Python-list
On 07/05/2016 03:05 PM, Seymore4Head wrote: import os f_in = open('win.txt', 'r') f_out = open('win_new.txt', 'w') for line in f_in.read().splitlines(): f_out.write(line + " *\n") f_in.close() f_out.close() os.rename('win.txt', 'win_old.txt') os.rename('win_new.txt', 'win.txt') I just

Re: Operator Precedence/Boolean Logic

2016-06-22 Thread Larry Hudson via Python-list
On 06/22/2016 12:42 AM, Lawrence D’Oliveiro wrote: [snip] I feel that’s a needlessly complicated rule. It would have been simpler if boolean operators (and conditional expressions like in if-statements and while-statements) only allowed values of boolean types. But that’s one of the few warts

Re: ASCII or Unicode? (was best text editor for programming Python on a Mac)

2016-06-21 Thread Larry Hudson via Python-list
On 06/19/2016 08:29 PM, Steven D'Aprano wrote: On Mon, 20 Jun 2016 12:07 pm, Rustom Mody wrote: [snip] In theory most Linux apps support an X mechanism for inserting characters that don't appear on the keyboard. Unfortunately, this gives no feedback when you get it wrong, and discoverablity is

Re: how to search item in list of list

2016-06-13 Thread Larry Hudson via Python-list
On 06/12/2016 08:29 PM, meInvent bbird wrote: once a nested list have a word "node" then true else false def search(current_item): if isinstance(current_item, list): if len(current_item)==4: if [item for item in current_item if item[4] == "node"] != []:

Re: i'm a python newbie & wrote my first script, can someone critique it?

2016-06-10 Thread Larry Hudson via Python-list
On 06/10/2016 03:52 PM, mad scientist jr wrote: Is this group appropriate for that kind of thing? (If not sorry for posting this here.) So I wanted to start learning Python, and there is s much information online, which is a little overwhelming. I really learn best from doing, especially i

Re: Summing/combining tuples

2016-05-19 Thread Larry Hudson via Python-list
On 05/18/2016 09:53 PM, DFS wrote: On 5/18/2016 10:58 PM, Larry Hudson wrote: [snip...] Why two loops? Put both summations in a single loop. Then you're only scanning the alist once instead of twice. groups1 = defaultdict(int) groups2 = defaultdict(int) for nm, matches, words in

Re: Program prints questions for user input, but won't show the answer output

2016-05-18 Thread Larry Hudson via Python-list
On 05/18/2016 06:50 PM, Jake Kobs wrote: MRAB, I am not quite sure how to return the print statements so I thought that returning the displayInfo def would help.. Im so lost. Why do you think you want to _return_ a print statement? The print statement _DOES_ the printing, there is nothing th

Re: Summing/combining tuples

2016-05-18 Thread Larry Hudson via Python-list
On 05/18/2016 05:59 PM, DFS wrote: Have aList = [ ('x','Name1', 1, 85), ('x','Name2', 3, 219), ('x','Name2', 1, 21), ('x','Name3', 6, 169) ] want aList = [ ('Name1', 1, 85), ('Name2', 4, 240), ('Name3', 6, 169) ] This drops the first element in each tuple: alist = [(b,c,d) for a,b,c,d in ali

Re: pylint woes

2016-05-08 Thread Larry Hudson via Python-list
On 05/08/2016 03:07 PM, Chris Angelico wrote: On Mon, May 9, 2016 at 6:45 AM, Larry Hudson via Python-list wrote: On 05/08/2016 06:01 AM, Chris Angelico wrote: [snip...] ... I like to recommend a little thing called "IIDPIO debugging" - I

Re: pylint woes

2016-05-08 Thread Larry Hudson via Python-list
On 05/08/2016 06:01 AM, Chris Angelico wrote: [snip...] ... I like to recommend a little thing called "IIDPIO debugging" - If In Doubt, Print It Out. That means: If you have no idea what a piece of code is doing, slap in a print() call somewhere. It'll tel

Re: How to become more motivated to learn Python

2016-05-03 Thread Larry Hudson via Python-list
On 05/03/2016 07:55 PM, Cai Gengyang wrote: Cool, I have finally summoned up enough activation energy to start on Unit 3, now going through the topic on Conditionals and Control Flows (stuff like this) boolthree = 200 == (50 * 5) boolthree False Guess it would be really cool to work on AI an

Re: one-element tuples

2016-04-11 Thread Larry Hudson via Python-list
On 04/10/2016 08:19 PM, Fillmore wrote: Thank you for trying to help, Martin. So: On 04/10/2016 09:08 PM, Martin A. Brown wrote: #1: I would not choose eval() except when there is no other solution. If you don't need eval(), it may save you some headache in the future, as well, to f

Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-22 Thread Larry Hudson via Python-list
I didn't see anyone responding to this, so I'll pop in here... On 03/22/2016 04:05 AM, BartC wrote: [...] (Suppose you need both the value and its index in the loop? Then the one-line for above won't work. For example, 'something' is [10,20,30] and you want to print: 0: 10 1: 20 2: 30 )

Re: Text input with keyboard, via input methods

2016-03-10 Thread Larry Hudson via Python-list
On 03/09/2016 11:54 PM, Rustom Mody wrote: [...] In between these two extremes we have many possibilities - ibus/gchar etc - compose key - alternate keyboard layouts Using all these levels judiciously seems to me a good idea... FWIW -- in Mint Linux you can select the compose key with the foll

Re: Considering migrating to Python from Visual Basic 6 for engineering applications

2016-02-20 Thread Larry Hudson via Python-list
On 02/20/2016 10:38 AM, wrong.addres...@gmail.com wrote: [snip] How complicated could this get in Python? Reading the numbers is one thing, and then placing the values in text boxes of the GUI. If that is the only object of using these values, there is no conversions necessary. The data is r

Re: Guido on python3 for beginners

2016-02-20 Thread Larry Hudson via Python-list
On 02/19/2016 06:36 PM, Steven D'Aprano wrote: On Fri, 19 Feb 2016 02:39 pm, Rustom Mody wrote: [snip] But you can't do anything interesting with this language, so it is not satisfying. On the other hand, here's "Hello World" in another language, one which is Turing complete so it can do anyt

Re: Considering migrating to Python from Visual Basic 6 for engineering applications

2016-02-19 Thread Larry Hudson via Python-list
On 02/19/2016 10:14 AM, wrong.addres...@gmail.com wrote: [snip] This is precisely reading one character at a time. If not exactly reading one character, it is effectively looking at each character to assemble the number. Not a good sign. I guess there might be libraries which will help read nu

Re: Syntax error (The Python Book) Linux User and Developer Bookazine

2016-02-15 Thread Larry Hudson via Python-list
On 02/15/2016 07:06 AM, Joel Goldstick wrote: [snip a lot...] Learn Python the Hard Way is pretty good some people say. Its online. Also Diving into Python is online written by the now offline Mark Pilgrim. I have a couple of "Hard Way" books and personally, I don't like his style of teachin

Re: Cygwin and Python3

2016-02-09 Thread Larry Hudson via Python-list
On 02/09/2016 08:41 AM, Fillmore wrote: Hi, I am having a hard time making my Cygwin run Python 3.5 (or Python 2.7 for that matter). The command will hang and nothing happens. Just curious... Since Python runs natively in Windows, why are you trying to run it with Cygwin? I'm not implying t

Re: x=something, y=somethinelse and z=crud all likely to fail - how do i wrap them up

2016-01-31 Thread Larry Hudson via Python-list
On 01/30/2016 10:29 PM, Veek. M wrote: [snip] Trivial comment (and irrelevant to your question)... Replace your print('-') with the shorter print('-' * 65) Of course, feel free to disagree if you think the longer version is

Re: psss...I want to move from Perl to Python

2016-01-30 Thread Larry Hudson via Python-list
On 01/28/2016 04:01 PM, Fillmore wrote: I learned myself Perl as a scripting language over two decades ago. All through this time, I would revert to it from time to time whenever I needed some text manipulation and data analysis script. My problem? maybe I am stupid, but each time I have to g

Re: pip install mitmproxy - fails on watchdog-0.8.3.tar.gz with "Permission denied" error (Python 2.7.11 on Win XP SP3);

2016-01-24 Thread Larry Hudson via Python-list
On 01/23/2016 11:43 AM, Steve Petrie, P.Eng. wrote: [snip] I'm not sure what your exact problem is, but I can say that it isn't this; the Unix-style forward slash is perfectly legal under Windows (and it's even legal to mix and match). ChrisA I never knew that the forward slash is legal under

Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2015-12-25 Thread Larry Hudson via Python-list
On 12/25/2015 06:04 PM, princeud...@gmail.com wrote: #i have worked over 2hours only to get this: some-one help please manipulate_data = [] [snip other incorrect nonsense...] #this is the instruction: Create a function manipulate_data that does the following [snip...] Let's start with your f

Re: Weird list conversion

2015-12-13 Thread Larry Hudson via Python-list
On 12/13/2015 12:05 PM, KP wrote: On Sunday, 13 December 2015 11:57:57 UTC-8, Laura Creighton wrote: In a message of Sun, 13 Dec 2015 11:45:19 -0800, KP writes: Hi all, f = open("stairs.bin", "rb") data = list(f.read(16)) print data returns ['=', '\x04', '\x00', '\x05', '\

Re: HELP PLEASE printing single characters!

2015-12-03 Thread Larry Hudson via Python-list
On 12/02/2015 04:08 PM, John Strick wrote: On Wednesday, December 2, 2015 at 12:58:30 PM UTC-6, Dylan Riley wrote: hi all, I have been trying to figure out all day why my code is printing single characters from my list when i print random elements using random.choice the elements in the list a

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-25 Thread Larry Hudson via Python-list
On 11/25/2015 12:32 AM, Chris Angelico wrote: On Wed, Nov 25, 2015 at 7:14 PM, Antoon Pardon wrote: [snip] "Oh come on. It's basic arithmetic. You should be able to add 7 and 7... the result's 14!" "But it's so confusing. Why can't it be 16? It'd be more convenient for me if it were 16." N

Re: anyone tell me why my program will not run?

2015-11-22 Thread Larry Hudson via Python-list
On 11/21/2015 06:44 PM, Larry Hudson wrote: On 11/20/2015 07:30 PM, Dylan Riley wrote: i am learning python and was tasked with making a program that flips a coin 100 times and then tells you the number of heads and tails. [snip] import random heads = int("1") tails = int("

Re: anyone tell me why my program will not run?

2015-11-21 Thread Larry Hudson via Python-list
On 11/20/2015 07:30 PM, Dylan Riley wrote: i am learning python and was tasked with making a program that flips a coin 100 times and then tells you the number of heads and tails. I have done so coming up with this piece of work but it doesnt run can anyone help me out? #This is credited to dy

Re: Question about math.pi is mutable

2015-11-13 Thread Larry Hudson via Python-list
On 11/13/2015 01:19 AM, Denis McMahon wrote: On Fri, 13 Nov 2015 09:04:54 +1100, Steven D'Aprano wrote: On Fri, 13 Nov 2015 07:40 am, Thomas 'PointedEars' Lahn wrote: [crap I expect] And you should consider the irony, and hypocrisy, of somebody who signs his posts "PointedEars" bitching a

Re: What is wrong in this example code?

2015-11-12 Thread Larry Hudson via Python-list
On 11/12/2015 06:07 AM, fl wrote: On Thursday, November 12, 2015 at 8:58:33 AM UTC-5, fl wrote: Hi, def tick(self): """ Time will be advanced by one second """ if self.__seconds == 59: self.__seconds = 0 if (self.__minutes == 59):

Re: using binary in python

2015-11-10 Thread Larry Hudson via Python-list
On 11/10/2015 12:14 PM, Dennis Lee Bieber wrote: On Mon, 9 Nov 2015 22:20:25 -0800, Larry Hudson via Python-list declaimed the following: Of course it can. The only difference a text file and a binary file is the way it's opened. Text files are opened with 'r' or 'w'

Re: using binary in python

2015-11-09 Thread Larry Hudson via Python-list
Your questions are somewhat difficult to answer because you misunderstand binary. The key is that EVERYTHING in a computer is binary. There are NO EXCEPTIONS, it's all binary ALL the time. The difference comes about in how this binary data is displayed and manipulated. I want to emphasize, A

Re: What does “grep” stand for?

2015-11-06 Thread Larry Hudson via Python-list
On 11/06/2015 05:25 AM, William Ray Wing wrote: On Nov 5, 2015, at 10:36 PM, Larry Hudson via Python-list wrote: [snip] You’re not REALLY an old timer unless you’ve used TECO. -Bill Agreed. I'm not really and old-timer, just old (I'm 78). My first exposure to computers wa

Re: What does “grep” stand for?

2015-11-05 Thread Larry Hudson via Python-list
On 11/05/2015 05:18 PM, Dennis Lee Bieber wrote: On Thu, 5 Nov 2015 20:19:39 + (UTC), Grant Edwards declaimed the following: Though I used a line-editor for a while on VMS, I was never very good at it, and abanded it for a full-screen editor at he first opportunity. But, if you ever get a

Re: GoPiGo script

2015-11-02 Thread Larry Hudson via Python-list
On 11/02/2015 11:31 AM, Robin Koch wrote: Am 02.11.2015 um 15:32 schrieb input/ldompel...@casema.nl: Thank you for the explanation for it. I must tell you that i yust beginning with python. I bought the book beginning programming with python. Have you programming experience with other langua

Re: Execute Python Scripts

2015-10-14 Thread Larry Hudson via Python-list
On 10/14/2015 10:04 AM, Cai Gengyang wrote: So I am going through this article on Python for newbies ---http://askpython.com/execute-python-scripts/ Managed to create a file with these contents : 1 #!/usr/bin/env python3 2 3 print('hello world') and saved it as hello.py You did write that f

Re: Learning Modules, Arguments, Parameters (imma noob)

2015-09-25 Thread Larry Hudson via Python-list
You've already received a lot of answers and guidance, but here is on more point... On 09/25/2015 12:03 PM, Cody Cox wrote: [snip] this I am not sure about, I set Kilo=get_input(kilo), ... Watch your capitalization! Kilo is _NOT_ the same as kilo. Case is significant in Python (as wel

Re: Learning Modules, Arguments, Parameters (imma noob)

2015-09-24 Thread Larry Hudson via Python-list
On 09/24/2015 11:45 AM, codyw...@gmail.com wrote: I seem to be having a problem understanding how arguments and parameters work, Most likely why my code will not run. Can anyone elaborate on what I am doing wrong? ''' Cody Cox 9/16/2015 Programming Exercise 1 - Kilometer Converter Design a modu

Re: Pipes

2015-08-10 Thread Larry Hudson via Python-list
On 08/10/2015 01:43 PM, E.D.G. wrote: [snip] It has been my experience that researchers, particularly scientists, need to have some versatile and powerful programming language available that is compatible with the Windows operating system. The language needs to make certain resources av

Re: Who uses IDLE -- please answer if you ever do, know, or teach

2015-08-07 Thread Larry Hudson via Python-list
On 08/05/2015 06:06 PM, Terry Reedy wrote: [snip] 0. Classes where Idle is used: Where? Level? None Idle users: 1. Are you grade school (1=12)? undergraduate (Freshman-Senior)? post-graduate (from whatever)? Some college, but didn't complete. Never had any CS or programming courses. 2. A

Re: Most pythonic way of rotating a circular list to a canonical point

2015-08-03 Thread Larry Hudson via Python-list
On 08/02/2015 01:58 PM, Joonas Liik wrote: I have this feeling that you would get a lot more useful anwsers if you were to describe your actual problem in stead of what you think the solution is. There might be other, better solutions but since we know so little about what you are doing we will l

Re: Most pythonic way of rotating a circular list to a canonical point

2015-08-02 Thread Larry Hudson via Python-list
On 08/01/2015 01:34 PM, Lukas Barth wrote: Hi! I have a list of numbers that I treat as "circular", i.e. [1,2,3] and [2,3,1] should be the same. Now I want to rotate these to a well defined status, so that I can can compare them. If all elements are unique, the solution is easy: find the mini

Re: Noob in Python. Problem with fairly simple test case

2015-07-16 Thread Larry Hudson via Python-list
On 07/15/2015 08:11 PM, Chris Angelico wrote: On Thu, Jul 16, 2015 at 1:01 PM, Larry Hudson via Python-list wrote: On 07/15/2015 05:11 AM, Chris Angelico wrote: [snip] In addition to using print(), in some places I like using input() instead, as in: input('x={}, y={} --> &#

Re: Noob in Python. Problem with fairly simple test case

2015-07-15 Thread Larry Hudson via Python-list
On 07/15/2015 05:11 AM, Chris Angelico wrote: On Wed, Jul 15, 2015 at 9:44 PM, Jason P. wrote: I can't understand very well what's happening. It seems that the main thread gets blocked listening to the web server. My intent was to spawn another process for the server independent of the test.

Re: Why doesn't input code return 'plants' as in 'Getting Started with Beautiful Soup' text (on page 30) ?

2015-07-12 Thread Larry Hudson via Python-list
On 07/12/2015 05:48 AM, Simon Evans wrote: Dear Peter Otten, Yes, I have been copying and pasting, as it saves typing. I do get 'indented block' error responses as a small price > to pay for the time and energy thus saved. > You CANNOT ignore indenting. Indenting is NOT optional, it is REQUIRED

Re: Using Python instead of Bash

2015-06-01 Thread Larry Hudson via Python-list
On 05/31/2015 05:42 AM, Cecil Westerhof wrote: I help someone that has problems reading. For this I take photo's of text, use convert from ImageMagick to make a good contrast (original paper is grey) and use lpr to print it a little bigger. I''m wondering why you bother to take a photo, which th

Re: Where is 'palindrome' defined?

2015-06-01 Thread Larry Hudson via Python-list
On 05/31/2015 09:46 PM, fl wrote: Hi, When I search solution of reverse a string/number, I came across a short function online: def palindrome(num): return str(num) == str(num)[::-1] I thought that it is a general function. And with the following variable: a '1234_' parlindr

Re: seek operation in python

2015-04-30 Thread Larry Hudson
On 04/30/2015 01:50 PM, Cecil Westerhof wrote: Op Thursday 30 Apr 2015 21:38 CEST schreef Larry Hudson: On 04/30/2015 01:06 AM, Cecil Westerhof wrote: [snip] I wrote a module where I have: def get_indexed_message(message_filename, index): """ Get index message from a file, w

Re: seek operation in python

2015-04-30 Thread Larry Hudson
On 04/30/2015 01:06 AM, Cecil Westerhof wrote: [snip] I wrote a module where I have: def get_indexed_message(message_filename, index): """ Get index message from a file, where 0 gets the first message """ return open(expanduser(message_filename), 'r').r

Re: New to Python - block grouping (spaces)

2015-04-17 Thread Larry Hudson
On 04/17/2015 07:22 PM, Ben Finney wrote: BartC writes: (Actually *I* would quite like to know why languages don't have switchable syntax anyway to allow for people's personal preferences.) Which people's personal preferences? Are these the same people who have such passionate disagreement a

Re: Supply condition in function call

2015-03-27 Thread Larry Hudson
On 03/26/2015 06:56 PM, Chris Angelico wrote: On Fri, Mar 27, 2015 at 12:41 PM, Rustom Mody wrote: [snip] After selecting the line above [inside python inside help(filter) ]for cut-pasting here, by mistake I pressed Ctrl-C rather than Ctrl-Shift-C An exception was thrown and the terminal remai

Re: Sudoku solver

2015-03-27 Thread Larry Hudson
On 03/27/2015 07:09 AM, Dave Angel wrote: [snip] I know, let's use "regular expressions" This is totally OT, but... There was a recent (2015-03-23) item on The Daily WTF web site concerning regular expressions. Take a look at http://thedailywtf.com/articles/regularly-expressing-hate

Re: subprocess command fails

2015-02-21 Thread Larry Hudson
On 02/20/2015 08:47 PM, Brad s wrote: [...] print("command = %r" % (cmdargv,)) sfmove = subprocess.call(cmdargv) also, is the % to Python what precision is to C++? No. It is like the % in C's printf(). -=- Larry -=- -- https://mail.python.org/mailman/listinfo/python-list

Re: Sort of Augmented Reality

2015-01-30 Thread Larry Hudson
On 01/29/2015 06:55 PM, Rustom Mody wrote: [snip...] Like smelly cheese and classical music, math is an acquired taste. Actually enjoyable once you get past the initiation This comment is OT, irrelevant and only about myself... I found the appreciation of classical music instinctive and immed

Re: How modules work in Python

2014-11-18 Thread Larry Hudson
On 11/18/2014 12:59 PM, sohcahto...@gmail.com wrote: On Tuesday, November 18, 2014 12:14:15 AM UTC-8, Larry Hudson wrote: First, I'll repeat everybody else: DON'T TOP POST!!! On 11/16/2014 04:41 PM, Abdul Abdul wrote: Dave, Thanks for your nice explanation. For your answer on

Re: How modules work in Python

2014-11-18 Thread Larry Hudson
First, I'll repeat everybody else: DON'T TOP POST!!! On 11/16/2014 04:41 PM, Abdul Abdul wrote: Dave, Thanks for your nice explanation. For your answer on one of my questions: *Modules don't have methods. open is an ordinary function in the module.* Isn't "method" and "function" used interch

Re: Understanding "help" command description syntax - explanation needed

2014-11-05 Thread Larry Hudson
On 11/05/2014 03:00 AM, Ivan Evstegneev wrote: Hello everyone, I’m a Python beginner and just getting familiar with it. (I need it for my EE B.Sc. project) For the learning purposes I use IDLE and (Learning Python by written by Mark Lutz). Let’s say that I have some earlier experience with C l

Re: Classes

2014-11-02 Thread Larry Hudson
On 11/02/2014 01:50 AM, Denis McMahon wrote: [snip] from math import sqrt class SquareGeometryError(Exception): """The parameters create an illegal geometry for a square""" pass class Rectangle: def __init__(self,length,width): self.length=length self.width=wid

Re: Classes

2014-10-30 Thread Larry Hudson
On 10/30/2014 01:16 PM, Seymore4Head wrote: class pet: def set_age(self,age): self.age=age def get_age(self): return self.age pax=pet pax.set_age(4) Traceback (most recent call last): File "C:\Functions\test.py", line 18, in pax.set_age(4) TypeError: set_age(

Re: I am out of trial and error again Lists

2014-10-24 Thread Larry Hudson
On 10/24/2014 12:07 PM, Seymore4Head wrote: On Fri, 24 Oct 2014 19:40:39 +0100, Mark Lawrence How many more times, state what you expect to happen and what actually happens. "doesn't work" is useless. Please read this http://sscce.org/ Good suggestion. OK how is this? It doesn't print wha

Re: I am out of trial and error again Lists

2014-10-24 Thread Larry Hudson
On 10/24/2014 09:37 AM, Seymore4Head wrote: import string Not needed, delete it. def nametonumber(name): lst=[] nx=[] digit=[] Not needed. You create digit as an empty list, them immediately follow by assigning a string to it (NOT a _list_ of characters, but an actual string

  1   2   >