> To: tutor@python.org
> From: alan.ga...@btinternet.com
> Date: Fri, 1 Oct 2010 00:59:06 +0100
> Subject: Re: [Tutor] inheritance problem
>
> "Roelof Wobben" wrote
>
>> So i have this programm now :
>
>> class Deck:
>> def __init__(self):
>> self.cards =
with coffee:
yes = """
v1 v2 5
2 someword7 3
""".splitlines()[1:]
no = """
word 2 3
1 2
""".splitlines()[1:]
import re
pattern = "(\w*\d\s+?)(\w*\d\s+?)(\d)$"
rx = re.compile(pattern)
for line in yes:
m = rx.match(line)
assert m
print([part.rstrip() for part in m.groups()])
f
On Fri, 1 Oct 2010 12:45:38 pm Alex Hall wrote:
> Hi, once again...
> I have a regexp that I am trying to use to make sure a line matches
> the format: [c*]n [c*]n n
> where c* is (optionally) 0 or more non-numeric characters and n is
> any numeric character. The spacing should not matter. These sh
Alex Hall wrote:
Hi, once again...
I have a regexp that I am trying to use to make sure a line matches the format:
[c*]n [c*]n n
where c* is (optionally) 0 or more non-numeric characters and n is any
numeric character. The spacing should not matter. These should pass:
v1 v2 5
2 someword7 3
whi
Hi, once again...
I have a regexp that I am trying to use to make sure a line matches the format:
[c*]n [c*]n n
where c* is (optionally) 0 or more non-numeric characters and n is any
numeric character. The spacing should not matter. These should pass:
v1 v2 5
2 someword7 3
while these should not
On 2:59 PM, Chris King wrote:
On 9/30/2010 8:43 PM, Steven D'Aprano wrote:
What problem are you trying to solve? There is likely another way to
solve it. (Not necessarily an easy way, but we'll see.)
So I'll have to create my own object which modifies each method to
fire off the set me
On Fri, 1 Oct 2010 11:24:16 am Chris King wrote:
> > What problem are you trying to solve? There is likely another way
> > to solve it. (Not necessarily an easy way, but we'll see.)
>
> So I'll have to create my own object which modifies each method to
> fire off the set method if the old form and
On 9/30/10, Steven D'Aprano wrote:
> On Fri, 1 Oct 2010 08:32:40 am Alex Hall wrote:
>
>> I fully expected to see txt be an array of strings since I figured
>> self.original would have been split on one or more new lines. It
>> turns out, though, that I get this instead:
>> ['l\nvx vy z\nvx vy z']
On 9/30/2010 8:43 PM, Steven D'Aprano wrote:
On Fri, 1 Oct 2010 10:24:50 am Chris King wrote:
Dear Tutors,
I noticed that when you make a property to represent a mutable
value
*class Obj(object):
def get(self):
print 'Get'
return self.prop
On Fri, 1 Oct 2010 10:24:50 am Chris King wrote:
> Dear Tutors,
> I noticed that when you make a property to represent a mutable
> value
>
> *class Obj(object):
> def get(self):
> print 'Get'
> return self.prop
> def set(self, new):
>
Dear Tutors,
I noticed that when you make a property to represent a mutable value
*class Obj(object):
def get(self):
print 'Get'
return self.prop
def set(self, new):
print 'Set'
self.prop = new
prop = propert
On Thu, 30 Sep 2010 11:52:49 pm Emmanuel Ruellan wrote:
> On Thu, Sep 30, 2010 at 1:57 PM, wrote:
> > 1 is prime
>
> One is /not/ prime.
There's no need to apologize for pedantry. Saying that one is prime is
like saying that 2 is an odd number, or that glass is a type of meat.
--
Steven D'A
On Thu, 30 Sep 2010 11:24:06 pm T MURPHY wrote:
> I was having trouble, where on the python site can i find steps on
> classes
Google is your friend: googling for "python tutorial" brings up lots of
tutorials that will help. Here's the first one:
http://docs.python.org/tutorial/
> and making a
On Fri, 1 Oct 2010 04:05:08 am Susana Iraiis Delgado Rodriguez wrote:
> Hello !
>
> I apoligize for the format of my last message, I didn't realize that
> putting my text in bold format will show those asterisks.
> By the way you're Alan, for the pythom module I first had to read my
> arguments and
On Fri, 1 Oct 2010 08:32:40 am Alex Hall wrote:
> I fully expected to see txt be an array of strings since I figured
> self.original would have been split on one or more new lines. It
> turns out, though, that I get this instead:
> ['l\nvx vy z\nvx vy z']
There's no need to call str() on somethin
"Roelof Wobben" wrote
So i have this programm now :
class Deck:
def __init__(self):
self.cards = []
for suit in range(4):
for rank in range(1, 14):
self.cards.append(Card(suit, rank))
def deal(self, hands, num_cards=999):
num_hands = len(
On Fri, 1 Oct 2010 08:49:31 am Alex Hall wrote:
> Ah-ha!!
> re.split(r"\n+", self.original)
> That did it, and my program once again runs as expected. Thanks!
There is no need to crack that tiny peanut with the 40 lb sledgehammer
of a regular expression.
list_of_lines = string.split('\n')
Much
On Fri, 1 Oct 2010 08:38:31 am Dipo Elegbede wrote:
> 4.4 An integer greater than 1 is said to be prime if it is divisible
> by only 1 and itself. For example,
> 2, 3, 5 and 7 are prime numbers, but 4, 6, 8 and 9 are not.
> a) Write a function that determines whether a number is prime.
The first
On Fri, 1 Oct 2010 09:26:16 am Russell Smith wrote:
> I’m trying to put together a script using urllib2, smtplib and
> stripogram/html2text which will use a healthcheck url, read the
> response after loading it and then email me the results without any
> unwanted html tags. I was able to do that b
Hey guys,
I’m trying to put together a script using urllib2, smtplib and
stripogram/html2text which will use a healthcheck url, read the response
after loading it and then email me the results without any unwanted html
tags. I was able to do that but, when I get a timeout on one of the servers
t
On 30-Sep-10 15:49, Alex Hall wrote:
re.split(r"\n+", self.original)
That did it, and my program once again runs as expected. Thanks!
If you don't need blank lines stripped out (r'\n+' considers multiple
consecutive \n characters to be a single record separator), you can
avoid the regex and j
On 9/30/10, Walter Prins wrote:
> On 30 September 2010 23:32, Alex Hall wrote:
>
>> txt=str(self.original).split(r"\n+") #create an array where elements
>>
>
> OK, consider this Python shell session:
>
s = "line1\nline2"
s.split()
> ['line1', 'line2']
s.split(r"\n+")
> ['line1\nlin
> I have data about zip codes, street and city names (and perhaps later also of
> street numbers). I made a dictionary of the form {zipcode: (street, city)}
One dictionary with all of the data?
That does not seem like it will work. What happens when
2 addresses have the same zip code?
> Are th
Kindly help me with the following tasks.
You may want to start with explanations for me and then pseudo-codes,
I should be able to take it from there.
They are exercises from deitel how to program for Python.
I have done a lot of thinking and its almost discouraging me. Please help.
Thanks.
4.4 A
Hi all,
I have a parser class which is supposed to take a text file and parse
it. I will then do more with the resulting data. The file is in a
particular format, specified by my professor, though this is not
homework (it will be used to do homework later). The file is in the
format:
l
vx vy z
vx v
"T MURPHY" wrote
I was having trouble, where on the python site can i find steps
on classes and making a doubly linked list, is there a help
option for linked lists.
Thee are several sites that discuss list structures in Python,
but mostly these are of academic interest only.
Do you hav
I looked at the chapter before, and found this in particular:
class Deck:
def __init__(self):
self.cards = []
for suit in range(4):
for rank in range(1, 14):
self.cards.append(Card(suit, rank))
I think the error in the book has to do with self.pop()
>> And so forth. Laborious? Time consuming? Lots of detail? Yes. Most of
>> us have gone thru the same thing in our education.
---> You forgot: 'Lots of frowning', 'lots of sixpacks' and 'lots of FUN' ;-)))
Cheers!!
Albert-Jan
Hi,
I have data about zip codes, street and city names (and perhaps later also of
street numbers). I made a dictionary of the form {zipcode: (street, city)}
I dumped the dictionary into a marshal file. I have two questions:
The first question is a very basic one: if I deserialize the dictionary
On 9/30/2010 6:24 AM T MURPHY said...
I was having trouble, where on the python site can i find steps on classes and
making a doubly linked list, is there a help option for linked lists.
Python itself doesn't provide a doubly linked list so I wouldn't expect
to find support ifo on the python
Sorry I hit the send button instead of the save button
On Thu, Sep 30, 2010 at 2:58 PM, Bob Gailer wrote:
> On Thu, Sep 30, 2010 at 2:38 PM, Roelof Wobben wrote:
>>
>> hello,
>>
>> Im following this page :
>> http://openbookproject.net/thinkcs/python/english2e/ch17.html
>>
>> [snip]
>>
>> What
Hi Roelof,
> Im following this page :
> http://openbookproject.net/thinkcs/python/english2e/ch17.html
I just checked this, and it appears you've copied this example fine.
> class Deck:
>def __init__(self):
>self.cards = []
>for suit in range(4):
>for rank in
hello,
Im following this page :
http://openbookproject.net/thinkcs/python/english2e/ch17.html
So i have this programm now :
class Card:
suits = ["Clubs", "Diamonds", "Hearts", "Spades"]
ranks = ["narf", "Ace", "2", "3", "4", "5", "6", "7",
"8", "9", "10", "Jack", "Queen",
Hello !
I apoligize for the format of my last message, I didn't realize that putting
my text in bold format will show those asterisks.
By the way you're Alan, for the pythom module I first had to read my
arguments and passed them to the os.system(), it worked. Now when I execute
this command, in m
On Thu, Sep 30, 2010 at 7:27 AM, R. Alan Monroe wrote:
>
> >> I'm needing to transfer the following shell construct to Python,
> >> plus save
> >> the output of execution:
>
> >> FTP_SITE='ftp.somesite.com'
> >> ftp -a $FTP_SITE < >> binary
> >> prompt off
> >> cd /some_dir
> >> dir
> >> bye
> >>
I was having trouble, where on the python site can i find steps on classes and
making a doubly linked list, is there a help option for linked lists.
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python
>> I'm needing to transfer the following shell construct to Python,
>> plus save
>> the output of execution:
>> FTP_SITE='ftp.somesite.com'
>> ftp -a $FTP_SITE <> binary
>> prompt off
>> cd /some_dir
>> dir
>> bye
>> EOF
> Are you sure? It looks like you would be better writing a python
> prog
On Thu, Sep 30, 2010 at 1:57 PM, wrote:
>
> 1 is prime
>
One is /not/ prime.
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
Ok. I will do that as soon As I get back to my workstation.
Sent from my BlackBerry wireless device from MTN
-Original Message-
From: Shashwat Anand
Date: Thu, 30 Sep 2010 19:11:33
To:
Cc:
Subject: Re: [Tutor] Printing prime numbers
On Thu, Sep 30, 2010 at 5:27 PM, wrote:
> Hi all,
On Thu, Sep 30, 2010 at 5:27 PM, wrote:
> Hi all,
> I am trying to write a function that prints out which number is prime in
> range (1,500)
> The function would check thru and the print out something like
> 1 is prime
> 2 is prime
> 3 is prime
> 4 is not
> 5 is prime
>
> Please help me.
> Thank
Hi all,
I am trying to write a function that prints out which number is prime in range
(1,500)
The function would check thru and the print out something like
1 is prime
2 is prime
3 is prime
4 is not
5 is prime
Please help me.
Thank you.
Sent from my BlackBerry wireless device from MTN
__
Copy the code into a text file with a name ending in .py - lets call it
myfile.py for now
(if you have not already done so)
>From a bash prompt type
$ python myfile.py
Then cut n paste any error messages into an email to the list
Alan Gauld
Author of the Learn To Program website
http://www.a
On Thu, 30 Sep 2010 02:38:31 pm Dave Angel wrote:
[snip nearly 300 lines of quoted text and 7 lines of new content]
Dave, and Carter, are the delete and backspace keys on your keyboards
broken?
There's no need to quote the ENTIRE thread every time you reply, and
then quote it in full AGAIN a h
Hi,
I've once written a script to sync my website with a local directory. I guess
that you will find anything you need in the FTPHelper class. Have a look at:
http://home.arcor.de/ralf_schoenian/websync/index.html At the bottom of the page
you can view and download the script.
Any questions are w
On Thu, Sep 23, 2010 at 5:26 PM, Pete wrote:
> Hiya,
>
> still working on my plugin architecture. I figured out how to import
> modules of which I don't know the name yet at compile time,
> by using __import__() instead of import.
>
> So that works fine when I want to have the equivalent of
>
> i
"James Hartley" wrote
I'm needing to transfer the following shell construct to Python,
plus save
the output of execution:
Are you sure? It looks like you would be better writing a python
program
using the ftp module. Shells are intended to execute external programs
but Python provides the
On Wed, Sep 29, 2010 at 11:13 PM, Alan Gauld wrote:
>
> OK, Thats a non standard error trace so presumably you are running it inside
> an IDE of some kind? It may be the IDE is masking the true error.
> What happens if you just execute the code from a shell prompt in a console
> window? Can you s
47 matches
Mail list logo