Re: [Tutor] Musical note on python

2012-09-12 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
Yes. As far as I can see it does not contain any thing which
concerns the volume of sound.


-- 
regards,
Sarma.

On Thu, Sep 13, 2012 at 5:42 AM, Mark Lawrence wrote:

> On 13/09/2012 00:57, D.V.N.Sarma డి.వి.ఎన్.శర్మ wrote:
>
>> The Beep attribute of winsound module is useful. But the volume is feeble.
>> Is there anyway to control the loudness.
>>
>>
> Have you read 
> http://docs.python.org/**library/winsound.html?
>
> --
> Cheers.
>
> Mark Lawrence.
>
>
> __**_
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/**mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Sigh first real python task

2012-09-12 Thread Mike S
Sorry, hit send a bit too fast there:

here is the output:


session setup failed: NT_STATUS_LOGON_FAILURE
/bin/sh: put: command not found


On Wed, Sep 12, 2012 at 8:14 PM, Steven D'Aprano wrote:

> On 13/09/12 13:06, Mike S wrote:
>
>  Now, I'm having to change the remote host and pass both the username and
>> pass but cannot get it to work.
>>
>
> Since we don't have access to your machine to try it, would you care to
> tell
> us what happens when you try, or shall we just guess?
>
>
> --
> Steven
> __**_
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/**mailman/listinfo/tutor
>



-- 
Mike of Many Stories, Ideas, and Ramblings
Game Chef 2009, 2010
NaNoWriMo 2008, 2009

http://mikeofmanystories.blogspot.com/ - writings
http://mikeofmany.wordpress.com/ - personal bloggery
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Sigh first real python task

2012-09-12 Thread Steven D'Aprano

On 13/09/12 13:06, Mike S wrote:


Now, I'm having to change the remote host and pass both the username and
pass but cannot get it to work.


Since we don't have access to your machine to try it, would you care to tell
us what happens when you try, or shall we just guess?


--
Steven
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Sigh first real python task

2012-09-12 Thread Mike S
So, trying to modify a python script that when invoked copies a local file
to a remote host.

Previously this was done with only needing to pass a username.


try:
ret = subprocess.call("smbclient //metricsmachine/reports/; put
%s\" -U metrics%%" % (fileName), shell=True)
if ret < 0:
print >>sys.stderr, "Child was terminated by signal", -ret
else:
os.unlink(path+fileName)
except OSError, e:
print >>sys.stderr, "Execution failed:", e


Now, I'm having to change the remote host and pass both the username and
pass but cannot get it to work.

Changing it to

try:
ret = subprocess.call("smbclient //reportingmachine/Dashboard/; put
%s\" -U Username%Password" % (fileName), shell=True)
if ret < 0:
print >>sys.stderr, "Child was terminated by signal", -ret
else:
os.unlink(path+fileName)
except OSError, e:
print >>sys.stderr, "Execution failed:", e

Any help would be appreciated.

-- 
Mike of Many Stories, Ideas, and Ramblings
Game Chef 2009, 2010
NaNoWriMo 2008, 2009

http://mikeofmanystories.blogspot.com/ - writings
http://mikeofmany.wordpress.com/ - personal bloggery
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Print List

2012-09-12 Thread Steven D'Aprano

On 13/09/12 10:57, bob gailer wrote:

On 9/12/2012 11:36 AM, Ashley Fowler wrote:

I am trying to complete the following below:
You also need to write a function "printList" of one parameter that
takes a list as its input and neatly prints the entire contents of the
list in a column.
Any Suggestions or Corrections?


I would correct the use of "neatly" and "column"- these are ill-defined terms!

Specifications should leave nothing to be guessed or assumed



Bob, "neatly" and "column" are perfectly clear and simple English words
that don't need additional definition. One might just as well say that
your use of the words "correct", "terms", "leave", "nothing", "guessed"
and "assumed" are ill-defined.



--
Steven
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Print List

2012-09-12 Thread bob gailer

On 9/12/2012 11:36 AM, Ashley Fowler wrote:

I am trying to complete the following below:
You also need to write a function "printList" of one parameter that
takes a list as its input and neatly prints the entire contents of the
list in a column.
Any Suggestions or Corrections?
I would correct the use of "neatly" and "column"- these are ill-defined 
terms!


Specifications should leave nothing to be guessed or assumed

--
Bob Gailer
919-636-4239
Chapel Hill NC

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Musical note on python

2012-09-12 Thread Mark Lawrence

On 13/09/2012 00:57, D.V.N.Sarma డి.వి.ఎన్.శర్మ wrote:

The Beep attribute of winsound module is useful. But the volume is feeble.
Is there anyway to control the loudness.



Have you read http://docs.python.org/library/winsound.html ?

--
Cheers.

Mark Lawrence.

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Musical note on python

2012-09-12 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
One can ofcourse increase the volume by adjusting master volume.
But one needs ability to program volume level in order to produce
sounds of different volume levels in a piece of music.

-- 
regards,
Sarma.

On Thu, Sep 13, 2012 at 5:27 AM, D.V.N.Sarma డి.వి.ఎన్.శర్మ <
dvnsa...@gmail.com> wrote:

> The Beep attribute of winsound module is useful. But the volume is feeble.
> Is there anyway to control the loudness.
>
> --
> regards,
> Sarma.
> On Thu, Sep 13, 2012 at 4:45 AM, Alan Gauld wrote:
>
>> On 12/09/12 14:53, D.V.N.Sarma డి.వి.ఎన్.శర్మ wrote:
>>
>>> My OS is Windows XP. I have Python 2.7.3(32 bit). My question is
>>> are there any commands in Python which directly allow me to produce a
>>> pure note
>>>
>>
>> Have a look at the audioop, wave and winsound modules.
>>
>> Also PyGame has some tools that try to do platform independent audio...
>>
>> Access to the sound card is another matter since that is non standard and
>> determined by the sound drivers exposed by the manufacturer. The drivers
>> may well vary in capability depending ion the OS in use etc.
>>
>> You can also use ctypes for direct access to the Windows audio libraries
>> but that's a whole lot more complicated!
>>
>> --
>> Alan G
>> Author of the Learn to Program web site
>> http://www.alan-g.me.uk/
>>
>>
>> __**_
>> Tutor maillist  -  Tutor@python.org
>> To unsubscribe or change subscription options:
>> http://mail.python.org/**mailman/listinfo/tutor
>>
>
>
>
>
>
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Musical note on python

2012-09-12 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
The Beep attribute of winsound module is useful. But the volume is feeble.
Is there anyway to control the loudness.

-- 
regards,
Sarma.
On Thu, Sep 13, 2012 at 4:45 AM, Alan Gauld wrote:

> On 12/09/12 14:53, D.V.N.Sarma డి.వి.ఎన్.శర్మ wrote:
>
>> My OS is Windows XP. I have Python 2.7.3(32 bit). My question is
>> are there any commands in Python which directly allow me to produce a
>> pure note
>>
>
> Have a look at the audioop, wave and winsound modules.
>
> Also PyGame has some tools that try to do platform independent audio...
>
> Access to the sound card is another matter since that is non standard and
> determined by the sound drivers exposed by the manufacturer. The drivers
> may well vary in capability depending ion the OS in use etc.
>
> You can also use ctypes for direct access to the Windows audio libraries
> but that's a whole lot more complicated!
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
>
>
> __**_
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/**mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Print List

2012-09-12 Thread akleider
> On 12/09/12 16:36, Ashley Fowler wrote:
>
>> def printList(lists):
>>  print("First Name\tLast Name\tCredits\tGPA")
>>  for i in lists:
>>  print (i)
>>
>>
>> Any Suggestions or Corrections?
>
> The input parameter is called 'lists' which implies that the input is
> more than one list. Try to make your input parameter names as accurate
> as possible. In this case you might think 'list' would be good, but its
> no, because list is a Python builtin word. So we would be better to
> choose something like aList or theList.
>
> Your function could have been generic in that it printed any kind of
> list but by printing a header line you have made it specific to a list
> of students. So you could call the input studentList.
>
> In general, in Python, generic functions are favoured. One way to have a
> header and be generic would be to pass the header in as a parameter too:
>
> def printList(theList, theHeader=""):
> print(theHeader)
> for item in theList:
>print item
>
>
> And then you would call it with:
>
> printList(myStudentList, "First Name\tLast Name\tCredits\tGPA")
>
> Or
>
> printList(myPetList, "Name, Breed, Age")
>
> Or
>
> printList(myBlankList)   # uses the default empty header
>
> or whatever...
>
> --
> Alan G

To make it even more generic I would suggest replacing
"""   print(theHeader) """
with
"""   if theHeader:
  print(theHeader)
"""
to avoid a blank line if you don't need/want a header line.
ak
> def printList(theList, theHeader=""):
> print(theHeader)
> for item in theList:
>print item
>


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How to print a variable from an if/else statement

2012-09-12 Thread Dave Angel
On 09/12/2012 12:38 PM, bob gailer wrote:
> 
>
> /Python has statements/./ /if // is a ///statement./So is
> /def.
>
> 

What's with the attempted italics?  This is a text mailing list, and the
text version of your html message was thoroughly mangled.  It'd be much
better to just send the messages in text form, as numerous manglings
occur, depending on the combination of sender and reader.




-- 

DaveA

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Print List

2012-09-12 Thread Alan Gauld

On 12/09/12 16:36, Ashley Fowler wrote:


def printList(lists):
 print("First Name\tLast Name\tCredits\tGPA")
 for i in lists:
 print (i)


Any Suggestions or Corrections?


The input parameter is called 'lists' which implies that the input is 
more than one list. Try to make your input parameter names as accurate 
as possible. In this case you might think 'list' would be good, but its 
no, because list is a Python builtin word. So we would be better to 
choose something like aList or theList.


Your function could have been generic in that it printed any kind of 
list but by printing a header line you have made it specific to a list 
of students. So you could call the input studentList.


In general, in Python, generic functions are favoured. One way to have a 
header and be generic would be to pass the header in as a parameter too:


def printList(theList, theHeader=""):
   print(theHeader)
   for item in theList:
  print item


And then you would call it with:

printList(myStudentList, "First Name\tLast Name\tCredits\tGPA")

Or

printList(myPetList, "Name, Breed, Age")

Or

printList(myBlankList)   # uses the default empty header

or whatever...

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Musical note on python

2012-09-12 Thread Alan Gauld

On 12/09/12 17:01, Dwight Hutto wrote:


If you have Windows, then you should be on the pywin32 list, I usually
assume linux on this list, but both get answered.


Just to be clear the tutor list is not OS biased. Windows, MacOS or 
Linux are all equally welcome (and indeed MVS or OpenVMS if necessary!)


If somebody asks an OS specific question we will often direct to a more 
focused forum but the tutor list does not favour any OS over another.



--
Alan G
Wearing my Moderator hat...

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Musical note on python

2012-09-12 Thread Alan Gauld

On 12/09/12 14:53, D.V.N.Sarma డి.వి.ఎన్.శర్మ wrote:

My OS is Windows XP. I have Python 2.7.3(32 bit). My question is
are there any commands in Python which directly allow me to produce a
pure note


Have a look at the audioop, wave and winsound modules.

Also PyGame has some tools that try to do platform independent audio...

Access to the sound card is another matter since that is non standard 
and determined by the sound drivers exposed by the manufacturer. The 
drivers may well vary in capability depending ion the OS in use etc.


You can also use ctypes for direct access to the Windows audio libraries 
but that's a whole lot more complicated!


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] setting a timer

2012-09-12 Thread eryksun
On Wed, Sep 12, 2012 at 1:56 PM, Matthew Ngaha  wrote:
> i have a way to set a timer for creating new objects copied from a
> book but as i have started my next exercise in a very different way, i
> want to avoid that math method/formula as it will cause me to
> rearrange some classes totally...
>
> i tried a simple method but its not working. any ideas?

threading has a Timer:

http://docs.python.org/library/threading#timer-objects

>>> def print_msg(msg):
... print msg

>>> t = threading.Timer(1, print_msg, ('Spam',))
>>> t.start()
>>> Spam

>>> t = threading.Timer(3, print_msg, ('Spam',))
>>> t.start(); t.join()  # waiting...
Spam

There's also the sched module, but only if you're not using threads:

http://docs.python.org/library/sched

>>> s = sched.scheduler(time.time, time.sleep)

>>> e = s.enter(3, 1, print_msg, ('Spam',))
>>> s.run()
Spam

>>> e = s.enterabs(time.time() + 5, 1, print_msg, ('Spam',))
>>> s.run()
Spam
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] setting a timer

2012-09-12 Thread Matthew Ngaha
> Get a slower computer.
>
> I expect that if you find an old Commodore 64 from 1982, or perhaps
> an 1984 Apple Macintosh, it might be slow enough for your count down
> idea to work. But with modern computers, counting up to, or down from,
> 5 is more or less instantaneous in human terms.
>
> A better way to pause for a moment is this:
>
> import time
> time.sleep(0.1)  # pause for 0.1 second
> time.sleep(60)  # pause for 1 minutes

hah do u think i could find one of those on ebay???

i wasnt aware of the time module! thanks a lot for your help:)
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] setting a timer

2012-09-12 Thread Steven D'Aprano

On 13/09/12 03:56, Matthew Ngaha wrote:


class Game(object):
 interval = 0

 def play(self):
 Game.interval = 40
 while Game.interval>  0:
 self.count_down()

 def count_down(self):
 Game.interval -= 1

so the play() method gives interval a value of 40. the while loop
should reduce interval by 1 everytime it calls the count_down()
method. The problem is this is happening instantly. i've even put the
Game.interval value as high as 5 and it reaches 0 instantly.


Get a slower computer.

I expect that if you find an old Commodore 64 from 1982, or perhaps
an 1984 Apple Macintosh, it might be slow enough for your count down
idea to work. But with modern computers, counting up to, or down from,
5 is more or less instantaneous in human terms.

A better way to pause for a moment is this:

import time
time.sleep(0.1)  # pause for 0.1 second
time.sleep(60)  # pause for 1 minutes




--
Steven
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How to print a variable from an if/else statement

2012-09-12 Thread Joel Goldstick
On Wed, Sep 12, 2012 at 12:38 PM, bob gailer  wrote:
> Precision in terminology is good.
>
> Python has keywords. if, and, else are keywords. All keywords are all lower
> case.
>
> Keywords cannot be overridden by assignment.
>
> Python has statements.  if is a statement. So is def.
>
> Some keywords are part of the structure of statements, e.g. if...else,
> for..in.
>
> Someof these may also be used in expressions, e.g. 3 if a == 1 else 2.
>
> In Python 3 print is a function.
>
> Python has a few built-in constants, including None, True, False. These
> names are Title case, and can be overridden by assignment.
>
> --
> Bob Gailer
> 919-636-4239
> Chapel Hill NC
>
thanks for clarifying.


-- 
Joel Goldstick
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] setting a timer

2012-09-12 Thread Matthew Ngaha
i have a way to set a timer for creating new objects copied from a
book but as i have started my next exercise in a very different way, i
want to avoid that math method/formula as it will cause me to
rearrange some classes totally...

i tried a simple method but its not working. any ideas? heres my code,
ill leave out the irrelevant code.

class Game(object):
interval = 0

def play(self):
Game.interval = 40
while Game.interval > 0:
self.count_down()

def count_down(self):
Game.interval -= 1

so the play() method gives interval a value of 40. the while loop
should reduce interval by 1 everytime it calls the count_down()
method. The problem is this is happening instantly. i've even put the
Game.interval value as high as 5 and it reaches 0 instantly.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Print List

2012-09-12 Thread Brannon, Terrence


From: Tutor 
[mailto:tutor-bounces+terrence.brannon=bankofamerica@python.org] On Behalf 
Of Ashley Fowler
Sent: Wednesday, September 12, 2012 11:36 AM
To: tutor@python.org
Subject: [Tutor] Print List


I am trying to complete the following below:



You also need to write a function "printList" of one parameter that

takes a list as its input

[Terrence Brannon] since it is taking a list as its input, why not call it 
students or simply list? Calling it "lists" implies that it is a list that 
contains other lists

and neatly prints the entire contents of the

list in a column. Each student in the list should be printed using __str__.



So far i have:



def printList(lists):

print("First Name\tLast Name\tCredits\tGPA")

for i in lists:

print (i)



Any Suggestions or Corrections?

[Terrence Brannon]

def print_list(students):

for student in students:

   print("{0}\t{1}\t{2}\t{3}".format(student.first_name, student.last_name, 
student.credits, student.gpa))



OHHH Wait a minute... that means you need to redefine the __str__() method 
of your Student class:



class Student(object):

  

 def __str__(self):

return "{0}\t{1}\t{2}\t{3}".format(student.first_name, student.last_name, 
student.credits, student.gpa)



And then print_list is simply:

def print_list(students):

for student in students:

   print student







--
This message w/attachments (message) is intended solely for the use of the 
intended recipient(s) and may contain information that is privileged, 
confidential or proprietary. If you are not an intended recipient, please 
notify the sender, and then please delete and destroy all copies and 
attachments, and be advised that any review or dissemination of, or the taking 
of any action in reliance on, the information contained in or attached to this 
message is prohibited. 
Unless specifically indicated, this message is not an offer to sell or a 
solicitation of any investment products or other financial product or service, 
an official confirmation of any transaction, or an official statement of 
Sender. Subject to applicable law, Sender may intercept, monitor, review and 
retain e-communications (EC) traveling through its networks/systems and may 
produce any such EC to regulators, law enforcement, in litigation and as 
required by law. 
The laws of the country of each sender/recipient may impact the handling of EC, 
and EC may be archived, supervised and produced in countries other than the 
country in which you are located. This message cannot be guaranteed to be 
secure or free of errors or viruses. 

References to "Sender" are references to any subsidiary of Bank of America 
Corporation. Securities and Insurance Products: * Are Not FDIC Insured * Are 
Not Bank Guaranteed * May Lose Value * Are Not a Bank Deposit * Are Not a 
Condition to Any Banking Service or Activity * Are Not Insured by Any Federal 
Government Agency. Attachments that are part of this EC may have additional 
important disclosures and disclaimers, which you should read. This message is 
subject to terms available at the following link: 
http://www.bankofamerica.com/emaildisclaimer. By messaging with Sender you 
consent to the foregoing.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Musical note on python

2012-09-12 Thread Jerry Hill
On Wed, Sep 12, 2012 at 8:38 AM, Dwight Hutto  wrote:
> If you have Windows, then you should be on the pywin32 list, I usually
> assume linux on this list, but both get answered.

If you're having a problem with either the specific pywin32 module[1],
or have questions about accessing the deep dark internals of windows
or com objects, then I would highly recommend the pywin32 list --
there are some great people there who I've seen field all kinds of
difficult problems.  That said, general python on windows questions
are perfectly on topic both here on the tutor list, and on the main
python list.

It does help to let us know right off what operating system you're
using -- there are some programming problems where it doesn't make any
difference at all, and for others it makes all the difference in the
world.  In this case, you're working on accessing hardware that
doesn't have a specific built in python module that takes care of the
platform specific difference, so your solution is very likely to be
different depending on where you're planning on running your code.

1: http://starship.python.net/crew/mhammond/win32/Downloads.html
and/or http://sourceforge.net/projects/pywin32/

-- 
Jerry
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How to print a variable from an if/else statement

2012-09-12 Thread bob gailer

Precision in terminology is good.

Python has /keywords./ /if, //and, //else /are /keywords. /All keywords 
are all lower case.


Keywords cannot be overridden by assignment.

/Python has statements/./ /if // is a ///statement./So is /def.

///Some keywords are part of the structure of statements, e.g. 
if...else, for..in.


Someof these may also be used in expressions, e.g. 3 if a == 1 else 2.
///
///In Python 3 /print/ is a /function./

Python has a few /built-in constants, /including /None, True, False. 
/These names are Title case, and can be overridden by assignment.


--
Bob Gailer
919-636-4239
Chapel Hill NC

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Print List

2012-09-12 Thread Oscar Benjamin
On Sep 12, 2012 4:53 PM, "Ashley Fowler" 
wrote:
>
> I am trying to complete the following below:
>
>
> You also need to write a function "printList" of one parameter that
> takes a list as its input and neatly prints the entire contents of the
> list in a column. Each student in the list should be printed using
__str__.
>
>
> So far i have:
>
>
> def printList(lists):
> print("First Name\tLast Name\tCredits\tGPA")
> for i in lists:
> print (i)
>
>
> Any Suggestions or Corrections?

Looks good to me.

My only suggestion is to use more descriptive names. I would have called it
'students' instead of 'lists' and 'student' instead of 'i'. I don't really
like 'printList' either but I guess your stuck with that.

Oscar
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Musical note on python

2012-09-12 Thread Dwight Hutto
> You have again snipped the entire context so nobody has a clue what you're
> replying to.
>

> Cheers.
>
> Mark Lawrence.

My last post refers to a previous post by eryksun. If you can't look
up and read it, that's cool, because you're the only one complaining.

And to put it into context that you're a complete jackass, look at the
context in this post, which is two above your last post(especially the
end part):

Please hit reply to all when responding.


You should be able to type in 'sudo apt-get install speaker-test' or
'yum speaker-test'


 wrote:
> This is what I got

>
 import os
 os.system("speaker-test"+"--frequency 2000"+"--period 5000"+"--test
 sine")

It should look like this:

import os
os.system("speaker-test"+" --frequency 2000"+" --period 5000"+ "--test sine")

You can copy and paste it to see.

This assumed you had speaker-test, you might have another command line
app that does the same thing. So if the instructions to download above
don't work. Let me know.



Note that there is a space before everything in the string, except the
first, speaker-test, other wise it looks like this to the command
line:

speaker-test--frequency2000--period5000--test sine

The space before the " --frequency 2000", and the rest makes it look like:

speaker-test --frequency 2000 --period 5000 --test sine

so put a space at the beginning of every string except speaker-test

If you have Windows, then you should be on the pywin32 list, I usually
assume linux on this list, but both get answered.

Remember to read this:
http://catb.org/esr/faqs/smart-questions.html

Mark is right, besides the little back and forth, that in fact you
need to describe, otherwise I have a tendency to speculate;)




-- 
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Print List

2012-09-12 Thread Ashley Fowler
I am trying to complete the following below:


You also need to write a function "printList" of one parameter that
takes a list as its input and neatly prints the entire contents of the
list in a column. Each student in the list should be printed using __str__.



So far i have:


def printList(lists):
print("First Name\tLast Name\tCredits\tGPA")
for i in lists:
print (i)


Any Suggestions or Corrections?

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Musical note on python

2012-09-12 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
My OS is Windows XP. I have Python 2.7.3(32 bit). My question is
are there any commands in Python which directly allow me to produce a pure
note
of a given frequency, given volume and given duration. Further can we access
the different sound channels(sound card) available through Python.

-- 
regards,
Sarma.


On Wed, Sep 12, 2012 at 6:47 PM, Mark Lawrence wrote:

> On 12/09/2012 13:43, Dwight Hutto wrote:
>
>> Also, you try eryksun's solution/example, pyaudio, as well, since it's
>> a mpdule, using different forms for cross compatibility.
>>
>>
> You have again snipped the entire context so nobody has a clue what you're
> replying to.
>
> --
> Cheers.
>
> Mark Lawrence.
>
>
> __**_
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/**mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Musical note on python

2012-09-12 Thread Mark Lawrence

On 12/09/2012 13:43, Dwight Hutto wrote:

Also, you try eryksun's solution/example, pyaudio, as well, since it's
a mpdule, using different forms for cross compatibility.



You have again snipped the entire context so nobody has a clue what 
you're replying to.


--
Cheers.

Mark Lawrence.

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Musical note on python

2012-09-12 Thread Dwight Hutto
Also, you try eryksun's solution/example, pyaudio, as well, since it's
a mpdule, using different forms for cross compatibility.
-- 
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] convert ascii to binary

2012-09-12 Thread Steven D'Aprano

On 12/09/12 21:20, Aaron Pilgrim wrote:

Hello,
I am trying to write a small program that converts ascii to binary.



Can you explain what you mean by "ascii to binary"? Any of these
could be described that way:

'hello world'

=> '68656c6c6f20776f726c64'
=> 'begin 666 \n+:&5L;&\\@=V]R;&0 \n \nend\n'
=> 'aGVsbG8gd29ybGQ=\n'
=> 'x\x9c\xcbH\xcd\xc9\xc9W(\xcf/\xcaI\x01\x00\x1a\x0b\x04]'

or many others.

For the record, those are:

* raw hex string
* uuencode
* base64
* zip compressed[1]


Reading ahead, I think you want the raw hex string, correct?



I tried using the python reference library section 18.8 but had
trouble understanding how to make it work.

  Here is the code I am currently trying to use:

def main(): 
import binascii


As a general rule, imports should go in the top-level of the module,
not inside the body of a function. There are exceptions to that
rule, but in this case there is no reason not to follow it. So:


import binascii

def main():
# body of main without the import



myWord = input("Enter the word to convert..") 
#convert text to ascii
for ch in myWord:
print(ord(ch))  
#convert ascii to binary
binascii.a2b_uu(ord(ch))



There is no need to process the string one character at a time.
Try this instead:


import binascii

def main():
line = input("Enter a line of text to convert: ")
print(binascii.hexlify(line))


If you want to do it one character at a time, there's no need
for binhex:



def main():
line = input("Enter a line of text to convert: ")
for c in line:
print("Char: '%c'  Ord: %3d (decimal) %x (hex)" % (c, ord(c), ord(c)))






[1] It is ironic that zip compression on a short string leads
to a *longer* string


--
Steven

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Musical note on python

2012-09-12 Thread Dwight Hutto
Please hit reply to all when responding.


You should be able to type in 'sudo apt-get install speaker-test' or
'yum speaker-test'


 wrote:
> This is what I got

>
 import os
 os.system("speaker-test"+"--frequency 2000"+"--period 5000"+"--test
 sine")

It should look like this:

import os
os.system("speaker-test"+" --frequency 2000"+" --period 5000"+ "--test sine")

You can copy and paste it to see.

This assumed you had speaker-test, you might have another command line
app that does the same thing. So if the instructions to download above
don't work. Let me know.



Note that there is a space before everything in the string, except the
first, speaker-test, other wise it looks like this to the command
line:

speaker-test--frequency2000--period5000--test sine

The space before the " --frequency 2000", and the rest makes it look like:

speaker-test --frequency 2000 --period 5000 --test sine

so put a space at the beginning of every string except speaker-test

If you have Windows, then you should be on the pywin32 list, I usually
assume linux on this list, but both get answered.

Remember to read this:
http://catb.org/esr/faqs/smart-questions.html

Mark is right, besides the little back and forth, that in fact you
need to describe, otherwise I have a tendency to speculate;)


Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] convert ascii to binary

2012-09-12 Thread eryksun
On Wed, Sep 12, 2012 at 7:20 AM, Aaron Pilgrim  wrote:
> Hello,
> I am trying to write a small program that converts ascii to binary.
>
> I tried using the python reference library section 18.8 but had
> trouble understanding how to make it work.
>
>  Here is the code I am currently trying to use:
>
> def main():
> import binascii
> myWord = input("Enter the word to convert..")
> #convert text to ascii
> for ch in myWord:
> print(ord(ch))
> #convert ascii to binary
> binascii.a2b_uu(ord(ch))


I'm not sure what you want, based on the code above. uuencoding is
meant for sending data through 7-bit channels like email and
newsgroups. For example:

>>> binascii.b2a_uu('\x81\x82')  # 8-bit binary to 7-bit ascii
'"@8( \n'
>>> binascii.a2b_uu('"@8( \n')   # 7-bit ascii back to 8-bit
'\x81\x82'

http://docs.python.org/py3k/library/binascii.html#binascii.a2b_uu

Do you instead want an ASCII bitstring (i.e. 1s and 0s)?

These will raise a UnicodeError if the string isn't ASCII.

# Python 3
def iter_bin(s):
sb = s.encode('ascii')
return (format(b, '07b') for b in sb)

# Python 2
def iter_bin(s):
sb = s.encode('ascii')
return (format(ord(b), '07b') for b in sb)

For example:

>>> for s in iter_bin("Spam"):
...   print(s)
...
1010011
111
111
1101101

>>> print(*iter_bin("Spam"), sep='')  # Python 3
1010011111101101

>>> print ''.join(s for s in iter_bin("Spam")) # Python 2
1010011111101101
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] convert ascii to binary

2012-09-12 Thread Dave Angel
On 09/12/2012 07:20 AM, Aaron Pilgrim wrote:
> Hello,
> I am trying to write a small program that converts ascii to binary.
>
> I tried using the python reference library section 18.8 but had
> trouble understanding how to make it work.

If you supplied a link, we might be able to figure out what section 10.8
is.  It'll vary between versions of Python.  And in version 2.7, there
doesn't seem to be a section 10.8
http://docs.python.org/reference/index.html#reference-index

It would also be useful to specify the version of Python that this is
for.  But on the assumption that it's either 2.6 or 2.7, try the
following link:

http://docs.python.org/library/functions.html#bin

if that's not what you want, then you'd better give us some sample input
and output, or give the usage context or quote the assigmment.

>  Here is the code I am currently trying to use:
>
> def main():   
>   import binascii
>   myWord = input("Enter the word to convert..")   
>   #convert text to ascii
>   for ch in myWord:
>   print(ord(ch))  
>   #convert ascii to binary
>   binascii.a2b_uu(ord(ch))

That function converts a line of uuencoded data to the binary data that
generated it.  Your ch isn't a line of uuencoded data, and you don't do
anything with the return value.  Besides, your subject line implies you
want the reverse order.
 
> main()
>
>


-- 

DaveA

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] convert ascii to binary

2012-09-12 Thread Dave Angel
On 09/12/2012 07:54 AM, Joel Goldstick wrote:
>  
> A couple of thoughts.  The section you reference suggests using higher
> level modules such as uu.
> uu seems to want to read an ascii file and write a uu encoded file.
>
> I just read the wikipedia article on uuencoding, since I have heard of
> it, but never needed to know about it.  It is apparently a pretty old
> method of transforming 3 consecutive 8 bit ascii characters into 4 6
> bit uuencoded characters so that they can be sent between (unix)
> computers.

It's old in the sense that it was defined a long time ago.  But it's
current, and variations of it are used regularly in email, as one way to
send binary attachments.  Look at the mime type called base64.

It converts 3 consecutive 8-bit NON-ASCII bytes into 4 consecutive 7-bit
ASCII characters.

I'm not sure what that has to do with the OP question.

> What are you really trying to do?  Is this for experimenting with
> python? or are you trying to solve some larger problem?
>
>


-- 

DaveA

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] convert ascii to binary

2012-09-12 Thread Joel Goldstick
On Wed, Sep 12, 2012 at 7:20 AM, Aaron Pilgrim  wrote:
> Hello,
> I am trying to write a small program that converts ascii to binary.
>
> I tried using the python reference library section 18.8 but had
> trouble understanding how to make it work.
>
>  Here is the code I am currently trying to use:
>
> def main():
> import binascii
> myWord = input("Enter the word to convert..")
> #convert text to ascii
> for ch in myWord:
> print(ord(ch))
> #convert ascii to binary
> binascii.a2b_uu(ord(ch))
>
> main()
>
A couple of thoughts.  The section you reference suggests using higher
level modules such as uu.
uu seems to want to read an ascii file and write a uu encoded file.

I just read the wikipedia article on uuencoding, since I have heard of
it, but never needed to know about it.  It is apparently a pretty old
method of transforming 3 consecutive 8 bit ascii characters into 4 6
bit uuencoded characters so that they can be sent between (unix)
computers.

What are you really trying to do?  Is this for experimenting with
python? or are you trying to solve some larger problem?


-- 
Joel Goldstick
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] convert ascii to binary

2012-09-12 Thread Aaron Pilgrim
Hello,
I am trying to write a small program that converts ascii to binary.

I tried using the python reference library section 18.8 but had
trouble understanding how to make it work.

 Here is the code I am currently trying to use:

def main(): 
import binascii
myWord = input("Enter the word to convert..")   
#convert text to ascii
for ch in myWord:
print(ord(ch))  
#convert ascii to binary
binascii.a2b_uu(ord(ch))

main()

Thank you for any help you can provide
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Musical note on python

2012-09-12 Thread eryksun
On Wed, Sep 12, 2012 at 4:49 AM, Dwight Hutto  wrote:
>
> pyaudio is compatible with python 3.0(just in case the OP has that
> version, and it doesn't look like on the main site it has it listed,
> nor if it's 64 bit, etc.

I'm surprised they don't have an official Python 3 port yet. I see now
the git repo hasn't seen a commit in 2 years. About a year ago I
ported PyAudio to Python 3 for my own use, based on the guide for
porting C extensions I found here:

http://python3porting.com/cextensions.html

But it was only a quick update (actually kind of tedious) of
_portaudiomodule.c. Christoph Gholke has a port online that modifies
setup.py as well. I prefer his version over my own (more eyes, fewer
bugs). It just needs a small modification for Linux (see below).

PyAudio for Windows Python 2.5 to 3.2 (32-bit and 64-bit):
http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyaudio

Pre-release pygame for Python 3, in case you want to use SDL as a tone
generator:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame

Debian Build

I downloaded Christoph's port of PyAudio from the site above and built
it on my Debian Linux box. I needed to install portaudio19-dev. You'll
also need python3-all-dev if it's not already installed. I had to
comment out line 138 of setup.py (data_files=data_files). Christoph
added it for the Windows build, but it's not required for Linux. I
only got a few compiler warnings running "sudo python3 setup.py
install". YMMV. The tone-playing script works fine, after making a few
modifications to use range instead of xrange and b''.join instead of
''.join.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How to print a variable from an if/else statement

2012-09-12 Thread Joel Goldstick
Following up on my earlier reply, ( I let the 'If' slip).  Python
statements are ALL lowercase.  Case matters in python, so If is not
if, Print is not print, Else is not else.
-- 
Joel Goldstick
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] How to print a variable from an if/else statement

2012-09-12 Thread Joaquim Santos
>
>
>
> Message: 3
> Date: Wed, 12 Sep 2012 09:32:38 +
> From: chrisbv...@gmail.com
> To: tutor@python.org
> Subject: [Tutor] How to print a variable from an if/else statement
> Message-ID:
> <2057338575-1347442886-cardhu_decombobulator_blackberry.rim.net-
> 2019341514-@b3.c12.bise6.blackberry>
>
> Content-Type: text/plain
>
> Hello,
>
> I'm very new thanks in advance for your help.
>
> My If statement is:
>
> If age < (40):
>   Print("you are young.")
> Else:
>   Print("You look great.")
>
> Basically what I want to do is have a sentence using print that includes
> the results of the If or Else which is based on the users input of age.
>
>  I don't know if I'm doing something wrong by doing it this way. I can't
> figure it out.
>
> Thankyou!
>
> Chris
> Sent via BlackBerry by AT&T
>
>
>
My first time answering the list!!! (sorry for this outburst!)

>From my limited knowledge your if/else statement is correct BUT your print
should start with lower caps, that's why it's not working.

You can see here a bunch of examples on how to use it properly ->
http://docs.python.org/release/3.0.1/library/functions.html?highlight=print#print

Hope this helps!

Cheers!

Joaquim Santos
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How to print a variable from an if/else statement

2012-09-12 Thread Joel Goldstick
On Wed, Sep 12, 2012 at 5:32 AM,   wrote:
> Hello,
>
> I'm very new thanks in advance for your help.
>
> My If statement is:
>
> If age < (40):
this will work, but python doesn't need the parentheses around the
second argument.  You can use it to make the logic more clear, but for
a single term it doesn't

>   Print("you are young.")
> Else:

in python else is lower case

>   Print("You look great.")
>
> Basically what I want to do is have a sentence using print that includes the 
> results of the If or Else which is based on the users input of age.
>
>  I don't know if I'm doing something wrong by doing it this way. I can't 
> figure it out.
>
so try this:

if age < 40:
  print ("you are young")
else:
  print ("you look great!")

-- 
Joel Goldstick
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] How to print a variable from an if/else statement

2012-09-12 Thread chrisbva81
Hello,

I'm very new thanks in advance for your help. 

My If statement is:

If age < (40):
  Print("you are young.")
Else:
  Print("You look great.")

Basically what I want to do is have a sentence using print that includes the 
results of the If or Else which is based on the users input of age.

 I don't know if I'm doing something wrong by doing it this way. I can't figure 
it out.

Thankyou!

Chris
Sent via BlackBerry by AT&T
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Musical note on python

2012-09-12 Thread Joel Goldstick
On Wed, Sep 12, 2012 at 2:47 AM, Mark Lawrence  wrote:
> On 12/09/2012 06:17, D.V.N.Sarma డి.వి.ఎన్.శర్మ wrote:
>>
>> How to produce  a musical note of given frequency,volume and duration in
>> Python.

I've not tried it, but I have seen several references to a game making
framework called pygame.  It has modules to play files and also
produce tones.

http://www.pygame.org/project-pitch+perfect-1689-2941.html
>>
>>

-- 
Joel Goldstick
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Musical note on python

2012-09-12 Thread Dwight Hutto
On Wed, Sep 12, 2012 at 4:04 AM, Mark Lawrence  wrote:
> On 12/09/2012 08:47, Dwight Hutto wrote:
>>
>> So the following would be the script, except the ability to change
>> specific values such as frequency with a scroll widget.
>>
>> import os
>>
>> #Variables for system call
>>
>> command_line_app_for sound = "speaker-test"
>> frequency =  " --frequency 2000"
>> length_of_sound_ms = " --period 5000"
>> test_type = " --test sine"
>>
>> #System call with variables placed in
>>
>> os.system( command_line_app_for sound + frequency + length_of_sound_ms
>> + test_type)
>>
>
> Extremely useful if and only if this is what the OP wants.  I prefer working
> to facts and not assumptions, plus the full context of previous messages.
>

The facts are, he's either going to call from a python module with
parameters, or use a command line call(whether it's windows, or
linux), or maybe he can type in 'python docs sound' into google, or go
through a ctypes(which I can reference, and find an example of.

Those are the facts.

The assumption is that they're going to use oneof the usual methods,
and I'm giving a VARIETY of factual options available.

What are you doing other than pointing out my comments are out of
context, when they clearly are in context.

All you can do is point out some it's out of context, when it's all in
context, and that is a fact.

Want to help them with how to ask a question...Quit saying give us an
OS, and some short blurb about how I'm answering out of context, and
point them to this link:

http://catb.org/esr/faqs/smart-questions.html
-- 
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Musical note on python

2012-09-12 Thread eryksun
On Wed, Sep 12, 2012 at 1:17 AM, D.V.N.Sarma డి.వి.ఎన్.శర్మ
 wrote:
> How to produce  a musical note of given frequency,volume and duration in
> Python.

Do you just want a sinusoidal, pure tone, or do you need a more
complex waveform?

For a pure tone you can use math.sin(2 * math.pi * f * dt * n). The
sin is a function of radians. 2*math.pi is the constant number of
radians/cycle, f is the frequency in cycles/second (Hz), dt is your
sampling step size in seconds/sample, and n is the index in samples.
Multiply all those units together and you get an argument in radians.
The sin function just samples the y value of the (x,y) coordinate as
you step around a unit circle in the given radians/step. You can scale
the amplitude and iterate for however many steps you want.

The discrete frequency is f*dt in cycles/sample, and the discrete
period is 1/(f*dt) in samples/cycle. You need this to be at least 2
samples/cycle to uniquely define a sinusoid. In other words, 1/dt >=
2*f.  The term 1/dt is the sampling rate fs. Two times the highest
frequency of interest (2*f) is called the Nyquist rate. Sampling a a
sinusoid at a sub-Nyquist rate will alias to a different frequency
(the spectrum of a sampled signal goes from 0 to fs/2; higher
frequencies fold back around). Search the web for animations that show
aliasing (typically with clock hands, fan blades, etc). If your sample
rate is 48000 Hz, you can create tones up to 24000 Hz, which is beyond
the spectrum of human hearing (20Hz - 20kHz).

The example below creates a generator for 1 cycle of a tone at a
sample rate of 48 ksps. Next it packs the floating point values as
bytes using struct.pack(). The resulting byte string is written to a
PyAudio stream. PyAudio is a C extension wrapper around the
cross-platform PortAudio library:

http://people.csail.mit.edu/hubert/pyaudio


import math
import struct
import pyaudio

def play_tone(frequency, amplitude, duration, fs, stream):
N = int(fs / frequency)
T = int(frequency * duration)  # repeat for T cycles
dt = 1.0 / fs
# 1 cycle
tone = (amplitude * math.sin(2 * math.pi * frequency * n * dt)
for n in xrange(N))
# todo: get the format from the stream; this assumes Float32
data = ''.join(struct.pack('f', samp) for samp in tone)
for n in xrange(T):
stream.write(data)

fs = 48000
p = pyaudio.PyAudio()
stream = p.open(
format=pyaudio.paFloat32,
channels=1,
rate=fs,
output=True)

# play the C major scale
scale = [130.8, 146.8, 164.8, 174.6, 195.0, 220.0, 246.9, 261.6]
for tone in scale:
play_tone(tone, 0.5, 0.75, fs, stream)

# up an octave
for tone in scale[1:]:
play_tone(2*tone, 0.5, 0.75, fs, stream)

stream.close()
p.terminate()
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Musical note on python

2012-09-12 Thread Mark Lawrence

On 12/09/2012 08:47, Dwight Hutto wrote:

So the following would be the script, except the ability to change
specific values such as frequency with a scroll widget.

import os

#Variables for system call

command_line_app_for sound = "speaker-test"
frequency =  " --frequency 2000"
length_of_sound_ms = " --period 5000"
test_type = " --test sine"

#System call with variables placed in

os.system( command_line_app_for sound + frequency + length_of_sound_ms
+ test_type)



Extremely useful if and only if this is what the OP wants.  I prefer 
working to facts and not assumptions, plus the full context of previous 
messages.


--
Cheers.

Mark Lawrence.

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Musical note on python

2012-09-12 Thread Mark Lawrence

On 12/09/2012 08:41, Dwight Hutto wrote:

Where have you forgotten to mention Ubuntu?  "I'm sure...", the OP has specifically said 
"in Python", which implies to me using a Python package or module, hence my question 
above.


Well, I was assuming he would write a command line app like so:

Python 2.7.3 (default, Aug  1 2012, 05:16:07)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import os
os.system("speaker-test" + " --frequency 2000" + " --period 5000" + " --test 
sine")



This would work in linux/ubuntu, but if they're using windows or don't
have this particular linux distribution/speaker-test installed, it
might need to be a different command line call, such as :


import os
os.system("your_sound_app_here" + " --frequency 2000" + " --period 5000" + " --test 
sine")


--
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor



You can assume until the cows come home, but unless the OP states their 
requirement nobody will know for certain :)


--
Cheers.

Mark Lawrence.

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Musical note on python

2012-09-12 Thread Dwight Hutto
So the following would be the script, except the ability to change
specific values such as frequency with a scroll widget.

import os

#Variables for system call

command_line_app_for sound = "speaker-test"
frequency =  " --frequency 2000"
length_of_sound_ms = " --period 5000"
test_type = " --test sine"

#System call with variables placed in

os.system( command_line_app_for sound + frequency + length_of_sound_ms
+ test_type)

-- 
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Musical note on python

2012-09-12 Thread Dwight Hutto
> Where have you forgotten to mention Ubuntu?  "I'm sure...", the OP has 
> specifically said "in Python", which implies to me using a Python package or 
> module, hence my question above.
>
Well, I was assuming he would write a command line app like so:

Python 2.7.3 (default, Aug  1 2012, 05:16:07)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.system("speaker-test" + " --frequency 2000" + " --period 5000" + " 
>>> --test sine")


This would work in linux/ubuntu, but if they're using windows or don't
have this particular linux distribution/speaker-test installed, it
might need to be a different command line call, such as :

>>> import os
>>> os.system("your_sound_app_here" + " --frequency 2000" + " --period 5000" + 
>>> " --test sine")

--
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Musical note on python

2012-09-12 Thread Mark Lawrence

On 12/09/2012 07:57, Dwight Hutto wrote:

On Wed, Sep 12, 2012 at 2:47 AM, Mark Lawrence wrote:


On 12/09/2012 06:17, D.V.N.Sarma డి.వి.ఎన్.శర్మ wrote:


How to produce  a musical note of given frequency,volume and duration in
Python.


__**_
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/**mailman/listinfo/tutor



Please give an indication of the research that you've done, the code that
you've tried, the target OS, Python version number and the issues that you
have before you post a question like this.





Apologies,
Forgot to mention I was using Ubuntu for this. However, I'm sure he's
going to want to initiate a command line app for this(no matter the OS,
unless he uses a python module), and define switches/params, even if he
wants to put it in an app.




___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor



Where have you forgotten to mention Ubuntu?  "I'm sure...", the OP has 
specifically said "in Python", which implies to me using a Python 
package or module, hence my question above.


--
Cheers.

Mark Lawrence.

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor