RE: creating lists in Python

Date : Fri, 13 Apr 2007 18:22:43 -0400
To : <XSI(at)Softimage.COM>
From : "Andre DeAngelis" <andre.deangelis(at)ubisoft.com>
Subject : RE: creating lists in Python
It's Windows XP 32.

I get errors yes.  Like running Python scripts without Python installed.

Thank you Marc-André , I will check the registry for these entries.  If not, what then?

Andre

-----Original Message-----
From: owner-xsi(at)Softimage.COM [mailto:owner-xsi(at)Softimage.COM] On Behalf Of Marc-André Belzile
Sent: April 13, 2007 5:25 PM
To: XSI(at)Softimage.COM
Subject: RE: creating lists in Python

Linux or Windows ? Make sure you have admin priviledges on Windows or write-access to /tmp/gen_py on linux.

Do you get any errors when running pyscript.py ?

You should have more or less these entries in the registry. 

[HKEY_CLASSES_ROOT\CLSID\{DF630910-1C1D-11d0-AE36-8C0F5E000000}]
(at)="Python ActiveX Scripting Engine"

[HKEY_CLASSES_ROOT\CLSID\{DF630910-1C1D-11d0-AE36-8C0F5E000000}\Debugging]
(at)="0"

[HKEY_CLASSES_ROOT\CLSID\{DF630910-1C1D-11d0-AE36-8C0F5E000000}\Implemented Categories]

[HKEY_CLASSES_ROOT\CLSID\{DF630910-1C1D-11d0-AE36-8C0F5E000000}\Implemented Categories\{B3EF80D0-68E2-11D0-A689-00C04FD658FF}]

[HKEY_CLASSES_ROOT\CLSID\{DF630910-1C1D-11d0-AE36-8C0F5E000000}\Implemented Categories\{F0B7A1A1-9847-11CF-8F20-00805F2CD064}]

[HKEY_CLASSES_ROOT\CLSID\{DF630910-1C1D-11d0-AE36-8C0F5E000000}\Implemented Categories\{F0B7A1A2-9847-11CF-8F20-00805F2CD064}]

[HKEY_CLASSES_ROOT\CLSID\{DF630910-1C1D-11d0-AE36-8C0F5E000000}\InprocServer32]
(at)="pythoncom25.dll"
"ThreadingModel"="Apartment"

[HKEY_CLASSES_ROOT\CLSID\{DF630910-1C1D-11d0-AE36-8C0F5E000000}\LocalServer32]
(at)="C:\\Python25\\pythonw.exe \"C:\\Python25\\lib\\site-packages\\win32com\\server\\localserver.py\" {DF630910-1C1D-11d0-AE36-8C0F5E000000}"

[HKEY_CLASSES_ROOT\CLSID\{DF630910-1C1D-11d0-AE36-8C0F5E000000}\ProgID]
(at)="Python.AXScript.2"

[HKEY_CLASSES_ROOT\CLSID\{DF630910-1C1D-11d0-AE36-8C0F5E000000}\PythonCOM]
(at)="win32com.axscript.client.pyscript.PyScript"

[HKEY_CLASSES_ROOT\CLSID\{DF630910-1C1D-11d0-AE36-8C0F5E000000}\VersionIndependentProgID]
(at)="Python"

-----Original Message-----
From: owner-xsi(at)Softimage.COM [mailto:owner-xsi(at)Softimage.COM] On Behalf Of Andre DeAngelis
Posted At: April 13, 2007 3:09 PM
Posted To: xsi
Conversation: creating lists in Python
Subject: RE: creating lists in Python


Speaking of Python and 6.0, I cannot get Python to show up as a scripting option in XSI.

I have loaded 2.5 and pywin32 and ever ran the pyscript.py and had no luck.

Any ideas?  I am getting desperate.

Andre

-----Original Message-----
From: owner-xsi(at)Softimage.COM [mailto:owner-xsi(at)Softimage.COM] On Behalf Of Bernard Lebel
Sent: April 13, 2007 1:13 PM
To: XSI(at)Softimage.COM
Subject: Re: creating lists in Python

> -----Original Message-----
> From: owner-xsi(at)Softimage.COM [mailto:owner-xsi(at)Softimage.COM] On 
> Behalf Of Matt Estela

> myList = None * 4860


I don't know if it's a python 2.4 thing, but the approach quoted below doesn't work at all for me. It raise this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: unsupported operand type(s) for *: 'NoneType' and 'int'

aList = [ None * 3 ]
does the same thing.


Now, if the intention of the example was something like aList = [ None ] * 3 to give [ None, None, None ], I have to warn to be careful when doing this. I used this approach to create particle arrays, and somehow ran into problems later on. I never use it to create lists. Here is an enlightening email from Patrick Boucher:


Bernard Lebel wrote:
> aArray = [ [] ] * iChannelCount
> # aArray looks like [ [], [], [] ]

This creates a list of three 'pointers' to the _same_ list (kinda / not really but it's the easiest way to decribe it in a few words)

> aArray = [ [], [], [] ]

This creates a list of three distinct, seperate, different lists.

In the first code example you're basically accessing the same list whether you're accessing aArray[0], aArray[1] or aArray[2]

Try the following in a python prompt for a demo:
 >>> a = [[]] * 5
 >>> a
[[], [], [], [], []]
 >>> a[0].append(1)
 >>> a
[[1], [1], [1], [1], [1]]

I don't think you can avoid doing:

aArray = []
for i in range(iChannelCount):
       aArray.append([])
---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in
body:
unsubscribe xsi

---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
unsubscribe xsi

---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
unsubscribe xsi

---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
unsubscribe xsi


Search the XSI List archives here or use the advanced search form to search across mailing lists. Searching help is available.
This site supposedly brought to you by Benjamin Grosser and the Imaging Technology Group.