Re: [Tutor] Making Doubly Linked List with Less Lines of Code.

2015-01-02 Thread Dave Angel
On 01/02/2015 10:43 AM, Steven D'Aprano wrote: On 03/01/15 02:14, WolfRage wrote: Dave or Steve, what mail program do you use? It appears Thunderbird is still posting the code all messed up. Which makes it impossible to communicate effectively with the list. One last test. I'

Re: [Tutor] thread-breaing

2015-01-02 Thread Dave Angel
On 01/02/2015 05:35 PM, WolfRage wrote: First an explanation of how the game works: The game is a simple matching game but with a twist. Instead of matching a straight 3 in a You forgot to start a new thread. A new thread isn't changing the subject in the middle of a deeply nested thread. A

Re: [Tutor] Improving My Simple Game Code for Speed, Memory and Learning

2015-01-02 Thread Dave Angel
On 01/02/2015 09:38 PM, Alan Gauld wrote: On 03/01/15 02:00, WolfRage wrote: What is "breaing"? I think he meant breaking I'm afraid some keys currently stick, and 'k' is one of them. Every so often I lose a key. -- DaveA ___ Tutor mailli

Re: [Tutor] Improving My Simple Game Code for Speed, Memory and Learning

2015-01-02 Thread Dave Angel
On 01/02/2015 09:00 PM, WolfRage wrote: Python3.4+ Linux Mint 17.1 but the code will be cross platform (Mobile, Windows, Linux, OSX). First an explanation of how the game works: The game is a simple matching game but with a twist. Instead of matching a straight 3 in a row, we have some rules tha

Re: [Tutor] Improving My Simple Game Code for Speed, Memory and Learning

2015-01-03 Thread Dave Angel
On 01/02/2015 10:21 PM, Dave Angel wrote: On 01/02/2015 09:00 PM, WolfRage wrote: Python3.4+ Linux Mint 17.1 but the code will be cross platform (Mobile, Windows, Linux, OSX). First an explanation of how the game works: The game is a simple matching game but with a twist. Instead of matching a

Re: [Tutor] Improving My Simple Game Code for Speed, Memory and Learning

2015-01-03 Thread Dave Angel
On 01/03/2015 04:22 PM, WolfRage wrote: On 01/03/2015 06:58 AM, Dave Angel wrote: To transpose a grid, you want to use the zip() function. self.transposed_grid = zip(*self.grid) I see this gives me a list that is the column. Thus it solves the column iteration problem, because now I can

Re: [Tutor] Improving My Simple Game Code for Speed, Memory and Learning

2015-01-03 Thread Dave Angel
On 01/03/2015 06:10 PM, WolfRage wrote: On 01/03/2015 04:42 PM, Dave Angel wrote: self.transposed_grid = list( zip(*self.grid) ) This results in the same thing with or with out the list() wrapper. Using Python 3.4.0 (default, Apr 11 2014, 13:05:11) [GCC 4.8.2] on linux In Python 3, zip

Re: [Tutor] Seismometer alarm

2015-01-04 Thread Dave Angel
On 01/04/2015 08:17 AM, Ted wrote: On 03/01/15 19:19, Ted wrote: Alan Thank you so much for the reply, attached is a screenshot of a 4.9M earthquake in Challis Idaho, about 150 miles north. this is what I need the alarm for. Ted, I don't know what mail program you're using, but you're not do

Re: [Tutor] File Compare

2015-01-08 Thread Dave Angel
On 01/09/2015 12:32 AM, Crusier wrote: Hi, Please specify Python version for any new question. I'll assume Python 3.4 Thank you for using text message, rather than html. But realize that attachments are also a problem for many people, as this forum goes through many gateways, some of whic

Re: [Tutor] File Compare

2015-01-08 Thread Dave Angel
On 01/09/2015 01:24 AM, Crusier wrote: Hi Danny, Thanks for your suggestion. The ideal of output of this program is to show if there is any new number added to the new file. In other words, the file content of file1 [0001.hk, 0002.hk, 0003.hk, 0004.hk] is comparing with the file content of fi

Re: [Tutor] Umm.. I need help on changing Global Variables.

2015-01-31 Thread Dave Angel
On 01/29/2015 12:16 PM, Tallen Grey Smith wrote: So, I’m trying to make a very simple game that involves time management properly, but I’m having an issue. thats my code, and I want it to where if I type charge it’ll make my charge go up 10, my steps go down 1, my divs going down 1, and

Re: [Tutor] Assistance with UnicodeDecodeError

2015-01-31 Thread Dave Angel
On 01/31/2015 08:37 AM, J Mberia wrote: Hi, Welcome to Python tutor. Thanks for posting using text email, and for specifying both your Python version and Operating system. I am teaching myself programming in python and assistance with UnicodeDecodeError I am trying to scrap text from a w

Re: [Tutor] first post

2015-02-01 Thread Dave Angel
On 02/01/2015 07:09 AM, sathya kumar Prasanna wrote: Hi guys, I am completely new to programming Welcome to the Python tutor forum. Thanks for posting in text format, but you forgot to describe your Python version and operating system. and have never had the opportunity to do attempt codi

Re: [Tutor] Assistance with UnicodeDecodeError

2015-02-02 Thread Dave Angel
On 02/02/2015 02:52 AM, Cristian Di Stefano wrote: Hi Dave, you should set the correct encoding (maybe utf-8) in order to handle data from web. You cannot handle unicode data with simple string, you should encode to ASCII or manage data with the unicode type Best Cristian Please don'

Re: [Tutor] Wondering about a project

2015-02-03 Thread Dave Angel
On 02/03/2015 07:12 AM, Alan Gauld wrote: On 02/02/15 18:42, dw wrote: You forgot to tell us the Python version you're targeting. From various clues in your code, I have to assume you're using 2.7, but if I'm wrong, there are other comments I should have made. geturl="" You don't reall

Re: [Tutor] Why is an instance smaller than the sum of its components?

2015-02-03 Thread Dave Angel
On 02/03/2015 04:12 PM, Jugurtha Hadjar wrote: Hello, Lots of other good comments, so I'll just remark on one point. >>> class bar(object): ...def __init__(self): ...self.w = 5 ...self.x = 6 ...self.y = 7 ...self.z = 8 If these really are "constants,"

Re: [Tutor] Need help writing code with python

2015-02-08 Thread Dave Angel
On 02/07/2015 05:36 PM, Conner Wood wrote: I fell behind 2 weeks in my class due to surgery and have a coding project due tonight (Saturday, Feb. 7). I've attached my project to this email. Please help! Also, I'm using a Mac laptop if that helps in anyway. Please get back to me as soon as you

Re: [Tutor] Explanation of this print statement

2015-02-08 Thread Dave Angel
On 02/08/2015 06:01 PM, Shawn Byers wrote: Hello I was wondering if someone could explain this print statement for r in range(6,0,-1): print((6-r)*''+r*'o') You probably intended to have a blank between the first two single-quotes. for r in range(6,0,-1): print((6-r)*'

Re: [Tutor] Creating a pojo in python

2015-02-09 Thread Dave Angel
On 02/09/2015 02:20 AM, rakesh sharma wrote: How can one create a POJO in python.I mean a class like this class A { private a; private b; public getA() { return a; } public getB() { return b }} I tried creating class in python but the variables were accessible as public d

Re: [Tutor] How to pass varying number of arguments to functions called by a dictionary?

2015-02-11 Thread Dave Angel
On 02/11/2015 08:27 AM, boB Stepp wrote: Python 2.4.4, Solaris 10 I have a file of functions. Based on what is read in a data file, different functions in the file of functions will need to be called. I have been trying to make the following approach work, so far unsuccessfully as, in general, e

Re: [Tutor] How to pass varying number of arguments to functions called by a dictionary?

2015-02-11 Thread Dave Angel
On 02/11/2015 10:29 AM, boB Stepp wrote: On Wed, Feb 11, 2015 at 8:45 AM, Dave Angel wrote: On 02/11/2015 08:27 AM, boB Stepp wrote: [...] Sure, it's viable, but the best approach depends on your goal (use case), and your restrictions. Are these functions really totally unrelated to

Re: [Tutor] trivial simple program..can it be made more concise?

2015-02-14 Thread Dave Angel
On 02/14/2015 04:07 AM, Steven D'Aprano wrote: On Sat, Feb 14, 2015 at 03:17:28AM +, steve10br...@comcast.net wrote: Hi all, I was playing with Python tonight and created a simple program that outputs numbers counting up then counting down all on the same terminal line. The code is as follo

Re: [Tutor] trivial simple program..can it be made more concise?

2015-02-14 Thread Dave Angel
On 02/14/2015 07:51 AM, Steven D'Aprano wrote: On Sat, Feb 14, 2015 at 06:40:56AM -0500, Dave Angel wrote: On 02/14/2015 04:07 AM, Steven D'Aprano wrote: On Sat, Feb 14, 2015 at 03:17:28AM +, steve10br...@comcast.net wrote: [...] for i in range (a): print i, '\r

Re: [Tutor] Help with program

2015-02-16 Thread Dave Angel
On 02/16/2015 11:27 AM, Courtney Skinner wrote: Hello, I am trying to build a program that approximates the value of cosine - this is my program so far. It is not returning the right values. Could you tell me what I am doing wrong? You've got several answers that point out several problems

Re: [Tutor] Hey guys!

2015-02-17 Thread Dave Angel
On 02/16/2015 11:22 PM, Levi Adissi wrote: Thank you for using text email, rather than the html mail that so many newcomers use. So I'm kind of stuck trying to program a function that returns a list of tuples. The function takes 2 lists containing circles of which it should compare list1[0] t

Re: [Tutor] Potential problem with Game Over 2.0 problem in "Python Programming for the Absolute Beginner, 3rd Ed."

2015-02-17 Thread Dave Angel
On 02/17/2015 02:12 PM, boB Stepp wrote: See https://docs.python.org/3.4/reference/lexical_analysis.html#string-and-bytes-literals At this point in the text he is not talking about raw literal strings. I examined the author's source and he has obviously inserted at least one space between each

Re: [Tutor] monkey patching question

2015-02-17 Thread Dave Angel
On 02/17/2015 04:53 PM, Albert-Jan Roskam wrote: Hi, I would like to monkey patch a function 'decode' that is defined inside a class. It is defined there because it is a logical place, next to its counterpart *method* 'encode'. I can successfully monkey patch meth1, but when I call meth2, it d

Re: [Tutor] Python Question: Excluding certain keywords.

2015-02-17 Thread Dave Angel
On 02/17/2015 03:30 PM, Arnold Chung wrote: Dear Python Tutor. Welcome to the tutor list. As far as I can tell, this is your first post. And thank you for using text mail, rather than html. First of all, thank you for your kindness in advance. I am learning python by myself and having s

Re: [Tutor] Python 3 simple socket issue

2015-02-18 Thread Dave Angel
On 02/18/2015 10:48 AM, Juan C. wrote: Code: # !/usr/bin/env python3 # -*- coding: utf-8 -*- import socket def main(): target_host = 'www.google.com' target_port = 80 client = socket.socket() client.connect((target_host, target_port)) client.send(b"GET HTTP/1.1\r\nHost:google.com\r\n\r\n") r

Re: [Tutor] Issue in date difference in Python 2.7.8

2015-02-20 Thread Dave Angel
On 02/20/2015 04:28 AM, Puruganti Ramesh wrote: Hi Friends, I have an issue in comparing dates in python 2.7.8 I have written code as below but i am getting error Code is : import datetime as dt from datetime import datetime from datetime import datetime, timedelta, date dt_str='2014-5-11' dt_s

Re: [Tutor] What exactly is "state"?

2015-03-02 Thread Dave Angel
On 03/02/2015 11:25 AM, Sydney Shall wrote: I am a beginner and I am now at the strage of learning to write unittests. I have followed the current discussion entitled "How to test a class in pyhton", and I am not clear precisely what is meant by state. In its common meaning I can see some relevan

Re: [Tutor] What exactly is "state"?

2015-03-02 Thread Dave Angel
On 03/02/2015 01:42 PM, Sydney Shall wrote: Thank you very much, Joel, Danny, Alan and Dave. Your explanations are all very clear and very enlightening. I shall have to change several of my unittests now. In good time. I am particularly pleased with the examples; they clarify matters

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

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

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

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

[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

[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

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

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

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

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

[Tutor] How to notify/handle an error?

2010-10-31 Thread dave p. guandalino
Which of the following ways is better to handle something wrong? Many thanks. # First: def is_valid_project(): # Do checks and valorize is_a_valid_project accordingly return is_a_valid_project # True / False # caller side if is_valid_project(): pass # do stuffs with valid project else

[Tutor] Talking to hardware with python

2005-05-08 Thread Ferry Dave Jäckel
with PyDev and CDT (and cygwin/gcc for win32), so I can use the same tools with all platforms (and all tools are OSS). Is this a reasonable choice? If I understood the docs, I got the big picture right. Any hints and tips (better ways/tools or typical pitfalls...) are wel

Re: [Tutor] Talking to hardware with python

2005-05-11 Thread Ferry Dave Jäckel
+. Ah yes, allways make your code reuseable for others. Another point for c. Thanks for your advices! Dave pgpD30Qp6qG3F.pgp Description: PGP signature ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Python and unicode

2006-03-09 Thread Ferry Dave Jäckel
al treatment because of lack of full unicode support? In general I'd like to keep all strings as unicode in utf-8, and just convert strings from/to other encodings upon input/output. Regards, Dave -- If you're using anything besides US-ASCII, I *stringly* suggest Python 2.0

Re: [Tutor] Python and unicode

2006-03-11 Thread Ferry Dave Jäckel
ackslashreplace') sys.stderror = codecs.getwriter('ascii')(sys.stderror, 'backslashreplace') solves all my output problems regarding debugging. Thank you for your help! Dave P.s.: The quotations in my signature are by chance, really. Normally I'm not the kind of guy belie

[Tutor] Talking to hardware with python

2005-05-08 Thread Ferry Dave Jäckel
with PyDev and CDT (and cygwin/gcc for win32), so I can use the same tools with all platforms (and all tools are OSS). Is this a reasonable choice? If I understood the docs, I got the big picture right. Any hints and tips (better ways/tools or typical pitfalls...) are wel

<    16   17   18   19   20   21