[newbie] Recursive algorithm - review

2014-01-03 Thread Wiktor
== "__main__": main() Footnote: English isn't my native language, so forgive me my bad grammar and/or vocabulary. :-) -- Best regrds, Wiktor Matuszewski 'py{}@wu{}em.pl'.format('wkm', 'ka') # spam trap -- https://mail.python.org/mailman/listinfo/python-list

[newbie] Recursive algorithm - review

2014-01-03 Thread Wiktor
name__ == "__main__": main() Footnote: English isn't my native language, so forgive me my bad grammar and/or vocabulary. :-) -- Best regrds, Wiktor Matuszewski 'py{}@wu{}em.pl'.format('wkm', 'ka') # spam trap -- https://mail.python.org/mailman/listinfo/python-list

Re: [newbie] Recursive algorithm - review

2014-01-04 Thread Wiktor
>> if repeat: # I'll repeat 'matching' next >> row.append(num) # number as long as last >> x -= 1 # changed column is unique > > Hmm, I'm slightly confused

Re: [newbie] Recursive algorithm - review

2014-01-04 Thread Wiktor
On Fri, 03 Jan 2014 20:47:16 -0500, Terry Reedy wrote: > [0]*size] is fine for one row > > towers = [[0]*size] for i in range(size)] > > should do what you want for a 2-d array instead of the above. Right. Thank you also. -- Best regards, Wiktor Matuszewski 'py{}@wu

Re: [newbie] Recursive algorithm - review

2014-01-04 Thread Wiktor
ffle(row) if not towers: towers = [[0]*size for _ in range(size)] towers[0] = row[:] random.shuffle(row) x = size - 1 if x + 1 < size**2: # [...] Much more cleaner. Thanks! -- Best regards, Wiktor Matuszewski 'py{}@wu{}em.pl'.

Re: [newbie] Recursive algorithm - review

2014-01-04 Thread Wiktor
Euler gave me habit to compare time consumption of script every time I make serious change in it. Your tune-ups made this script (mostly check() I guess) about 20% faster. So it's not only 'more readable' profit. :-) -- Best regards, Wiktor Matuszewski 'py{}@wu{}em.pl'.

Re: [newbie] Recursive algorithm - review

2014-01-04 Thread Wiktor
On Sat, 4 Jan 2014 01:16:14 +0100, Wiktor wrote: > Hi, OK, another question. This time, I think, closer to the original subject (recursive algorithm). Thanks to Terry's and Chris' advises I refined script. Then I thought, that with some changes and with minimal effort I c

Re: [newbie] Recursive algorithm - review

2014-01-04 Thread Wiktor
On Sat, 4 Jan 2014 20:07:33 +0100, Wiktor wrote: > I guess that some kind of you have done this before. ;-) Damn it. This 'kind' shouldn't be there. Now it sounds silly, even offensive. ;-) Normally I would supersede it, but

Re: Flip a graph

2014-01-04 Thread Wiktor
= max(measurement_dict.values()) temporary_graph = [] for t, y in measurement_dict.items(): temporary_graph.append('X'*y + ' '*(max_height - y)) for i in range(max_height-1, -1, -1): for item in temporary_graph: print(item[i], end='') print() -- Best regards,

Re: Python prime numbers

2014-02-01 Thread Wiktor
return True So, this is your main loop. Very inefficient. Think about that: a) do you really have to check divisors up to the potentialprime? Maybe there is a point, where you may say, that you've checked all possibilities? Remember that a * b = b * a b) do you really have to check every divisor? I mean, increasing it by 1 in every step? -- Best regards, Wiktor Matuszewski 'py{}@wu{}em.pl'.format('wkm', 'ka') -- https://mail.python.org/mailman/listinfo/python-list

Re: Loading Python 2.7

2014-11-24 Thread Wiktor
On Mon, 24 Nov 2014 18:25:25 -0500, Seymore4Head wrote: > What I do when I need to run 2.7 code is to just save the file to my > Python 2.7 folder and run a command prompt. I then just type the py > file. That works but I am left with a dos prompt when the file > finishes. I sometimes would lik

Forking PyPI package

2014-05-28 Thread Wiktor
s? So, what should I do? I know, that maybe I shouldn't touch that script in first place and just mail to author "Hey, would you please port it to Py3?", but I also treated it as programming exercise, and I didn't think about consequences. ;-) TIA -- Best regard

Re: Forking PyPI package

2014-05-29 Thread Wiktor
On Thu, 29 May 2014 02:31:56 +0200, Wiktor wrote: > So, what should I do? Thanks guys, you're right. I'll contact the Lion. ;-) Yes, I forgot to mention that pwdhash.py was published under BSD licence. Without knowing that I wouldn't even consider forking it.

Re: Forking PyPI package

2014-06-05 Thread Wiktor
ript isn't published under any BSD license. I guess, I'll try to do what Chris proposed. Forget about this implementation and write python script from the scratch looking only at the original JavaScript version. :-/ Thank you guys. -- Best regards, Wiktor Matuszewski 'py{}@wu{}em.pl'.format('wkm', 'ka') -- https://mail.python.org/mailman/listinfo/python-list

Re: Forking PyPI package

2014-06-05 Thread Wiktor
On Fri, 6 Jun 2014 03:37:56 +1000, Chris Angelico wrote: > On Fri, Jun 6, 2014 at 2:56 AM, Wiktor wrote: >> I guess, I'll try to do what Chris proposed. Forget about this >> implementation and write python script from the scratch looking only at the >> o

cmd.exe on WIndows - problem with displaying some Unicode characters

2014-08-03 Thread Wiktor
those Unicode characters (by copy/paste them in command line or by listing filenames containing that characters), no matter what CP is set. How does it manage to do it? Can I exploit that writing my Python program? Wiktor -- Best regards, Wiktor Matuszewski 'py{}@wu{}em.pl'.format('wkm', 'ka') -- https://mail.python.org/mailman/listinfo/python-list

Re: cmd.exe on WIndows - problem with displaying some Unicode characters

2014-08-04 Thread Wiktor
s silly to tell them 'It is pure console based game/framework but works only in ConEmu'... Now, to Terry's post: On 8/3/2014 6:52 PM, Wiktor wrote: >> as OO programming exercise, I'm trying to port to Python one of my favorite >> game from early'90 (Atar

Re: cmd.exe on WIndows - problem with displaying some Unicode characters

2014-08-04 Thread Wiktor
bly bad) design, but now I need all three packages. Maybe if I resign from storing my colored strings, and color them just while sending them to printing function, I could get rid of colorama and termcolor... Well, thanks for asking, because now, during writing this response, I see that maybe red

Re: cmd.exe on WIndows - problem with displaying some Unicode characters

2014-08-04 Thread Wiktor
On Tue, 5 Aug 2014 03:06:41 +1000, Chris Angelico wrote: > On Tue, Aug 5, 2014 at 2:48 AM, Wiktor wrote: >> From colorama I just use one function - init(). Without this >> initialization all those ansii escape characters (used by colorama itself, >> but also by termcolor.

Re: cmd.exe on WIndows - problem with displaying some Unicode characters

2014-08-04 Thread Wiktor
x27;t do this fancy frame from first post with Polish strings inside. There will be simpler version instead. -- Best regards, Wiktor Matuszewski 'py{}@wu{}em.pl'.format('wkm', 'ka') -- https://mail.python.org/mailman/listinfo/python-list

Re: cmd.exe on WIndows - problem with displaying some Unicode characters

2014-08-05 Thread Wiktor
heck them all. But you need to understand, that I'm already OK with those cmd.exe limitations, and really not trying to achieve look of frame from first post. I'm OK with those single-only and double-only lines. Now my game would look like this: https://dl.dropboxusercontent.com/u/105

Re: cmd.exe on WIndows - problem with displaying some Unicode characters

2014-08-05 Thread Wiktor
On 05 Aug 2014 20:26:08 GMT, Tony the Tiger wrote: > On Mon, 04 Aug 2014 00:52:29 +0200, Wiktor wrote: > >> okumenty\python\kolony\menu.py", line 14, in > > This works for me on Linux: I believe you, but I use Windows and its cmd.exe (as mentioned in subject). -- B

PyThreadState_Swap crash

2011-04-04 Thread Wiktor Adamski
I have 2 threads in C code using python 2.5.2. First thread creates new interpreter (i need several interpreters but those 2 threads use only one) like that: PyEval_AcquireLock(); threadState = Py_NewInterpreter(); PyThreadState_Swap(threadState); // calling python API PyThreadState_Swap(NULL);