[QGIS-Developer] free variable 'self' referenced before assignment in enclosing scope

Raymond Nijssen r.nijssen at terglobo.nl
Thu Jan 31 00:41:57 PST 2019


Nevermind, that return line should work. The self.Branches and 
self.Nodes are variables containing the strings for your dict.

The problem is in the AlgorithmDialog code. Hope someone else can help 
you with that.

Cheers,
Raymond


On 31-01-19 09:02, Raymond Nijssen wrote:
> Hi Bjorn,
> 
> What do you expect this
> 
> {self.Branches:dest_id,self.Nodes:dest_id2}
> 
> would result in? It doesn't look like python to me but I might be 
> missing something.
> 
> 
> What does the variable self.Branches contain?
> 
> 
> "self" Refers to your Branches_Nodes class itself.
> 
> 
> (By the way, it is a good habit to start variable names with a lower 
> case character.)
> 
> Regards,
> Raymond
> 
> 
> 
> On 30-01-19 17:40, Bjørn Burr Nyberg wrote:
>> Dear QGIS community,
>>
>> In the spirit of open-source I am trying to convert a set of scripts 
>> that ive designed in ArcMap to QGIS 3.x. I hope that this will enable 
>> a broader community of individuals to use the workflows ive designed. 
>> The original scripts can be found at 
>> https://github.com/BjornNyberg/NetworkGT/tree/master/Scripts
>>
>> My problem is that in my first attempt to convert the scripts, QGIS 
>> either crashes or gives the following error.
>>
>> 2019-01-30T16:51:27     WARNING    Traceback (most recent call last):
>>                File 
>> "C:/PROGRA~1/QGIS3~1.4/apps/qgis/./python/plugins\processing\gui\AlgorithmDialog.py", 
>> line 238, in on_complete
>>                self.feedback.pushInfo(self.tr('Execution completed in 
>> {0:0.2f} seconds').format(time.time() - start_time))
>>               NameError: free variable 'self' referenced before 
>> assignment in enclosing scope
>>
>> I have established that this error occurs at the very end of the 
>> script when calling ' return 
>> {self.Branches:dest_id,self.Nodes:dest_id2}'. I do not believe that I 
>> have explicitly defined self  anywhere in the processAlgorithm 
>> function itself. The algorithms themselves work as intended and the 
>> shapefiles are created before the program crashes.
>>
>> I am not a programmer by trait so I'm not entirely sure how to problem 
>> solve this error and any help would be most appreciated. I can also 
>> provide a test dataset if that is helpful.
>>
>> Cheers,
>> Bjorn
>> -----------------------------
>> Postdoctoral Fellow
>> Department of Earth Science, University of Bergen
>> PO Box 7803, 5020, Bergen, Norway
>> +47 485 024 08
>>
>>
>>
>> _______________________________________________
>> QGIS-Developer mailing list
>> QGIS-Developer at lists.osgeo.org
>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>>
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


More information about the QGIS-Developer mailing list