# Beads audio library in Python mode

**URL:** <https://discourse.processing.org/t/beads-audio-library-in-python-mode/3077>\
**Category:** Processing.py\
**Created:** [August 28, 2018, 3:08pm UTC](https://discourse.processing.org/t/beads-audio-library-in-python-mode/3077 "2018-08-28T15:08:11Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![neilcsmith](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/neilcsmith/32/144_2.png) [@neilcsmith](https://discourse.processing.org/u/neilcsmith)\
**Post date:** [September 6, 2018, 7:05pm UTC](https://discourse.processing.org/t/beads-audio-library-in-python-mode/3077/21 "2018-09-06T19:05:13Z")

</div>

> [@GoToLoop](#):
>
> I’ve merely listed the 2 possible easiest options to “fix” the issue for Processing’s Python Mode,

Isn’t setting `python.security.respectJavaAccessibility` to `false` a potentially easier option? At least, if it works it doesn’t involve code changes.

Other than that either forking the library or starting a conversation on the mailing list are the ways forward. I believe a protected getter should also work?

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [September 6, 2018, 7:14pm UTC](https://discourse.processing.org/t/beads-audio-library-in-python-mode/3077/22 "2018-09-06T19:14:08Z")

</div>

> [@neilcsmith](#):
>
> Isn’t setting `python.security.respectJavaAccessibility` to `false` a potentially easier option?

I’ve got no idea on how to do that for Processing’s Python Mode! 😕

Even if we could hack the Python Mode to include that setting, that’d work only for folks who did it as well! Extremely impractical! 🙄

> [@neilcsmith](#):
>
> I believe a `protected` getter should also work?

You believe wrongly. As I have stated here a couple of times already: 🧐

> [@GoToLoop](#):
>
> Jython treats any Java’s non- `public` members as if they were full-force `private`, …

> [@GoToLoop](#):
>
> And Jython can’t access non- `public` members from Java classes! 🥶

I’ve said members; which include fields, methods and constructors! 😮

---

<div class="post-metadata">

**Author:** ![neilcsmith](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/neilcsmith/32/144_2.png) [@neilcsmith](https://discourse.processing.org/u/neilcsmith)\
**Post date:** [September 6, 2018, 7:28pm UTC](https://discourse.processing.org/t/beads-audio-library-in-python-mode/3077/23 "2018-09-06T19:28:21Z")

</div>

> [@GoToLoop](#):
>
> You believe wrongly. As I have stated here a couple of times already

That’s not what the docs say though.

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [September 6, 2018, 7:49pm UTC](https://discourse.processing.org/t/beads-audio-library-in-python-mode/3077/24 "2018-09-06T19:49:27Z")

</div>

> [@neilcsmith](#):
>
> That’s not what the docs say though.

Dunno which “docs” you’d be reading which would imply that `protected` methods are OK to access freely while `protected` fields aren’t! 🤨

Here’s some test sketch in order to check whether `protected` methods got a free pass or not. 🧪

In this test, `public` method AudioContext::**isRunning()** is invoked:  
[BeadsProject.net/doc/net/beadsproject/beads/core/AudioContext.html#isRunning--](http://BeadsProject.net/doc/net/beadsproject/beads/core/AudioContext.html#isRunning--)

Then followed by `protected` method AudioContext::**update()**:  
[BeadsProject.net/doc/net/beadsproject/beads/core/AudioContext.html#update--](http://BeadsProject.net/doc/net/beadsproject/beads/core/AudioContext.html#update--)

Lo & behold: “AttributeError: ‘beads.AudioContext’ object has no attribute ‘update’” 🙈

```auto
add_library('beads')

ac = AudioContext()

print ac.isRunning() # public method (works!)

# AttributeError: 'beads.AudioContext' object has no attribute 'update'
ac.update() # protected method (doesn't work!)

exit()

```

---

<div class="post-metadata">

**Author:** ![neilcsmith](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/neilcsmith/32/144_2.png) [@neilcsmith](https://discourse.processing.org/u/neilcsmith)\
**Post date:** [September 6, 2018, 7:55pm UTC](https://discourse.processing.org/t/beads-audio-library-in-python-mode/3077/25 "2018-09-06T19:55:03Z")

</div>

> [@GoToLoop](#):
>
> Dunno which “docs” you’d be reading which would imply that `protected` methods are OK to access freely while `protected` fields aren’t

[http://www.jython.org/archive/21/docs/subclassing.html](http://www.jython.org/archive/21/docs/subclassing.html)

I think your code is wrong.

And this is all going around in circles unless someone posts on the Beads mailing list with what (you think) is required here. I’m not interested in arguing how Jython works, or doesn’t! 😄

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [September 6, 2018, 8:12pm UTC](https://discourse.processing.org/t/beads-audio-library-in-python-mode/3077/26 "2018-09-06T20:12:19Z")

</div>

> [@neilcsmith](#):
>
> I think your code is wrong.

You’re right this time! Indeed methods got a free pass in Jython, while fields don’t! 😵

Here’s a more extensive test which proves that: 🥴

```auto
add_library('beads')

def setup():
    ac = MyAudio()
    ac.test()
    ac.update() # protected method access

    f = MyFunct(WavePlayer(ac, 5.0, Buffer.SINE))
    f.test()

    exit()

class MyAudio(AudioContext):
    def test(self):
        print self.isRunning() # public method access
        self.update() # protected method access

class MyFunct(Function):
    def test(self):
        # AttributeError: 'MyFunct' object has no attribute 'x'
        print len(self.x) # protected field access

```

[Previous page](https://discourse.processing.org/t/beads-audio-library-in-python-mode/3077.md?page=1)
