[Tutor] Help

2015-08-09 Thread Shannon Callahan
To anybody,

I am new to this with so small experiences. I am struggle to get around
with python's install that connect with Mac's terminal. Basically, I am
trying to make a codes into sd card for raspberry pi to have it detect
specific sound  then it ring that al.

Any idea?


Shannon
SDSU Graduate Student

"Disability was not an outcome of bodily pathology, but of social
organization: it was socially produced by systematic patterns of exclusion
that were - quite literally - built into the social fabric." (Hughes &
Paterson 1997).
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Help

2015-08-09 Thread Steven D'Aprano
Hi Shannon, and welcome,

My comments below yours:

On Sun, Aug 09, 2015 at 03:14:38PM -0700, Shannon Callahan wrote:
> To anybody,
> 
> I am new to this with so small experiences. I am struggle to get around
> with python's install that connect with Mac's terminal. Basically, I am
> trying to make a codes into sd card for raspberry pi to have it detect
> specific sound  then it ring that al.
> 
> Any idea?

I'm sorry, I have no idea what you are asking for.

Are you having problems installing Python on a Macintosh?

Are you trying to write code for a Raspberry Pi, to have it detect a 
specific sound? To have it detect *any* sound is one thing, to have it 
detect a specific sound is much, much, much harder, and will probably 
require specialised knowledge that you are unlikely to learn here.

I don't understand your reference to an SD card. Is your problem that 
you don't know how to copy files to an SD card?

And I am afraid I have no idea what you mean by "then it ring that al". 
Ring that "all" perhaps? All what?

Can you please explain, carefully and in detail:

- what you are trying to do;
- what you have done so far;
- what result you hope to get;
- the actual result you have got.

It will help if you also show the code you have written so far.


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


Re: [Tutor] R: Tutor Digest, Vol 138, Issue 26 Re: Problem on select esecution of object in a class (Alan Gauld)

2015-08-09 Thread Steven D'Aprano
Hi Jarod,

I'm not sure if you have received an answer to your question.

It might help if you use a subject line that describes your question.

See below for my answer:


On Wed, Aug 05, 2015 at 10:33:01PM +0200, jarod_v6--- via Tutor wrote:
> Thanks so much fro the help. What I want to do is to obtain a selection of 
> the 
> function I want to run.
> 
> ena = Rnaseq(options.configura, options.rst, options.outdir)
>   cmdset = [ ena.trimmomatic,
>   ena.star,
>   ena.merge_trimmomatic_stats
>   ]
> ena.show()
> 1 ena.trimmomatic
> 2 ena.star
> 3 ena.merge_trimmomatic_stats
> The class RNaseq have multiple function. I want a way to run or from 1 to 3 
> or 
> from 2 to 3 or only the 2 o 3 step.
> 
> ...
>   parser.add_option("-s", "--step",action="store", 
> dest="steps",type="string",
> help=" write input file: %prg -o : directory of results ")
> 
> python myscript -s 1,3 ...
> 
> At the moment the only way I found is this:
>  for cmd in cmdset: 
>   step = cmd()
>   for i in step:
>   print i.command
> 
> but is not elegant so I want to know more what is the right way to generate a 
> execution f the function of the class by select which is the step we want to 
> start.

This is hard to answer since you don't tell us directly what cmdset is, 
but I think I can guess. Something similar to this should work:


cmdset = ena.cmdset
options = "1,3"  # for example
options = options.replace(",", " ").split()
# options now has ["1", "3"]
options = [int(s) for s in options]
# options now has [1, 3], integers, not strings

for opt in options:
cmd = cmdset[i-1]  # remember Python starts counting at 0, not 1
print cmd()



Does that help?



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


Re: [Tutor] output formatting question

2015-08-09 Thread Steven D'Aprano
On Wed, Aug 05, 2015 at 09:08:16PM -0700, tom arnall wrote:
> i have read --  with what i think is a reasonable amount of attention
> -- all of the doc' i can find about string formatting in python. for
> the life of me, i cannot see how any of the other methods do more than
> you can do with, to use a concrete example:
> 
> print "Here %s a number: %3d" % ("is",  1)
> 
> #OR:
> 
> s =   "Here %s a number: %3d" % ("is", 1)
> print s
> 
> what am i not getting?

%s and %r work with any object at all. Or do they? Run 
this code snippet to find out:

objects = [ 1, "a", 2.5, None, [1,2], (1,2) ]
for o in objects:
print "the object is: %s" % o


With positional arguments, % formatting operates strictly left to right, 
while the format() method lets you operate on arguments in any order, 
and you can refer to the same item multiple times:

py> "{1} {0} {0}".format("first", "second")
'second first first'

Compared to:

"%s %s %s" % ("second", "first", "first")

which is inconvenient and annoying.


% formatting allows you to use positional arguments or keyword 
arguments, but not both at the same time. The format() method allows 
both at the same time:

py> "{1} {0} {spam}".format("first", "second", spam="third")
'second first third'

The format() method also supports customization via the special method 
__format__, although I haven't done this and I'm not sure how it works. 
But I think it means that you can invent your own formatting codes.

The format() method also supports centring with the ^ alignment option, 
thousands separators with , and a few other additional features, e.g. 
binary output:

py> "{:b}".format(3000)
'101110111000'

There's no doubt that the format() method is significantly more powerful 
than % interpolation, but its also slower, and for many purposes good 
old fashioned % is perfectly fine.



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