PEP-ping Python Examples

Is it just me or other also think <> in IronPython examples in RhinoCommon to be very weird looking.

I’m not a programmer but I’ve always used != and if I haven’t used DS scripting language EKL I wouldn’t have ever known what <> is.

e.g.: (I’ll skip focusing on the two space_char indentation cuz that was already discussed)
https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_DocObjects_RhinoObject_DuplicateGeometry.htm


from System import *
from Rhino import *
from Rhino.Commands import *
from Rhino.DocObjects import *
from Rhino.Input import *
from scriptcontext import doc

def RunCommand():

  rc, obj_ref = RhinoGet.GetOneObject("Select object to duplicate", False, ObjectType.AnyObject)
  if rc <> Result.Success:
    return rc
  rhino_object = obj_ref.Object()

  geometry_base = rhino_object.DuplicateGeometry()
  if geometry_base <> None:
    if doc.Objects.Add(geometry_base) <> Guid.Empty:
      doc.Views.Redraw()

  return Result.Success

if __name__ == "__main__":
  RunCommand()
1 Like

Can you point me to the pep that you are referring to?

I’m a script kiddie, my PEP is all the code snippets I’ve read and used my entire scripting life.

I have never seen <> used in Python. I’ve used it in DS.EKL because that’s the only (Not equal) sign there.

Another thing here in this example Steve.

from System import *
from Rhino import *
from Rhino.Commands import *
from Rhino.DocObjects import *
from Rhino.Input import *
from scriptcontext import doc

def RunCommand():

    rc, obj_ref = RhinoGet.GetOneObject("Select object to duplicate", False, ObjectType.AnyObject)

Can you tell me where RhinoGet.GetOneObject() is coming from when libraries are imported with * (asterisk)

1 Like

Little research in stack overflow:


It was taken from ABC (python’s predecessor) see here:
“”
I believe ABC took it from Pascal, a language Guido began programming with.

It has now been removed in Python 3. Use != instead.
“”

So in Python examples there are notations taken from Pascal -> one of the dead languages.

1 Like

Basically it’s coming from Rhino.Input*… * means import ALL the modules in this class.

This also makes me scream, it’s totally counterproductive, it’s difficult to learn anything from the examples that way. :rage:

–Mitch

2 Likes

Not quite…
<> is used in vbscript/vb.net/Rhinoscript to designate not equal to…

so in this case it’s probably just a bad “translation”.

Yeah I know what it means but because I use it with another language. Never seen it in Python examples, ever.

I added this to our bugtracker at
https://mcneel.myjetbrains.com/youtrack/issue/RH-49811

100%. Never use wildcard imports unless you know every variable name which is now occupied. Writing out the full namespace may look like its more typing, but you get autocomplete and learn where the used methods are located. I think the reason why the help is using this is that it was easier to port the code from C# to Python.

_
c.

Well, unfortunately, this means that someone needs to go through every method that has an example and fix the stuff if necessary - that sounds like days and days worth of work. Who’s going to do it?

Sounds scriptable :wink:

_
c.

In the previous thread that I created about the two-spaced indentation I think Alain was up to the task and he said there was an automated way to do that.

I did clean up the indentation problem in the rss api samples with the help of a script. This will be more work but I’ll take the same approach

1 Like