Hello,
For a exerise I made this one :"
import string
def extract_words(s):
"""
>>> extract_words('Now is the time! "Now", is the time? Yes, now.')
['now', 'is', 'the', 'time', 'now', 'is', 'the', 'time', 'yes', 'now']
>>> extract_words('she tried to curtsey as she
> For a exerise I made this one :"
>
> import string
> def extract_words(s):
> """
> >>> extract_words('Now is the time! "Now", is the time? Yes, now.')
> ['now', 'is', 'the', 'time', 'now', 'is', 'the', 'time', 'yes', 'now']
> >>> extract_words('she tried to curtsey as she
> Subject: Re: [Tutor] can this be done easerly
> From: evert@gmail.com
> Date: Mon, 30 Aug 2010 12:04:08 +0200
> CC: tutor@python.org
> To: rwob...@hotmail.com
>
> > For a exerise I made this one :"
> >
> > import string
> > def extract_words(s):
> > """
> > >>> extract_words('Now is th
"Roelof Wobben" wrote
import string
I know your tutorial uses the string module but you really should
get out of that habit. It will not work in the newer versions of
Python
and is less efficient that using the builtin methods.
And invariably requires more typing! :-)
def extract_words(s):
On Mon, 30 Aug 2010 07:44:06 pm Roelof Wobben wrote:
> Hello,
>
>
>
> For a exerise I made this one :"
>
>
>
> import string
>
> def extract_words(s):
[...]
> But now I wonder if this can be done more easerly ?
def extract_words(s):
"""
>>> extract_words('Now is the time! "Now", is the
Hey everyone,
I have a huge number of data items coming from a database. So far
there're no restrictions about how to model the items. They can be
dicts, objects of a custom class (preferable with __slots__) or namedTuple.
Those items have references to each other using ids. Fresh from the
d
On 30/08/2010 16.44, Knacktus wrote:
Hey everyone,
I have a huge number of data items coming from a database. So far
there're no restrictions about how to model the items. They can be
dicts, objects of a custom class (preferable with __slots__) or namedTuple.
Those items have references to each
> I tried your suggestion with strip and it looks like this :
> import string
You don't need this now
> def extract_words(s):
>word= ""
You dont need this
> s2=[]
> s = string.lower(s)
> s = s.replace( "--", " ")
You probably don't need this either - just add '-' to the str
I checked out the csv module and got a little further along, but still can't
quite figure out how to iterate line by line properly.
# This shows that I'm reading the file in correctly:
input_file=open("test-8-29-10.csv","rb")
for row in input_file:
print row
MyWord,Category,Ct,CatCt
!,A,29
On Mon, Aug 30, 2010 at 12:04 PM, wrote:
> I checked out the csv module and got a little further along, but still can't
> quite figure out how to iterate line by line properly.
> > # But when I try to add columns, I'm only filling in some static value. So
> there's something wrong with my loopin
Hi Everybody,
I'm beefing up my Object-Oriented Analysis and Design - getting
the gaps in my
knowledge filled in through the Head First OOAD book
(http://headfirstlabs.com/books/hfooad/).
That book focuses on Java - is there a comparable book for Python? I
have already read the
Alan Gauld'
Am 30.08.2010 17:53, schrieb Francesco Loffredo:
Two questions and one doubt for you:
1- How many "generations" do you want to keep in a single item (call it
dictionary or list, or record, whatever)? I mean, what if some children
have children too, and some of those have more children, etc ?
The
I haven't read it yet myself, but the below book just came out:
http://www.amazon.com/Python-3-Object-Oriented-Programming/dp/1849511268/ref=cm_cr_pr_sims_t
I'm not aware of any other book that focuses exclusively on OO in Python,
though you'll find good intros to the topic in a number of the "cl
Am 30.08.2010 20:13, schrieb Tino Dai:
Hi Everybody,
I'm beefing up my Object-Oriented Analysis and Design - getting
the gaps in my
knowledge filled in through the Head First OOAD book
(http://headfirstlabs.com/books/hfooad/).
That book focuses on Java - is there a comparable book for
Ok, Looks like you need the replace() on anything that could be a separator...
BTW.
Did you see Steven's implementation? He used a list comprehension
which is probably a little beyond your "comprehension" for now (sorry,
I couldn't resist! :-) but can be translated easily back to an explicit loo
You could google for
1) Alex Martelli, Design Patterns
He's a Pyton guru and there're some online talks (at Google and some
conferences) about DP; a bit difficult to understand, well, he's guru ;-)
2) http://www.suttoncourtenay.org.uk/duncan/accu/pythonpatterns.html
I like that one.
Also, the
"Tino Dai" wrote
I'm beefing up my Object-Oriented Analysis and Design -
getting
the gaps in my
knowledge filled in through the Head First OOAD book
I don't know it although I've seen a couple of others in the series.
My recommendations for general OOAD books are:
Timothy Budd - OOP
Hi Guys,
I'd like remove contents between tags that matches pattern "WORD1"
as follows:
Change
"stuff word1-emai...@domain.com more stuff
word1-emai...@domain.com still more stuff
word2-emai...@domain.com stuff after WORD2
word1-emai...@domain.com"
To
"stuff more stuff still more s
On Mon, Aug 30, 2010 at 10:52 PM, Sam M wrote:
> Hi Guys,
>
> I'd like remove contents between tags that matches pattern "WORD1"
> as follows:
>
> Change
> "stuff word1-emai...@domain.com more stuff
> word1-emai...@domain.com still more stuff
> word2-emai...@domain.com stuff after WORD2
> word1-e
To make a qualifier non-greedy,
> simply add an asterix at its end:
>
> r'WORD1-.*?'
>
>
Hugo explains this nicely, but I just wanted to make one minor correction
-- the non-greedy qualifier is the question mark AFTER an the asterisk
(which is what Hugo's code shows but I believe he accidentally
On 8/30/2010 4:52 PM, Sam M wrote:
Hi Guys,
I'd like remove contents between tags that matches pattern
"WORD1" as follows:
Change
"stuff word1-emai...@domain.com more stuff
word1-emai...@domain.com still more stuff
word2-emai...@domain.com stuff after WORD2
word1-emai...@domain.com"
To
On Tue, Aug 31, 2010 at 12:02 AM, Serdar Tumgoren wrote:
> To make a qualifier non-greedy,
>>
>> simply add an asterix at its end:
>>
>> r'WORD1-.*?'
>>
>
> Hugo explains this nicely, but I just wanted to make one minor correction
> -- the non-greedy qualifier is the question mark AFTER an the a
On Mon, Aug 30, 2010 at 2:56 PM, Hugo Arts wrote:
> To solve, we have the non-greedy patterns. They eat not as much
> possible, but as little as possible. To make a qualifier non-greedy,
> simply add an asterix at its end:
>
> r'WORD1-.*?'
>
> I would also like to offer one small correction: an a
Hi all,
Can someone please give a very simple example of using __new__ wherein
__init__ cannot be used?
With warm regards,
-Payal
--
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman
Payal wrote:
> Can someone please give a very simple example of using __new__ wherein
> __init__ cannot be used?
Subclasses of immutable types, e. g. tuple:
>>> class A(tuple):
... def __init__(self, a, b):
... pass
...
>>> a = A(1,2)
Traceback (most recent call last):
File "",
25 matches
Mail list logo