Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-18 Thread Marc Tompkins
On Sun, Aug 17, 2014 at 10:51 PM, Terry--gmail  wrote:
> I'm copy and pasting from Ninja-IDE, which I thought was created
> specifically to do python programming...

Specifically for programming, yes, and Python is among the supported
languages - but according to their web page, they support many
languages (and in many other languages, whitespace is either not
meaningful, or else you might actually want the Tab key to produce a
tab character.)
Anyway, I'm only guessing that the reason your indentation was
disappearing was a tab/space issue; I don't actually know.

>
> for line_number, row in enumerate(catalog2):
> for col, item in enumerate(row):
> if lens[col] < len(item):
> lens[col] = len(item)
>
> How's that?

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


Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-18 Thread Cameron Simpson

On 17Aug2014 23:51, Terry--gmail  wrote:
I'm copy and pasting from Ninja-IDE, which I thought was created 
specifically to do python programming...so I never checked to see if 
it needs to have the tab set to enter 4 spaces, as it appeared 
visually to be doing that.  But, I don't remember whether I used their 
tab or manually typed 4 spaces. SO, I have typed the lines below in 
manually:


for line_number, row in enumerate(catalog2):
   for col, item in enumerate(row):
   if lens[col] < len(item):
   lens[col] = len(item)

How's that?


All good except for the last line, which would normally be indented further 
than the "if".


Cheers,
Cameron Simpson 

This information is absolutely reliable; I read it on Usenet somewhere.
- sc...@festival.ed.ac.uk (Scott Larnach)
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Building Starships -- object of type 'int' has no len()

2014-08-18 Thread Marc Tompkins
On Mon, Aug 18, 2014 at 12:13 AM, Cameron Simpson  wrote:
> On 17Aug2014 23:51, Terry--gmail  wrote:
>>
>> I'm copy and pasting from Ninja-IDE, which I thought was created
>> specifically to do python programming...so I never checked to see if it
>> needs to have the tab set to enter 4 spaces, as it appeared visually to be
>> doing that.  But, I don't remember whether I used their tab or manually
>> typed 4 spaces. SO, I have typed the lines below in manually:
>>
>> for line_number, row in enumerate(catalog2):
>>for col, item in enumerate(row):
>>if lens[col] < len(item):
>>lens[col] = len(item)
>>
>> How's that?
>
>
> All good except for the last line, which would normally be indented further
> than the "if".
Poop.  I missed that.

Also, looking at the Ninja-IDE website more closely I see that,
although they do mention compatibility with multiple languages, they
were designed by and for Python programmers - which makes the
tab/space issue less likely.  I dunno.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Tutor

2014-08-18 Thread BALDWIN, CATHY L (Legal)
"I'm in Grand Prairie, TX and need
a tutor. Someone I can meet with who can explain it to me like I'm 4
years old. Anybody out there up for the challenge. I will gladly pay
you for your help. email me at home dac...@aol.com"



Cathy L. Baldwin
Legal Assistant to:
Ken Gitter, Mert Simons
208 S. Akard Floor 31
Dallas, TX 75202
214 757-3499

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


Re: [Tutor] Error in get pixel value in coordinate (x, y) using getPixel(x, y)

2014-08-18 Thread Whees Northbee
I'm so sorry for late reply, my laptop broken, the code actually I already
put in thread before so I'll copy to here..
I don't know how to get pixel, I just searched and many link using
'getPixel' to get value of pixel..
I know color frame using 3 channel B G R to get pixel, but I just want to
get pixel value in 1 channel, they said I need to use video in gray scale,
and I already convert my video to gray scale
Here's the code:

cap  =cv2.VideoCapture("c:\Users\Shiloh\Videos\AVI\MOV_5675.avi")
width=cap.get(cv2.cv.CV_CAP_PROP_FRAME_WIDTH)
height   =cap.get(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT)

NUM_SAMPLES  =20
RADIUS   =20
MIN_MATCHES  =2
SUBSAMPLE_FACTOR =16

c_xoff= [-1,  0,  1, -1, 1, -1, 0, 1, 0]
c_yoff= [-1,  0,  1, -1, 1, -1, 0, 1, 0]

while(1):
#Assign space and init
m_samples=[]

#height, width, depth=cap.shape
c_black=np.zeros( (height,width), dtype=np.uint8)
for i in range(0,NUM_SAMPLES,1):
m_samples.append(c_black)

m_mask=np.zeros( (width,height), dtype=np.uint8)
m_foregroundMathCount=np.zeros( (width,height), dtype=np.uint8)


# Capture frame-by-frame
ret, frame = cap.read()


#Init model from first frame
for i in range(0,width,1):
for j in range(0,height,1):
for k in range(0,NUM_SAMPLES,1):
random=np.random.randint(0,9)

row=i+c_yoff[random]
if(row<0):
row=0
if(row>=width):
row=width-1

col=j+c_xoff[random]
if(col<0):
col=0
if(col>=height):
col=height-1

m_samples[k][i][j]=getPixel(frame,row,col)
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] how do I make my code better?

2014-08-18 Thread keith papa
Am a newbie and I decided to code a program that you input a round number and  
spit out the list of names or other information? how do I make this better? how 
do I make the code repeat itself, so I can keep asking the program to print out 
list of names for a variable? 

here my code:

print 'Hello TheNetWork A' round1 = "First Round players: [Jamaal Charles RB
   KC], [LeSean McCoy RB PHI], [Calvin Johnson WR DET]" round2 = "Second 
round player: [Matt Forte RB CHI], [Eddie Lacy RB  GB]," round3 = "Third 
Round players: [Peyton Manning QB DEN], [Jimmy Graham TE NO], [Demaryius Thomas 
WR DEN]" round4 = '[Dez Bryant WR DAL], [A.J. Green  WR  CIN],[ Brandon 
Marshall WR  CHI], [Julio Jones WR   ATL]' answer =raw_input('Enter round 
number here: \n')if answer == 'round1':print round1if answer == 'round2':   
 print round2if answer == 'round3':print round3if answer == 'round4':
print round4 ___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Tutor

2014-08-18 Thread Alan Gauld

On 18/08/14 16:23, BALDWIN, CATHY L (Legal) wrote:

"I'm in Grand Prairie, TX and need
a tutor. Someone I can meet with who can explain it to me like I'm 4
years old. Anybody out there up for the challenge.


That's not really how the tutor list works.

Instead, you try to learn the language (either by using a course,
book, video or online tutorial) and when you get stuck or want feedback 
you send a mail here and whoever is available and interested will post a 
reply. Usually you will get several replies (and occasionally none).


However somebody may be willing to meet you for 1-1  tutoring
but its not the preferred way on this list. Not least because only
you benefit whereas by doing it as described above everyone gets
the chance to learn.

There is a list of tutorials for absolute beginners here:

https://wiki.python.org/moin/BeginnersGuide/NonProgrammers

Or you can try my tutorial, see below

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

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


Re: [Tutor] Tutor

2014-08-18 Thread Ben Finney
"BALDWIN, CATHY   L (Legal)"  writes:

> "I'm in Grand Prairie, TX and need a tutor.

This forum is dedicated to tutoring people *here*, in the forum, in
public. This is a great benefit because all participants (including you)
can observe the discussions and learn from them.

> Anybody out there up for the challenge.

If you're up for the challenge:

* Set up your mail client to post plain text messages only, so your code
  examples survive.

* Ask a question, preferably showing some (very short and simple) code
  which you would like to understand better.

* Participate in the ensuing discussion.

* Ask more questions in new threads, and repeat :-)

Welcome, and here's to learning a great language!

-- 
 \ “Not to be absolutely certain is, I think, one of the essential |
  `\ things in rationality.” —Bertrand Russell |
_o__)  |
Ben Finney

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


Re: [Tutor] how do I make my code better?

2014-08-18 Thread Danny Yoo
Hello,


Often, when you're writing code that looks roughly like:

###
a_1 = ...
a_2 = ...
...
a_n = ...

if ... a_1:
  ...
if ... a_2:
  ...
...
if ... a_n:
  ...
###

then your program is crying out to use a table.  The idea is to use a
list to structure the pieces into a single, tabular thing, so that you
can just point to an entry in the table to do something.

>From a brief glance, as a first pass, your code can be transformed to:

##
rounds = ["First Round players: [Jamaal Charles RB   KC], [LeSean
McCoy RB PHI], [Calvin Johnson WR DET]",
  "Second round player: [Matt Forte RB CHI], [Eddie Lacy RB  GB],"
  "Third Round players: [Peyton Manning QB DEN], [Jimmy Graham
TE NO], [Demaryius Thomas WR DEN]",
  "[Dez Bryant WR DAL], [A.J. Green  WR  CIN],[
Brandon Marshall WR  CHI], [Julio Jones WR   ATL]",
]

answer = raw_input('Enter round number here: \n')

print rounds[int(answer)-1]
##

where the user now just enters a number, and that number is used to
lookup in the "rounds".  We use a list here to represent the table.


There may be other ways to improve this.  The entries in this table
are strings: maybe it makes sense for them to have some more
structure.  Depends on if you have more plans to expand the program
further.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] how do I make my code better?

2014-08-18 Thread Alan Gauld

On 18/08/14 20:18, keith papa wrote:

Am a newbie and I decided to code a program that you input a round
number and  spit out the list of names or other information? how do I
make this better? how do I make the code repeat itself, so I can keep
asking the program to print out list of names for a variable?


Have you come across the while loop?

It looks like this:

while :
do stuff here

So for your program it should look something like:

while True:  # loop forever
answer = raw_input(
if answer = 'quit':
   break   # exits the loop
elif answer = 
   as before

If while loops are new to you then you will find more info in
the Loops topic of my tutorial (see .sig).

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

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