Re: Help with Python

Date : Wed, 1 Nov 2006 21:16:44 -0500
To : XSI(at)Softimage.COM
From : "Bernard Lebel" <3dbernard(at)gmail.com>
Subject : Re: Help with Python
I've had considerable problems with this, they came down to these two scenarios:


I'm using a French-Canadian keyboard (both hardware and Windows settings). When I type lists and dictionaries, I tend to mistakenly type a "à" after the opening bracket in-place of a space (don't ask me why).

However, for some very obscure reason, the "à" character shows up as a
space, so there is nothing telling me I made a mistake until I try to
run the code and get meaningless errors.

The only way I can find the error, in this case, is to paste the
entire code in a Python command line shell, which at one point will
barf a syntax error error and show me the wrong character.

I've lost entire days on this until I could nail it down. I now avoid
putting spaces in brackets as much as possible.


The other case of meaningless syntax errors is when you import modules. Sometimes you may forget a colon character, mess up the intentation, forget an equal sign in an equality test, or whatever. This is usually pointed correctly with the top-level file, but when the error occurs in an imported module all you get is the faulty line. So you have track down each files being imported, check the specified line, until you find it.


Cheers Bernard



On 11/1/06, Andy Jones <andy(at)thefront.com> wrote:
I don't think I've noticed this.  When stuff like that happens, I
usually just assume I'm losing my mind and decide it's finally time for
some sleep.  The two guesses that jump to mind would be tabs vs. spaces
and other weird characters that look like spaces and could have gotten
in there if code was copy/pasted.  I don't even know if that second
thing exists, but it seems like it would be possible.  I guess the other
thing could be that sometimes the Python debugger remembers code from
before the previous round of changes, so it lies to you about what the
actual error is.  At least, I think that's what goes on.  Anyway, it
might cause you to correct a line that wasn't wrong in the first place.

-Andy

Bradley Gabe wrote:

>>Thanks Andy,
>>
>>That does the trick.
>>
>>Also, I have come across some really weird intermittent problems with
>>XSI complaining about Python syntax.
>>
>>It sometimes spits out an error on a particular line.  Then when I
>>retype it verbatim, it works fine.
>>
>>Is this common?
>>
>>
>
>No, usually there are a few typos when a line is re-typed. ;-p
>
>
>
>
>>Andre
>>
>>-----Original Message-----
>>From: owner-xsi(at)Softimage.COM [mailto:owner-xsi(at)Softimage.COM] On Behalf
>>Of Andy Jones
>>Sent: November 1, 2006 4:07 PM
>>To: XSI(at)Softimage.COM
>>Subject: Re: Help with Python
>>
>>How about Application.ClassName()?
>>
>>-Andy
>>
>>Andre DeAngelis wrote:
>>
>>
>>
>>>Hi guys,
>>>
>>>Does anyone know of a Python equivalent of the typof function in
>>>jscript?
>>>
>>>I am having some trouble converting a vbscript to Python so any help
>>>would be grand.
>>>
>>>Here is the working VBscript version.
>>>
>>>set oObj = selection(0)
>>>set clusters = oObj.ShapeAnimatedClusters
>>>for each cls in clusters
>>>  LogMessage cls.name
>>>Next
>>>
>>>I tried to convert this to Python with this:
>>>
>>>oObj = Application.selection(0)
>>>clusters = oObj.ShapeAnimatedClusters
>>>for cls in clusters:
>>>  Application.LogMessage (cls.name)
>>>
>>>When I run this, I get the following error:
>>>
>>>#TypeError: iteration over non-sequence
>>>
>>>No doubt this is a very trivial error.
>>>
>>>Any ideas?
>>>
>>>---
>>>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
>
>
>

---
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.