Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin1!goblin.stu.neva.ru!uio.no!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'python.': 0.02; 'syntax': 0.04; 'subject:Python': 0.06; 'attribute': 0.07; "'no": 0.09; 'formatting': 0.09; 'posting.': 0.09; 'subject:using': 0.09; 'try:': 0.09; '\xa0we': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'assume': 0.14; '2.7.2': 0.16; '23,': 0.16; 'mangled': 0.16; 'thanks,': 0.17; 'wrote:': 0.18; 'code.': 0.18; 'library': 0.18; 'trying': 0.19; 'else,': 0.19; '>>>': 0.22; 'import': 0.22; 'cc:addr:python.org': 0.22; 'error': 0.23; 'directory.': 0.24; 'skip:\xa0 20': 0.24; 'mon,': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; "i've": 0.25; 'header:In- Reply-To:1': 0.27; 'michael': 0.29; 'am,': 0.29; 'dec': 0.30; 'errors': 0.30; 'kevin': 0.30; 'mode': 0.30; 'message- id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'work.': 0.31; 'code': 0.31; 'getting': 0.31; '"",': 0.31; 'directory,': 0.31; 'peterson': 0.31; 'file': 0.32; 'url:python': 0.33; 'running': 0.33; '(most': 0.33; 'guess': 0.33; 'skip:# 10': 0.33; 'skip:d 20': 0.34; 'something': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'url:listinfo': 0.36; 'subject:?': 0.36; 'hi,': 0.36; 'url:org': 0.36; 'should': 0.36; 'error.': 0.37; 'skip:& 10': 0.38; '8bit%:4': 0.38; 'files': 0.38; 'pm,': 0.38; 'recent': 0.39; 'skip:& 20': 0.39; 'reported': 0.39; 'delete': 0.39; '8bit%:6': 0.40; 'url:mail': 0.40; 'how': 0.40; "you're": 0.61; 'name': 0.63; 'such': 0.63; 'more': 0.64; 'here': 0.66; 'sample': 0.67; 'jul': 0.74; 'obvious': 0.74; 'batchelder': 0.84; 'snapshot': 0.84; '2013,': 0.91; 'widespread': 0.91; 'online,': 0.96; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=5MonZQmwnDCzDH7DZL4cvcjtxwdC7cgomlHXAyvJoTY=; b=sk56vaH2tCHF+iWtDJNTweK5ZoPWqVbzvPkDCyvDTjZD9NYEgyG9xY3zszgKZAEB39 v9k2xbMNZnK8HprG9WsN8Vv7NesxF4vLMN6xkTSTPk4lIi9to99f2wVvnrw8YTWmynmY zSPI1pWhuiRO8yUbAA4DzBPyNSVFUrtFg/YiZcdosC5WI7W9n7j+JaGv55Lp8IRVNAtm +8vOjEyb7xOs9oPv7Ey2GO0gSBsXql/Zg4rt5NQ4prnDoyDXCOsorMDCsL4D57+kINpD 5cW0m3uljwuk2Q2M0FGX8oDe+B7gT0rM6t4GNcgv9FFmXlfiAGrdUvN6w9PdyZBvg3BA UMMA== MIME-Version: 1.0 X-Received: by 10.182.2.170 with SMTP id 10mr1275451obv.50.1387802707956; Mon, 23 Dec 2013 04:45:07 -0800 (PST) In-Reply-To: References: <52B7B0D5.4060804@gmail.com> Date: Mon, 23 Dec 2013 18:15:07 +0530 Subject: Re: Airplane mode control using Python? From: Kevin Peterson To: Ned Batchelder Content-Type: multipart/alternative; boundary=f46d0444ea996d184704ee32ff30 Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 152 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1387802717 news.xs4all.nl 2841 [2001:888:2000:d::a6]:56169 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:62622 --f46d0444ea996d184704ee32ff30 Content-Type: text/plain; charset=ISO-8859-1 Hi Ned, I havenot named it as android.py and there are no .pyc files in my directory. Here is the snapshot $ python Python 2.7.2 (default, Jul 20 2013, 22:54:57) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import android >>> droid = android.Android() Traceback (most recent call last): File "", line 1, in AttributeError: 'module' object has no attribute 'Android' >>> Thanks, On Mon, Dec 23, 2013 at 9:29 AM, Ned Batchelder wrote: > On 12/22/13 10:41 PM, Michael Torrie wrote: > >> On 12/22/2013 08:20 PM, Kevin Peterson wrote: >> >>> Hi, >>> >>> I am trying to control Aeroplane mode on Android using Python code. >>> I am running QPyPlus python. When I execute this code(that is widespread >>> in the net), >>> >>> #!/usr/bin/python >>> import android droid = android.Android() >>> # go to airplane mode >>> droid.toggleAirplaneMode() >>> >>> droid.makeToast('exiting') >>> >>> I get the error 'no such attribute Android()'. >>> >> >> Is that really how your code is formatted? The import line is an error. >> >> try: >> >> import android >> >> >> droid = android.Android() >> >> > The OP reported an error of "no such attribute Android", it's pretty > obvious that he isn't getting a syntax error. We can assume the code has > been mangled in the posting. > > Your code sample (once the obvious formatting errors have been fixed) is > identical to ones I've found online, so I assume it should work. > > My best guess is that you have named your own file android.py, shadowing > the library you're trying to import. Name it something else, delete all > the *.pyc files in your directory, and try again. > > -- > Ned Batchelder, http://nedbatchelder.com > > -- > https://mail.python.org/mailman/listinfo/python-list > --f46d0444ea996d184704ee32ff30 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Hi Ned,=A0

I havenot named it as androi= d.py and there are no .pyc files in my directory.=A0
Here is the snapshot
$ python
Python 2.7.2 = (default, Jul 20 2013, 22:54:57)
[GCC 4.4.3] on linux2
Type "help", "copyright= ", "credits" or "license" for more information.
>>> import android
>>> droid =3D androi= d.Android()
Traceback (most recent call last):
=A0 File "<stdin&= gt;", line 1, in <module>
AttributeError: 'module&= #39; object has no attribute 'Android'
>>>

Thank= s,


On Mo= n, Dec 23, 2013 at 9:29 AM, Ned Batchelder <ned@nedbatchelder.com&= gt; wrote:
On 1= 2/22/13 10:41 PM, Michael Torrie wrote:
On 12/22/2013 08:20 PM, Kevin Peterson wrote:
Hi,

I am trying to control Aeroplane mode on Android using Python code.
I am running QPyPlus python. When I execute this code(that is widespread in the net),

=A0 =A0 =A0#!/usr/bin/python
=A0 =A0 =A0import android droid =3D android.Android()
=A0 =A0 =A0# go to airplane mode
=A0 =A0 =A0 droid.toggleAirplaneMode()

=A0 =A0 =A0droid.makeToast('exiting')

I get the error 'no such attribute Android()'.

Is that really how your code is formatted? The import line is an error.

try:

import android


droid =3D android.Android()


The OP reported an error of "no such attribute Android", it's= pretty obvious that he isn't getting a syntax error. =A0We can assume = the code has been mangled in the posting.

Your code sample (once the obvious formatting errors have been fixed) is id= entical to ones I've found online, so I assume it should work.

My best guess is that you have named your own file android.py, shadowing th= e library you're trying to import. =A0Name it something else, delete al= l the *.pyc files in your directory, and try again.<= font color=3D"#888888">

--
Ned Batchelder, http= ://nedbatchelder.com

--
https://mail.python.org/mailman/listinfo/python-list

--f46d0444ea996d184704ee32ff30--