On 18/06/2014 01:02, Alex Kleider wrote:
On 2014-06-17 13:35, Alan Gauld wrote:
Don't test types, use the interface
Can you please explain what you mean by this?
alex
Further to Danny Yoo's response have a read of this
http://en.wikipedia.org/wiki/Duck_typing
--
My fellow Pythonistas, a
Hi,
I'm new to programming and I've tried to learn in the past but I gave up
easily. I tried learning Java but I feel that Python would be the best
route to take since it's easier to learn and then I'll move on to learning
Java. I want to learn Python 3.x not Python 2.
My goal(s) are:
Learn Python
> On 2014-06-17 13:35, Alan Gauld wrote:
>
>> Don't test types, use the interface
>
> Can you please explain what you mean by this?
> alex
He means use the Python interpreter, by going to your console and typing
"python", or in Windows
it's called 'IDLE'.
__
On 18/06/14 06:27, Brandon Price wrote:
Hi,
I'm new to programming and I've tried to learn in the past but I gave up
easily.
Learn Python within 1 month
That's achievable, at least to a working level.
Expert takes a tad longer.
Questions:
1. Which one of these resources would you recommend
On 18/06/14 01:15, Nanohard wrote:
On 2014-06-17 13:35, Alan Gauld wrote:
Don't test types, use the interface
Can you please explain what you mean by this?
He means use the Python interpreter, by going to your console and typing
"python", or in Windows
it's called 'IDLE'.
Nope, I meant
On 17/06/2014 22:35, Alan Gauld wrote:
Use modules instead of singleton classes
As a new beginner with Python, I am having problem understanding the
difference here.
I think I understand classes, but still have problems with inheritance,
but I do not understand what defines a module.
With many
- Original Message -
> From: Alan Gauld
> To: tutor@python.org
> Cc:
> Sent: Wednesday, June 18, 2014 11:47 AM
> Subject: Re: [Tutor] Tips
>
> On 18/06/14 01:15, Nanohard wrote:
>>> On 2014-06-17 13:35, Alan Gauld wrote:
>>>
Don't test types, use the interface
>>>
>>> Can you p
On 18/06/14 15:25, Albert-Jan Roskam wrote:
Just do this:
def add(a,b):
return a+b
Given that the concept of Ducktyping has already been mentioned, is there a
reason why you did not mention try-except?
def add(a, b):
try:
return a + b
except TypeError:
rais
On 18/06/2014 15:25, Albert-Jan Roskam wrote:
- Original Message -
From: Alan Gauld
To: tutor@python.org
Cc:
Sent: Wednesday, June 18, 2014 11:47 AM
Subject: Re: [Tutor] Tips
On 18/06/14 01:15, Nanohard wrote:
On 2014-06-17 13:35, Alan Gauld wrote:
Don't test types, use the inte
- Original Message -
> From: Mark Lawrence
> To: tutor@python.org
> Cc:
> Sent: Wednesday, June 18, 2014 9:03 PM
> Subject: Re: [Tutor] Tips
>
> On 18/06/2014 15:25, Albert-Jan Roskam wrote:
>> - Original Message -
>>> From: Alan Gauld
>>> To: tutor@python.org
>>> Cc:
>>>
Whats a more pythony way to do this? I have a dict with a few dozen
elements, and I want to pull a few out. I've already shortened it with
itemgetter, but it still seems redundant. I feel like I can do something
like I've seen with *kwargs, but I'm not sure.
I'm using old style sprintf formatti
Ben Sherman wrote:
> Whats a more pythony way to do this? I have a dict with a few dozen
> elements, and I want to pull a few out. I've already shortened it with
> itemgetter, but it still seems redundant. I feel like I can do something
> like I've seen with *kwargs, but I'm not sure.
>
> I'm
On 18/06/2014 20:17, Albert-Jan Roskam wrote:
- Original Message -
From: Mark Lawrence
To: tutor@python.org
Cc:
Sent: Wednesday, June 18, 2014 9:03 PM
Subject: Re: [Tutor] Tips
On 18/06/2014 15:25, Albert-Jan Roskam wrote:
- Original Message -
From: Alan Gauld
To: t
Sydney Shall Wrote in message:
>
but I do not understand what defines a module
Please post in plain text, not html.
A module is a source file (eg. .py) or a compiled source file (eg
.pyc) that's generally intended to be used via an import.
--
DaveA
___
Hi Experts,
I have a file with below format
this is first file operation
x-1 "all the best"
x-2 "all the best 2 next line
check this"
x-3 "last line"
i need extract the lines starting with x-1 and x-2, can some throw some
light on how to do?
Thanks,
Uma
On Wed, Jun 18, 2014 at 07:25:41AM -0700, Albert-Jan Roskam wrote:
> Given that the concept of Ducktyping has already been mentioned, is
> there a reason why you did not mention try-except?
>
> def add(a, b):
> try:
> return a + b
> except TypeError:
> raise
As others
On Wed, Jun 18, 2014 at 6:08 PM, Umamaheshwar Rao
wrote:
> Hi Experts,
>
> I have a file with below format
>
Can you describe the format a little more precisely? You're giving
examples, which is wonderful. But the examples are missing something.
What's the output you want to get here? Imagi
[content about __add__ dispatch resolution cut]
We should remember the target audience, lest this thread doesn't
spiral away so that only the tutors are talking to each other. I'm
guilty of this as anyone, mind you. Pot. Kettle. :P
The original question that the OP posed was:
I want to
On Wed, Jun 18, 2014 at 12:35:20PM +0200, Sydney Shall wrote:
> On 17/06/2014 22:35, Alan Gauld wrote:
> >Use modules instead of singleton classes
> As a new beginner with Python, I am having problem understanding the
> difference here.
> I think I understand classes, but still have problems with
i agree.
i expect the output be
"all the best"
"all the best 2 next line\n check this"
On Wed, Jun 18, 2014 at 6:24 PM, Danny Yoo wrote:
> On Wed, Jun 18, 2014 at 6:08 PM, Umamaheshwar Rao
> wrote:
> > Hi Experts,
> >
> > I have a file with below format
> >
>
>
> Can you describe the format
Hi Uma,
In your case, I'd look at the file as a sequence of "tokens" and look
at this as a tokenization problem
I think we'll see some kind of _identifier_, followed by _whitespace_,
followed by a _string_. All these three tokens will repeat, until we
hit the end of the the file.
More formally
Hi Ben,
There's a bit of duplication in the keys being looked up, making it a
bit fragile if you need to correct the spelling of a key or need to
add additional keys, since there are two places that need to be
changed.
One way to make this a little cleaner might be to have a helper
function that
On 19/06/2014 02:36, Danny Yoo wrote:
[content about __add__ dispatch resolution cut]
We should remember the target audience, lest this thread doesn't
spiral away so that only the tutors are talking to each other. I'm
guilty of this as anyone, mind you. Pot. Kettle. :P
The original questi
23 matches
Mail list logo