Stop argument evaluation

Is there a way in ignition to stop arguments from being evaluated before entering the method?

For example I want to inspect the argument being sent into test, but when I print it out right now I get the value False instead of something I can parse and inspect.

class Something(object):
	x = "something"

def test(a):
	print a
	
test(Something.x > 5)

No. Python doesn't make expressions into objects to pass. (This behavior is not specific to jython, and conforms to pretty much every programming language I know.)

Any idea what trickery SqlAlchemy is using? I doubt it is filtering after the dataset is returned. I would think that it is some how making a where clause from the filter methods parameter.

for (name,) in session.query(User.name).filter(User.fullname == "Ed Jones")

SQLAlchemy redefines the operators for its classes so that they defer execution. (Strictly speaking, they participate in a framework that outputs SQL to perform the comparison within the DB.) It's mind-numbingly complex. Yes, I've been under that hood.

See the "rich comparison" method signatures here:

https://docs.python.org/2.7/reference/datamodel.html#basic-customization

Essentially, you have your class override those methods to, instead of returning an answer, return an object that remembers the original arguments and knows how to apply that later.

Yeah, many things are possible through operator overloading...including making things wildly unreadable and hard to parse. "Domain specific languages", especially inside of other programming languages are often a bad move. 9 times out of 10, avoid them.

2 Likes