Re: [Tutor] don't understand iteration

2014-11-10 Thread Peter Otten
Clayton Kirkwood wrote: > > >>-Original Message- >>From: Tutor [mailto:tutor-bounces+crk=godblessthe...@python.org] On >>Behalf Of Peter Otten >>Sent: Sunday, November 09, 2014 5:47 PM >>To: tutor@python.org >>Subject: Re: [Tutor] don't understand iteration >> >>Clayton Kirkwood wrote: >

Re: [Tutor] don't understand iteration

2014-11-10 Thread Alan Gauld
On 10/11/14 00:34, Clayton Kirkwood wrote: if 'EST' in line or 'EDT' in line: # look for Eastern Time blah = re.search(r'<\w\w>(\w{3}\.)\s+(\d{2}),\s+(\d{2}).+([AP]M)\s+(E[SD]T)', line) (month, day, time, ap, offset) = blah.group(1,2,3,4,5) <_sre.SRE_Match object; span=(0, 28), match='

Re: [Tutor] don't understand iteration

2014-11-10 Thread Clayton Kirkwood
>-Original Message- >From: Tutor [mailto:tutor-bounces+crk=godblessthe...@python.org] On >Behalf Of Alan Gauld >Sent: Monday, November 10, 2014 4:20 AM >To: tutor@python.org >Subject: Re: [Tutor] don't understand iteration > >On 10/11/14 00:34, Clayton Kirkwood wrote: > >> if 'EST' in li

[Tutor] Help with Dice game

2014-11-10 Thread coryloghry
Hello, I can not for the life of me figure out where I have gone wrong. I wrote the following code as a simulation for the table top game x-wing. It basically simulates dice rolls but the issue is the fact that every time I choose a number of dice to roll, they all hit. None of them ever miss

[Tutor] “has a value of True” versus “evaluates true” (was: don't understand iteration)

2014-11-10 Thread Ben Finney
"Clayton Kirkwood" writes: > Also of confusion, the library reference says: > > Match objects always have a boolean value of True. Since match() and > search() return None when there is no match, you can test whether there was > a match with a simple if statement: > > match = re.search(pattern, s

Re: [Tutor] don't understand iteration

2014-11-10 Thread Alan Gauld
On 10/11/14 23:08, Clayton Kirkwood wrote: I couldn't find a way to get the len of blah. What would you expect the answer to be? I would expect len(sizeof, whatever)(blah) to return the number of (in this case) matches, so 5. But remember that search is matching the pattern, not the groups

Re: [Tutor] Help with Dice game

2014-11-10 Thread Alan Gauld
On 10/11/14 20:57, corylog...@yahoo.com.dmarc.invalid wrote: I wrote the following code as a simulation for the table top game x-wing. I don;t know it so can only give some general comments below... import random print("X-wing dice simulator") x = int(input("How many dice will the offensive

Re: [Tutor] don't understand iteration

2014-11-10 Thread Clayton Kirkwood
>-Original Message- >From: Tutor [mailto:tutor-bounces+crk=godblessthe...@python.org] On >Behalf Of Ben Finney >Sent: Sunday, November 09, 2014 8:25 PM >To: tutor@python.org >Subject: Re: [Tutor] don't understand iteration > >"Clayton Kirkwood" writes: > >> >-Original Message- >>

Re: [Tutor] don't understand iteration

2014-11-10 Thread Clayton Kirkwood
>-Original Message- >From: Tutor [mailto:tutor-bounces+crk=godblessthe...@python.org] On >Behalf Of Alan Gauld >Sent: Monday, November 10, 2014 3:59 PM >To: tutor@python.org >Subject: Re: [Tutor] don't understand iteration > >On 10/11/14 23:08, Clayton Kirkwood wrote: > I couldn't fi

Re: [Tutor] don't understand iteration

2014-11-10 Thread Alan Gauld
On 11/11/14 00:28, Clayton Kirkwood wrote: This seems to be the only relevant words: 4.7.4. Unpacking Argument Lists ...when the arguments are already in a list or tuple but need to be unpacked > > for a function call If they are not available separately, write the function > call with

Re: [Tutor] Help with Dice game

2014-11-10 Thread Lifeng Lin
I am not familiar with the game, but maybe using "offense += 1" and "defense += 1" to replace the corresponding "continue" would help? On Mon, Nov 10, 2014 at 2:57 PM, wrote: > Hello, I can not for the life of me figure out where I have gone wrong. > I wrote the following code as a simulation f

Re: [Tutor] don't understand iteration

2014-11-10 Thread Alan Gauld
On 11/11/14 00:52, Clayton Kirkwood wrote: But group() - singular - returns a single group item which is always a string. You use group() to get the matching substring. You use groups to find all the substrings. I believe that is true only if you are receiving a single return value. If it is m

Re: [Tutor] “has a value of True” versus “evaluates true” (was: don't understand iteration)

2014-11-10 Thread Clayton Kirkwood
I reported it. I feel all grown up now. Kind of like one of the boys(girls...) Clayton:<) >-Original Message- >From: Tutor [mailto:tutor-bounces+crk=godblessthe...@python.org] On >Behalf Of Ben Finney >Sent: Monday, November 10, 2014 3:24 PM >To: tutor@python.org >Subject: [Tutor] “has a

[Tutor] Project tree

2014-11-10 Thread Wiktor Matuszewski
Hi, let's assume I have this project tree: project_name/ |-src/ | |- __init__.py | |- moda.py | '- modb.py '- start.py And individual files contain: - modb.py: - def hello(txt): return "Hello " + txt + "!" def plus1(num): return num + 1 - moda.

Re: [Tutor] Project tree

2014-11-10 Thread Danny Yoo
> Traceback (most recent call last): > File "E:\tests\project_name\start.py", line 1, in > from src import moda > File "E:\tests\project_name\src\moda.py", line 1, in > import modb > ImportError: No module named 'modb' Hi Wiktor, In Python 3, imports are not relative by default.

Re: [Tutor] don't understand iteration

2014-11-10 Thread Clayton Kirkwood
>-Original Message- >From: Tutor [mailto:tutor-bounces+crk=godblessthe...@python.org] On >Behalf Of Ben Finney >Sent: Sunday, November 09, 2014 8:25 PM >To: tutor@python.org >Subject: Re: [Tutor] don't understand iteration > >"Clayton Kirkwood" writes: > >> >-Original Message- >>

Re: [Tutor] don't understand iteration

2014-11-10 Thread Clayton Kirkwood
>-Original Message- >From: Tutor [mailto:tutor-bounces+crk=godblessthe...@python.org] On >Behalf Of Alan Gauld >Sent: Monday, November 10, 2014 5:07 PM >To: tutor@python.org >Subject: Re: [Tutor] don't understand iteration > >On 11/11/14 00:28, Clayton Kirkwood wrote: > > >> This seems to

Re: [Tutor] http question

2014-11-10 Thread Clayton Kirkwood
>-Original Message- >From: Tutor [mailto:tutor-bounces+crk=godblessthe...@python.org] On >Behalf Of Steven D'Aprano >Sent: Sunday, November 09, 2014 3:04 AM >To: tutor@python.org >Subject: Re: [Tutor] http question > >On Sat, Nov 08, 2014 at 09:53:33PM -0800, Clayton Kirkwood wrote: > >>

Re: [Tutor] “has a value of True” versus “evaluates true” (was: don't understand iteration)

2014-11-10 Thread wesley chun
good catch, and definitely a distinction beginners should be more cognizant of. it's also good to recognize that a call to "bool(match)" would render that statement correct, as the built-in/factory function will return what an object evaluates to (True [re.match object] or/vs.False [None]). On Mo