Hi Tom
Thanks for spotting this one.
There isn’t anything in the documentation on it. No doubt it would be obvious
to python developers and it is assumed we all know, but I wonder if that is
true? Especially as we are writing to XML describing the interface to a C++
program.
Now I know I am not very clever but how would I know what are reserved python
codes? It would be obvious to a c programmer not to call something float or
int, from, for class and so on.
I looked up on the web for reserved python keywords:
Reserved Words
You may not name your variables any of the following words as they mean special
things in Python:
and
assert
break
class
continue
def
del
elif
else
except
exec
finally
for
from
global
if
import
in
is
lambda
not
or
pass
print
raise
return
try
while
Do NOT use any of the following words either (although they are not strictly
Python reserved words, they conflict with the names of commonly-used Python
functions):
Data
Float
Int
Numeric
Oxphys
array
close
float
int
input
open
range
type
write
zeros
You should also avoid all the names defined in the math library (you must avoid
them if you import the library):
acos
asin
atan
cos
e
exp
fabs
floor
log
log10
pi
sin
sqrt
tan
I would never have guessed not to use lambda. It is just the sort of thing I
might chose for a wavelength input but “id” is not one of these. It’s a
function:
<https://docs.python.org/3.3/library/functions.html#abs> abs()
<https://docs.python.org/3.3/library/functions.html#func-dict> dict()
<https://docs.python.org/3.3/library/functions.html#help> help()
<https://docs.python.org/3.3/library/functions.html#min> min()
<https://docs.python.org/3.3/library/functions.html#setattr> setattr()
<https://docs.python.org/3.3/library/functions.html#all> all()
<https://docs.python.org/3.3/library/functions.html#dir> dir()
<https://docs.python.org/3.3/library/functions.html#hex> hex()
<https://docs.python.org/3.3/library/functions.html#next> next()
<https://docs.python.org/3.3/library/functions.html#slice> slice()
<https://docs.python.org/3.3/library/functions.html#any> any()
<https://docs.python.org/3.3/library/functions.html#divmod> divmod()
<https://docs.python.org/3.3/library/functions.html#id> id()
<https://docs.python.org/3.3/library/functions.html#object> object()
<https://docs.python.org/3.3/library/functions.html#sorted> sorted()
<https://docs.python.org/3.3/library/functions.html#ascii> ascii()
<https://docs.python.org/3.3/library/functions.html#enumerate> enumerate()
<https://docs.python.org/3.3/library/functions.html#input> input()
<https://docs.python.org/3.3/library/functions.html#oct> oct()
<https://docs.python.org/3.3/library/functions.html#staticmethod>
staticmethod()
<https://docs.python.org/3.3/library/functions.html#bin> bin()
<https://docs.python.org/3.3/library/functions.html#eval> eval()
<https://docs.python.org/3.3/library/functions.html#int> int()
<https://docs.python.org/3.3/library/functions.html#open> open()
<https://docs.python.org/3.3/library/functions.html#func-str> str()
<https://docs.python.org/3.3/library/functions.html#bool> bool()
<https://docs.python.org/3.3/library/functions.html#exec> exec()
<https://docs.python.org/3.3/library/functions.html#isinstance> isinstance()
<https://docs.python.org/3.3/library/functions.html#ord> ord()
<https://docs.python.org/3.3/library/functions.html#sum> sum()
<https://docs.python.org/3.3/library/functions.html#bytearray> bytearray()
<https://docs.python.org/3.3/library/functions.html#filter> filter()
<https://docs.python.org/3.3/library/functions.html#issubclass> issubclass()
<https://docs.python.org/3.3/library/functions.html#pow> pow()
<https://docs.python.org/3.3/library/functions.html#super> super()
<https://docs.python.org/3.3/library/functions.html#bytes> bytes()
<https://docs.python.org/3.3/library/functions.html#float> float()
<https://docs.python.org/3.3/library/functions.html#iter> iter()
<https://docs.python.org/3.3/library/functions.html#print> print()
<https://docs.python.org/3.3/library/functions.html#func-tuple> tuple()
<https://docs.python.org/3.3/library/functions.html#callable> callable()
<https://docs.python.org/3.3/library/functions.html#format> format()
<https://docs.python.org/3.3/library/functions.html#len> len()
<https://docs.python.org/3.3/library/functions.html#property> property()
<https://docs.python.org/3.3/library/functions.html#type> type()
<https://docs.python.org/3.3/library/functions.html#chr> chr()
<https://docs.python.org/3.3/library/functions.html#func-frozenset> frozenset()
<https://docs.python.org/3.3/library/functions.html#func-list> list()
<https://docs.python.org/3.3/library/functions.html#func-range> range()
<https://docs.python.org/3.3/library/functions.html#vars> vars()
<https://docs.python.org/3.3/library/functions.html#classmethod> classmethod()
<https://docs.python.org/3.3/library/functions.html#getattr> getattr()
<https://docs.python.org/3.3/library/functions.html#locals> locals()
<https://docs.python.org/3.3/library/functions.html#repr> repr()
<https://docs.python.org/3.3/library/functions.html#zip> zip()
<https://docs.python.org/3.3/library/functions.html#compile> compile()
<https://docs.python.org/3.3/library/functions.html#globals> globals()
<https://docs.python.org/3.3/library/functions.html#map> map()
<https://docs.python.org/3.3/library/functions.html#reversed> reversed()
<https://docs.python.org/3.3/library/functions.html#__import__> __import__()
<https://docs.python.org/3.3/library/functions.html#complex> complex()
<https://docs.python.org/3.3/library/functions.html#hasattr> hasattr()
<https://docs.python.org/3.3/library/functions.html#max> max()
<https://docs.python.org/3.3/library/functions.html#round> round()
<https://docs.python.org/3.3/library/functions.html#delattr> delattr()
<https://docs.python.org/3.3/library/functions.html#hash> hash()
<https://docs.python.org/3.3/library/functions.html#func-memoryview>
memoryview()
<https://docs.python.org/3.3/library/functions.html#func-set> set()
Somewhere in the documentation, it would be really useful to have a list of
reserved words and function names we can’t use, or even better some checking of
the XML to warn people. It ought to be clear from the context that a user is
not attempting to call a python function in describing a variable name.
It is probably also the case that any function in any library that is imported
is also not usable.
Mike
From: [email protected] [mailto:[email protected]] On Behalf Of Tom
Rondeau
Sent: 22 November 2014 17:08
To: Mike Willis
Cc: GNURadio Discussion List
Subject: Re: [Discuss-gnuradio] Problems with Gnuradio-Companion
On Sat, Nov 22, 2014 at 11:08 AM, Mike Willis <[email protected]
<mailto:[email protected]> > wrote:
Thanks to Sebastian for his help.
This appears to be a bug? Well maybe my bug. My input parameter was intended as
an identification number and not unreasonably I called it “id”. Apparently I
can’t call the parameter “id”. I can call it “ix” and grc will find it. What on
earth?
Mike
$ ipython
In [1]: help(id)
Help on built-in function id in module __builtin__:
id(...)
id(object) -> integer
Return the identity of an object. This is guaranteed to be unique among
simultaneously existing objects. (Hint: it's the object's memory address.)
GRC runs in Python. It outputs Python code. You tried to use a reserved Python
keyword.
Tom
_______________________________________________ Discuss-gnuradio mailing list [email protected] https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
