Re: (Execution) Termination bit, Alternation bit.
Should be easy to turn that somewhat pseudo code into python code ! :) If it is so easy, why won't you do it? Not sure why, I use SikuliX and it's kinda buggy and slow, and I also had little time, it's also pretty trivial and I doubt you guys will have a solution that will actually work, so it's time wasted most likely. However I will not let the missing of code be an excuse for you guys and gals :) So here is the code. It may also clearify some things cause some were already confused by the simple conditions it seems ! ;) :) # Begin of Code Condition1 = True Condition2 = True Condition3 = True Condition4 = True Condition5 = True Condition6 = True Condition7 = True def Routine2(): print "Entering Routine2()" global Condition6 global Condition7 while Condition6: while Condition7: print "routine 2: executing" print "Leaving Routine2()" def Routine1(): print "Entering Routine1()" global Condition4 global Condition5 while Condition4: while Condition5: Routine2() print "Leaving Routine1()" # main print "Entering main loop" while Condition1: while Condition2: while Condition3: Routine1() print "Leaving main loop" # End of Code Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: (Execution) Termination bit, Alternation bit.
"Chris Angelico" wrote in message news:mailman.64.1451433611.11925.python-l...@python.org... On Wed, Dec 30, 2015 at 8:43 AM, Skybuck Flying <skybuck2...@hotmail.com> wrote: Not at all, these assembler statements can be replaced with python statements and then you have the exact same problem ! ;) " Then do so. Give us an example where this problem occurs in pure Python. " I basically already did... The while loops and calls themselfes already enough of a burdon... Should be easy to turn that somewhat pseudo code into python code ! :) Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: (Execution) Termination bit, Alternation bit.
"Steven D'Aprano" wrote in message news:5682892c$0$1587$c3e8da3$54964...@news.astraweb.com... On Tue, 29 Dec 2015 10:25 pm, Skybuck Flying wrote: Great that means you will understand the example below: mov eax, 0 add eax, 10 mul eax, 4 There is an instruction sequence for you. " Skybuck, this is completely off-topic for a Python forum like this. " Not at all, these assembler statements can be replaced with python statements and then you have the exact same problem ! ;) Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: (Execution) Termination bit, Alternation bit.
"Grant Edwards" wrote in message news:n59k40$e27$1...@reader1.panix.com... On 2015-12-21, Dennis Lee Bieber <wlfr...@ix.netcom.com> wrote: On Mon, 21 Dec 2015 13:40:21 +0100, "Skybuck Flying" <skybuck2...@hotmail.com> declaimed the following: The original idea I posted is less about sending a signal to another processor. It is more about how to break out of an instruction sequence. Example of problem: Main: while Condition1 do begin while Condition2 do begin while Condition3 do begin Routine1 end end; end; I do hope this is the result of over simplification for the example, as otherwise I'd turn it into while C1 and C2 and C3: R1 " Not that this means that all rest of what Skyhawk posted makes any sense at all. I've spent a lot of time programming on "bare metal", in assembly, Pascal, PL/M, and C (including using coroutines and various other "multi-thread" constructs with no OS support), and I really don't see the utility of his initial suggestion. " Great that means you will understand the example below: mov eax, 0 add eax, 10 mul eax, 4 There is an instruction sequence for you. This instruction sequence is too long believe it or not. The mission is to make the CPU break out of instruction 2 and execute something else. How would you do it ? Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: (Execution) Termination bit, Alternation bit.
"Grant Edwards" wrote in message news:n59k40$e27$1...@reader1.panix.com... On 2015-12-21, Dennis Lee Bieber <wlfr...@ix.netcom.com> wrote: On Mon, 21 Dec 2015 13:40:21 +0100, "Skybuck Flying" <skybuck2...@hotmail.com> declaimed the following: The original idea I posted is less about sending a signal to another processor. It is more about how to break out of an instruction sequence. Example of problem: Main: while Condition1 do begin while Condition2 do begin while Condition3 do begin Routine1 end end; end; I do hope this is the result of over simplification for the example, as otherwise I'd turn it into while C1 and C2 and C3: R1 " That's not equivalent to what Skybuck posted. Think about what happens when Routine1 causes Condition1 and Condition2 to become false but Condition3 remains true. " Thanks for pointing that out to him, it's funny to see that at least that part of the logic you understand ! ;) " Not that this means that all rest of what Skyhawk posted makes any sense at all. " Perhaps it will help you if I tell you the following: 1. This is just pseudo code. 2. The conditions C1, C2, C3 can be functions/routines returning booleans. Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: (Execution) Termination bit, Alternation bit.
"Chris Angelico" wrote in message news:mailman.62.1450799815.2237.python-l...@python.org... On Wed, Dec 23, 2015 at 2:46 AM, Skybuck Flying <skybuck2...@hotmail.com> wrote: One idea which immediatly comes to mind to fix this problem is to offer a "PushTerminationFlag" onto stack and then a "ClearTerminationFlag" instruction. Then a code section can be executed without breaking or terminating. Once that's done the code would then call "PopTerminationFlag". At least this offers some protection against arbitrarely breaking code sections. " Here on python-list/comp.lang.python, we have all those high level facilities. " Ok, if that were true, please solve the problem then with python code ! ;) Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: (Execution) Termination bit, Alternation bit.
"Richard Damon" wrote in message news:QXSdy.6634$qg6.5...@fx31.iad... On 12/21/15 7:40 AM, Skybuck Flying wrote: The original idea I posted is less about sending a signal to another processor. It is more about how to break out of an instruction sequence. Example of problem: [snip] Bye, Skybuck. " The issue is that if your threads are doing real work, the cleanup needed at each point keep the environment clean for other threads likely varies. Just arbitrarily stopping or blindly going off to something else is very apt to create problems. Some languages can be better at automatically cleaning up for you, these will tend to be languages that support some form of exception processing, as that tends to need similar support. You abort can be treated as a type of exception that is automatically thrown when signaled. The problem here is that most programs, while they can handle exceptions in many spots, have some spots where exceptions will cause problems, especially in code that is directly managing the resources. Thus, you still need to have some definition of where to check for the breaks. " I can imagine that arbitrarily terminating somewhere can lead to problems for example in memory clean up code, where then memory leaks might occur. Though applications do sometimes seem to clean up anyway. One idea which immediatly comes to mind to fix this problem is to offer a "PushTerminationFlag" onto stack and then a "ClearTerminationFlag" instruction. Then a code section can be executed without breaking or terminating. Once that's done the code would then call "PopTerminationFlag". At least this offers some protection against arbitrarely breaking code sections. Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: (Execution) Termination bit, Alternation bit.
The original idea I posted is less about sending a signal to another processor. It is more about how to break out of an instruction sequence. Example of problem: Main: while Condition1 do begin while Condition2 do begin while Condition3 do begin Routine1 end end; end; Routine1: while Condition4 do begin while Condition5 do begin Routine2: end; end; Routine2: while Condition6 do begin while Condition7 do begin end; end; Breaking out of these kinds of loops, routines, code currently requires something like: Current cumbersome solution for problem: Main: while Condition1 and not Terminated do begin while Condition2 and not Terminated do begin while Condition3 and not Terminated do begin Routine1 end end; end; Routine1: while Condition4 and not Terminated do begin while Condition5 and not Terminated do begin Routine2: end; end; Routine2: while Condition6 and not Terminated do begin while Condition7 and not Terminated do begin end; end; It can take a long while before all this code exits, plus the Terminated boolean is probably placed on wrong side. It should be on the left side in case the Conditions are actual functions otherwise those would unnecessarily be executed as well. Having something that can immediatly exit all of this code would be a nice feature to have. Perhaps something like an exception block, perhaps it could be called a termination block. Routine1: Result = False Execute while True do begin end; Result = True Termination OnTerminate: begin end; end; return Result Preferrably , optionally this can be omitted/left out. Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: (Execution) Termination bit, Alternation bit.
"Richard Damon" wrote in message news:QHody.3724$bz5.3...@fx04.iad... On 12/19/15 9:03 PM, Skybuck Flying wrote: It could be usefull if the instruction pointer/return address that was pushed onto the stack when the interrupt handler was called can be modified by the interrupt handler so that when it returns the modified instruction pointer is popped from the stack. This would assume: 1. To be interrupted processor pushed it's own instruction pointer onto the stack. 2. To be interrupted processor pops it's own instruction pointer from stack. Bye, Skybuck. " It would be an unusual machine where you couldn't modify the return address on the stack to change the address you return to. " This does make me wonder how Windows 7 terminates threads/processes/hanging applications. Apperently there is some kind of mechanism for this. Perhaps it's not fully exposed to application developers or perhaps in a somewhat more complex way via all kinds of APIs ? An example of how to terminate threads/processes instantly on Windows 7 could be interesting. Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
(Execution) Termination bit, Alternation bit.
Hello, I'd like to see instruction execution enhanced with the following two ideas: 1. A termination bit, and a terminator pointer. 2. A alternation bit, and a alternate pointer. The purpose of these bits is as follows: Before a processor/core executes an instruction both bits are examined. 1. If the termination bit is set the instruction is not executed and instead the processor sets the instruction pointer to the termination pointer. 2. If the alternation bit is set the instruction is not executed and instead the processor sets the instruction pointer to the alternation pointer. The idea behind this is support multi threading/parallelism better. The idea is that Thread A could terminate Thread B immediately so that Thread B does not continue execution. The idea is also that Thread A could influence Thread B to start executing a different path. Hopefully these bits are enough for operating systems to add support for this. Some issues remaining could be items pushed on the stack. Perhaps operating system can deal with that, or perhaps compiler or perhaps some other special instructions or software methods can be added. Hopefully operating systems can include data structures per thread that can be loaded into the core, and into these bits and pointers so that it becomes active. During a context switch these bits and pointers should be loaded accordingly. So these two bits and these two pointers become part of the context. I think these two features would be usefull to make multi-threading more responsive and faster reaction time to changes/events occuring. (Eventually it would be nice if these low level features would end up in high level languages like Python ;)) Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Is Microsoft Windows secretly downloading childporn to your computer ?!
It's not YOU doing it. Since you obviously don't understand that it's not worth reading anything else you wrote LOL. Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Dummy Decoder Example (was Re: Parallel decoding lesson for you.)
tiplier[1,5]) shl 5); Processor[2] := ((Stream[RowOffset[0]+2]*FieldRowMultiplier[2,0]) shl 0) or ((Stream[RowOffset[1]+2]*FieldRowMultiplier[2,1]) shl 1) or ((Stream[RowOffset[2]+2]*FieldRowMultiplier[2,2]) shl 2) or ((Stream[RowOffset[3]+2]*FieldRowMultiplier[2,3]) shl 3) or ((Stream[RowOffset[4]+2]*FieldRowMultiplier[2,4]) shl 4) or ((Stream[RowOffset[5]+2]*FieldRowMultiplier[2,5]) shl 5); Processor[3] := ((Stream[RowOffset[0]+3]*FieldRowMultiplier[3,0]) shl 0) or ((Stream[RowOffset[1]+3]*FieldRowMultiplier[3,1]) shl 1) or ((Stream[RowOffset[2]+3]*FieldRowMultiplier[3,2]) shl 2) or ((Stream[RowOffset[3]+3]*FieldRowMultiplier[3,3]) shl 3) or ((Stream[RowOffset[4]+3]*FieldRowMultiplier[3,4]) shl 4) or ((Stream[RowOffset[5]+3]*FieldRowMultiplier[3,5]) shl 5); // *** STILL TO DO (solved by extending array): // *** ^^^ may have to look into potential out of range problem ^^^ // * // for now it seems ok, also as long as stream array has +NumberOfProcessors scratch pad at end it may be ok ! ;) :) // one last problem might remain... the row offset may go out of range... // we could either use a scratch pad or solve this in another way. // I think it's best to leave it as as and perhaps make the stream a bit larger or omething let's see what happens. // print processor values. writeln( 'Processor[0]: ', Processor[0] ); writeln( 'Processor[1]: ', Processor[1] ); writeln( 'Processor[2]: ', Processor[2] ); writeln( 'Processor[3]: ', Processor[3] ); writeln; end; begin try Main; except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; ReadLn; end. // *** End of Delphi Program *** // *** Begin of C/C++ Program *** // ParallelDecodingCVersion.cpp : Defines the entry point for the console application. // // Full C version 0.01 created on 23 september 2015 by Skybuck Flying =D #include "stdafx.h" // Begin of Dummy Decoder Example const int MaxProcessorCount = 4; int Constrain( int Para ) { if (Para < 0) Para = 0; if (Para >= 1) Para = 1; return Para; } int _tmain(int argc, _TCHAR* argv[]) { // information stream, input int Stream[21+(MaxProcessorCount-1)]; // add max processor count to create a safe "padding" for reading so no out of bounds/range check errors with arrays. // bits representing fields of data int a1,a2,a3,a4; int b1,b2,b3; int c1; int d1,d2,d3,d4,d5,d6; // output int RowIndex; int RowCount; int RowLength[6]; int RowOffset[6]; int FieldRowMultiplier[4][6]; int DataOffset; int FieldCount; int FieldLength[4]; int Processor[4]; // debug fields int FieldA; int FieldB; int FieldC; int FieldD; // input test 1 /* a1 = 1; a2 = 1; a3 = 1; a4 = 1; b1 = 1; b2 = 1; b3 = 1; c1 = 1; d1 = 1; d2 = 1; d3 = 1; d4 = 1; d5 = 1; d6 = 1; */ // input test 2 a1 = 1; a2 = 0; a3 = 0; a4 = 1; b1 = 1; b2 = 1; b3 = 0; c1 = 1; d1 = 1; d2 = 1; d3 = 0; d4 = 0; d5 = 1; d6 = 0; // compute input fields to compare it later with output fields FieldA = (a1) | (a2 << 1) | (a3 << 2) | (a4 << 3); FieldB = (b1) | (b2 << 1) | (b3 << 2); FieldC = (c1); FieldD = (d1) | (d2 << 1) | (d3 << 2) | (d4 << 3) | (d5 << 4) | (d6 << 5); // print field values printf( "FieldD: %d \n", FieldD ); printf( "FieldA: %d \n", FieldA ); printf( "FieldB: %d \n", FieldB ); printf( "FieldC: %d \n\n", FieldC ); // number of rows Stream[0] = 6; // row lengths Stream[1] = 4; Stream[2] = 3; Stream[3] = 3; Stream[4] = 2; Stream[5] = 1; Stream[6] = 1; // sorted information stream: // d1a1b1c1d2a2b2d3a3b3d4a4d5d6 // data bits Stream[7] = d1; Stream[8] = a1; Stream[9] = b1; Stream[10] = c1; Stream[11] = d2; Stream[12] = a2; Stream[13] = b2; Stream[14] = d3; Stream[15] = a3; Stream[16] = b3; Stream[17] = d4; Stream[18] = a4; Stream[19] = d5; Stream[20] = d6; // now the decoding algorithm: // determine number of rows RowCount = Stream[0]; // extract row lengths RowLength[0] = Stream[1]; RowLength[1] = Stream[2]; RowLength[2] = Stream[3]; RowLength[3] = Stream[4]; RowLength[4] = Stream[5]; RowLength[5] = Stream[6]; // determine field count FieldCount = RowLength[0]; // row[0] indicates number of fields. // I will help out a bit... by leaving this code in ! ;) seems somewhat obvious ;) // first determine data offset properly ! ;) :) 1 for the row count + // RowCount to skip over row lengths. DataOffset = 1 + RowCount; RowOffset[0] = DataOffset; RowOffset[1] =
Re: Cyber Grand Challenge, prizes up to 2 million dollars ! (DARPA)
Also very interesting read: http://blog.trailofbits.com/2015/07/15/how-we-fared-in-the-cyber-grand-challenge/ " How We Fared in the Cyber Grand Challenge July 15, 2015 by Artem Dinaburg 6 Comments The Cyber Grand Challenge qualifying event was held on June 3rd, at exactly noon Eastern time. At that instant, our Cyber Reasoning System (CRS) was given 131 purposely built insecure programs. During the following 24 hour period, our CRS was able to identify vulnerabilities in 65 of those programs and rewrite 94 of them to eliminate bugs built in their code. This proves, without a doubt, that it is not only possible but achievable to automate the actions of a talented software auditor. Despite the success of our CRS at finding and patching vulnerabilities, we did not qualify for the final event, to be held next year. There was a fatal flaw that lowered our overall score to 9th, below the 7th place threshold for qualification. In this blog post we’ll discuss how our CRS works, how it performed against competitor systems, what doomed its score, and what we are going to do next. Cyber Grand Challenge Background The goal of the Cyber Grand Challenge (CGC) is to combine the speed and scale of automation with the reasoning capabilities of human experts. Multiple teams create Cyber Reasoning Systems (CRSs) that autonomously reason about arbitrary networked programs, prove the existence of flaws in those programs, and automatically formulate effective defenses against those flaws. How well these systems work is evaluated through head-to-head tournament-style competition. The competition has two main events: the qualifying event and the final event. The qualifying event was held on June 3, 2015. The final event is set to take place during August 2016. Only the top 7 competitors from the qualifying event proceed to the final event. During the qualifying event, each competitor was given the same 131 challenges, or purposely built vulnerable programs, each of which contained at least one intentional vulnerability. For 24 hours, the competing CRSes faced off against each other and were scored according to four criteria. The full details are in the CGC Rules, but here’s a quick summary: The CRS had to work without human intervention. Any teams found to use human assistance were disqualified. The CRS had to patch bugs in challenges. Points were gained for every bug successfully patched. Challenges with no patched bugs received zero points. The CRS could prove bugs exist in challenges. The points from patched challenges were doubled if the CRS could generate an input that crashed the challenge. The patched challenges had to function and perform almost as well as the originals. Points were lost based on performance and functionality loss in the patched challenges. A spreadsheet with all the qualifying event scores and other data used to make the graphs in this post is available from DARPA (Trail of Bits is the ninth place team). With the scoring in mind, let’s review the Trail of Bits CRS architecture and the design decisions we made. Preparation We’re a small company with a distributed workforce, so we couldn’t physically host a lot of servers. Naturally, we went with cloud computing to do processing; specifically, Amazon EC2. Those who saw our tweets know we used a lot of EC2 time. Most of that usage was purely out of caution. We didn’t know how many challenges would be in the qualifying event — just that it would be “more than 100.” We prepared for a thousand, with each accompanied by multi-gigabyte network traffic captures. We were also terrified of an EC2 region-wide failure, so we provisioned three different CRS instances, one in each US-based EC2 region, affectionately named Biggie (us-east-1), Tupac (us-west-2), and Dre (us-west-1). It turns out that there were only 131 challenges and no gigantic network captures in the qualifying event. During the qualifying event, all EC2 regions worked normally. We could have comfortably done the qualifying event with 17 c4.8xlarge EC2 instances, but instead we used 297. Out of our abundance of caution, we over-provisioned by a factor of ~17x. Bug Finding The Trail of Bits CRS was ranked second by the number of verified bugs found (Figure 1). This result is impressive considering that we started with nothing while several other teams already had existing bug finding systems prior to CGC. Figure 1: Teams in the qualifying event ranked by number of bugs found. Orange bars signify finalists. Our CRS used a multi-pronged strategy to find bugs (Figure 2). First, there was fuzzing. Our fuzzer is implemented with a custom dynamic binary translator (DBT) capable of running several 32-bit challenges in a single 64-bit address space. This is ideal for challenges that feature multiple binaries communicating with one another. The fuzzer’s instrumentation and mutation are separated, allowing for
Cyber Grand Challenge, prizes up to 2 million dollars ! (DARPA)
(Click on little icon on website top left for menu): Information about challenge: http://www.cybergrandchallenge.com/site/index.html#about https://cgc.darpa.mil/CGC_Rules_16_May_14_Version_2.pdf Perhaps this will be a yearly contest. There is a catch though, to collect the prizes: "The prize recipient shall be a citizen, a permanent resident of the United States, or a US Entity. " Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Cyber Grand Challenge, prizes up to 2 million dollars ! (DARPA)
Also very interesting read: https://cgc.darpa.mil/CGC_FAQ.pdf Just the list of common programming mistakes is already pretty interesting ! ;) =D Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Dummy Decoder Example (was Re: Parallel decoding lesson for you.)
The example may be modified as much as needed. For now my solution needs a little reading pad to avoid costly mods or branches or whatever. I think this is a nice speedy solution, so code may be modified as follows: const MaxProcessorCount = 4; var // information stream, input Stream : array[0..20+(MaxProcessorCount-1)] of integer; // add max processor count to create a safe "padding" for reading so no out of bounds/range check errors with arrays. Bye, Sybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Dummy Decoder Example (was Re: Parallel decoding lesson for you.)
Here is the C version of the example in case your Delphi-to-C skills are not so great or you lazy lol =D: // ParallelDecodingCVersion.cpp : Defines the entry point for the console application. // #include "stdafx.h" // Begin of Dummy Decoder Example const int MaxProcessorCount = 4; int _tmain(int argc, _TCHAR* argv[]) { // information stream, input int Stream[21+(MaxProcessorCount-1)]; // add max processor count to create a safe "padding" for reading so no out of bounds/range check errors with arrays. // bits representing fields of data int a1,a2,a3,a4; int b1,b2,b3; int c1; int d1,d2,d3,d4,d5,d6; // output int RowIndex; int RowCount; int RowLength[6]; int RowOffset[6]; int DataOffset; int FieldCount; int FieldLength; int Processor[4]; // debug fields int FieldA; int FieldB; int FieldC; int FieldD; a1 = 1; a2 = 1; a3 = 1; a4 = 1; b1 = 1; b2 = 1; b3 = 1; c1 = 1; d1 = 1; d2 = 1; d3 = 1; d4 = 1; d5 = 1; d6 = 1; // compute input fields to compare it later with output fields FieldA = (a1) | (a2 << 1) | (a3 << 2) | (a4 << 3); FieldB = (b1) | (b2 << 1) | (b3 << 2); FieldC = (c1); FieldD = (d1) | (d2 << 1) | (d3 << 2) | (d4 << 3) | (d5 << 4) | (d6 << 5); // print field values printf( "FieldD: %d \n", FieldD ); printf( "FieldA: %d \n", FieldA ); printf( "FieldB: %d \n", FieldB ); printf( "FieldC: %d \n\n", FieldC ); // number of rows Stream[0] = 6; // row lengths Stream[1] = 4; Stream[2] = 3; Stream[3] = 3; Stream[4] = 2; Stream[5] = 1; Stream[6] = 1; // sorted information stream: // d1a1b1c1d2a2b2d3a3b3d4a4d5d6 // data bits Stream[7] = d1; Stream[8] = a1; Stream[9] = b1; Stream[10] = c1; Stream[11] = d2; Stream[12] = a2; Stream[13] = b2; Stream[14] = d3; Stream[15] = a3; Stream[16] = b3; Stream[17] = d4; Stream[18] = a4; Stream[19] = d5; Stream[20] = d6; // now the decoding algorithm: // determine number of rows RowCount = Stream[0]; // extract row lengths RowLength[0] = Stream[1]; RowLength[1] = Stream[2]; RowLength[2] = Stream[3]; RowLength[3] = Stream[4]; RowLength[4] = Stream[5]; RowLength[5] = Stream[6]; // determine field count FieldCount = RowLength[0]; // row[0] indicates number of fields. // I will help out a bit... by leaving this code in ! ;) seems somewhat obvious ;) // first determine data offset properly ! ;) :) 1 for the row count + // RowCount to skip over row lengths. DataOffset = 1 + RowCount; RowOffset[0] = DataOffset; RowOffset[1] = RowOffset[0] + RowLength[0]; RowOffset[2] = RowOffset[1] + RowLength[1]; RowOffset[3] = RowOffset[2] + RowLength[2]; RowOffset[4] = RowOffset[3] + RowLength[3]; RowOffset[5] = RowOffset[4] + RowLength[4]; // some how the data bits from the stream needs to end up in these 4 // processors so that it produces the same values // as below: // fields may be processed in a different order though. // *** You will need to replace this code with your own code... and // preferably it should be parallel, fast and somewhat general/scalable. *** Processor[0] = FieldD; Processor[1] = FieldA; Processor[2] = FieldB; Processor[3] = FieldC; // print processor values. printf( "Processor[0]: %d \n", Processor[0] ); printf( "Processor[1]: %d \n", Processor[1] ); printf( "Processor[2]: %d \n", Processor[2] ); printf( "Processor[3]: %d \n\n", Processor[3] ); return 0; } // End of Dummy Decoder Example Bye, Skybuck :) -- https://mail.python.org/mailman/listinfo/python-list
Re: Dummy Decoder Example (was Re: Parallel decoding lesson for you.)
Also here is test set 2 to test input values: // input test 2, c version a1 = 1; a2 = 0; a3 = 0; a4 = 1; b1 = 1; b2 = 1; b3 = 0; c1 = 1; d1 = 1; d2 = 1; d3 = 0; d4 = 0; d5 = 1; d6 = 0; Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Dummy Decoder Example (was Re: Parallel decoding lesson for you.)
Just to be clear on this, the code you have to write doesn't need to be truely parallel. It must be parallel in potential, so it should be able to execute independenlty from each other and out of order. Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Dummy Decoder Example (was Re: Parallel decoding lesson for you.)
Since more people might be interested in this I will re-post this a second time to include more newsgroups... those two threads will need to be followed if all responses are to be seen ;) Here is your dummy decoder example: Let's turn this into a somewhat of a contest and ofcourse also teaching lesson... now I am a true teacher... I provided you with most of the code. The code you will need to write yourself/replace is indicated by // *** Good luck and may the force be with you ! Ofcourse as announced earlier on 29 september 2015 I will reveal my parallel solution to all of you ! So you have now 9 days to come up with your own solution before I publish mine ! ;) =D For those that missed the start/most of this thread, try googling for comp.arch and "Parallel decoding lesson for you" by Skybuck. // Begin of Dummy Decoder Example program TestProgram; {$APPTYPE CONSOLE} {$R *.res} uses System.SysUtils; function Constrain( Para : integer ) : integer; begin result := Para; if Para < 0 then Result := 0; if Para >= 1 then Result := 1; end; procedure Main; // must put variables here otherwise won't show up in debugger. var // information stream, input Stream : array[0..20] of integer; // bits representing fields of data a1,a2,a3,a4 : integer; b1,b2,b3 : integer; c1 : integer; d1,d2,d3,d4,d5,d6 : integer; // output RowIndex : integer; RowCount : integer; RowLength : array[0..5] of integer; RowOffset : array[0..5] of integer; DataOffset : integer; FieldCount : integer; FieldLength : array[0..3] of integer; Processor : array[0..3] of integer; // debug fields FieldA : integer; FieldB : integer; FieldC : integer; FieldD : integer; begin a1 := 1; a2 := 1; a3:= 1; a4 := 1; b1 := 1; b2 := 1; b3 := 1; c1 := 1; d1 := 1; d2 := 1; d3 := 1; d4 := 1; d5 := 1; d6 := 1; // compute input fields to compare it later with output fields FieldA := (a1) or (a2 shl 1) or (a3 shl 2) or (a4 shl 3); FieldB := (b1) or (b2 shl 1) or (b3 shl 2); FieldC := (c1); FieldD := (d1) or (d2 shl 1) or (d3 shl 2) or (d4 shl 3) or (d5 shl 4) or (d6 shl 5); // print field values writeln( 'FieldD: ', FieldD ); writeln( 'FieldA: ', FieldA ); writeln( 'FieldB: ', FieldB ); writeln( 'FieldC: ', FieldC ); writeln; // number of rows Stream[0] := 6; // row lengths Stream[1] := 4; Stream[2] := 3; Stream[3] := 3; Stream[4] := 2; Stream[5] := 1; Stream[6] := 1; // sorted information stream: // d1a1b1c1d2a2b2d3a3b3d4a4d5d6 // data bits Stream[7] := d1; Stream[8] := a1; Stream[9] := b1; Stream[10] := c1; Stream[11] := d2; Stream[12] := a2; Stream[13] := b2; Stream[14] := d3; Stream[15] := a3; Stream[16] := b3; Stream[17] := d4; Stream[18] := a4; Stream[19] := d5; Stream[20] := d6; // now the decoding algorithm: // determine number of rows RowCount := Stream[0]; // extract row lengths RowLength[0] := Stream[1]; RowLength[1] := Stream[2]; RowLength[2] := Stream[3]; RowLength[3] := Stream[4]; RowLength[4] := Stream[5]; RowLength[5] := Stream[6]; // determine field count FieldCount := RowLength[0]; // row[0] indicates number of fields. // I will help out a bit... by leaving this code in ! ;) seems somewhat obvious ;) // first determine data offset properly ! ;) :) 1 for the row count + RowCount to skip over row lengths. DataOffset := 1 + RowCount; RowOffset[0] := DataOffset; RowOffset[1] := RowOffset[0] + RowLength[0]; RowOffset[2] := RowOffset[1] + RowLength[1]; RowOffset[3] := RowOffset[2] + RowLength[2]; RowOffset[4] := RowOffset[3] + RowLength[3]; RowOffset[5] := RowOffset[4] + RowLength[4]; // some how the data bits from the stream needs to end up in these 4 processors so that it produces the same values // as below: // fields may be processed in a different order though. // *** You will need to replace this code with your own code... and preferably it should be parallel, fast and somewhat general/scalable. *** Processor[0] := FieldD; Processor[1] := FieldA; Processor[2] := FieldB; Processor[3] := FieldC; // print processor values. writeln( 'Processor[0]: ', Processor[0] ); writeln( 'Processor[1]: ', Processor[1] ); writeln( 'Processor[2]: ', Processor[2] ); writeln( 'Processor[3]: ', Processor[3] ); writeln; end; begin try Main; except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; ReadLn; end. // End of Dummy Decoder Example Oh one last thing when you think you have a valid solution and/or need to test more, replace the initialization of the test data bits with this initialization for example: a1 := 1; a2 := 0; a3:= 0; a4 := 1; b1 := 1; b2 := 1; b3 := 0; c1 := 1; d1 := 1; d2 := 1; d3 := 0; d4 := 0; d5 := 1; d6 := 0; in the original posting (the one before this they were all set to 1). This helped a bit during the development just to see if it was reading anything at all at the somewhat correct places. But this may later put you off if the values are not matching input vs output. So this test data in this posting is better to spot any inconsistencies/bugs in your solution(s). Bye, Skybuck.
Re: Dummy Decoder Example (was Re: Parallel decoding lesson for you.)
Or point your newsgroup reader to newsgroup: comp.arch Then see thread/topic: "Parallel decoding lesson for you" by Skybuck. Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Python handles globals badly.
"Ned Batchelder" wrote in message news:180fe671-7bf9-4544-a3ad-d98a4a497...@googlegroups.com... On Sunday, September 13, 2015 at 8:11:13 AM UTC-4, Skybuck Flying wrote: I don't even understand how python interpreter works but I can understand it better than you guys do apperently hahaha. " As tempting as it is to respond to Skybuck, with a brief pause to consider, and a deep breath, I'm sure we can all agree that there is no point in it. Skybuck: go in peace, and thanks for being part of the Python community. " Go in Peace yourself -- https://mail.python.org/mailman/listinfo/python-list
Re: Python handles globals badly.
" Namespaces don't "become writeable". The purpose of "global" is to tell the compiler that this name should be bound in the global namespace, not the local namespace. " How does it become writeable then ? Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Python handles globals badly.
"Steven D'Aprano" wrote in message news:55f566c8$0$1644$c3e8da3$54964...@news.astraweb.com... On Sun, 13 Sep 2015 10:04 pm, Skybuck Flying wrote: " Namespaces don't "become writeable". The purpose of "global" is to tell the compiler that this name should be bound in the global namespace, not the local namespace. " How does it become writeable then ? " It's always writeable. " Thus my logic is correct. By making something global, it ends up in the global namespace, and it becomes writeable. I don't even understand how python interpreter works but I can understand it better than you guys do apperently hahaha. Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Python handles globals badly.
I may add to that: Just like most programmers don't truely understand what a compiler does ! HAHAHAHAHA. C programmers, Delphi programmers, Java programmers. What python's interpreter is doing same thing, probably completely irrelevant. Except when it comes to making changes to how python works ;) I don't need to know how the Python interpreter works, cause I will never change Python's implementation. However as indicated I did try to help out. Reversing the logic for python's global functioning should be possible. Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Python handles globals badly.
"Emile van Sebille" wrote in message news:mailman.433.1442078406.8327.python-l...@python.org... On 9/11/2015 10:22 PM, Skybuck Flying wrote: I didn't learn anything from this posting, sorry ! ;) " I'm seeing a pattern here... " Only thing I might have learned from him was global namespace make thing writeable. But now somebody else says nope. So I can truely say nothing was learned. Explaining concepts to people takes something different. As far as I am concerned python works with objects like Delphi. And everything else is a reference to it. And the globals are somehow protected. But he's as clueless as everybody else seems to be. For me it doesn't matter since I will write python code just fine without understanding any of it. Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Python handles globals badly.
From what he wrote I can see he's not making much sense... Neither are you. Just lot's of nag and little python related stuff. Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Python handles globals badly.
"Random832" wrote in message news:mailman.242.1441758354.8327.python-l...@python.org... MRABwrites: If you're allowed to specify both bounds, why would you be forbidden from negative ones? " It makes it non-obvious what value should be returned from e.g. search methods that return a negative number on failure. .NET's IndexOf function returns -1, but MaxValue if the array has a negative bound. BinarySearch returns the complement of the nearest index to the value you were searching for, which requires some gymnastics if you want to make use of it for an array that has negative and positive bounds. " Yes pascal/Delphi allows negative bounds if I recall correctly, example: var vIntegerArray : array[-10..10] of integer; You have just given a very good reason why to not use negative values for return values/indications of success or failure. In pascal I pretty much always try and use booleans to return success. This is a smart thing to do... especially in pascal/Delphi, since one never knows when one is dealing with negative numbers having processing needs. -1 could then cause problems/troubles/errors. There is a drawback of using booleans which I suspect is the real reason why C programmers for example like to use -1 to indicate failure. It's "speed/performance". Using a seperate boolean doubles memory requirement and might or might not require extra processing time from the CPU. Delphi usually optimizes these booleans to be returned in EAX register... so it's a register based thing... if enough registers or so are available otherwise perhaps some pushes/pops needed... not sure about that last thing. Whatever the case may be... I will assume for now... that nowadays the performance impact of using booleans as return values is not that great ? Also I am not sure... but perhaps booleans allow safer/better procesing of boolean operations. Not sure how -1 or if -1 could lead to problems with or/and statements... mixing C function results will also become problematic... sometimes C functions return 0 to indicate failure. Sometimes 0 can even mean success. So C is pretty inconsistent when it comes to return values. Hence I believe Pascal/Delphi to be better/safer at this. Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Python handles globals badly.
Hello, I'll add some arguments to the global discussion for you. First a look back at the origin of this "global" keyword, basically it's idea behind it, which is probably a flawed assumption. The origin/purpose of global as I now understand it is to give "write" access to globally declared variables. This is first of all something unusual. Which other programmer language has this weird/whacky inconsistency ? In general I believe inconsistent behaviour should be prevented in programming languages. Anyway... having written/said that... there is a flawed assumption with this idea. The assumption is that: "writing to globals is bad and can lead to bugs". The further assumption is that: "denieing write access to globals prevents bugs". Especially the last assumption is just plain wrong. Not giving write access to globals can also lead to even much harder to find bugs. The unaware programmer may assume that a global was changed, while in reality it was not. How will such a bug be found ? Very hard to do in general, especially in an interpreter like python... where these bugs will need to be catched at run time. Catching these bugs at runtime is far more difficult than bugs/errors which show up during compile time. Thus forgetting "global" is going to be a far worse mistake... then actually overwritten or re-using some global accidently. This kind of mistake can be checked by the programmer without requiring runtime inspection. As soon as the programmer notices that some global is being re-used abusively the programmer can correct the situation. With forgetting the global keyword not so... much harder to find. Only possibility is to add "global" everywhere out of paranoya... which prevents the programmer from having to inspect every possibly line of code. The global/write access requirement right now basically forces the programmer to check EVERY line of python code to see if a global is being written to which actually does not have the required write permission ?!? How can anybody in their right mind think that is is somehow an improvement ? It simply is not... unless the interpreter at runtime would start to BEEP or show ERROR messages in some log... that a global is being written too which actually does not have WRITE permissions ? So far I have only used Sikuli to develop in Python... so let me ask a question here: Is there ANY Python IDE that actually produces such a warning or error message at runtime Is there any IDE which outputs: "Error: GLOBAL variable being written too without WRITE permission ?!?". How would the interpreter know that it is a global variable ? Well it's declared somewhere outside the scope of the function... so that's not the issue... issue is missing GLOBAL declaration inside the function... so it's more of a "WRITE" permission than "global permission". So the name itself: "GLOBAL" is somewhat misleading... it's more a "WRITE" permission lol. Just that reason alone is enough to remove "GLOBAL" from python language and replace it with: "WRITE". or if it has to be: "GLOBAL-WRITE". But any programmer would probably find that ridicilous. So that basically proves that this GLOBAL requirement in itself is pretty ridicilous... though it does give a nice hint that this variable is a global variable ?! But is that really necessary ?!? Perhaps, perhaps not... in PASCAL one would simply look at the top section of the function... where all variable must be declared, python lacks this feature which is kinda nice... but it does make it a bit problematic to spot if something is local or global. While the next best thing the python programmer can do is: inspect the entire function to see if the variable is being written to or read from somewhere... but in reality this is no garantuee that it is local or global... so hence a little bit of a problem... adding global to the language is not really going to solve that... since programmer will have to add that manually to a variable... might forget it... and then the variable will actually still be a global variable.. and any bug fixer will still need to inspect code. So basically this global requirement doesn't really help that much... as some say... it's a bit of a hint... a shitty one for that... it's almost like fuzzy logic... 50% chance that it's gonna help... 50% it's not gonna help ;) or might even lead to problems if read-only behaviour was actually required. So when it comes to assumptions which bug is worse: 1. Willfully writing to a read-only global variable. (assignment failed-bug) 2. Mistakenly writing to a writeable global variable. (overwrite-bug) As I already wrote before I think bug1 is much harder to spot then bug 2 by pure code inspection. Ask yourself one question: How many times does a programmer actually want a "read-only" global variable ? This seems very weird to me. Pascal solves this very nicely for "constants" with
Re: Python handles globals badly.
"Michael Torrie" wrote in message news:mailman.384.1442016089.8327.python-l...@python.org... On 09/11/2015 03:50 PM, Skybuck Flying wrote: Something which python does not seem to do currently ?! So that's weird. I will leave it at that for now. " Seems to me you have a completely mistaken understanding of how variables work in Python. This is one of the reasons why I have said in the past, erroneously, that Python does not have variables. It does of course but not in the same way as C or Pascal. In those languages names are source-code abstractions only, and irrelevant to the compiler and machine code. C and Pascal define variables as boxes that can be written to. Not so in Python. " Well you basically said it yourself: " irrelevant to the compiler and machine code". That's kinda nice about a high level language. Programmer does not need to understand anything below the language. A python programmer shouldn't need to understand a damn thing to write: A = 10 A = A + 1 print A However for sake of your discussion I will continue your arguments below, since I get the impression you guys are clueless how to change python implementation ;) " In Python most common objects are immutable. Meaning they can never change or be overwritten. They are bound to names. This binding is what makes names look like and act like traditional variables. The secret to understanding the global keyword is to understand how Python namespaces work. The statement "a=5" does not assign a 5 to the box called "a." Rather it binds the name "a" to the "5" object, which is immutable and called into existence by the interpreter implementation. Subsequently "a=6" disconnects a from the 5 object, casting the 5 object loose to be reclaimed in some fashion that doesn't matter at this point. "a" is then rebound to a new object, 6. " What happens for following code: A=123456789011 Are you going to claim it's going to bind to all these numbers and then also multiple times ? Sounds a bit shady ?! ;) Perhaps python considers it a string ? Python applies math to strings ? Sounds a bit slow... therefore perhaps you're wrong... " When doing a look-up on a name, the interpreter first checks the local scope's dictionary and if it does not find the name there there, goes to the outer scope and so forth until you get to the module global namespace. So we don't need any special keywords to do Pascal-style constants. We just define them in the module and they work. Usually we name them in all caps so we have a bit of a convention as to where they come from. And yes we're talking about looking up strings in a dictionary here. " So big deal, solution is easy to see, invert interpreter logic: Everything declared is "not constant". Everything declared as "constant" suddenly becomes constant. And thus everything declared as not constant behaves the same way as "global", problem solved. " When binding a name to an object, the interpreter always binds a name in the local namespace, unless the global keyword has been used previously and then it goes right to the global namespace. As has been said numerous times on this thread, how else would the interpreter do this? There simply isn't any other way that makes sense. Certainly you haven't made the case for it, seeing as you have some fundamental misunderstandings about variables in Python. " You didn't completely explain how the global namespace becomes writeable ? or re-bindeable ? (It seems not necessary to explain it you implement the constant idea, as explained above already). Do I have to assume that global namespace is "re-bindeable" = writeable ? " You keep saying things like "writing to a variable" or "declared variables" which just don't apply to Python because that's not how Python variables work. It may appear this way on the surface, but the differences are subtle yet important. Namespaces are written to, not variables, some objects can be mutated. Names are bound to objects, but variables are not declared, as a name can be bound to an object of any type. " Well again you didn't explain how using namespaces suddenly lead to "rewritable" and/or "rebinding" if A is declared as global as follows: global A and then code is written as follows: A = 10 A = 20 def Test() global A = 30 return How does this make A "rewriteable" ? Or "rebindable" to 30 ? " Namespaces are powerful constructs that give Python much of its dynamic nature and expressivity. Learn to use them! " I didn't learn anything from this posting, sorry ! ;) Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Integers with leading zeroes
Don't be noob ? ;) Always remove leading zeroes ? One case that comes to mind is ASCII art like code... where programmer may want to align numbers for clearity: 0014324 0234545 345 0534543 ^ That could be a problem but possibly solveable with spaces instead: 14324 234545 345 534543 ^ Looks less good though in non-fixed-sized font. Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Parser needed.
Well it did help a little bit. Somebody asked if there was already a parser for it. I answered yes in C#. So I took a closer look at it... and learned something from it. Maybe I would have done that anyway... or maybe not... Now we will never know... but I am happy that the parser is now ok, done and pretty easy extendable. I think it's probably my first really good one. I did do a little assembler before... but not sure if it was any good. I also read before I started the thread... what parse means in dictionary. That also helped me understand it a little bit better. And also I read how it's usually done... tokens/tokenize etc... kinda already knew that... but still. Turned out to be quite easy... But at the start /always it seemed so difficult... So any little bits of help/advice/information can help ! :) Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: I don't like the OO part of python. In particular the self keyword everywhere.
Another typo corrected... see (*) Skybuck Flying wrote in message news:2c87e$55796f2c$5419aafe$47...@news.ziggo.nl... Little typo corrected... it's a common typo I seem to make. with had to be without see ***. Skybuck Flying wrote in message news:... Hello, I don't like the object orientated part of Python. The idea/prospect of having to write self everywhere... seems very horrorific and a huge time waster. (Perhaps the module thing of python might help in future not sure about that). What are your thoughts on the self thing/requirement. I only want replies from expert programmers, cause we need a language for expert programmers... Not noobies that need to be hand-held... Personally I think I could do just fine without (***) the self keyword everywhere. So question is... can the python interpreter/compiler be written in such a way that self can be left out ? In other words: Is there any hope... that this part of the language will be cleaned up some day ? Are there any tricks to get rid of it ? Maybe with (*) like in Delphi ? I haven't written much OO code yet in Python... and don't plan on doing it too... Cause it looks hellish confusing... and clouded/clodded. I think I have better things to do then to insert self everywhere... It's almost like self masturbation LOL. Bye, Skybuck =D -- https://mail.python.org/mailman/listinfo/python-list
Re: I don't like the OO part of python. In particular the self keyword everywhere.
Little typo corrected... it's a common typo I seem to make. with had to be without see ***. Skybuck Flying wrote in message news:... Hello, I don't like the object orientated part of Python. The idea/prospect of having to write self everywhere... seems very horrorific and a huge time waster. (Perhaps the module thing of python might help in future not sure about that). What are your thoughts on the self thing/requirement. I only want replies from expert programmers, cause we need a language for expert programmers... Not noobies that need to be hand-held... Personally I think I could do just fine without (***) the self keyword everywhere. So question is... can the python interpreter/compiler be written in such a way that self can be left out ? In other words: Is there any hope... that this part of the language will be cleaned up some day ? Are there any tricks to get rid of it ? Maybe white like in Delphi ? I haven't written much OO code yet in Python... and don't plan on doing it too... Cause it looks hellish confusing... and clouded/clodded. I think I have better things to do then to insert self everywhere... It's almost like self masturbation LOL. Bye, Skybuck =D -- https://mail.python.org/mailman/listinfo/python-list
I don't like the OO part of python. In particular the self keyword everywhere.
Hello, I don't like the object orientated part of Python. The idea/prospect of having to write self everywhere... seems very horrorific and a huge time waster. (Perhaps the module thing of python might help in future not sure about that). What are your thoughts on the self thing/requirement. I only want replies from expert programmers, cause we need a language for expert programmers... Not noobies that need to be hand-held... Personally I think I could do just fine with the self keyword everywhere. So question is... can the python interpreter/compiler be written in such a way that self can be left out ? In other words: Is there any hope... that this part of the language will be cleaned up some day ? Are there any tricks to get rid of it ? Maybe white like in Delphi ? I haven't written much OO code yet in Python... and don't plan on doing it too... Cause it looks hellish confusing... and clouded/clodded. I think I have better things to do then to insert self everywhere... It's almost like self masturbation LOL. Bye, Skybuck =D -- https://mail.python.org/mailman/listinfo/python-list
Re: I don't like the OO part of python. In particular the self keyword everywhere.
Then again... I also believe the highest goal for a programming language is natural spoken language. If self.somefield equals 10 then... Does have some understandable ring to it. However... time constraints also have to be kept in mind. In another words if the code looks like begin of class section if somefield equals 10 then... end of class section Should be pretty obvious that somefield belongs to class section... So no need to specify self... If I wanted to access a global variable I would use the existing global thing global SomeField... maybe if I wanted to use a local variable for routine: local SomeField... seems nicer... then having to use self everywhere... Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Parser needed.
Euhm... My parser is already done... since today Loving it too Wrote it myself... based on the c# code technique explained somewhere in this thread too Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Parser needed.
Oh I think I forgot to mention... parser is now getting close to 1 second... with tokenizer and such. But I think this is still within acceptable performance level for now. Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Parser needed.
I made it way too difficult on myself with that stupid dictionary bs... What I really wanted was to know if the ref was already in the reflist. Turns out python has a really nice simple operation for that: if not (Ref in EntityRef): EntityRef.append(Ref) DONE ! =D No need for dictionary. Anyway... I am trying a more robust parser... because my own parser right now didn't work out for new inputs. It almost worked except for first item... don't know what problem was maybe just this... But I'll try and do it the usually way. Tokenize, Parse etc. It's significantly slower though. Maybe an idea for a new kind of parser could be: Find all recgonized token keywords in one go... and stuff all find indexes into a list... and then perhaps sort the list... and then use the sorted list... to return token found at that position... and then start processing like that... Benefit of this idea is less characters to compare... and could be done with just integer compare... or even lookup table processing. Added benefit is still in-order which is nice. For now I won't do it... cause I am not sure it would be an improvemt. Another idea which might be an improvement is. Parallel searching... ofcourse that might not be possible... though... multi core does it exist and threading too. But to mimic parallel searching and to prevent problems. A sliding window approach could be taken. And perhaps items found that way in a certain buffer or so and then still added to processing list or so... which kinda mimics parallel search... but just uses data cache nicely. Though it's somewhat of a complex method... I will avoid it for now. The split() routine is real nice... to get rid of fudd/white space... and just tokens which is nice. So for now I will use that as my tokenizer ;) =D and bracket level counting and sections and stuff like that yeah... Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Parser needed.
get was tried but now new error somewhere else: [error] TypeError ( list indices must be integers ) [error] --- Traceback --- error source first line: module ( function ) statement 133: main ( ProcessUpdateEntityDead ) DemoEntityDead[DemoEntityIndex] = Dead Apperently the returned index from get is not an integer ? Weird... so far dictionaries offer misery. Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Parser needed.
Well... I must say I am impressed: Python parsers the file/info I want in just: Seconds: 0.013389648 For +/- 20.000 lines of input data/text. This makes it very usuable cool ! Now I try the bigger file: +/- 285.000 lines of input data/text: Seconds: 0.092351501 Very impressive ! I guess I was wrong about python... Python pretty good at text processing wieee =D Bye, Skybuck =D -- https://mail.python.org/mailman/listinfo/python-list
Re: Parser needed.
Ok problem found. The data contains: EntityRef EntityRef So perhaps I screwed it up or perhaps the data is a bit bad. I ll check on my web drive: http://www.skybuck.org/Games/StartrekOnline/Parser/SpaceFleetAlertEnemyExample.demo Firefox doesn't find it... so apperently I fucked up data a bit... Ok so it's not a bug... thank god for that. So this is not really a problem. Now to redownload this file for now or so ;) Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Parser needed.
Very nice code almost done. Now I am trying to do the code correctly and fast, thus using a dictionary, but I run into a little problem: The dictionary is declared as: DemoEntityRefIndex = {} Pairs are added as: DemoEntityRefIndex[Ref] = DemoEntityIndex And now I try to retrieve the demo entit index as follows: DemoEntityIndex = DemoEntityRefIndex[Ref] But somehow it fails with error: [error] script [ ParseDemoFile ] stopped with error in line 211 [error] KeyError ( EntityRef ) [error] --- Traceback --- error source first line: module ( function ) statement 146: main ( ProcessUpdateEntityRef ) DemoEntityIndex = DemoEntityRefIndex[Ref] Hmm.. I may try dict.get maybe that ll help. Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Parser needed.
I feel my conclusion is a bit hasty... but using dictionaries is not easy that for sure. Apperently the problem is DemoEntityInde is none ? But why would it be none ? Hmmm strange... maybe some refs are not in there... hmmm... Yeah could be... I cutted some stuff out... so I better check for none then for now ;) So for now consider this solved, unless I return ! ;) :) Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Parser needed.
Something strange happens with: 36044817 near the update section... for some reason it doesn't copy it properly... Hmm... Maybe a bug in output or an additional new line or maybe something wrong... Hmm.. Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Parser needed.
Yes these string processing techniques will work very nicely and very fast: cut and pasted an example but should work... now I developed it a bit further, bye ,bye. BotDemoFolder = C:\\Games\\Startrek Online\\Startrek Online\\Cryptic Studios\\Star Trek Online\\Live\\demos BotDemoFile = SpaceFleetAlertEnemyExample.demo import time def ProcessEntityRef(): global DemoChars global CreatedEntsIndex StartIndex = DemoChars.find(EntityRef, CreatedEntsIndex) StopIndex = DemoChars.find(\n,StartIndex) if StartIndex -1: Ref = DemoChars[StartIndex:StopIndex] else: Ref = 0 return Ref def ProcessCreatedEntities(): global DemoChars global CreatedEntsIndex CreatedEntsIndex = 0 while (CreatedEntsIndex -1): # and (CreatedEntsIndex 10): CreatedEntsIndex = DemoChars.find(createdEnts, CreatedEntsIndex) RefNumber = ProcessEntityRef() if CreatedEntsIndex -1: CreatedEntsIndex = CreatedEntsIndex + 1 print RefNumber: + str(RefNumber) return def Main(): global DemoChars DemoFilePath = BotDemoFolder + \\ + BotDemoFile FileObject = open( DemoFilePath, r) # DemoLines = FileObject.readlines() # ParseDemoLines( DemoLines ) DemoChars = FileObject.read() ProcessCreatedEntities() # Index = DemoChars.find(createdEnts) # print DemoChars[Index:Index+5] # rfind # ParseDemoChars( DemoChars ) FileObject.close() return print program started Tick1 = time.time() Main() Tick2 = time.time() Seconds = Tick2 - Tick1 print program finished # Skybuck -- https://mail.python.org/mailman/listinfo/python-list
Re: Parser needed.
Yeah... my first nice parser for this kind of stuff... Python is really nice for this stuff... Piece a cake.. now I just need to stuff it in some dictionary and I am done or so ;) Though a dictionary might be hard to traverse in sequence... A list is probably enough... assuming no duplicate entries for now... And done ;) =D Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Parser needed.
MRAB wrote in message news:mailman.71.1433263397.13271.python-l...@python.org... On 2015-06-02 05:45, Skybuck Flying wrote: Example for python: MyString = Hello World print MyString.rfind(World) if MyString.rfind(World): print yes else: print no Pretty cool. .rfind returns the index if found, -1 if not found. World.rfind(World) returns 0, which will be treated as false. foo.rfind(World) returns -1, which will be treated as true. Yes I agree, that code is not very clean. Hence I added: print MyString.rfind(World) Just to figure out if it indeed prints an index. Index 0 might be of use too, so checking for true/false like I did above should not be done. Consider it incorrect code. However I didn't care at the time cause I was in a hurry... I knew it was dirty but this post correct that and warns people not to write code like I did... just in case ! ;) And also to let you know I am full aware of the shady nature of this code ! ;) =D Bye, Skybuck :) -- https://mail.python.org/mailman/listinfo/python-list
Re: Parser needed.
This will probably help: http://stackoverflow.com/questions/14676265/how-to-read-text-file-into-a-list-or-array-with-python text_file = open(filename.dat, r) lines = text_file.readlines() print lines print len(lines) text_file.close() Usually I like to consult officals docs though...Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Parser needed.
Some further information about the demo file: It seems to be split up into creation sections and update sections. The update sections contain the positions. The update sections also contain a reference number to the created entities. (There is one empty creation section but that's because I cut it out... so it can be ignored for now). Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Parser needed.
Readlines is indeed documented as reading EOF: http://www.tutorialspoint.com/python/file_methods.htm Bye, skybuck. Skybuck Flying wrote in message news:37cda$556d009d$5419aafe$38...@news.ziggo.nl... This will probably help: http://stackoverflow.com/questions/14676265/how-to-read-text-file-into-a-list-or-array-with-python text_file = open(filename.dat, r) lines = text_file.readlines() print lines print len(lines) text_file.close() Usually I like to consult officals docs though...Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Parser needed.
Since the file is probably ascii... not sure... I might come away with: file.read([size]) Reads at most size bytes from the file (less if the read hits EOF before obtaining size bytes). The doc does not mention is size is optionally... I will try and leave it out, see what happens, otherwise a big number will have to be given or so... or perhaps retrieve file size and add it. Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Parser needed.
Test program shows, python/sikulix can handle about 3m chars per second so I must continue with a parser attempt. # test char processing speed. # test if sikulix 1.1, python, jython/whatever is a piece of shit when it comes to parsing dealing with characters, unicode processing bottleneck theory. import time import random MaxChars = 300 MinChar = 33 MaxChar = 200 Chars = [] def GenerateChars(): vRandomChar = for vIndex in range(0, MaxChars): vRandomChar = chr(random.randrange(MinChar,MaxChar)) Chars.append(vRandomChar) return def ProcessChars(): Result = 0 for vIndex in range(0, MaxChars): if Chars[vIndex] == chr(45): Result = Result + 1 return Result Tick1 = time.time() GenerateChars() Tick2 = time.time() Seconds = Tick2 - Tick1 print GenerateChars seconds: + str(Seconds) Tick1 = time.time() ProcessChars() Tick2 = time.time() Seconds = Tick2 - Tick1 print ProcessChars seconds: + str(Seconds) #print Chars -- https://mail.python.org/mailman/listinfo/python-list
Re: Parser needed.
Perhaps the list.append operation is the cause of the slowdown, or perhaps my algo is flawed. No idea yet with slowdown of parser code so far. Instead of trying to debug everything going to add some time outputs to the whole thing to get to bottom of this ;) Ok another sikuli failure... I just won't run the script... this is seriously getting on my tits...and I am seriously getting on your tits. Time to nuke sikuli for now... and either give up on this idea... Or try it in a more serious dev environment cause this sucks balls. To bad this was a failure, bye bye. Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Parser needed.
Hmm this parser uses an interesting technique: if line.Contains(activePlayerRef): self._activePlayerRef = Convert.ToInt64(line.Substring(line.LastIndexOf(activePlayerRef) + 16)) I'll see if python can do this as well... ;) Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Parser needed.
Michael Torrie wrote in message news:mailman.31.1433207544.13271.python-l...@python.org... On 06/01/2015 06:29 PM, Skybuck Flying wrote: The parser should be able to parse a textfile of somewhere between 20.000 lines to 50.000 lines in about 1 to 2 seconds. My environment is SikuliX 1.1 I don't have any inclination to examine your input files, but you could certainly mock up a parser fairly quickly with the fantastic pyparsing module (you'll have to install it from your distro's package manager, or through pip. Once you have figure out how to parse the data you can fill in your data structures as you go along. Pyparsing has pretty good docs; just google for it. Usually first I get pyparsing working on my input file, then I add code to each of the steps along the way to actually do something with the data that has been parsed. You could parse it manually using regular expressions if the data is fairly structured and regular. It seems the data file is structure as: { structure name { SomeField SomeData another structure name { SomeField SomeData } } } Example: { createdEnts { EntityRef 29294664 ContainerID 65086 EntitySendDistance 1500.00 entityTypeEnum ENTITYCRITTER CostumeV5 { hReferencedCostume Loot_Space_Common_01 } } } How hard would it be to encode that into pyparser ? Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Parser needed.
Yes this will work: DemoChars = FileObject.read() I think this is a cleaner solution. EOL can be ignored and focusses on { } and stuff like that... when extracting information EOL could be used as well. Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Parser needed.
Test program shows, python/sikulix can handle about 3m chars per second so I must continue with a parser attempt. Apperently there is some bottleneck/slowdown in posted code... I may have to slow down a bit take more time... and perhaps use global vars or so... instead of parameters. Maybe that will help, not sure. Kinda strange... how test program is super fast in other thread and this one is slow. Maybe it's the printing that's slow... Hmm... I shall test print speed instead to figure this out. Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Parser needed.
I will try and help for as far as possible, maybe I will end up writing it myself in the process. The first problem seems to be, how to read a textfile into python all at once... and then perhaps process them per line. Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Parser needed.
Joel Goldstick wrote in message news:mailman.34.1433209315.13271.python-l...@python.org... On Mon, Jun 1, 2015 at 9:31 PM, Skybuck Flying skybuck2...@hotmail.com wrote: Yes this will work: DemoChars = FileObject.read() I think this is a cleaner solution. EOL can be ignored and focusses on { } and stuff like that... when extracting information EOL could be used as well. Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list This is kind of a q and a mailing list. I'm baffled by all of your posts, that seem to be a conversation with yourself. Do you have a question you need help with? All of my postings contain things I run into. Missing documentation, python limitations, and other problems. Algo design considerations etc. What I need help with is a parser for the file mentioned in the link. So far it looks bad for python. I may give the parser frameworks a try to see if they are speedier then 120 chars per second ?! :P :) Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Parser needed.
I am trying to rush it a bit but things are starting to go to hell. SikuliX needs to be restarted continously to deal with bugs. Plus Eclipse breakpoints cannot be set. So both IDEs totally suck for any complex code development. Plus I can already tell this is going to be insanely slow in python for some reason. I am starting to have serious doubts for python as a parser platform: This simple piece of code already takes 10 seconds for just 120 characters ? HOLYSHIT ?! Bad sign. BotDemoFolder = C:\\Games\\Startrek Online\\Startrek Online\\Cryptic Studios\\Star Trek Online\\Live\\demos BotDemoFile = SpaceFleetAlertEnemyExample.demo import time def ParseDemoLines( ParaLines ): print Parsing + str( len(ParaLines) ) + lines. for LineIndex in range(0, len(ParaLines)): if { in ParaLines[LineIndex]: # how to process a line.. hmmm... print yup return def ParseStructureOpen( ParaChars, CharIndex ): # find eol before it and re-read characters until eol this is the structure name while (CharIndex = 0) and (CharIndex len(ParaChars)) and (ParaChars[CharIndex] \n): print CharIndex: + str(CharIndex) CharIndex = CharIndex - 1 # re-read characters for structure name StructureName = while (CharIndex len(ParaChars)) and (ParaChars[CharIndex] \n): print CharIndex: + str(CharIndex) StructureName = StructureName + ParaChars[CharIndex] CharIndex = CharIndex + 1 print StructureName return def ParseStructureClose( ParaChars, CharIndex ): pass return def ParseDemoChars( ParaChars ): print Parsing + str( len(ParaChars) ) + chars. for CharIndex in range(0, len(ParaChars)): print Parsing char index: + str(CharIndex) if ParaChars[CharIndex] == {: ParseStructureOpen( ParaChars, CharIndex ) elif ParaChars[CharIndex] == }: ParseStructureClose( ParaChars, CharIndex ) return def Main(): DemoFilePath = BotDemoFolder + \\ + BotDemoFile FileObject = open( DemoFilePath, r) # DemoLines = FileObject.readlines() # ParseDemoLines( DemoLines ) DemoChars = FileObject.read() ParseDemoChars( DemoChars ) FileObject.close() return print program started Tick1 = time.time() Main() Tick2 = time.time() Seconds = Tick2 - Tick1 print Time in seconds: + str(Seconds) print program finished Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Parser needed.
Together with this it's might be of some use: http://codeconverter.sharpdevelop.net/SnippetConverter.aspx It converts C# to Python pretty fast. I'll give it a try to see if it can work. Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Parser needed.
From examining the demo file it seems each bracketted data sections if pre-header/pre-fixed with it's name. So it's somewhat similar to a C structure: structure { } Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Parser needed.
This can help with parsing the C like bracketted data: http://stackoverflow.com/questions/1651487/python-parsing-bracketed-blocks algo: For each string in the array: Find the first '{'. If there is none, leave that string alone. Init a counter to 0. For each character in the string: If you see a '{', increment the counter. If you see a '}', decrement the counter. If the counter reaches 0, break. Here, if your counter is not 0, you have invalid input (unbalanced brackets) If it is, then take the string from the first '{' up to the '}' that put the counter at 0, and that is a new element in your array.Not sure what this is, but more points: Or this pyparsing version: from pyparsing import nestedExpr txt = { { a } { b } { { { c } } } } nestedExpr('{','}').parseString(txt).asList() [[['a'], ['b'], [[['c'] Not sure if I want a data structure like that... not sure what data structure it is anyway... seems to be a list in a list in a list... hmm Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Parser needed.
On 06/01/2015 07:19 PM, Skybuck Flying wrote: How hard would it be to encode that into pyparser ? Check out the docs and you probably will get an idea. The only real way to find out is to try it. Is this file from a certain program? If so, it's possible someone has already written a python library for reading it. It's from a game called Star Trek Online, I think there is a C# parser for it. The ammount of data I need from this file is very limited. I don't want to spent too much time on a solution. I have perhaps today to try and get a solution working ;) So no time to learn complex pyparsers ? If you can provide a simple example I might give it a shot ;) Otherwise I try to wing my own. Your help might be usefull later on if my own parser sux, fails or is too slow ;) Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Parser needed.
Actually that's not true... messages not that interesting. This C# parser does not parse what I want which is: updates and positions. Thus I rejected this parser some days ago. But it's technique could be handy. Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Parser needed.
Except for the first bracket... it has no structure name. Perhaps the demo filename could be used as structure name or just be left empty. Bye, Skybuck. Skybuck Flying wrote in message news:aef84$556d00e7$5419aafe$39...@news.ziggo.nl... From examining the demo file it seems each bracketted data sections if pre-header/pre-fixed with it's name. So it's somewhat similar to a C structure: structure { } Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Parser needed.
I really like this python help file, it has served me well so far: http://www.tutorialspoint.com/python/python_functions.htm It's unusually better than the rest on the net ;) It matches nicely Sikuli's python's capabilities. Bye, Skybuck :) -- https://mail.python.org/mailman/listinfo/python-list
Re: Parser needed.
So far this is what I got... I like to name things for what they are so FileObject I like better than something abstract/weird like text file, my code: BotDemoFolder = C:\\Games\\Startrek Online\\Startrek Online\\Cryptic Studios\\Star Trek Online\\Live\\demos BotDemoFile = SpaceFleetAlert.demo def Main(): DemoFilePath = BotDemoFolder + \\ + BotDemoFile FileObject = open( DemoFilePath, r) DemoLines = FileObject.readlines() print DemoLines print len(Demolines) FileObject.close() return Main() So far it took multiple seconds to print the demo lines... Hopefully that's just a printing issue to the console and not a processing limitation of python. I know python/sikulix can do about 500.000 if statements per second. I shall have to add some timing code, to rule out sikulix startup time... Hmmm.. Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Parser needed.
Here is a parser for sto demo files written in C# maybe it can be of some use, check trunk folders: http://sourceforge.net/p/stodemolauncher/code/HEAD/tree/ Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Parser needed.
If some of this code could be made to work it could be of some use: ParserEngine is the least important... MessageParser is interesting. class AbstractSectionsParser(AbstractParser): # Provides a method to return a list of sections def GetResult(self): # Returns the list with the found resources. pass class AbstractParser(object): # Must be implemented by objects that want to use the DemoFileParser. # Provides an empty implementation for conveniance def StartParsing(self, filename): # Is called before the first line is parsed. # filename Absolute path to the file being parsed pass def NewLine(self, line, lineNumber): # Is called by the parser when it has fetched a new line # line Content of the line # lineNumber Current line number (0 index) pass def HasAllInformation(self): # Is called before each line is read. When you return true, parsing # will stop prematurely. # returns true if this plugin does not want to process any more lines return False def StopParsing(self, lineCount): # Is called, when all lines have been read by the parser. # lineCount Total number of lines in the demo file. pass class MessagesParser(AbstractSectionsParser): # Parses a demo file for Notifications # The list in which the parser stores the pprocessed messages # The string we are looking for in parsed messages # Number of open braces ({ increments, } decrements) # The number of open braces at the last encounter of Messages # The line at which the last Messages section started # Flag that indicates if the parser has currently entered a # Messages section # Flag that indicates if we are currently processing a Messages # section that contains the messageSearchString # The last visited message test # The command identifier # The time index of the message in seconds # The entity ref for this message def __init__(self, messageSearchString): # Creates a new MessageParser object # param name=messageSearchStringThe string to look for in parsed self._result = List[DemoSection]() self._braceLevel = 0 self._lastMessagesBraceLevel = 0 self._lastMessagesSectionStart = 0 self._inMessagesSection = False self._inSearchSection = False self._messageText = self._command = -1 self._time = -1 self._entityRef = -1 self._messageSearchString = messageSearchString def NewLine(self, line, lineNumber): # Is called by the parser when it has fetched a new line # param name=lineContent of the line/param # param name=lineNumberCurrent line number (0 index)/param if line.Trim().StartsWith(Messages): self._lastMessagesSectionStart = lineNumber self._lastMessagesBraceLevel = self._braceLevel self._inMessagesSection = True if self._inMessagesSection and line.Trim().StartsWith(Time): timeString = line.Substring(line.IndexOf(Time ) + 5) self._time = Double.Parse(timeString, System.Globalization.CultureInfo.GetCultureInfo(en-US).NumberFormat) if self._inMessagesSection and line.Trim().StartsWith(Message ) and line.Contains(self._messageSearchString): self._inSearchSection = True self._messageText = line.Substring(line.IndexOf(Message ) + 8) if self._inMessagesSection and line.Trim().StartsWith(Command): self._command = Convert.ToInt32(line.Substring(line.IndexOf(Command ) + 8)) if self._inMessagesSection and line.Trim().StartsWith(EntityRef): self._entityRef = Convert.ToInt32(line.Substring(line.IndexOf(EntityRef ) + 10)) if self._inSearchSection and line.Trim().StartsWith(}) and self._braceLevel - 1 == self._lastMessagesBraceLevel: self._inMessagesSection = False self._inSearchSection = False message = DemoMessage() message.StartLine = self._lastMessagesSectionStart message.EndLine = lineNumber + 1 message.Message = self._messageText message.Time = self._time message.Command = self._command message.EntityRef = self._entityRef self._result.Add(message) if line.Trim().StartsWith({): self._braceLevel += 1 if line.Trim().StartsWith(}): self._braceLevel -= 1 def GetResult(self): # Returns the list of parsed messages # returnsReturns a list of parsed messages/returns return self._result class ParserEngine(object): def Parse(filename, plugin): summary Parses a demo file /summary param name=filenameThe file to be parsed/param param name=pluginThe ParserPlugin to use/param returnstrue if parsing was successful/returns # here we read the contents of the demo file line-by-line line = lineNumber = 0 # only run if the file actually exists if File.Exists(filename): plugin.StartParsing(filename) # start reading file line by line file = None try: file = StreamReader(filename) # parse as long as we don't have all information and there are still lines to read while not plugin.HasAllInformation() and (line = file.ReadLine()) != None: plugin.NewLine(line, lineNumber) lineNumber += 1 plugin.StopParsing(lineNumber) except Exception, e: # report exception MessageBox.Show(The demo file + filename + could not be parsed
Parser needed.
Hello, I need some kind of parser and some kind of way to access the data contained in a file like the one below: (text file): http://www.skybuck.org/Games/StartrekOnline/Parser/SpaceFleetAlertEnemyExample.demo I am interested in learning the entity numbers: EntityRef number and their positions: Pos x, z, y I am also interested in the creation of these entities, especially their type: entityTypeEnum type So basically the parser should produce a few lists: EntityNumber = [] EntityType = [] EntityPositionX = [] EntityPositionY = [] EntityPositionZ = [] Any extra information about entities is welcome. The parser should be able to parse a textfile of somewhere between 20.000 lines to 50.000 lines in about 1 to 2 seconds. My environment is SikuliX 1.1 Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Parser needed.
Ok, so far so good, a little start has been made. Text file is read into lines... I am not so sure if this is a good idea... Maybe it's easier if the entire file is one gigant array of characters instead of fragmented lines. However I don't know yet exactly how to read as one gigant array of characters. I don't really like this line approach but maybe it's nice: But I am not faced with a new problem: How to process individually lines. So this solution has created more problems than it solves :) BotDemoFolder = C:\\Games\\Startrek Online\\Startrek Online\\Cryptic Studios\\Star Trek Online\\Live\\demos BotDemoFile = SpaceFleetAlert.demo import time def ParseDemoLines( ParaLines ): print Parsing + str( len(ParaLines) ) + lines. for LineIndex in range(0, len(ParaLines)): if { in ParaLines[LineIndex]: # how to process a line.. hmmm... print yup return def Main(): DemoFilePath = BotDemoFolder + \\ + BotDemoFile FileObject = open( DemoFilePath, r) DemoLines = FileObject.readlines() ParseDemoLines( DemoLines ) # print DemoLines FileObject.close() return print program started Tick1 = time.time() Main() Tick2 = time.time() Seconds = Tick2 - Tick1 print Time in seconds: + str(Seconds) print program finished Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Parser needed.
I tried running this in SikuliX 1.1 from pyparsing import Word, alphas greet = Word( alphas ) + , + Word( alphas ) + ! greeting = greet.parseString( Hello, World! ) print greeting Doesn't seem to run pyparser module missing. Another reason why not to use it, unfortunately. Not sure if it's possible to somehow include it with SikuliX. This might mean the end for this little experiment. I think SikuliX/Jython might be too slow for parsing purposes which is kinda odd... since it can do 500.000 if statements last time I tested it... but when it comes to dealing with characters it seems to turn into a pile of shit ? Hmmm.. maybe unicode processing has something to do with it :) Perhaps I should write a small little test program to test this python/jython is a piece of char shit theory. Yes interesting test. Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Parser needed.
Example for python: MyString = Hello World print MyString.rfind(World) if MyString.rfind(World): print yes else: print no Pretty cool. Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Parser needed.
Apperently print speed has some exponential time issue in SikuliX kinda weird. But at least processing is high... however, debug console/print is only thing I got to diagnose problems... Could get time-wise nasty... hmmm... Perhaps I should make a small little parser in Delphi and port it to Python instead... But it a bit risky if not using python only code hmm... # test print speed. # 1000 prints costs 3 seconds # 10.000 prints costed 60 seconds. # this is weird indeed, seems to be some kind of exponential growth. import time MaxPrints = 1 def PrintMeARiver(): for vIndex in range(0, MaxPrints): print str(vIndex) return def Main(): PrintMeARiver() return print program started Tick1 = time.time() Main() Tick2 = time.time() Seconds = Tick2 - Tick1 print Seconds: + str(Seconds) print program finished Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Parser needed.
Link looks a bit odd, home index link: Nice python documentation/tutorial/help: http://www.tutorialspoint.com/python/index.htm Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Parser needed.
Nice char based code: BotDemoFolder = C:\\Games\\Startrek Online\\Startrek Online\\Cryptic Studios\\Star Trek Online\\Live\\demos BotDemoFile = SpaceFleetAlert.demo import time def ParseDemoLines( ParaLines ): print Parsing + str( len(ParaLines) ) + lines. for LineIndex in range(0, len(ParaLines)): if { in ParaLines[LineIndex]: # how to process a line.. hmmm... print yup return def ParseDemoChars( ParaChars ): print Parsing + str( len(ParaChars) ) + chars. for CharIndex in range(0, len(ParaChars)): if ParaChars[CharIndex] == {: print yup return def Main(): DemoFilePath = BotDemoFolder + \\ + BotDemoFile FileObject = open( DemoFilePath, r) # DemoLines = FileObject.readlines() # ParseDemoLines( DemoLines ) DemoChars = FileObject.read() ParseDemoChars( DemoChars ) FileObject.close() return print program started Tick1 = time.time() Main() Tick2 = time.time() Seconds = Tick2 - Tick1 print Time in seconds: + str(Seconds) print program finished -- https://mail.python.org/mailman/listinfo/python-list
Re: Logic problem: need better logic for desired thruth table. (thruth table to logic/boolean operations generator sought/needed)
I think I have run into this problem before... but solved it with some seperate if statements. However in this case/this time I would like to not solve it with if statements, but simply and/or/not/xor, in other words, boolean operators. So what would help is a thruth table to logic convertor/generator ?! Anybody know one that is suited for boolean logic/software programming/programming languages/boolean operations ? Bye, Skybuck. Original posting: Skybuck Flying wrote in message news:3794b$55678d83$5419aafe$56...@news.ziggo.nl... Hello, I was just coding and ran into a little logic problem which is as follows: There are two booleans/variables which can be either false or true. The desired thrutle table is: A = input B = input C = output A B C: --- F F T F T F T F T T T T Surpisingly enough I don't think there is a casual/common operator for this thruth table. AND does not apply. OR does not apply. XOR does not apply. So I would need some combined operators to give the desired result. I tried logic below... but funny enough it failed, now I feel like a noob lol and share this funny little fail logic with you. Can you improve/fix the logic ? This is python code, but this^ logic/thruth table problem basically applies to any programming language: # loop has to run if: # while DesiredResult==True: # Desired truth table for BotWaitForCooldown and CooldownDetected # BotWaitForCooldown: CooldownDetected: Desired Result: # False FalseTrue # False True False # True FalseTrue # True True True # desired/suiting logic: # (BotWaitForCooldown or ((not BotWaitForCooldown) and CooldownDetected)) def TestLogic( BotWaitForCooldown, CooldownDetected ): return BotWaitForCooldown or ((not BotWaitForCooldown) and CooldownDetected) # this logic is flawed, please improve logic. if TestLogic( False, False ) == True: print test 1 ok else: print test 1 failed if TestLogic( False, True ) == False: print test 2 ok else: print test 2 failed if TestLogic( True, False ) == True: print test 3 ok else: print test 3 failed if TestLogic( True, True ) == True: print test 4 ok else: print test 4 failed Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Logic problem: need better logic for desired thruth table. (thruth table to logic/boolean operations generator sought/needed)
However I can already see I am not happy with this video solution. I have 3 true outputs, and only 1 false output. That would require a lot of logic. I guess I can turn it around and negate the whole thing... and focus on the false output. Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Logic problem: need better logic for desired thruth table. (thruth table to logic/boolean operations generator sought/needed)
Ok, problem solved for now, it seems: I used video tutorial method and inverted it for the false case ;) But anyway... I would not only need a thruth table to logic/boolean operations converter but also a boolean operations optimizer ;) # loop has to run if: # while DesiredResult==True: # Desired truth table for BotWaitForCooldown and CooldownDetected # BotWaitForCooldown: CooldownDetected: Desired Result: # False FalseTrue # False True False # True FalseTrue # True True True # desired/suiting logic: # (BotWaitForCooldown or ((not BotWaitForCooldown) and CooldownDetected)) def TestLogic( BotWaitForCooldown, CooldownDetected ): # return BotWaitForCooldown or ((not BotWaitForCooldown) and CooldownDetected) # this logic is flawed, please improve logic. return (not ((not BotWaitForCooldown) and CooldownDetected)) # fixes it. if TestLogic( False, False ) == True: print test 1 ok else: print test 1 failed if TestLogic( False, True ) == False: print test 2 ok else: print test 2 failed if TestLogic( True, False ) == True: print test 3 ok else: print test 3 failed if TestLogic( True, True ) == True: print test 4 ok else: print test 4 failed Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Logic problem: need better logic for desired thruth table.
Hello, I was just coding and ran into a little logic problem which is as follows: There are two booleans/variables which can be either false or true. The desired thrutle table is: A = input B = input C = output A B C: --- F F T F T F T F T T T T Surpisingly enough I don't think there is a casual/common operator for this thruth table. AND does not apply. OR does not apply. XOR does not apply. So I would need some combined operators to give the desired result. I tried logic below... but funny enough it failed, now I feel like a noob lol and share this funny little fail logic with you. Can you improve/fix the logic ? This is python code, but this^ logic/thruth table problem basically applies to any programming language: # loop has to run if: # while DesiredResult==True: # Desired truth table for BotWaitForCooldown and CooldownDetected # BotWaitForCooldown: CooldownDetected: Desired Result: # False FalseTrue # False True False # True FalseTrue # True True True # desired/suiting logic: # (BotWaitForCooldown or ((not BotWaitForCooldown) and CooldownDetected)) def TestLogic( BotWaitForCooldown, CooldownDetected ): return BotWaitForCooldown or ((not BotWaitForCooldown) and CooldownDetected) # this logic is flawed, please improve logic. if TestLogic( False, False ) == True: print test 1 ok else: print test 1 failed if TestLogic( False, True ) == False: print test 2 ok else: print test 2 failed if TestLogic( True, False ) == True: print test 3 ok else: print test 3 failed if TestLogic( True, True ) == True: print test 4 ok else: print test 4 failed Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Logic problem: need better logic for desired thruth table. (thruth table to logic/boolean operations generator sought/needed)
This is a start lol: https://www.youtube.com/watch?v=lKqTSBKmWA4 I wonder if it can be simplied... I'll give it a try. Basically it comes down to creating a logic expression for each true result in the desired output and or-ing with each other. The variables leading to the true result in the desired output need to be kept if true, and negated if false. So for example: A B C F T T ((NOT A) AND (B) AND ETC) OR ETC. What the video didn't really explain is probably to and the variables... but it did mention multiply. I guess AND is the closest thing to a multiply ;) Makes sense... only AND gives a 1 output if all variables are true, otherwise it would zero out... Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Logic problem: need better logic for desired thruth table.
Denis McMahon wrote in message news:mk884e$gth$1...@dont-email.me... On Thu, 28 May 2015 14:58:19 -0700, sohcahtoa82 wrote: On Thursday, May 28, 2015 at 2:50:18 PM UTC-7, Skybuck Flying wrote: Hello, # Desired truth table for BotWaitForCooldown and CooldownDetected # BotWaitForCooldown: CooldownDetected: Desired Result: # FalseFalse True # FalseTrue False # True False True # True True True I think the logic you're really looking for is: return BotWaitForCooldown or (not (BotWaitForCooldown or CooldownDetected)) Nope, it simplifies to: BotWaitForCooldown or not CooldownDetected Apperently it can be simplied even further: BotWaitForCooldown = CooldownDetected Interesting isn't it ? :) Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Logic problem: need better logic for desired thruth table.
wrote in message news:mailman.152.1432869623.5151.python-l...@python.org... On Thu, May 28, 2015, at 17:50, Skybuck Flying wrote: Surpisingly enough I don't think there is a casual/common operator for this thruth table. AND does not apply. OR does not apply. XOR does not apply. All sixteen possible logical operators have formal names. This one is called B implies A. It can be implemented, as others have mentioned with A or not B. Ok thanks for this information. I was just wondering how many thruth table combinations there can be for a typical thruth table with 2 inputs and 1 output. Since there are 2 inputs, this means 4 possible outputs, which means 2 to the power of 4 different thruth tables possible, which is indeed 16. Perhaps you have a link to all possible 16 thruth tables and their formal names ? That would help ! Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Logic problem: need better logic for desired thruth table. (thruth table to logic/boolean operations generator sought/needed)
I am not so sure anymore about my conclusion, I will investigate this further tomorrow. It seems safe to conclude that at least the following operators have their own thruth tables: = = = These are the comparision operators. Assume True is greater than False allows them to be used as well. The question that remains is: How many gates or basic operations or wires would they require. Are some of these perhaps very efficient and could thus lead to even shorter gate designs ? However for my purposes, reducing code, the answer is already: YES For software logic/boolean reduction the answer is already YES, funny and interestingly enough ! ;) :) Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Logic problem: need better logic for desired thruth table. (thruth table to logic/boolean operations generator sought/needed)
Interestingly enough the shortest I have seen so far is ***: def TestLogic( BotWaitForCooldown, CooldownDetected ): # return BotWaitForCooldown or ((not BotWaitForCooldown) and CooldownDetected) # this logic is flawed, please improve logic. # return (not ((not BotWaitForCooldown) and CooldownDetected)) # fixes it. # return (BotWaitForCooldown or (not CooldownDetected)) # optimization but looks weird :) return (BotWaitForCooldown = CooldownDetected) # *** even shorter, wow cool, thanks to Jussi Piitulainen Apperently there is a short-coming/flaw in the reasoning about boolean logic, if boolean logic is converted to numbers/0/1 and comparisions allowed then apperently there are even shorter forms ?!? Am I correct ? Or am I missing something ? Perhaps branching don't count ? H. Is this branching ? Or something else... hmmm I think the comparison result could be used without requiring branching... so I think my conclusion might be correct. Bye, Skybuck. Skybuck Flying wrote in message news:7b1ef$556792ab$5419aafe$58...@news.ziggo.nl... Ok, problem solved for now, it seems: I used video tutorial method and inverted it for the false case ;) But anyway... I would not only need a thruth table to logic/boolean operations converter but also a boolean operations optimizer ;) # loop has to run if: # while DesiredResult==True: # Desired truth table for BotWaitForCooldown and CooldownDetected # BotWaitForCooldown: CooldownDetected: Desired Result: # False FalseTrue # False True False # True FalseTrue # True True True # desired/suiting logic: # (BotWaitForCooldown or ((not BotWaitForCooldown) and CooldownDetected)) def TestLogic( BotWaitForCooldown, CooldownDetected ): # return BotWaitForCooldown or ((not BotWaitForCooldown) and CooldownDetected) # this logic is flawed, please improve logic. return (not ((not BotWaitForCooldown) and CooldownDetected)) # fixes it. if TestLogic( False, False ) == True: print test 1 ok else: print test 1 failed if TestLogic( False, True ) == False: print test 2 ok else: print test 2 failed if TestLogic( True, False ) == True: print test 3 ok else: print test 3 failed if TestLogic( True, True ) == True: print test 4 ok else: print test 4 failed Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Feature Request: Reposition Execution
Steven D'Aprano wrote in message news:5553145b$0$9$c3e8...@news.astraweb.com... On Wednesday 13 May 2015 17:27, Christian Gollwitzer wrote: A clean way to exit your script could be to raise an exception. It should propagate to the toplevel and halt your script. However it is not possible to back and resume the execution. while True: try: run_script() # May raise TryAgain break except TryAgain: pass If you prefer to only retry a finite number of times: for i in range(10): try: run_script() # May raise TryAgain break except TryAgain: pass else: # break skips past the for...else block raise GiveUpError('too many failures') Hi, Thanks for the ideas, I haven't tried them yet. I wonder if they will work in a multi-threaded fashion. I doubt it. The run_script runs in it's own thread. The exception would have to be raise from another thread. (The other thread check for errors and needs to abort the run script). I doubt thread B can interrupt thread A via exceptions/exception handling ?!? Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Feature Request: Reposition Execution
Dave Angel wrote in message news:mailman.354.1431345441.12865.python-l...@python.org... On 05/11/2015 07:46 AM, Skybuck Flying wrote: Hello, Sometimes it can be handy to interrupt/reset/reposition a running script. For example something externally goes badly wrong. os.kill() then in your process, handle the exception, and do whatever you think is worthwhile. Thanks for suggestion, but I need a solution which can work in SikuliX as well. Especially inside an observer handler that would be ideal. So far os.kill() is not supported in SikuliX as far as I can tell. Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Feature Request: Reposition Execution
Hello, Sometimes it can be handy to interrupt/reset/reposition a running script. For example something externally goes badly wrong. The script is unaware of this. Current solution would require to have an Abort boolean everywhere. The abort boolean could then be set to True to indicate all code and all loops must abort. This is far from the ideal solution. I think a much better solution could be to reposition the instruction pointer so to speak. However for x86 stack clean up would be necessary. I would assume python has a stack too... which would need cleaning up. Perhaps the entire stack can simply be cleaned up. So that the point for execution continuation is always clean in a clean state. So this allows for the stack to be cleaned completely... without any trouble. I also hope this feature gets implemented quickly cause I kinda need it. Therefore I will give some example code to see how it could look like: def MyFunction(): while SomeCondition: RunMyCode return def OtherFunction(): while BatmanIsAliveLOL: BustPenguins return def DetectProblem: if ProblemDetected: Aborted = True Abort( AbortToPoint ) return SpawnThread( DetectProblem) while MyMainLoop: AbortToPoint: if Aborted: Reset stuff MainCode, Call Routines. Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
KB 2670838 - The EVIL UPDATE
KB 2670838 - The EVIL UPDATE This Windows 7 update wasted a lot of my time today. I could not find my own postings in the past... maybe I was unsure in the past... I am still unsure today.. but much more sure than previously. When installing IE11 I suspect this patch also gets installed. This patch will cause: 1. Windows Live Mail fail to crash, making mail inaccessible. 2. Company of Heroes, Tales of Valor to crash. 3. Call of Duty 5 World at War to stop loading. 4. Possibly even IE9 to keep crashing... 5. And perhaps other misschief. This patch is the worst patch I have ever seen... I am not 100% sure but it's a very good guess. Therefore it's time for me to spam this message all across usenet... so that I will always find it in google hopefully, next time it pops it's ugly head... Hopefully it will save my lost of time in the future. Also bare in mind: IE9 crashes IE10,IE11 is junk, it's slow... it's laggy and it's not worth this patch trouble. My advice is stick with Firefox and other browsers... always make sure to have multiple browsers installed otherwise you might be stranded... Also if you ever have a crashing internet explorer and you really can't recover... remember that you can de-install it... this will revert it back to IE8... at least that should give you a chance to become unstranded and access the web again for help. KB 2670838 - The EVIL UPDATE http://answers.microsoft.com/en-us/windows/forum/windows_7-windows_update/kb-2670838-the-evil-update/08bfdb2b-6896-4c34-89c2-16896a25dc3d I was hoping Microsoft fixed this patch by now... unfortunately they did not... and are probably too busy messing around with windows 8.1/windows 10 etc. Shame on them cause this is ONE BITCH OF A PATCH !!! Also FUCK Microsoft for intentionally DAMAGING computer software ! My trust in Microsoft is disappearing. Their behaviour is always the same basically: Damage old software to try and get people to buy new systems/upgrade. This patch makes me sick to my stomach... mostly because it endangers my data ! If Microsoft causes my DATA to be lost or inaccessable their software will be TERMINATED by me and I will switch to something else. Even if it's just a stupid little patch like this... this kind of thing making my mail archieve inaccessible is unacceptable behaviour. I will keep a close eye on this patch to see if it ever gets fixed. If now I may get so sick to my stumach that I might just skip Windows 10 and go to Linux route... For now at least it can be deinstalled... but it comes at a great risk: no more internet explorer, no more internet explorer updates... Now I have to trust Mozilla and Open Source developers ?! What's the world coming too ?! ;) ;) ;) If Microsoft keeps this up they will drive everybody to open source... is that what you want Microsoft ? You guys are doing really bad right now... one little patch and you can't fix it REally ??? I will examine your details about this patch... I probably did it n the past already... You know what I will do it right now... just to see if I can add some info to this posting. Basically this is some kind of graphics patch update for hybrid graphics cards... fuck that... please shove this up your ass. Integrated graphics probably HHH WHERE HAVE I HEAR THAT BEFORE DOES INTEL WRING A BE ? INTEGRATED ELECTRONICS = INTEL. This patch is apperently CODE-AUTHORED BY INTEL. INTEL IS PURPOSELY NUKING YOUR SYSTEMS. THIS PUTS A NEW PERSPECTIVE ON INTEL. I WAS PLANNING TO BUY THEIR NEW SKYLAKE PROCESSOR... THOUGH THEIR HASWELL HAD A TRANSACTIONAL MEMORY BUG. THIS LATEST RELEVATION/CONCLUSION SHEDS NEW LIGHT ON THIS POTENTIAL EVIL FROM INTEL. I can only advice researchers, academics, hackers, press... to investigate this matter further. IF THIS IS TRUE THEN THIS IS A GIGANTIC SCHANDAL OF IMAGINABLE PROPORTIONS AND NEEDS A SEVERE COUNTER REACTION. IF THIS IS TRUE I CAN RECOMMEND A BOYCOTT OF INTEL PROCESSORS AND MICROSOFT SOFTWARE AND SWITCH TO OPEN SOURCE SOFTWARE where these kind of trust issues and bugs can be more easily spotted and fixed and hopefully AVOIDED. Basically I DEMAND A FULL INVESTIGATION from the goverments INTO PATCH 2670838. GOODBYE, FAILURE TO DO SO PUTS YOUR SYSTEMS AT RISK ! Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Direct3D/DirectX interception ?
Hello, On the topic of Direct3D/DirectX interception ? Is this possible with Python ? If so how to do it ? Can you give example and/or links ? Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Why my ; continuator idea is better for debugging too.
A:=B:=C:=D:=0; With the continuator idea this coding would look as follows: Good single line code: A:=B:=C:=D:=0 Bad multi line code: A:= B:= C:= D:= 0 ^This would not be allowed and lead to error messages. Good multi line code: A:=; B:=; C:=; D:=; 0 ^ This would lead to a good compile. Bye, Skybuck :) -- https://mail.python.org/mailman/listinfo/python-list
Why my ; continuator idea is better for debugging too.
Hello, In the past I wrote about pascal's ; mistake. ; should be used as a continuator. I just made a programming mistake which solidifies/merits my idea: The programming mistake was this: vBattlefieldLosingWarrior := // modified warrior and brain vSimulatorWinningWarrior := vBattlefieldBattle.Warrior[0]; Code should look like this: vBattlefieldLosingWarrior := TBattlefieldWarrior(vBattlefieldBattle.Warrior[2].Association); // modified warrior and brain vSimulatorWinningWarrior := vBattlefieldBattle.Warrior[0]; Fortunately there was a type mistmatch which hinted me at the programming mistake. The code is a bit messy above so let's make a simpler example to understand, the in my oppinion, dangerous programming mistake: A := B := C; The above statements A := is valid in Delphi's current design. The danger is that B is assigned to A which is not what I wanted, the problem was missing code at A. So the danger is that some day, somebody will write B in such a way that it will accidently be assigned to A. By using ; as a continuator instead of a seperator the code would look as follows: A := B := C Since there was no continuator specified, future-Delphi would have been able to detect this programming mistake. Since it won't try to attach B to A since there is no continuator symbol. I found it worth it to mention this so there ya go. I am always glad when Delphi finds bugs like these... fortunately this time I got lucky thanks to a type mismatch. Also the statement would have looked like A:=B:=C; which I think is not a valid statement in Delphi. I ll test that just to be sure. Yes fortunately Delphi does not allow such dangerous statements. However I think C does, I am pretty sure of it. Another nice example why C is dangerous ! ;) (Also my request for python is the : symbol removed from language and instead require statements to be on next line below if statement that be nice) (Currently the : is perceived by me as unnecessary and annoying, an easy typo to make just like forgetting a ; however these are not necessary in python so why remove ; but not : ? seems inconsistent, and ya know me... I don't like inconsistencies, it's frikking annoying.). Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Python handles globals badly.
Mark Lawrence wrote in message news:mailman.16534.1417610132.18130.python-l...@python.org... On 03/12/2014 02:27, Skybuck Flying wrote: Excuse is: bad programming style. I don't need snot telling me how to program after 20 years of programming experience. This is so far the only thing pissing me off in python. Now I have to declare global in front of these variables every where I want to use em: Another example of a bad workman always blames his tools. Euhm, so why don't you program with just 0 and 1's then ? ;) Bye, Skybuck :) -- https://mail.python.org/mailman/listinfo/python-list
Python handles globals badly.
Excuse is: bad programming style. I don't need snot telling me how to program after 20 years of programming experience. This is so far the only thing pissing me off in python. Now I have to declare global in front of these variables every where I want to use em: ShipAbilityDistributeShieldPower ShipAbilityTargetWeaponsSubsystems ShipAbilityTargetEnginesSubsystems ShipAbilityTargetShieldsSubsystems ShipAbilityTargetAuxiliarySubsystems CapTactAbilityAttackPatternAlpha CapTactAbilityFireOnMyMark CapTactAbilityTacticalInitiative CapTactAbilityGoDownFighting CapTactAbilityTacticalFleet CapEngAbilityRotateShieldFrequency CapEngAbilityEPSPowerTransfer CapEngAbilityNadionInversion CapEngAbilityMiracleWorker CapEngAbilityEngineeringFleet CapSciAbilitySensorScan CapSciAbilitySubnucleonicBeam CapSciAbilityScatteringField CapSciAbilityPhotonicFleet CapSciAbilityScienceFleet CapSharedAbilityEvasiveManeuvers CapSharedAbilityBraceForImpact CapSharedAbilityRammingSpeed CapSharedAbilityAbandonShip CapSharedAbilityFleetSupport BoffTactAbilityBeamArrayFireAtWill BoffTactAbilityBeamArrayOverload BoffTactAbilityTacticalTeam BoffTactAbilityTorpedoHighYield BoffTactAbilityTorpedoSpread BoffTactAbilityTargetWeaponsSubsystems BoffTactAbilityTargetEnginesSubsystems BoffTactAbilityTargetShieldsSubsystems BoffTactAbilityTargetAuxiliarySubsystems BoffTactAbilityAttackPatternBeta BoffTactAbilityAttackPatternDelta BoffTactAbilityCannonRapidFire BoffTactAbilityCannonScatterVolley BoffTactAbilityDispersalPatternAlpha BoffTactAbilityDispersalPatternBeta BoffTactAbilityAttackPatternOmega BoffEngAbilityEmergencyPowerToAuxiliary BoffEngAbilityEmergencyPowerToWeapons BoffEngAbilityEmergencyPowerToEngines BoffEngAbilityEmergencyPowerToShields BoffEngAbilityEngineeringTeam BoffEngAbilityAuxiliaryToBattery BoffEngAbilityAuxiliaryToDampeners BoffEngAbilityAuxiliaryToStructural BoffEngAbilityBoardingParty BoffEngAbilityDirectedEnergyModulation BoffEngAbilityExtendShields BoffEngAbilityReverseShieldPolarity BoffEngAbilityAcetonBeam BoffEngAbilityEjectWarpPlasma BoffSciAbilityHazardEmitters BoffSciAbilityJamSensors BoffSciAbilityMaskEnergySignature BoffSciAbilityPolarizeHull BoffSciAbilityScienceTeam BoffSciAbilityTachyonBeam BoffSciAbilityTractorBeam BoffSciAbilityTransferShieldStrength BoffSciAbilityChargedParticleBurst BoffSciAbilityEnergySiphon BoffSciAbilityFeedbackPulse BoffSciAbilityPhotonicOfficer BoffSciAbilityTractorBeamRepulsors BoffSciAbilityScrambleSensors BoffSciAbilityTykensRift BoffSciAbilityGravityWell BoffSciAbilityPhotonicShockwave BoffSciAbilityViralMatrix SpaceSetAbilityAssimilatedBorgTechnologyTractorBeam SpaceSetAbilityRomulanSingularityHarnessPlasmaHyperflux SpaceSetAbilityNukaraStrikeforceTechnologiesUnstableTetryonLattice UniConAbilityPhotonicShockwaveTorpedo UniConAbilityTholianWeb UniConAbilityBattleModule3000BattleMode UniConAbilityBattleModule3000SwarmMissiles UniConAbilitySubspaceRupture UniConAbilityTholianTetryonGrid UniConAbilityIsometricCharge UniConAbilitySpatialChargeLauncher UniConAbilityAcetonAssimilator UniConAbilitySabotageProbeLauncher UniConAbilityRepairPlatform UniConAbilityProjectedSingularity RepNukAbilityTetryonCascade InvAbilitiesNimbusPirateDistressCall CarrierAbilityPetAttackMode PetAbilityLaunchEliteTholianMeshWeavers PetAbilityLaunchAdvancedObeliskSwarmers PetAbilityLaunchEliteScorpionFighters SingCoreAbilityPlasmaShockwave SingCoreAbilityQuantumAbsorption WarpCoreShieldCapacitator KlingonCaptAbilityBattleCloak -- https://mail.python.org/mailman/listinfo/python-list
Re: Python handles globals badly.
Meanwhile... I modified my code, and added these globals in front of it. It didn't take too long to do. But it did add something like 300 unnecessary lines of code, which is what kinda annoys me. I'd like to keep my code compact. Anyway I double checked to make sure other routines had global for other variables as well. Perhaps I made some programming mistakes which went unnoticed because of smart code handling optimizations and such. But because the global was omitted perhaps those optimizations never kicked in. I am not completely sure, but so far my bot seems to run real fast. Personally I do not like the way global works in python... it sucks quite bad, because it's confusing and inconsistent as hell and it doesn't do anything usefull example: a = 1 def Test() if a == 1: print hello return a can still be accessed by Test, so this makes it highly confusing ?! Should global be added to a or not ?! This creates doubts among the programmers. Was a perhaps maybe initialized or not ? What is it's contents ? The lack of a debugger in Sikuli makes this problem much worse. Only way to know for sure would be to print debug logs of variables which would get a bit excessive to do always, but I guess in case of doubt perhaps it could be done temporarely, however this additional paranoid checking does waste some programmer time. Therefore enough reasons for me not to like this... it's weird/akward. I hope python one day gets rid of it; 1. To stop the confusion. 2. To stop the doubt. 3. To stop the wasted lines. 4. To program with more confidence. 5. To stop to have to inspect what's going on if one wants to know for sure. 6. To stop any weird programming mistakes because a global declaration was not used somewhere in a function, it's probably easier to miss, cause in the programmers mind he's thinking: it's global. Now it's just some half-ass-fucked-up-not-really-global-variable-unless-you-specify-it-local-to-be-global-holy-shit-batman-feel-the-brain-pain ?! Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Re: Python handles globals badly.
Some issues I'd like to address to you: 1. Structured programming requires more programming time. 2. Structured programming implies structure which might be less flexible. 3. Python objects require self keyword to be used everywhere, and other akwardness wich leads to more typing/programming/writing time. I used the list feature of python to dump these variable in a list so that all variables can be processed by a while loop and so forth. At first I wanted flexibility and all variables were individually logic-ed / processed but this became too much code to work with. I was also under the impression using many ifs might be faster than lists, but this was bogus information at best. I wrote a simple short benchmark for if vs list and list performed fast enough for my purposes, it could both handle 500k of items without breaking a sweat, meaning within 1 to 3 seconds or so. I am still new at python and definetly don't feel comfortable with the object feature, though I did use it for these variables which are actually objects. I used to program in Delphi, there I would do everything OO and modular. However python feels more like a script language and I am enjoying it quite a lot. I try not to get entangled into all kinds of structuring which leads to much time wasted. Though sometimes it can also gain some time. Lastly I also don't like the module approach in python because the sikuli ide doesn't really support working with multiple files that well. Even if it did, having all code in one big file is a pretty big adventage. This allow me to see the code every day I work on it, and think about how to improve the code further, making it faster, more reliable, shorter, and so forth. And it also offers a lot of flexibility and time savings. No need to search in what file, what was located. Python also comes with nice libaries/lists/dictionaries/file io etc.. all easy to use... I haven't tried networking with python yet... that could be funny to try next for my bots :) Anyway this global thing made my doubt if python is a good thing... all in all it wasn't too bad... Though I do hope to see a programming language some day, that is aimed at more mature programmers that know what they are doing. Instead of a language aimed at noobs :) a noob language which forbids certain styles of programming because it would be bad. There is a word for it in dutch: beteutelend I am not sure what the word is in english but it's a bit like childesh So features I miss in python are: labels goto statements and repeat until. Funny thing is these goto statements would be very handy for bot programming, so it's a painfull feature to miss. Also as already pointed out above structure programming has disadventages as well. I'd like to see other languages which focus at more flexibility instead of structure. Python is already a nice step towards more flexiblity, for example it's auto-type feature is nice, it can detect if a variable is an integer, string or object. Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Recording instruction/data flow for a python script/program.
Hello, Is there a way for a python script's execution to be capture in an instruction/data flow log ? Since python is an interpreter this should be easy to do ? Such a feature would then allow the script to be played back in some kind of log player for a script or something ? And compare how the script executed on my PC versus perhaps the recorded log. Or perhaps follow the recorded log to see what happened... Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list
Python to be replaced by the new language called Cookie !
April Fools =D Bye, Skybuck =D -- https://mail.python.org/mailman/listinfo/python-list