Best strategy for testing class and subclasses in pytest?

2015-08-22 Thread C.D. Reimer
Greetings, I'm writing a chess engine to learn about Python classes and inheritance, and using pytest for the unit test. I've created a Piece class, which has 99% of the functionality for a chess piece, and subclass the other pieces -- Bishop, King, Knight, Pawn, Queen, Rook -- that will

Re: Do I need license to release the Python version of old BASIC games?

2015-06-21 Thread C.D. Reimer
On 6/21/2015 3:02 PM, Marko Rauhamaa wrote: As they say, tell that to the judge. More than likely, the original copyright owner can issue an DMCA take down notice and that will be end of that. Thanks, Chris R. -- https://mail.python.org/mailman/listinfo/python-list

Re: Do I need license to release the Python version of old BASIC games?

2015-06-21 Thread C.D. Reimer
On 6/21/2015 1:58 PM, Marko Rauhamaa wrote: Converting BASIC games to Python results in derived works, which are under the original copyright of the BASIC games. From the given link: BASIC Computer Games is copyright © 1978 by David H. Ahl, and is posted on www.atariarchives.org

Re: Do I need license to release the Python version of old BASIC games?

2015-06-21 Thread C.D. Reimer
On 6/21/2015 1:00 PM, Laura Creighton wrote: In a message of Sun, 21 Jun 2015 12:32:46 -0700, C.D. Reimer writes: Do I need to release my scripts under a license? If so, which one? You should, because if you don't you could pop up some day and assert copyright and sue the hell out of people

Do I need license to release the Python version of old BASIC games?

2015-06-21 Thread C.D. Reimer
Greetings, I'm in the process of converting 101 old BASIC games into Python (see link below). http://www.atariarchives.org/basicgames/ The short term goal is to learn the finer aspects of the Python language and reliving my misbegotten past on the Commodore 64. The long term goal is to use

Re: Is there a utility to tally function calls from other files?

2015-06-13 Thread C.D. Reimer
Here's my code and output for the curious. I'm sure someone will come up with a five-line version. :) import os, time def main(): def_str = 'def ' line_limit = 5 call_tally = [] import_str = 'from bg_helper import ' path = 'scripts' startTime = time.time()

Is there a utility to tally function calls from other files?

2015-06-13 Thread C.D. Reimer
Greetings, I'm converting 101 BASIC games from an old book (http://www.atariarchives.org/basicgames/) into Python scripts. After a dozen conversions, I've created a helper file for common functions (i.e., pick_card(), replay_game() and roll_dice()). The functions for card and dice games are

Re: Is there a utility to tally function calls from other files?

2015-06-13 Thread C.D. Reimer
On 6/13/2015 12:31 PM, Chris Angelico wrote: Depending on your requirements, it could be anywhere from easy to hard. Good luck:) I don't have grep on my Windows machine. Writing a script might be easier. Each file has a import statement for the helper file: from bg_helper import

Re: Is there a utility to tally function calls from other files?

2015-06-13 Thread C.D. Reimer
On 6/13/2015 1:02 PM, Terry Reedy wrote: If you have a normal Python installation, you do. Idle's Find in Files is a grep function with a gui interface. I have Notepad++ on Windows. The find function for that program does the same thing. If I have a working Mac, Text Wrangler does the same

Re: Is there a utility to tally function calls from other files?

2015-06-13 Thread C.D. Reimer
On 6/13/2015 1:59 PM, Laura Creighton wrote: Idle is written in pure python. Steal from: https://hg.python.org/cpython/file/74d182cf0187/Lib/idlelib/GrepDialog.py if you do not have a copy locally. I've been using Notepad++ (Windows) and TextWrangler (Mac) for over a decade now. Idle may be

Re: Is there a utility to tally function calls from other files?

2015-06-13 Thread C.D. Reimer
On 6/13/2015 12:58 PM, Chris Angelico wrote: Hmm, I think the Windows 'find' command can do the same sort of job. Though it's not hard to grab a Windows port of grep and use that. Should be easier than writing your own script. Writing the script would be easier for me since I'll be cobbling

Re: XCode and Python

2015-06-11 Thread C.D. Reimer
On 6/11/2015 3:09 PM, Sebastian M Cheung via Python-list wrote: Or I need to configure something in Xcode? Perhaps this link might help determine if the problem is with Xcode and/or Python. http://stackoverflow.com/questions/5276967/python-in-xcode-6 Chris R. --

Re: Testing random

2015-06-07 Thread C.D. Reimer
On 6/7/2015 10:20 AM, Chris Angelico wrote: A fourth possibility is that mathematics works differently for him and for us, which I suppose is possible; when I visited sci.math a while ago, I found some people for whom everything I'd learned in grade school was clearly wrong, and they were doing

Re: Python Random vs. Cython C Rand for Dice Rolls

2015-06-07 Thread C.D. Reimer
On 6/7/2015 11:33 AM, Steven D'Aprano wrote: C rand is not even close to random. The technical term for it is shite. Looking through the BASIC book, I remembered all the tricks needed to get a half-way decent number generator on a 1MHz processor back in the day. Either the numbers start

Re: Python Random vs. Cython C Rand for Dice Rolls

2015-06-07 Thread C.D. Reimer
On 6/7/2015 10:33 AM, Chris Angelico wrote: The negative result is a strong indicator that you're not seeing the results of rand() here. While there is a potential for bias (check out RAND_MAX, and consider that there may be some small bias there; although on most modern systems, RAND_MAX is

Re: Python Random vs. Cython C Rand for Dice Rolls

2015-06-07 Thread C.D. Reimer
On 6/7/2015 10:23 AM, Chris Angelico wrote: Before you go any further, can you just try this script, please, and see how long it takes to run? import random, time startTime = time.time() for i in range(5000): pass print '\n', time.time() - startTime I know, seems a stupid thing to

Python Random vs. Cython C Rand for Dice Rolls

2015-06-07 Thread C.D. Reimer
Greetings, I've revisited my misbegotten childhood by translating the programs from BASIC Computer Games by David H. Ahl into Python. This is mostly an exercise in unraveling spaghetti code with all those GOTO statements going all over the place. The dice program caught my attention in

Re: What is considered an advanced topic in Python?

2015-05-30 Thread C.D. Reimer
On 5/29/2015 9:01 AM, Mike Driscoll wrote: I've been asked on several occasions to write about intermediate or advanced topics in Python and I was wondering what the community considers to be intermediate or advanced. I'm trying my hand at Cython (http://cython.org/). I just know enough of

Re: Rule of order for dot operators?

2015-05-18 Thread C.D. Reimer
On 5/16/2015 6:45 PM, Steven D'Aprano wrote: On Sun, 17 May 2015 05:40 am, Thomas 'PointedEars' Lahn wrote: C.D. Reimer wrote: Who? Don't be a dick, Thomas. Lots of people use their initials. You use your nickname as part of your sender address, why are you questioning somebody for using

Re: Rule of order for dot operators?

2015-05-17 Thread C.D. Reimer
On 5/17/2015 10:17 AM, Thomas 'PointedEars' Lahn wrote: C.D. Reimer wrote: Consider using a regular expression or the urllib object instead. See RFC 3986, Appendix B, and https://docs.python.org/3/library/urllib.html, respectively. That wouldn't work for me. I'm in the process of converting

Re: Rule of order for dot operators?

2015-05-16 Thread C.D. Reimer
On 5/16/2015 12:34 PM, Peter Otten wrote: You can find out yourself by using operations where the order does matter: Test.upper().lower() I was wondering about that and couldn't think of an example off the top of my head. Thank you, Chris Reimer --

Rule of order for dot operators?

2015-05-16 Thread C.D. Reimer
Greetings, Noobie question regarding a single line of code that transforms a URL slug (this-is-a-slug) into a title (This Is A Slug). title = slug.replace('-',' ').title() This line also works if I switched the dot operators around. title = slug.title().replace('-',' ') I'm reading the

Re: Rule of order for dot operators?

2015-05-16 Thread C.D. Reimer
On 5/16/2015 12:40 PM, Thomas 'PointedEars' Lahn wrote: However, for greater efficiency, in general you should call .replace() in such a way that the length of the string it operates on is minimized. For example, if feasible, always slice *before* .replace(). Slice was how I got the slug from

Re: one to many (passing variables)

2014-07-25 Thread C.D. Reimer
On 7/24/2014 2:58 AM, Ben Finney wrote: Here is an article on good API design; the principles apply to Python URL:http://blog.isnotworking.com/2007/05/api-design-guidelines.html. You know your API and its requirements better than we; see whether that sheds any light on improvements to make.

What's the proper style for a library string function?

2014-07-19 Thread C.D. Reimer
Greetings, I typically write a Python 2.7 string function in my library like this: def getCompletedTime(start, end): return Time completed:, str(end - start) And called it like this: print getCompletedTime(start, end) Since every Python script I write is executed from the command

Re: Python and IDEs [was Re: Python 3 is killing Python]

2014-07-19 Thread C.D. Reimer
On 7/19/2014 12:28 AM, Steven D'Aprano wrote: Earlier, I mentioned a considerable number of IDEs which are available for Python, including: I prefer to use Notepad++ (Windows) and TextWrangler (Mac). Text editors with code highlighting can get the job done as well, especially if the project

Re: What's the proper style for a library string function?

2014-07-19 Thread C.D. Reimer
On 7/19/2014 11:24 AM, Mark Lawrence wrote: Besides that I wouldn't write the function on one line, the first. I've seen code samples for simple functions with the definition and return statements written on one line. Once you return your data you can do what you want with it. Returning

Re: What's the proper style for a library string function?

2014-07-19 Thread C.D. Reimer
On 7/19/2014 11:56 AM, Ian Kelly wrote: On Sat, Jul 19, 2014 at 12:24 PM, Mark Lawrence breamore...@yahoo.co.uk wrote: Also notice that I changed the function naming style from mixedCase to lower_case_with_underscores. This is the style recommended for Python by PEP 8, which you should read

Re: What's the proper style for a library string function?

2014-07-19 Thread C.D. Reimer
On 7/19/2014 12:14 PM, Mark Lawrence wrote: Is this what you intended? I'm in the process of generalizing a library module from my first Python programming project to make it more accessible to other projects. The code I wrote for that project doesn't make sense anymore. As I generalize

Re: Python and IDEs [was Re: Python 3 is killing Python]

2014-07-19 Thread C.D. Reimer
On 7/19/2014 5:41 PM, Tim Delaney wrote: The main thing is that versioning should be automatic now - it's almost free, and the benefits are huge because even trivial scripts end up evolving. I keep my modest Python scripts in a Dropbox directory and run a weekly Python script to zip up the

Re: Python and IDEs [was Re: Python 3 is killing Python]

2014-07-19 Thread C.D. Reimer
On 7/19/2014 6:23 PM, Steven D'Aprano wrote: I haven't used Python on Windows much, but when I did use it, I found the standard Python interactive interpreter running under cmd.exe to be bare- bones but usable for testing short snippets. If I recall correctly, it is missing any sort of

Re: Python and IDEs [was Re: Python 3 is killing Python]

2014-07-19 Thread C.D. Reimer
On 7/19/2014 7:03 PM, TP wrote: I would say that since PyCharm (https://www.jetbrains.com/pycharm/) now has a free Community Edition it is an even more notable IDE as the above two programs cost $. PyCharm look really nice as an IDE. Thanks for the heads up. Chris Reimer --

Re: What Next After Python Basics

2014-07-13 Thread C.D. Reimer
On 7/13/2014 1:16 PM, Orochi wrote: Hi, I am beginner in Python I have Completed Basic Python Course from Codecademy.com . Now that I have a hands on the basics what is the next thing I should do. I mean should I learn more or start a small Project(Any Ideas are Welcomed) or any Other