discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] Problems with Gnuradio-Companion


From: Mike Willis
Subject: Re: [Discuss-gnuradio] Problems with Gnuradio-Companion
Date: Sat, 22 Nov 2014 17:26:21 -0000

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:

 

abs()

dict()

help()

min()

setattr()

all()

dir()

hex()

next()

slice()

any()

divmod()

id()

object()

sorted()

ascii()

enumerate()

input()

oct()

staticmethod()

bin()

eval()

int()

open()

str()

bool()

exec()

isinstance()

ord()

sum()

bytearray()

filter()

issubclass()

pow()

super()

bytes()

float()

iter()

print()

tuple()

callable()

format()

len()

property()

type()

chr()

frozenset()

list()

range()

vars()

classmethod()

getattr()

locals()

repr()

zip()

compile()

globals()

map()

reversed()

__import__()

complex()

hasattr()

max()

round()

 

delattr()

hash()

memoryview()

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: address@hidden [mailto:address@hidden 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 <address@hidden> 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

 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]