<div dir="ltr">Hello,<div>Thanks, but this doesn't work in the console - it's invalid syntax. Incidentally, I looked into the C++ code that initializes Python  for QGIS (as I was looking for a solution to the issue above) and I made a pull request to remove some duplicate code. </div><div><a href="https://github.com/qgis/QGIS/pull/1967">https://github.com/qgis/QGIS/pull/1967</a><br></div><div><br></div><div>Bests</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Mar 28, 2015 at 4:03 AM, Andrew McClure <span dir="ltr"><<a href="mailto:andrew@agsense.co.nz" target="_blank">andrew@agsense.co.nz</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Caroline<br>
<br>
Have tired prepending the dollar symbol $?<br>
<br>
> $a()<br>
<div><div class="h5"><br>
<br>
<br>
On 28/03/2015, at 3:18 am, Caroline Alexiou <<a href="mailto:carolinegr@gmail.com">carolinegr@gmail.com</a>> wrote:<br>
<br>
> Hello,<br>
> I want to have some helper functions available in the Python console within qgis, for instance this:<br>
> def a():<br>
>     return iface.activeLayer()<br>
> so that I type less things. I tried to start qgis with the --code argument but this didn't work. I also tried to put this function in the .qgis2/python/startup.py but when I am in the console a() is not recognized. I can create<br>
><br>
> @qgsfunction(0, "Python")<br>
>    def a(v,f,p):<br>
>        return iface.activeLayer()<br>
><br>
> in startup.py but then I'm not sure how I'd use it from within the console. Also, I know I can use scriptrunner to get the function to work, but I am looking to do this on startup, ie I start qgis, go to the console and a() is available. Is this possible within Qgis core or should I look into maybe adapting script runner for my purposes?<br>
><br>
> Bests,<br>
> Karolina Alexiou<br>
</div></div>> _______________________________________________<br>
> Qgis-developer mailing list<br>
> <a href="mailto:Qgis-developer@lists.osgeo.org">Qgis-developer@lists.osgeo.org</a><br>
> <a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
<br>
</blockquote></div><br></div>