I guess you want something like this:

if event.record['pressure'] != None:
  newpressure = (event.record['pressure'] * 10)
  event.record['pb'] = newpressure

Dne pátek 3. května 2024 v 3:38:01 UTC+2 uživatel Tom Keffer napsal:

> On Thu, May 2, 2024 at 6:32 PM Michael Frotscher <[email protected]> 
> wrote:
>
>> Here's the full code of my service:
>>      
>>
>    def new_archive_packet(self, event): 
>>
>>       if 'pressure' != None:
>>         newpressure = ('pressure' * 10)
>>         event.record['pb'] = newpressure
>>
>
>
> Strictly interpreted, you first ask whether the string "'pressure'" is 
> equal to None. It's not, so we proceed to the next statement. Now you're 
> trying to multiply a string ('pressure') by 10. Surprisingly, this will 
> succeed, but likely does not give you the results you expect. The variable 
> "newpressure" will actually be set to the string 
> 'pressurepressurepressurepressurepressurepressurepressurepressurepressurepressure'.
>  
> That is, the string 'pressure' concatenated 10 times.
>
> You want a *variable* pressure, not the literal string 'pressure'. Where 
> will it come from?
>
> I would suggest taking an online Python course if this is unfamiliar to 
> you. 
>
> -tk
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-development/84c56ca6-f871-406e-a94d-0a45358523c8n%40googlegroups.com.

Reply via email to