List problems in C code ported to Python

Lucas Raab pythongnome at hotmail.com
Mon Jan 17 10:28:56 EST 2005


Lucas Raab wrote:
> I'm done porting the C code, but now when running the script I 
> continually run into problems with lists. I tried appending and 
> extending the lists, but with no avail. Any help is much appreciated 
> Please see both the Python and C code at 
> http://home.earthlink.net/~lvraab. The two files are ENIGMA.C and engima.py
> 
> TIA

OK, here's the Python code and the corresponding C code:

def init_mach():
	import string
	#setup rotor data
	i=1
	j=0
	for j in j<26, j+1:
		data[4],[j] = (ref_rotor[j] - 'A'+26) % 26
		
	for i in i<4, i+1:
		step[i-1] = step_data[order[i-1]]
		for j in j<26, j+1:
			data[i],[j] = (rotor[order[i-1]],[j]-'A'+26)%26
			data[8-i],[data[i],[j]] = j


void
init_mach( void )
{
   int i, j;
   int ds;
   int u, v;

   /* setup rotor data */
   for (j=0;j<26;j++)
     data[4][j] = ((int)ref_rotor[j]-'A'+26)%26;

   for (i=1;i<4;i++)
     {
       step[i-1] = step_data[order[i-1]];
       for (j=0;j<26;j++)
	{
	  data[i][j] = ((int)(rotor[order[i-1]][j])-'A' + 26) % 26;
	  data[8-i][data[i][j]] = j;
	}
     }

Now, do I need to start boning up on lists and how to use them or am I 
missing the bigger picture?? Again, for the complete code see 
http://home.earthlink.net/~lvraab. I'm not asking you to do it for me, 
just some pointers on going about this.



More information about the Python-list mailing list