# Python Scripting Question

**URL:** <https://forum.inductiveautomation.com/t/python-scripting-question/16841>\
**Category:** General Discussion\
**Created:** [February 1, 2018, 7:27pm UTC](https://forum.inductiveautomation.com/t/python-scripting-question/16841 "2018-02-01T19:27:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![shwethag](https://avatars.discourse-cdn.com/v4/letter/s/e47774/32.png) [@shwethag](https://forum.inductiveautomation.com/u/shwethag)\
**Post date:** [February 1, 2018, 7:27pm UTC](https://forum.inductiveautomation.com/t/python-scripting-question/16841/1 "2018-02-01T19:27:39Z")

</div>

Hello All:  
I am trying to extract bits from integer by using simple python script as shown below:  
vaule=currentValue\>\>(7&1)  
system.tag.write(“PLC/SensorFailure”, currentValue)  
This script works with Python IDE (2.7 and 3.x) both, but it is giving me error as shown in the attachment

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/1/10f6d23bfca4b4d202bf3a3502039e616b8fe7f8.PNG)

Could you please let me know what is the problem  
Thanks,  
Shwetha.

---

<div class="post-metadata">

**Author:** ![Kyle\_Chase](https://avatars.discourse-cdn.com/v4/letter/k/9de0a6/32.png) [@Kyle\_Chase](https://forum.inductiveautomation.com/u/Kyle_Chase)\
**Post date:** [February 1, 2018, 7:45pm UTC](https://forum.inductiveautomation.com/t/python-scripting-question/16841/2 "2018-02-01T19:45:39Z")

</div>

currentValue is not a primitive value. It is a BasicTagValue. To get the actual value as a primitive, in this case, you need to go something like this, using your example:

```auto
vaule=currentValue.value>>(7&1)

```

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [February 1, 2018, 7:49pm UTC](https://forum.inductiveautomation.com/t/python-scripting-question/16841/3 "2018-02-01T19:49:02Z")

</div>

If you read the comment section at the top of the script you will notice that:

> currentValue: This current value. This is a "qualified value", so it has value, quality, and timestamp properties.

Try using currentValue.value.

EDIT: Kyle beat me to it. 😉

---

<div class="post-metadata">

**Author:** ![shwethag](https://avatars.discourse-cdn.com/v4/letter/s/e47774/32.png) [@shwethag](https://forum.inductiveautomation.com/u/shwethag)\
**Post date:** [February 1, 2018, 8:33pm UTC](https://forum.inductiveautomation.com/t/python-scripting-question/16841/4 "2018-02-01T20:33:28Z")

</div>

Thank you, Both. It works.

Shwetha

---

<div class="post-metadata">

**Author:** ![Kyle\_Chase](https://avatars.discourse-cdn.com/v4/letter/k/9de0a6/32.png) [@Kyle\_Chase](https://forum.inductiveautomation.com/u/Kyle_Chase)\
**Post date:** [February 1, 2018, 10:30pm UTC](https://forum.inductiveautomation.com/t/python-scripting-question/16841/5 "2018-02-01T22:30:21Z")

</div>

https://tenor.com/embed/5827519?playertype=card
