Re: [Tutor] Collating date data from a csv file

2019-05-14 Thread Dave Hill
Something else to have a look at, but it might have to wait for the longer winter nights :-) On 14/05/2019 06:20, Ben Hancock via Tutor wrote: On Sun, May 12, 2019 at 07:17:53PM +0100, Alan Gauld via Tutor wrote: On 12/05/2019 11:27, Dave Hill wrote: I found out by accident that the Megger

Re: [Tutor] Collating date data from a csv file

2019-05-12 Thread Dave Hill
for writing to an ODS spreadsheet. Having seen todays posts I am going to look at wxPython, as a front-end (and possibly display?) Thank you for your consideration Dave On 12/05/2019 04:20, David L Neil wrote: Hi Dave, I also volunteer to do PAT safety testing during my "20% time&qu

Re: [Tutor] Collating date data from a csv file

2019-05-09 Thread Dave Hill
Gregorian ordinal of the date 8-) ( I had to look up what proleptic meant) This means I can access the elements by the ordinal of the date, for later processing, and extraction to a spreadsheet Dave On 09/05/2019 04:08, Cameron Simpson wrote: On 08May2019 21:04, Dave Hill wrote: I have a csv

[Tutor] Collating date data from a csv file

2019-05-08 Thread Dave Hill
count numbers tested on each date. Can I have a list of tuples, where one item is the date and the second the count? or is there a better construct? Thanks in advance, Dave For completeness, I have listed below an extract from a target file, where the 10 digit number is the UNIX timestamp 182

Re: [Tutor] systemd

2019-03-03 Thread Dave Hill
Thank you - registering with Linux Mint On 03/03/2019 16:01, Alan Gauld via Tutor wrote: On 03/03/2019 14:46, Dave Hill wrote: on power up, and I thought that I would use 'systemd'. This is really a Linux question not Python so you might like to try the Mint forums too. They a

[Tutor] systemd

2019-03-03 Thread Dave Hill
ram using: [Unit] Description=TestVideo Service After=multi-user.target [Service] Type=idle User=pi ExecStart=/bin/bash /home/pi/Code/testVideo.sh Restart=no RestartSec=0 [Install] WantedBy=multi-user.target where 'testVideo.sh' ## Dave Hill, 28/02/2019

Re: [Tutor] subprocess.Popen()

2018-12-03 Thread Dave Hill
asPi forum. Thank you. Dave On 03/12/2018 16:27, Mats Wichmann wrote: On 12/2/18 3:29 AM, Dave Hill wrote: Having 'graduated' to Python 3.7, I thought I would explore subprocess.Popen, and put the code in a Class, see code below. The video runs, but an error occurs, which I do

Re: [Tutor] subprocess.Popen()

2018-12-03 Thread Dave Hill
I had not spotted that! It appears that, although I have 3.7 on my laptop, 3.7 is not a part of the latest standard Raspbian release. I will install this later today and try again. Dave On 03/12/2018 10:12, Alan Gauld via Tutor wrote: On 02/12/2018 10:29, Dave Hill wrote: Having 'grad

[Tutor] subprocess.Popen()

2018-12-02 Thread Dave Hill
I am a volunteer at a Heritage Railway in N.Wales and, amongst other things, I provide electronics and software for various exhibits in the museum. I use the Raspberry Pi to provide various video presentations, employing the omxplayer. I am in the process of updating an application known as th

[Tutor] Is there a better way

2018-11-07 Thread Dave Hill
ta(self, sheet, roomNum):         .         .     groupID = self.get_TestGroup(group) This works but feels 'clumpy', and I have a feeling that there is a better way, but I have run out of ideas. I am running Python 3.7.0, on a Windows 10 PC Thank you for any assistance Dave ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Problem compiling code from GitHub

2018-09-02 Thread Dave Hill
st attempt at the latter steps was thwarted by some path problem re. Windows? On 29/08/2018 14:04, Oscar Benjamin wrote: On Mon, 27 Aug 2018 at 13:18, Dave Hill wrote: I have found 'odswriter' on GitHub https://github.com/mmulqueen/odswriter which appears to provide what I want. Howev

Re: [Tutor] Problem compiling code from GitHub

2018-08-28 Thread Dave Hill
I did as suggested but with the same result. I am now looking at extracting the code from the the separate files to form a single module, and hopefully get a result. On 27/08/2018 14:14, Steven D'Aprano wrote: Hi Dave, and welcome! On Mon, Aug 27, 2018 at 12:14:33PM +0100, Dave Hill

[Tutor] Problem compiling code from GitHub

2018-08-27 Thread Dave Hill
a what the following extract means, and searching online on & off for two days has proved unfruitful. from __future__ import unicode_literals from zipfile import ZipFile import decimal import datetime from xml.dom.minidom import parseString from . import ods_components f

Re: [Tutor] Recommendations for best tool to write/run Python

2016-03-02 Thread Dave P
On Wed, Mar 2, 2016 at 1:26 PM, Lisa Hasler Waters wrote: > Hello everyone, > > I am new to Python, as are my middle school students. We are using Python > 3.5.1 IDLE to write and run our (simple) code. However, this tool does not > seem to be the best way to write longer code or to be able to re-

Re: [Tutor] unittest not working

2015-11-19 Thread Dave P
On Thu, Nov 19, 2015 at 8:25 AM, Mike wrote: > I'm trying to unit test a self-built regular expression processor for an > assignment. I'm trying to set up unit tests for the package, but it's not > executing them. This is my first time trying to use the unittest module, so > I'm sure I'm missing

Re: [Tutor] Design question: Web-based vs. desktop-based vs. desktop-based with data backed up to web server with a tablet thrown in for all cases?

2015-07-19 Thread Dave P
reporting (using Python, of course!) I'll be glad to help you and your wife off-list if you'd like some pointers. Good luck! Dave ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] split a string inside a list

2015-05-09 Thread Dave Angel
On 05/09/2015 04:13 AM, Alan Gauld wrote: On 09/05/15 04:24, Kayla Hiltermann wrote: i want to account for variability in user input, > like using commas or just spaces. the user input is initially a string, but is converted to a list once > run through .split() . > I would like to split

Re: [Tutor] pointer puzzlement

2015-05-08 Thread Dave Angel
On 05/08/2015 06:26 PM, Alan Gauld wrote: On 08/05/15 19:10, Jim Mooney Py3.4.3winXP wrote: On 7 May 2015 at 18:42, Dave Angel wrote: Python doesn't have pointers So what is the difference between a python name and a pointer? OK, This could get deepo. Lets start with the supoerf

Re: [Tutor] formatting strings

2015-05-08 Thread Dave Angel
On 05/07/2015 02:57 PM, Tudor, Bogdan - tudby001 wrote: Hi, This is my first time. First time doing what? Presumably the first time on this forum. But what is your history of using Python, or of programming in general? I am using python 3.4.3 on windows 7 64bit. I am trying to make a bi

Re: [Tutor] pointer puzzlement

2015-05-08 Thread Dave Angel
On 05/08/2015 02:10 PM, Jim Mooney Py3.4.3winXP wrote: On 7 May 2015 at 18:42, Dave Angel wrote: Python doesn't have pointers So what is the difference between a python name and a pointer? I'm a bit fuzzy on that. What's the difference between a painting of Obama and

Re: [Tutor] introspection

2015-05-08 Thread Dave Angel
On 05/08/2015 02:26 AM, Alex Kleider wrote: On 2015-05-07 20:45, Dave Angel wrote: You also only showed it working on module globals. (For code at top-level, locals() returns the same as globals() ) You could also try it inside functions, where locals() really makes sense as a name. And you

Re: [Tutor] introspection

2015-05-07 Thread Dave Angel
On 05/07/2015 11:23 PM, Alex Kleider wrote: On 2015-05-07 19:10, Dave Angel wrote: def get_name(localmap, item): """As suggested. Returns 'a' name, not necessarily 'the' name.""" for name in localmap: if localmap[

Re: [Tutor] introspection

2015-05-07 Thread Dave Angel
On 05/07/2015 09:50 PM, Alex Kleider wrote: On 2015-04-21 16:48, Cameron Simpson wrote: But it would not be schizophrenic to write a function that returned a name arbitrarily, by inspecting locals(). It depends whether you only need a name, or if you need "the" name. Write yourself a "find_nam

Re: [Tutor] pointer puzzlement

2015-05-07 Thread Dave Angel
On 05/07/2015 07:51 PM, Dave Angel wrote: On 05/07/2015 04:54 PM, Jim Mooney Py3.4.3winXP wrote: On 7 May 2015 at 13:03, Emile van Sebille wrote: Compare to: def testid(K=100): K += 10 return 'the ID is', id(K), K Ah, thanks. I forgot small integers are saved

Re: [Tutor] pointer puzzlement

2015-05-07 Thread Dave Angel
On 05/07/2015 05:25 PM, Alan Gauld wrote: On 07/05/15 21:54, Jim Mooney Py3.4.3winXP wrote: Ah, thanks. I forgot small integers are saved in a table. I was looking at a demo that pointers to defaults in function parameters are persistent. But remember they variables are NOT pointers. They are

Re: [Tutor] pointer puzzlement

2015-05-07 Thread Dave Angel
On 05/07/2015 04:54 PM, Jim Mooney Py3.4.3winXP wrote: On 7 May 2015 at 13:03, Emile van Sebille wrote: Compare to: def testid(K=100): K += 10 return 'the ID is', id(K), K Ah, thanks. I forgot small integers are saved in a table. I was looking at a demo that pointers to def

Re: [Tutor] pointer puzzlement

2015-05-07 Thread Dave Angel
On 05/07/2015 03:15 PM, Jim Mooney Py3.4.3winXP wrote: I find this a bit confusing. Since the ID of K remains the same, so it's the same object, why isn't it increasing each time. i.e, 20, 30, 40,. I understand that it's immutable but doesn't that mean K is created each time in local scope so it

Re: [Tutor] pointer puzzlement

2015-05-07 Thread Dave Angel
On 05/07/2015 04:03 PM, Emile van Sebille wrote: On 5/7/2015 12:15 PM, Jim Mooney Py3.4.3winXP wrote: I find this a bit confusing. Since the ID of K remains the same, so it's the same object, why isn't it increasing each time. i.e, 20, 30, 40,. I understand that it's immutable but doesn't that m

Re: [Tutor] key detection

2015-05-06 Thread Dave Angel
On 05/06/2015 01:41 PM, Jim Mooney Py3.4.3winXP wrote: from msvcrt import * while True: if kbhit(): key = getch() if key == b'\xe0' or key == b'\000': print('special key follows') key = getch() print(str(key, encoding='utf-8')) #got

Re: [Tutor] Fwd: Re: Adding consecutive numbers

2015-05-06 Thread Dave Angel
On 05/06/2015 07:51 AM, Alan Gauld wrote: Please use ReplyAll to include the list members. Forwarded Message Subject: Re: [Tutor] Adding consecutive numbers Date: Wed, 6 May 2015 21:13:15 +1000 From: Whom Isac To: Alan Gauld Thanks for the reply. I am sorr

Re: [Tutor] key detection

2015-05-06 Thread Dave Angel
On 05/06/2015 12:02 AM, Jim Mooney Py3.4.3winXP wrote: actually worked in windows instead of using their awful screen copy. What a surprise: Many people don't realize that you can turn on a better screen copy feature for the CMD window (DOS box) in Windows. I've given up Windows, and no lon

Re: [Tutor] Object references and garbage collection confusion

2015-05-05 Thread Dave Angel
On 05/05/2015 12:29 AM, Brandon D wrote: Hello tutors, I'm having trouble understanding, as well as visualizing, how object references work in the following situation. For demonstration purposes I will keep it at the most rudimentary level: x = 10 x = x ** x If my knowledge serves me correct

Re: [Tutor] Sieve of Erastthotenes without sofisticated tools

2015-05-04 Thread Dave Angel
mailer to use text. On 05/04/2015 10:07 PM, yvan moses levy wrote:> Le 04/05/15 13:00, Dave Angel a écrit : >> On 05/04/2015 03:19 AM, yvan moses Levy wrote: >>> My code is wrong! >> >> You'd find it a lot easier to get responses if you'd say in what wa

Re: [Tutor] Python program malfunction

2015-05-04 Thread Dave Angel
On 05/04/2015 07:08 PM, Jag Sherrington wrote: Hi, Alan> Please don't top-post. Enter your new message *after* whatever portion of the previous message you're quoting. I'm rearranging the portion of your message to conform to that standard. On Monday, 4 May 2015, 17:35, Alan Ga

Re: [Tutor] Sieve of Erastthotenes without sofisticated tools

2015-05-04 Thread Dave Angel
On 05/04/2015 03:19 AM, yvan moses Levy wrote: My code is wrong! You'd find it a lot easier to get responses if you'd say in what way the code is wrong. If you get an exception, show the full traceback. If you get printed results, show what you expected, and what you got instead. If it hu

Re: [Tutor] Having Unusual results

2015-05-02 Thread Dave Angel
On 05/02/2015 04:36 AM, Peter Otten wrote: Jag Sherrington wrote: With that the calculation becomes buns = 20 package_size = 8 whole_packages, missing_buns = divmod(buns, package_size) total_packages = whole_packages if missing_buns: total_packages += 1 ... total_packages 3 And that can b

Re: [Tutor] Newbie problems

2015-05-02 Thread Dave Angel
1) Please reply-list, or if your email program doesn't support that, do a reply-all. The idea is to make sure tutor@python.org is in your To: field. Otherwise you're just leaving private messages, and that's not what a public forum like this is about. 2) Please use text email, not html. As

Re: [Tutor] Good Taste Question: Using SQLite3 in Python

2015-04-30 Thread Dave Angel
On 04/30/2015 03:22 PM, Roel Schroeven wrote: Alan Gauld schreef op 2015-04-30 00:51: > ... Trying to visually scan for _ or even __ is hard. Also different fonts make _ and __ hard to distinguish. > ... But they will be. Almost for certain. It's human nature and the nature of code maint

Re: [Tutor] Newbie problems

2015-04-30 Thread Dave Angel
On 04/29/2015 11:58 PM, Jag Sherrington wrote: Can anyone please tell me what I am doing wrong?As this code I have for the Roulette Wheel colours exercise, won't work. number = int(input('Enter a number between 0 and 36: '))green_number = (0) red_number = (1, 3, 5, 7, 9, 12, 14, 16, 18, 19, 21

Re: [Tutor] How to use Git from Windows PC for files on Solaris machine where Git cannot be installed?

2015-04-29 Thread Dave Angel
On 04/30/2015 12:28 AM, boB Stepp wrote: The main danger as I see it is that if I am not careful, then the code on the dev environment could diverge from the state of code on my Windows PC, i.e., I forgot to do the scp part. But when I am actively working on a section of code I always insert a fe

Re: [Tutor] raise exception works as planned in program but not when imported into testing module

2015-04-29 Thread Dave Angel
On 04/29/2015 09:05 PM, Jim Mooney Py3.4.3winXP wrote: I raised an exception in the parse_string function in my math parser program, function_tosser.py, and caught it in the calling routine, and that worked fine. But when I imported function_tosser.py into a test program, tester.py, it threw the

Re: [Tutor] Fwd: circular movement in pygame

2015-04-29 Thread Dave Angel
On 04/29/2015 02:37 PM, diliup gabadamudalige wrote: I do not understand how Alan does not get the code that is in this thread. There are at least 3 ways of posting to "this thread": A) email B) newsgroup C) googlegroups and at least 5 ways of looking at "this thread" A) email B

Re: [Tutor] subprocess.Popen(..., cwd) and UNC paths

2015-04-29 Thread Dave Angel
On 04/29/2015 08:47 AM, Albert-Jan Roskam wrote: Hello, Windows has the 'feature' that the CD command does not work with UNC paths. So in the code below, I cannot use the 'cwd' parameter of subprocess.Popen. Therefore I use pushd/popd to accomplish the same effect. Is there a better way to do t

Re: [Tutor] circular movement in pygame

2015-04-29 Thread Dave Angel
On 04/29/2015 03:15 AM, diliup gabadamudalige wrote: Thanks all for the responses. Charles Cossé - yes I can write a simple pygame program that makes a sprite move in a circle but it may not be the style and order that many may approve or accept. I consider myself a student. :) No one has pointe

Re: [Tutor] if then statements

2015-04-29 Thread Dave Angel
On 04/28/2015 09:24 PM, Jacqueline G Solis wrote: hello, I keep getting a syntax error. Could you please explain why that happens and how to correct it. def main (): print( "Welcome to Gonzo Burger!") order= int(input("Enter 1 if you want a hamburger,\ or 2 if you want a cheese

Re: [Tutor] Fwd: circular movement in pygame

2015-04-28 Thread Dave Angel
On 04/28/2015 02:37 PM, diliup gabadamudalige wrote: I thank all those who responded to my question Here is the code that I had written. When updating is applied to a surface object the rotation works but when it is applied through a class to an object it goes wrong in about 3 rotations. As far

Re: [Tutor] Adding consecutive numbers

2015-04-27 Thread Dave Angel
On 04/27/2015 06:37 AM, Whom Isac wrote: Hi, I am trying to build a python mini program to solve a math problem . I wanted my program to ask two number from the operator and it can add those number as a integer but as consecutive number in range. For example, if num1 entry =1 & num2 entry = 100 ,

Re: [Tutor] Please disable “digest mode” before participating

2015-04-26 Thread Dave Angel
On 04/26/2015 08:07 AM, Ben Finney wrote: Jim Mooney writes: On 25 April 2015 at 18:03, Ben Finney wrote: Digest mode should only ever be used if you know for certain you will never be responding to any message. That brings up a great shortcut if you use gmail. If you select some text bef

Re: [Tutor] name shortening in a csv module output

2015-04-24 Thread Dave Angel
On 04/24/2015 07:34 PM, Jim Mooney wrote: Apparently so. It looks like utf_8-sig just ignores the sig if it is present, and uses UTF-8 whether the signature is present or not. That surprises me. -- Steve I was looking things up and although there are aliases for utf_8 (utf8 and

Re: [Tutor] name shortening in a csv module output

2015-04-23 Thread Dave Angel
On 04/23/2015 05:08 PM, Mark Lawrence wrote: Slight aside, why a BOM, all I ever think of is Inspector Clouseau? :) As I recall, it stands for "Byte Order Mark". Applicable only to multi-byte storage formats (eg. UTF-16), it lets the reader decide which of the formats were used. For exa

Re: [Tutor] name shortening in a csv module output

2015-04-23 Thread Dave Angel
On 04/23/2015 02:14 PM, Jim Mooney wrote: By relying on the default when you read it, you're making an unspoken assumption about the encoding of the file. -- DaveA So is there any way to sniff the encoding, including the BOM (which appears to be used or not used randomly for utf-8), so you c

Re: [Tutor] name shortening in a csv module output

2015-04-23 Thread Dave Angel
On 04/23/2015 06:37 AM, Jim Mooney wrote: .. Ï»¿ is the UTF-8 BOM (byte order mark) interpreted as Latin 1. If the input is UTF-8 you can get rid of the BOM with with open("data.txt", encoding="utf-8-sig") as csvfile: Peter Otten I caught the bad arithmetic on name length, but where is t

Re: [Tutor] enhanced subtration in an exponent

2015-04-21 Thread Dave Angel
On 04/20/2015 08:44 PM, Jim Mooney wrote: Why does the compiler choke on this? It seems to me that the enhanced subtraction resolves to a legitimate integer in the exponent, but I get a syntax error: B = '11011101' sum = 0 start = len(B) for char in B: sum += int(char) * 2**(start -= 1) ##

Re: [Tutor] introspection

2015-04-21 Thread Dave Angel
On 04/21/2015 01:21 AM, Danny Yoo wrote: What's supposed to happen in this situation? ## class Person(object): def __init__(self): pass j = Person() john = j jack = j ## What single name should we get back fr

Re: [Tutor] bin to dec conversion puzzlement

2015-04-20 Thread Dave Angel
On 04/20/2015 04:15 PM, Jim Mooney wrote: The key is that the result gets multiplied by 2 each time so for an N bit number the leftmost digit winds up being effectively 2**N, which is what you want. Alan G Ah, the light dawns once it was restated. It would be even simpler if you could

Re: [Tutor] lists, name semantics

2015-04-19 Thread Dave Angel
On 04/19/2015 06:28 PM, Joel Goldstick wrote: On Sun, Apr 19, 2015 at 6:23 PM, boB Stepp wrote: On Sun, Apr 19, 2015 at 4:05 PM, Dave Angel wrote: On 04/19/2015 03:08 PM, boB Stepp wrote: Or is the real point that we are adding an abstraction layer so we don't even have to think

Re: [Tutor] lists, name semantics

2015-04-19 Thread Dave Angel
On 04/19/2015 03:08 PM, boB Stepp wrote: On Sun, Apr 19, 2015 at 6:47 AM, Dave Angel wrote: On 04/19/2015 12:07 AM, boB Stepp wrote: [...] I hope this is helpful, and, if there are any misstepps, that when they are revealed both of our understandings will be enhanced! Some of your

Re: [Tutor] lists, name semantics

2015-04-19 Thread Dave Angel
On 04/19/2015 12:07 AM, boB Stepp wrote: . Before Peter changed one of these changeable objects, he had: a = [1, ["x", "y"], 3] b = a[:] Now BOTH a[1] and b[1] now identify the location of the inner list object, ["x", "y"] . Apparently, Python, in its ever efficient memory management fash

Re: [Tutor] How (not!) lengthy should functions be?

2015-04-18 Thread Dave Angel
On 04/18/2015 03:01 PM, boB Stepp wrote: As I final note I want to emphasize that I am not writing a program to *create* a treatment plan. Nor am I writing a program that can *alter* an existing treatment plan. It is merely reading output from the treatment plan and evaluating that output agains

Re: [Tutor] lists, name semantics

2015-04-17 Thread Dave Angel
On 04/17/2015 11:51 PM, Ben Finney wrote: Ben Finney writes: Bill Allen writes: If I have a list defined as my_list = ['a','b','c'], what is the is differnce between refering to it as my_list or my_list[:]? ‘my_list’ is a reference to the object you've already described (the existing obje

Re: [Tutor] Unicode encoding and raw_input() in Python 2.7 ?

2015-04-17 Thread Dave Angel
On 04/17/2015 04:39 AM, Samuel VISCAPI wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA256 Hi, This is my first post to that mailing list if I remember correctly, so hello everyone ! Welcome to the list. I've been stuck on a simple problem for the past few hours. I'd just like raw_input

Re: [Tutor] Fraction - differing interpretations for number and string - presentation

2015-04-16 Thread Dave Angel
On 04/16/2015 01:24 PM, Jim Mooney wrote: Is this "inaccurate"? Well, in the sense that it is not the exact true mathematical result, yes it is, but that term can be misleading if you think of it as "a mistake". In another sense, it's not inaccurate, it is as accurate as possible (given the limi

Re: [Tutor] Fraction - differing interpretations for number and string

2015-04-16 Thread Dave Angel
On 04/16/2015 08:11 AM, Dave Angel wrote: On 04/16/2015 01:03 AM, Jim Mooney wrote: Why does Fraction interpret a number and string so differently? They come out the same, but it seems rather odd from fractions import Fraction Fraction(1.64) Fraction(738590337613, 4503599627370496

Re: [Tutor] Fraction - differing interpretations for number and string

2015-04-16 Thread Dave Angel
On 04/16/2015 01:03 AM, Jim Mooney wrote: Why does Fraction interpret a number and string so differently? They come out the same, but it seems rather odd from fractions import Fraction Fraction(1.64) Fraction(738590337613, 4503599627370496) Fraction("1.64") Fraction(41, 25) 41/25 1.64

Re: [Tutor] Reference last email message...

2015-04-15 Thread Dave Angel
On 04/15/2015 07:47 PM, Ken G. wrote: I just emailed that I was unable to correct a message in ModTools so I went to Yahoo and made the change and then approved it. Noticing it did not appear on the list, I checked the Activity Log in Yahoo and it was marked Bounced! Several days ago, we had an

Re: [Tutor] Changing a string number to another number

2015-04-15 Thread Dave Angel
On 04/15/2015 08:21 AM, Ken G. wrote: When running the following code, I get the following error code: 201504110102030405061 Traceback (most recent call last): File "Mega_Millions_Tickets_Change.py", line 11, in datecode[20:21] = "0" TypeError: 'str' object does not support item assignm

Re: [Tutor] Function not returning 05 as string

2015-04-13 Thread Dave Angel
On 04/13/2015 08:11 AM, Ken G. wrote: I am sure there is an simple explanation but when I input 5 (as integer), resulting in 05 (as string), I get zero as the end result. When running the code: START OF PROGRAM: Enter the 1st number: 5 05 0 END OF PROGRAM: START OF CODE: import sys def numb

Re: [Tutor] Why is it invalid syntax to have a particular dictionary value as an argument?

2015-04-08 Thread Dave Angel
On 04/07/2015 10:16 PM, boB Stepp wrote: Despite Mark's warning, I feel I must see if I understand what is going on here. Switching to Py 3.4 since I am now at home: Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:44:40) [MSC v.1600 64 bit (AMD64)] on win32 Type "copyright", "credits" or "l

Re: [Tutor] Why is it invalid syntax to have a particular dictionary value as an argument?

2015-04-06 Thread Dave Angel
On 04/06/2015 03:20 PM, Emile van Sebille wrote: On 4/6/2015 7:54 AM, boB Stepp wrote: Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. d = {'n': 'Print me!'} d {'n': 'Print me!'} d['n'] 'Print

Re: [Tutor] Why is it invalid syntax to have a particular dictionary value as an argument?

2015-04-06 Thread Dave Angel
On 04/06/2015 12:43 PM, boB Stepp wrote: I was breaking down longer functions into smaller ones. Along the way I noticed I was passing an entire dictionary from one function to another. I only needed to pass one particular value, not the whole dictionary, so that is how I got into the issue I a

Re: [Tutor] Why is it invalid syntax to have a particular dictionary value as an argument?

2015-04-06 Thread Dave Angel
On 04/06/2015 10:54 AM, boB Stepp wrote: Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. d = {'n': 'Print me!'} d {'n': 'Print me!'} d['n'] 'Print me!' def func(d['n']): SyntaxError: invalid

Re: [Tutor] Functional Programming in Python

2015-04-04 Thread Dave Angel
On 04/04/2015 09:53 PM, WolfRage wrote: (Pointing to the different classes. Since C++ has virtual methods but Python does not?) I'd say that all methods in Python are virtual, except for those which are classmethod or staticmethod. -- DaveA _

Re: [Tutor] Use of "or" in a lambda expression

2015-04-04 Thread Dave Angel
On 04/04/2015 05:57 PM, boB Stepp wrote: On Sat, Apr 4, 2015 at 3:35 PM, Alan Gauld wrote: He could have done it in various other ways too: eg. lambda : all(print('Hello lambda world!'), sys.exit() ) Is this what you meant? Because print will always return False. Or did you actually mean: l

Re: [Tutor] Request review: A DSL for scraping a web page

2015-04-02 Thread Dave Angel
On 04/02/2015 03:49 PM, Albert-Jan Roskam wrote: - On Thu, Apr 2, 2015 1:17 PM CEST Alan Gauld wrote: On 02/04/15 12:09, Dave Angel wrote: Ah, Jon Bentley (notice the extra 'e'). I should dig out my *Pearls books, and have a trip down memory lane. I

Re: [Tutor] New to Programming: TypeError: coercing to Unicode: need string or buffer, list found

2015-04-02 Thread Dave Angel
On 04/02/2015 08:28 AM, Saran Ahluwalia wrote: Good Morning: I understand this error message when I run this code. However, I am curious to know what the most pythonic way is to convert the list to a string? I use Python 2.7. "Traceback (most recent call last): before = dict([(f, None) for f i

Re: [Tutor] Request review: A DSL for scraping a web page

2015-04-02 Thread Dave Angel
On 04/02/2015 07:17 AM, Alan Gauld wrote: On 02/04/15 12:09, Dave Angel wrote: Ah, Jon Bentley (notice the extra 'e'). I should dig out my *Pearls books, and have a trip down memory lane. I bet 95% of those are still useful, even if they refer to much earlier versions of language

Re: [Tutor] Request review: A DSL for scraping a web page

2015-04-02 Thread Dave Angel
On 04/02/2015 06:41 AM, Alan Gauld wrote: On 02/04/15 10:50, Dave Angel wrote: On 04/02/2015 04:22 AM, Alan Gauld wrote: DSL? This is "Domain Specific Language". This is a language built around a specific problem domain, Ah, Thanks Dave! I am used to those being called simp

Re: [Tutor] Request review: A DSL for scraping a web page

2015-04-02 Thread Dave Angel
On 04/02/2015 04:22 AM, Alan Gauld wrote: DSL? This is "Domain Specific Language". This is a language built around a specific problem domain, in order to more easily express problems for that domain than the usual general purpose languages. I was a bit surprised to find few google matche

Re: [Tutor] Python Idioms?

2015-04-01 Thread Dave Angel
On 04/01/2015 12:50 AM, Jim Mooney wrote: I'm looking at this and can't see how it works, although I understand zipping and unpacking. The docs say it's a Python idiom. Does "idiom" mean it works in a special way so I can't figure it out from basic principles? It looks to me like the iterator in

Re: [Tutor] Unexpected results using enumerate() and .split()

2015-03-31 Thread Dave Angel
On 03/31/2015 04:23 PM, boB Stepp wrote: The following behavior has me stumped: Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. L = ['#ROI:roi_0', '#TXT:text_0', '#1:one^two^three'] for i, item i

Re: [Tutor] Dynamic naming of lists

2015-03-31 Thread Dave Angel
On 03/31/2015 10:00 AM, Ian D wrote: Hi I have a list that I am splitting into pairs of values. But the list is dynamic in size. It could have 4 values or 6 or more. I originally split the list into pairs, by using a new list and keep a pair in the old list by just popping 2 values. But if th

Re: [Tutor] trying to convert pycurl/html to ascii

2015-03-29 Thread Dave Angel
On 03/29/2015 09:49 PM, bruce wrote: Hi. Doing a quick/basic pycurl test on a site and trying to convert the returned page to pure ascii. You cannot convert it to pure ASCII. You could replace all the invalid characters with some special one, like question marks. But I doubt if that's what

Re: [Tutor] What is wrong with my code?

2015-03-29 Thread Dave Angel
On 01/23/2015 04:40 PM, Antonia van der Leeuw wrote: Hehey! I'm learning python on a website called codecademy.com, where I made a program to decode binary numbers. I guess the site uses a different compiler, because on the site my code worked fine, but when I copied and pasted it into the Pytho

Re: [Tutor] Python OO

2015-03-29 Thread Dave Angel
On 03/28/2015 09:16 PM, Juan C. wrote: Ok, so, let me try to express what I think is 'right' here according to what you said. My code structure needs to be something like that: pycinema - package: pycinema - - __init__.py - - api.py - - actor.py - - movie.py - - serie.py - __main__.py I'd su

Re: [Tutor] escape character regex

2015-03-28 Thread Dave Angel
On 03/28/2015 03:37 PM, Ian D wrote: Hi I run a regex like this: pchars = re.compile('\x00\x00\x00') #with or without 'r' for raw Which one did you actually want? The 3 byte sequence consisting of nulls, or the 12 byte one containing zeroes and backslashes? I'm going to assume the form

Re: [Tutor] List comprehensions to search a list--amazing!

2015-03-23 Thread Dave Angel
On 03/23/2015 10:17 PM, Dave Angel wrote: On 03/23/2015 09:42 PM, boB Stepp wrote: Not really. See Steve's OOPS. Peter's > response for some numbers. If I had to guess, I'd say that for lists over 100 items, you should use bisect or equivalent. But I'd also

Re: [Tutor] List comprehensions to search a list--amazing!

2015-03-23 Thread Dave Angel
On 03/23/2015 09:42 PM, boB Stepp wrote: On Thu, Mar 19, 2015 at 12:10 AM, Dave Angel wrote: The catch to a list comprehension is it has to visit all the elements, while a binary search would visit log-base-2 of them. So instead of 1 elements, you'd be searching about 14 items

Re: [Tutor] Reversi Game Logic

2015-03-20 Thread Dave Angel
On 03/20/2015 06:20 PM, niyanax...@gmail.com wrote: Thank you Danny Yoo for replying. I figured out what to do for the isLegalMove but I ran into another problem. I now get a traceback error every chip is black. This is the traceback: Traceback (most recent call last): File "C:\Python34\l

Re: [Tutor] Reversi Game Logic

2015-03-20 Thread Dave Angel
On 03/20/2015 01:28 PM, niyanax...@gmail.com wrote: You have more than one copy of some lines of previous messages, and more than one version of code in the message. So I have to guess which one you intend to be current. Thank you Mark for replying. I fixed the note you provided on the

Re: [Tutor] Reversi Game Logic

2015-03-20 Thread Dave Angel
On 03/19/2015 08:50 PM, niyanax...@gmail.com wrote: I am having trouble with a function in my reversi logic code. The function is the isLegalMove I am asked to "Return a Boolean indicating if the current player can place their chip in the square at position (row, col). Both row and col must be

Re: [Tutor] List comprehensions to search a list--amazing!

2015-03-18 Thread Dave Angel
On 03/19/2015 12:20 AM, boB Stepp wrote: I hope extolling the beauty and power of Python on this list is allowed, because I have had a large "WOW!!!" moment tonight. I had a problem I was working on at work this afternoon. I have a list of ~ 10,000 floating point numbers, which run from largest t

Re: [Tutor] using json to pass a dict thru a file

2015-03-17 Thread Dave Angel
On 03/17/2015 06:30 PM, Doug Basberg wrote: I appreciate the advise to use json to pass a dict thru a file. Below is the code To 'dump' the dict to a file and the code to 'load' the dict and the error message I get testing this. What am I doing wrong? Thanks. First two things I see are that

Re: [Tutor] print string using triple quote

2015-03-17 Thread Dave Angel
On 03/17/2015 05:54 AM, Alan Gauld wrote: On 17/03/15 04:13, Nick Nguyen wrote: Hi, I use python 3.4.3. I'm using print function with triple quote, > as I understand all the character will be printed as exactly within the triple quote, even with > the backslash character. You understand

Re: [Tutor] set current working dir

2015-03-17 Thread Dave Angel
On 03/16/2015 02:29 PM, Rajbir Singh wrote: i need to know how i can set current working dir in an executing phython using os module os.chdir() will change the current directory, but it changes it for the whole program (all threads), and the change lasts till the program terminates. Very of

Re: [Tutor] Rearranging a list of numbers with corresponding index

2015-03-13 Thread Dave Angel
On 03/13/2015 09:57 AM, Ken G. wrote: I have been keeping track of numbers drawn in our local lotto drawings into a list format as shown in a short example below. Using such list, I am able to determine how often a number appears within the last 100 plus drawings. The length of my lists range fr

Re: [Tutor] How linux software centers make “search” operation?

2015-03-11 Thread Dave Angel
On 03/11/2015 07:21 PM, metis wisdom wrote: Hello, I want to develop a software center in Ubuntu similar to Ubuntu software center. You forgot the rest of the caps. It's "Uuntu Software Center". Why? Is there something wrong with what it does, that you need something different? Is this ac

Re: [Tutor] String method "strip()" not working

2015-03-07 Thread Dave Angel
On 03/07/2015 08:15 AM, Akash Shekhar wrote: I am trying to learn how to use strip() method. It is supposed to cut out all the whitespace as I read in the tutorial. But the code is not working. Here's my code: sentence = "Hello, how are you?" print(sentence) print(sentence.strip())

Re: [Tutor] Idle - ImportError: No module named numpy

2015-03-06 Thread Dave Angel
On 03/06/2015 01:27 PM, Markos wrote: Hi, I'm beginning to study the numpy. And what does this have to do with the """Strengths & weaknesses of Python lists compared to "old school" arrays [Was "Fixed Vector Array"]""" thread? Please don't hijack a thread by replying with an unrelated

Re: [Tutor] Python 3 - bugs or installation problem

2015-03-04 Thread Dave Angel
On 03/04/2015 09:11 PM, boB Stepp wrote: On Wed, Mar 4, 2015 at 7:53 PM, Phil wrote: I hope this is not another embarrassingly obvious answer to a simple question. Python 3, under Kubuntu. xrange() fails whereas range() is accepted. Could this be an installation problem? etc This may fall i

Re: [Tutor] Fixed Vector Array

2015-03-04 Thread Dave Angel
On 03/04/2015 10:40 AM, niyanax...@gmail.com wrote: Need help trying to implement insert, remove, indexof, and reverse functions. I tried to do them but am not sure if it is correct. I am struggling with arrays. This is python and using ezarrays. I don't know any Python that includes somet

  1   2   3   4   5   6   7   8   9   10   >