Re: [Tutor] Integrating TDD into my current project work-flows

2015-05-05 Thread WolfRage
I find myself in the same mind set as this individual: http://stackoverflow.com/a/64453/4285911 It is hard to write a proper test with out me initially outlining where I am going. Perhaps I need to better understand planning and drafting a programming project before I can hope to emulate TDD.

Re: [Tutor] Integrating TDD into my current project work-flows

2015-05-05 Thread WolfRage
On 05/05/2015 06:49 PM, Alan Gauld wrote: Not better, just necessary. The two concepts are complementary. You need both. The developer primarily needs unit testing, the integrator*(who may of course be the developer in a different role) needs integration testing and the client/project manager ne

Re: [Tutor] Integrating TDD into my current project work-flows

2015-05-05 Thread WolfRage
Update: My previous hack, has been changed. I now put: import os import sys sys.path.append(os.path.join(os.path.dirname(__file__), '..')) in the __main__.py file located under the tests/ directory and it is only needed the one time in that one file. Not sure why I was thinking I would need to

Re: [Tutor] Integrating TDD into my current project work-flows

2015-05-05 Thread WolfRage
On 05/04/2015 04:49 PM, Martin A. Brown wrote: Hi there, Yes, a bit ugly. Have you tried using nose? I have used a similar project development tree and use nose to run the tests. I had thought about it, but decided not too, since it was not part of the standard library. But then again, it is

Re: [Tutor] Integrating TDD into my current project work-flows

2015-05-05 Thread WolfRage
Project/develop/Project/Project/ There is only __main__.py and Project.py files. The __main__.py file imports Project.py. $ python3 Project/develop/Project/Project $ python3 Project # Assuming cwd is Project/develop/Project I tested the above on the terminal and it does not work. I get: wolfrage

[Tutor] Integrating TDD into my current project work-flows

2015-05-04 Thread WolfRage
I would like some help integrating TDD into my current projects. My chosen TDD framework is unittest from the standard library. My system details are: Linux Mint 17.1 64-bit, Python 3.4, bzr(for version control). My projects are structured like: Project > develop > Project > Project > __main__.

Re: [Tutor] CPU Scheduling

2015-04-27 Thread WolfRage
On 04/27/2015 01:13 PM, Danny Yoo wrote: On 27/04/15 02:18, alex gonsalez wrote: Need help trying to implement a CPU scheduling algorithm. Can I recommend that you read this: http://www.dabeaz.com/coroutines/Coroutines.pdf About half way through it has a Excellent example of how an OS schedule

Re: [Tutor] Functional Programming in Python

2015-04-04 Thread WolfRage
So I was surprised I did not get more feedback on my abused coroutine, maybe that is good or bad, not sure. Any ways I am on to trying to make that coroutine act more like the State Pattern from Gang of Four. And well reading this: http://gameprogrammingpatterns.com/state.html I am not sure ho

Re: [Tutor] Functional Programming in Python

2015-04-02 Thread WolfRage
On 04/02/2015 03:08 PM, Tim Johnson wrote: You have already received valuable replies from two advanced python experts. If you are looking for a book (available digitally for kindle) I would recommend Guide To: Functional Python & Comprehension Constructs by Matt Harrison Tha

Re: [Tutor] Functional Programming in Python

2015-04-02 Thread WolfRage
On 04/02/2015 02:52 PM, Danny Yoo wrote: This is not to say that closures are bad. It's just to point out that just because functional programs use closures quite a lot, doesn't automatically mean closures are the most appropriate tool for everything. If there are parts of the language that al

Re: [Tutor] Functional Programming in Python

2015-04-02 Thread WolfRage
On 04/02/2015 02:07 PM, Steven D'Aprano wrote: What are the best practices to create more Functional Python? Best practices: * Don't force your code to use one style exclusively. Use the most natural style for the task. Python makes it easy to mix functional, procedural, imperative and

Re: [Tutor] Functional Programming in Python

2015-04-02 Thread WolfRage
On 04/02/2015 01:07 PM, Alan Gauld wrote: I'm not sure what you mean is impossible? The specific issues you are having or the general FP paradigm? I mean achieving truely functional code, atleast to the extent of some of the things that I have read. But in general I do not need nor want any of

[Tutor] Functional Programming in Python

2015-04-02 Thread WolfRage
These are just some questions that I have regarding the topic of Functional Programming. I am working towards a more functional approach to programming but acknowledge that it is far from Functional, especially since this is mostly impossible in Python. Questions: What are the best practices to

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

2015-03-06 Thread WolfRage
Well on the python interpretor did you use python3 or just python? On 03/06/2015 01:27 PM, Markos wrote: Hi, I'm beginning to study the numpy. When I open a terminal (Debian Squeeze) and run the python interpreter the command "import numpy as np" run without errors. But when I run the same co

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

2015-01-16 Thread WolfRage
On 01/12/2015 04:47 PM, Mark Lawrence wrote: I haven't looked carefully at your code but there's always a smell in Python when you see structure[x][y]. Can you change the grid so you always write something like:- for row in grid: for cell in row: process(cell) I say this as I'm

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

2015-01-12 Thread WolfRage
Updated the code to now allow for a fill_rows optional argument for Grid, that determines how many rows are filled with values. I have also added some experimental code to invert the dropping, as in all of the values can float to the top. Other code is even more experimental and not yet working

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

2015-01-12 Thread WolfRage
On 01/12/2015 05:00 PM, Alan Gauld wrote: __str__methodf of the grid. Then the draw method becomes print(self) And you can also just use print(aGrid) etc. Implemented with some other improvements using the same idea but applied to several of the other functions, that provide output. Now I

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

2015-01-12 Thread WolfRage
On 01/12/2015 05:00 PM, Alan Gauld wrote: Sorry, no time to read the detail, but one thing I thought might be handy is to convert the draw method to return a string and make it the __str__methodf of the grid. Then the draw method becomes print(self) And you can also just use print(aGrid) etc.

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

2015-01-12 Thread WolfRage
I haven't looked carefully at your code but there's always a smell in Python when you see structure[x][y]. Can you change the grid so you always write something like:- for row in grid: for cell in row: process(cell) I say this as I'm all for short term pain, long term gain, esp

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

2015-01-12 Thread WolfRage
I fixed the other functions to again work as expected. But the procedural access of the self.grid and self.transposed_grid also function correctly. That is good because now I can again do lookups if I need to. Although I do not have a need to at this time. Can anyone see anything wrong with th

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

2015-01-12 Thread WolfRage
Now I have the output that I expect and procedurally they output matches the id of the Node/Tile. But I am thoroughly confused as to why my by_id functions use the opposite grid to get the correct output? # Output python3 test1.py | 6 | 20 | 19 | 11 | 11 | 20 | 5 | 11 | | 20 | 19 | 20 | 11 |

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

2015-01-12 Thread WolfRage
So I was write as I suspected; the grid is not actually being built like I thought it was. Sure the ID's print fine but when the grid positions are procedurally accessed the program fails with IndexError. python3 test1.py | 19 | 5 | 5 | 5 | | 11 | 6 | 19 | 11 | | 6 | 6 | 11 | 19 | | 11 |

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

2015-01-11 Thread WolfRage
Ok, now the code works as expected to drop the non zero values. But I think there exist an error in the naming and display of the col and row variables at least from with in the GameTile() class, looking into that now. All Suggestions Welcome! Thank You All. import random class GameTile():

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

2015-01-11 Thread WolfRage
I had an issue in my logic and again my named variables provided for confusion, so I had to add some comments to clarify. I got much closer by editing my code like this: def drop_floating_nodes0(self): i = self.rows # first_zero_row serves as memory for how far to drop non-zero

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

2015-01-11 Thread WolfRage
On 01/05/2015 06:21 PM, Danny Yoo wrote: SNIP if total in (17, 21, 28, ...): Implemented, thanks. SNIP The other comment I'd make is to start thinking about how you'd _test_ your program automatically. SNIP You are right, I should. But I am fighting with myself on this topic. I have been

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

2015-01-03 Thread WolfRage
On 01/03/2015 06:46 PM, Steven D'Aprano wrote: On Sat, Jan 03, 2015 at 06:10:31PM -0500, 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 (de

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

2015-01-03 Thread WolfRage
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 ___ Tutor maillist -

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

2015-01-03 Thread WolfRage
On 01/03/2015 04:42 PM, Dave Angel wrote: 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

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

2015-01-03 Thread WolfRage
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 feed it to my checking and elimination fun

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

2015-01-03 Thread WolfRage
On 01/03/2015 06:58 AM, Dave Angel wrote: self.transposed_grid = zip(*self.grid) zip() sounds confusing. But I am going to try this and see what it gives me. But Somehow I think it will require me to understand yield, which I still do not totally get how to use. Also from the documentation, wil

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

2015-01-03 Thread WolfRage
On 01/03/2015 10:09 AM, Steven D'Aprano wrote: On Fri, Jan 02, 2015 at 09:00:22PM -0500, 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

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

2015-01-03 Thread WolfRage
On 01/03/2015 06:58 AM, Dave Angel wrote: My error. Since nodes are GameTile objects, not values, converting to a tuple is a little trickier: values = tuple( [node.value for node in nodes] ) if values in table: do-something I will try an implement this after I s

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

2015-01-03 Thread WolfRage
On 01/02/2015 10:21 PM, Dave Angel wrote: This code is way too complex for what it accomplishes. See below. Yes, that it why it needs to be optimized. It is unfortunate that my first goes at many tasks are not the most efficient. But hopefully that will get better as I learn from all of you.

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

2015-01-02 Thread WolfRage
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 that only certain combinations will resul

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

2015-01-02 Thread WolfRage
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 that only certain combinations will result in an elimination. In general 2 of the same value in a row with with 1 of 2 other possible va

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

2015-01-02 Thread WolfRage
Tutors, on my next iteration I am going to add more of the game code. Since I am no longer using Doubly Linked Lists, should I create a new thread? Or should I continue with this thread to continue with the established context? ___ Tutor maillist -

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

2015-01-02 Thread WolfRage
On 01/02/2015 12:08 PM, Dave Angel wrote: class GameGrid(): def __init__(self, cols=8, rows=7, **kwargs): You probably want to reverse the order of the parameters; you've got almost everything else row-major You are right, a lot of inconsistency that will lead to errors latter on. I nee

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

2015-01-02 Thread WolfRage
On 01/02/2015 02:21 AM, Steven D'Aprano wrote: What is the purpose of the **kwargs? It doesn't get used, it just silently ignores them. Hopefully you got the answer for this from the previous message. Why does the GameTile record the coordinates as strings? Hopefully you got the answer for

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

2015-01-02 Thread WolfRage
On 01/02/2015 10:37 AM, Alan Gauld wrote: I use Thunderbird for posting too, and nobody has complained yet about my code layout. My account settings are: Composition&Addressing Compose in HTML - OFF Auto quote original then "START REPLY BELOW QUOTE" My Tbird prefs are: Composition->General ta

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

2015-01-02 Thread WolfRage
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. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscripti

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

2015-01-02 Thread WolfRage
On 01/02/2015 02:21 AM, Steven D'Aprano wrote: Fixing the mangled formatting, as best as I am able (and can be bothered). On Thu, Jan 01, 2015 at 11:48:18PM -0500, WolfRage wrote: class GameTile(): def __init__(self, id, **kwargs): # id is (X,Y) self.id = id Wh

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

2015-01-02 Thread WolfRage
import sys class GameTile(): def __init__(self, id, **kwargs): # id is (X,Y) self.id = id class GameGrid(): def __init__(self, **kwargs): self.cols = 8 self.rows = 8 # grid is 2d array as y, x ie [y][x]. self.grid = [[None] * self.rows for i in range(self.cols)] def make_grid(self)

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

2015-01-02 Thread WolfRage
On 01/02/2015 12:28 AM, Dave Angel wrote: On 01/01/2015 11:48 PM, WolfRage wrote: Final Code Using 2d List instead of Doubly Linked List. Please don't top-post. Instead, post your comments inline with the parts of the previous message to which you're responding. I did reply in

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

2015-01-01 Thread WolfRage
Final Code Using 2d List instead of Doubly Linked List. class GameTile(): def __init__(self, id, **kwargs): # id is (X,Y) self.id = id class GameGrid(): def __init__(self, **kwargs): self.cols = 7 self.rows = 8 # grid is 2d array as y, x ie [y][x]. self.grid = [[None] * self.rows for i

Re: [Tutor] Convert string to bytes

2014-12-31 Thread WolfRage
I wrote a program to help me break out hex strings awhile ago. It was written to communicate with a Atmega 168. This is written for Python 3. Here is a snippet, see if this helps you. s4 = "28 40 7A 7C 05 00 00 34" hex_array = bytearray.fromhex(s4) print(s4) print(list(hex_array)) print(hex_arr

Re: [Tutor] Help on Python drop-down list options

2014-12-31 Thread WolfRage
What is the user interface that your program is using, currently? IE: QT, GTK, Tkinter, Curses, Kivy, Pygame, Or None? What is the target system on which your program runs? How are you currently viewing the mean and standard deviation results? What version of Python are you using and what is your

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

2014-12-30 Thread WolfRage
This is my most recent rendition of the code. It still needs to be improved. Below I am answering some questions that were posed. Also I think my code is currently wrong because I think the print_by functions are both printing the list the same way. Tomorrow I will fix this and improve the code

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

2014-12-25 Thread WolfRage
Thanks, definitely adding this concept into my code. And re-writing. I originally hard coded everything just to get it working... but obviously, it would have been more time efficient to have thought in these terms from the beginning. Hopefully I can learn to write code more like this to begin

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

2014-12-24 Thread WolfRage
Here is a condensed version of all of the applicable code but with out Linked List filled in, as I am preparing to re-write it. class GameTile(): def __init__(self, id, **kwargs): self.id = id class GameGrid(): def __init__(self, **kwargs): self.cols = 8 self.row

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

2014-12-24 Thread WolfRage
OK thanks for the rapid response, I will start rewriting the functions in this way now, and will come back with what I wind up with. Also Merry Christmas! On 12/24/2014 04:56 PM, Steven D'Aprano wrote: On Wed, Dec 24, 2014 at 04:35:06PM -0500, WolfRage wrote: I wrote some code recent

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

2014-12-24 Thread WolfRage
I wrote some code recently to make a linked list of Nodes for a 2d graph, so it consists of rows and columns. Now I wanted to make the code support being doubly linked, forwards and backwards. The difficult part of this is that the links are per row and per column. But the code I think is over

Re: [Tutor] Already Initialized Object Inheritance?

2011-06-15 Thread WolfRage
All, I have found a way to use __getattr__() to redirect failed calls to the variable that holds 'stdscr'. I will draw up some better potential code tomorrow, and then you can provide me feedback, for a potentially better method. Or perhaps optimized code. I think I also understand OOP a little be

Re: [Tutor] Tutor Digest, Vol 88, Issue 56

2011-06-15 Thread WolfRage
> From: Steven D'Aprano > To: Python Tutor > Subject: Re: [Tutor] Already Initialized Object Inheritance? > Message-ID: <4df898e9.5050...@pearwood.info> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > WolfRage wrote: > > Unfortunately I

Re: [Tutor] Already Initialized Object Inheritance?

2011-06-15 Thread WolfRage
gt; into stdscr > Or maybe you meant do that, because I don't know what stdscr or > the curses module is > > On Wed, Jun 15, 2011 at 12:47 AM, WolfRage > wrote: > I can not get this to behave in the manor that I would like. I > am trying >

Re: [Tutor] Already Initialized Object Inheritance?

2011-06-14 Thread WolfRage
l generate the error message for that method. -- Jordan On Wed, 2011-06-15 at 02:04 -0400, Japhy Bartlett wrote: > When you're subclassing something, you use the syntax: > > class Foo(Bar): > > It seems like you're trying to do: > > class Bar: > class Foo: >

[Tutor] Already Initialized Object Inheritance?

2011-06-14 Thread WolfRage
I can not get this to behave in the manor that I would like. I am trying to have an object refereed to as CursesApp.Screen become the already initialized object "stdscr". To elaborate I would like it to become that object but to also be able to define additional methods and properties, so more alon