Pete O'Connell wrote:
> Hi, I have tried to simplify things and am running into a bit of trouble.
> What i am really trying to do is: Keep all the lines starting with "v "
> and then delete those lines whose modulus 5 don't equal zero
>
> I have written it like this which seems to take a really l
On 08/23/2012 10:37 PM, eryksun wrote:
> On Thu, Aug 23, 2012 at 11:55 PM, Ray Jones wrote:
>
>> For example, if I wish to test if a file exists, I might do
>>
>> test = Popen('[ -f file-i-want-to-test-for ]')
>>
>> But the moment I invoke Bash for a test, I must deal with the fact that
>> Bash re
On 08/23/2012 09:53 PM, aklei...@sonic.net wrote:
>> As I code Python, I find myself falling back on Bash to handle basic OS
>> tasks. How do you gurus deal with Python --> Bash conflicts?
>>
>> For example, if I wish to test if a file exists, I might do
>>
>> test = Popen('[ -f file-i-want-to-test
On Thu, Aug 23, 2012 at 11:55 PM, Ray Jones wrote:
> For example, if I wish to test if a file exists, I might do
>
> test = Popen('[ -f file-i-want-to-test-for ]')
>
> But the moment I invoke Bash for a test, I must deal with the fact that
> Bash returns a zero for true and a non-zero for false.
> As I code Python, I find myself falling back on Bash to handle basic OS
> tasks. How do you gurus deal with Python --> Bash conflicts?
>
> For example, if I wish to test if a file exists, I might do
>
> test = Popen('[ -f file-i-want-to-test-for ]')
>
> But the moment I invoke Bash for a test, I
(you replied off-list, so I'm cc'ing the list here, to keep it public)
On 08/23/2012 10:42 PM, Pete O'Connell wrote:
> On Fri, Aug 24, 2012 at 1:39 PM, Dave Angel wrote:
>
>> On 08/23/2012 09:11 PM, Pete O'Connell wrote:
>>> Hi, I have tried to simplify things and am running into a bit of troubl
On 08/23/2012 10:34 PM, eryksun wrote:
> On Thu, Aug 23, 2012 at 9:39 PM, Dave Angel wrote:
>>
>>> theGoodLines = [line.strip("\n") for line in lines if "v " ==
>>> line[0:2]]
>>
>> Better to use startswith(), since short lines will cause the if
>> expression above to blow up.
>
> A slice won
As I code Python, I find myself falling back on Bash to handle basic OS
tasks. How do you gurus deal with Python --> Bash conflicts?
For example, if I wish to test if a file exists, I might do
test = Popen('[ -f file-i-want-to-test-for ]')
But the moment I invoke Bash for a test, I must deal wit
On Thu, Aug 23, 2012 at 9:39 PM, Dave Angel wrote:
>
>> theGoodLines = [line.strip("\n") for line in lines if "v " ==
>> line[0:2]]
>
> Better to use startswith(), since short lines will cause the if
> expression above to blow up.
A slice won't blow up. At worst you get an empty string. But t
> On Thu, Aug 23, 2012 at 9:08 PM, wrote:
>>
> s.dir()
>>
>
> Surely you mean dir(s). Maybe you're thinking of the __dir__ special
> method you can add to a class to override the default behavior.
>
Yes, dir(s) is what I gave the interpreter.
I should have used cut and paste (but tend not t
On Thu, Aug 23, 2012 at 9:08 PM, wrote:
>
s.dir()
>
Surely you mean dir(s). Maybe you're thinking of the __dir__ special
method you can add to a class to override the default behavior.
You can also dir(str), or call help(str) to page through all of the doc strings.
___
On 08/23/2012 09:11 PM, Pete O'Connell wrote:
> Hi, I have tried to simplify things and am running into a bit of trouble.
> What i am really trying to do is: Keep all the lines starting with "v " and
> then delete those lines whose modulus 5 don't equal zero
>
> I have written it like this which se
Hi, I have tried to simplify things and am running into a bit of trouble.
What i am really trying to do is: Keep all the lines starting with "v " and
then delete those lines whose modulus 5 don't equal zero
I have written it like this which seems to take a really long time (a
couple of minutes wh
> On 23/08/12 23:08, aklei...@sonic.net wrote:
>
>> (I often find myself wanting to hack in "off line environments" so
>> something as old fashion as a book would be nice:-)
>
> Depends how off line you are.
> If you still have the python interpreter then just using dir() and
> help() should be all
On 23/08/12 23:08, aklei...@sonic.net wrote:
(I often find myself wanting to hack in "off line environments" so
something as old fashion as a book would be nice:-)
Depends how off line you are.
If you still have the python interpreter then just using dir() and
help() should be all you need.
On 08/23/2012 02:33 PM, Norman Khine wrote:
> Hello,
> I have this code (http://pastie.org/4575790) which pulls data from a list
> and then modifies some of the values such as the 'yield' entry, which has
> entries like:
>
> 21
> 15
> ≤ 1000
> ≤ 20
> 2.2 - 30
>
> so that they are cleaned up.
>
>
On 23/08/12 22:14, William R. Wing (Bill Wing) wrote:
While all that is true, I'm pretty sure she is going to need enough knowledge
> of the simplest -NIX commands to
edit .py files,
> rename them occasionally,
organize them into appropriate directories
> and occasionally change a permissio
On 08/23/2012 11:33 AM, Victoria Homsy wrote:
>
> Dear All - sorry to bother you. I just tried to run this program:
>
>
> def isPalindrome(s):
> if len(s) <= 1: return True
> else: return s[0] == s[-1] and isPalindrome (s[1:-1])
> isPalindrome('aba')
>
>
> However when I run it in terminal it does
h,s,t = st.partition(' and')
>
>The keyword needs a space at both ends:
>
> >>> st = 'an androphobic andromedan android'
> >>> results
> ['an', ' and', 'rophobic', ' and', 'romedan', ' and', 'roid', '']
>
>Good catch, although to be honest I intended it to have a space...
>But I did
On 23/08/2012 23:08, aklei...@sonic.net wrote:
This question seemed a good excercise so I banged out a little script
(which worked) but latter I saw posts showing code that by using string
method 'partition' provided a more elegant solution.
I was previously unaware of this method. My "bible" ha
On Thu, Aug 23, 2012 at 5:25 PM, Alan Gauld wrote:
>
> To use partition just call it repeatedly until the last string is empty. As
> ever the >>> prompt is your friend:
>
st = 'here we go and there you are and we all go roundabout'
h,s,t = st.partition(' and')
results = [h,s]
w
On Aug 23, 2012, at 12:59 PM, Steven D'Aprano wrote:
> On 23/08/12 23:18, Cecilia Chavana-Bryant wrote:
> [...]
>> I found this command:
>> mkdir -p i/like/icecream. I am guessing that the -p stands for directory
>> path?
>
> Ha, that's the trouble with command line interfaces -- they tend to en
This question seemed a good excercise so I banged out a little script
(which worked) but latter I saw posts showing code that by using string
method 'partition' provided a more elegant solution.
I was previously unaware of this method. My "bible" has been David M.
Beazley's Python Essential Refere
On 23/08/12 20:05, Jared Nielsen wrote:
But split() doesn't retain the separator and partition() retains the
white space and returns a 3-tuple which I'll have to figure out how to
rejoin nor does it partition on subsequent instances of the separator.
David has shown one option for using split(
On Thu, Aug 23, 2012 at 4:03 PM, David Rock wrote:
> text = raw_input("Enter text: ")
> sep = 'and'
> parts = text.split(sep)
> for i in parts[:-1]:
> print i
> print sep
> print [-1]
>>> "band".split("and")
['b', '']
It needs to be sep = " and ". That's assuming we're ignoring t
* eryksun [2012-08-23 17:02]:
> On Thu, Aug 23, 2012 at 3:05 PM, Jared Nielsen
> wrote:
> > Hi all,
> > I'm new to programming and Python.
> > I want to write a script that takes a string input and breaks the string at
> > keywords then outputs the pieces on separate lines.
>
> This is just for
On Thu, Aug 23, 2012 at 3:05 PM, Jared Nielsen wrote:
> Hi all,
> I'm new to programming and Python.
> I want to write a script that takes a string input and breaks the string at
> keywords then outputs the pieces on separate lines.
This is just for printing? You can use replace():
>>> text = "H
* David Rock [2012-08-23 15:03]:
> * Jared Nielsen [2012-08-23 12:05]:
> > Hi all,
> > I'm new to programming and Python.
> > I want to write a script that takes a string input and breaks the string at
> > keywords then outputs the pieces on separate lines.
>
> > But split() doesn't retain the s
* Jared Nielsen [2012-08-23 12:05]:
> Hi all,
> I'm new to programming and Python.
> I want to write a script that takes a string input and breaks the string at
> keywords then outputs the pieces on separate lines.
> But split() doesn't retain the separator and partition() retains the white
> spa
On Thu, Aug 23, 2012 at 1:02 PM, Ashley Fowler
wrote:
>
> Instructions: Your "main" function should do the following:
> (1) create an empty list;
> (2) ask the user if he/she wants to perform a list operation.
> if "yes":
> (a) prompt the user for the operation:
> "tes
On Thu, Aug 23, 2012 at 8:36 PM, Ashley Fowler
wrote:
>
>
> From: tutor-bounces+afowler2=broncos.uncfsu@python.org
> [tutor-bounces+afowler2=broncos.uncfsu@python.org] on behalf of Alan
> Gauld [alan.ga...@btinternet.com]
> Sent: Thursday, August
(resent due to sending off-list by mistake)
Let's begin with telling you what you did wrong here. A fixed and
completed code is below.
(> = okay, # = modified/deleted; python code in `backticks`)
On Thu, Aug 23, 2012 at 7:02 PM, Ashley Fowler
wrote:
> def main():
# l = list()
l = [] is more
From: tutor-bounces+afowler2=broncos.uncfsu@python.org
[tutor-bounces+afowler2=broncos.uncfsu@python.org] on behalf of Alan Gauld
[alan.ga...@btinternet.com]
Sent: Thursday, August 23, 2012 5:59 PM
To: tutor@python.org
Subject: Re: [Tutor] Questio
Hi all,
I'm new to programming and Python.
I want to write a script that takes a string input and breaks the string at
keywords then outputs the pieces on separate lines.
I'm not sure how to break the string, though.
I looked through the docs and found split() and partition(), which come
close.
But
Hello,
I have this code (http://pastie.org/4575790) which pulls data from a list
and then modifies some of the values such as the 'yield' entry, which has
entries like:
21
15
≤ 1000
≤ 20
2.2 - 30
so that they are cleaned up.
# -*- coding: UTF-8 -*-
# Norman Khine
import operator, json
from B
On 23/08/12 18:02, Ashley Fowler wrote:
def main():
l = list()
x = eval(input('Enter a number: '))
Don;t use eval() its bad practicecand fort advanced use only.
Instead explicitly convert to int() or float()
while x >= 0:
l.append(x)
x = eval(input('Enter a n
I am trying to complete an assignment and I am stuck at the if-else statements
area. Could someone please help me?
the instructions and what I have so far are below...
Instructions: Your "main" function should do the following:
(1) create an empty list;
(2) ask the user if he/she wants to perfo
On 23/08/12 23:18, Cecilia Chavana-Bryant wrote:
[...]
I found this command:
mkdir -p i/like/icecream. I am guessing that the -p stands for directory
path?
Ha, that's the trouble with command line interfaces -- they tend to end up
being cryptic and painfully terse. In this case, -p actually sta
On 23/08/12 16:42, Marco Mistroni wrote:
i have tried to use python-ntml but it does not seems to work as i keep
on getting thiserror
lib\python2.6\ntlm\ntlm.py", line 219, in parse_NTLM_CHALLENGE_MESSAGEerror:
> unpack requires a string argument of length 4
It looks as if its working just
On 24/08/12 00:42, Flynn, Stephen (L & P - IT) wrote:
Python 3.2, as in the subject, although I also have 2.7 on this machine
too.
I have some data which contains text separated with field delimiters
(|~) and a record terminator (||)
[trim well over 50 lines of explanation]
Is there a meth
On 23/08/2012 16:33, Victoria Homsy wrote:
Dear All - sorry to bother you. I just tried to run this program:
def isPalindrome(s):
if len(s) <= 1: return True
else: return s[0] == s[-1] and isPalindrome (s[1:-1])
isPalindrome('aba')
However when I run it in terminal it doesn't give me any
On 24/08/12 01:33, Victoria Homsy wrote:
Dear All - sorry to bother you. I just tried to run this program:
def isPalindrome(s):
if len(s)<= 1: return True
else: return s[0] == s[-1] and isPalindrome (s[1:-1])
isPalindrome('aba')
However when I run it in terminal it doesn't give me any answer
Flynn, Stephen (L & P - IT) wrote:
> Python 3.2, as in the subject, although I also have 2.7 on this machine
> too.
>
>
>
> I have some data which contains text separated with field delimiters
> (|~) and a record terminator (||)
>
> 12345600990|~5229|~990|~0|~4|~1|~2006-09-08|~13:2
On 24/08/12 01:42, Marco Mistroni wrote:
Hi all
i was wondering if anyone coud provide examples on how to open an URL
that requires NTLM authentication
i have tried to use python-ntml but it does not seems to work as i keep on
getting this errorlib\python2.6\ntlm\ntlm.py", line 219, in
parse
Hi all
i was wondering if anyone coud provide examples on how to open an URL
that requires NTLM authentication
i have tried to use python-ntml but it does not seems to work as i keep on
getting this errorlib\python2.6\ntlm\ntlm.py", line 219, in
parse_NTLM_CHALLENGE_MESSAGEerror: unpack require
Hi all
i was wondering if anyone coud provide examples on how to open an URL
that requires NTLM authentication
i have tried to use python-ntml but it does not seems to work as i keep on
getting this error
lib\python2.6\ntlm\ntlm.py", line 219, in parse_NTLM_CHALLENGE_MESSAGE
error: unpack req
Dear All - sorry to bother you. I just tried to run this program:
def isPalindrome(s):
if len(s) <= 1: return True
else: return s[0] == s[-1] and isPalindrome (s[1:-1])
isPalindrome('aba')
However when I run it in terminal it doesn't give me any answer - True or
False. (I want the program
Python 3.2, as in the subject, although I also have 2.7 on this machine
too.
I have some data which contains text separated with field delimiters
(|~) and a record terminator (||)
12345600990|~5229|~990|~0|~4|~1|~2006-09-08|~13:29:39|~some
text.|~xxx, x|~||
12345600991|~
Hi, Cecilia:
I came across your posts when catching up with my tutor-request digest
emails. I did not see the Udacity site mentioned--if it was, my apologies
for the repetition.
Udacity.com, a free online education service, offers a number of
high-quality courses. They include interactive quizzes
On Aug 23, 2012, at 9:18 AM, Cecilia Chavana-Bryant
wrote:
> Hola,
>
> I'm going through the 'Command line crash course' by Zed Shaw, thanks to the
> people that recommended this book, its quite a good course, I can see what
> the author was going for with the title but if it wasn't for your
Excellent - thank you so much everyone. All is clear now!!
From: Mark Lawrence
To: tutor@python.org
Sent: Thursday, 23 August 2012, 15:29
Subject: Re: [Tutor] Error message...
On 23/08/2012 15:17, Victoria Homsy wrote:
> Dear all,
>
> Sorry to bother you wit
On 08/23/2012 04:43 AM, Steven D'Aprano wrote:
> On Wed, Aug 22, 2012 at 11:39:46PM -0400, Dave Angel wrote:
>> On 08/22/2012 07:32 PM, Richard D. Moores wrote:
>>>
>>>
>>> My code uses gmpy2.is_prime() (lines 79 and 89). is_prime() is VERY fast.
>> You do know that this gmpy2 function is only st
On 23/08/2012 15:17, Victoria Homsy wrote:
Dear all,
Sorry to bother you with a beginner's problem again...
You're welcome as that's what we're here for.
I have tried to write a program that can check if a string is a palindrome. My
code is as follows:
def isPalindrome(s):
if len(s) <= 1
On 23 August 2012 15:17, Victoria Homsy wrote:
>
> def isPalindrome(s):
> if len(s) <= 1: return True
> else: return s(0) == s(-1) and isPalindrome (s[1:-1])
>
> I don't see why this wouldn't work...
>
> Many thanks in advance.
>
> Kind regards,
>
> Victoria
>
Parentheses are used for function
Victoria Homsy wrote:
> Sorry to bother you with a beginner's problem again...
This is the place for beginners.
> I have tried to write a program that can check if a string is a
> palindrome. My code is as follows:
>
>
> def isPalindrome(s):
> if len(s) <= 1: return True
> else: retur
Dear all,
Sorry to bother you with a beginner's problem again...
I have tried to write a program that can check if a string is a palindrome. My
code is as follows:
def isPalindrome(s):
if len(s) <= 1: return True
else: return s(0) == s(-1) and isPalindrome (s[1:-1])
isPalindrome('aba')
How
Cecilia Chavana-Bryant wrote:
> Hola,
>
> I'm going through the 'Command line crash course' by Zed Shaw, thanks to
> the people that recommended this book, its quite a good course, I can see
> what the author was going for with the title but if it wasn't for your
> recommendations, it would have
* Cecilia Chavana-Bryant [2012-08-23 14:18]:
> mkdir -p i/like/icecream. I am guessing that the -p stands for directory
> path? I have seen other such letters sometimes with or without the ' - '
> before them (I think) in commands so my question is, what are these letters
> for? what are they call
Hi Cecilia,
On 23 August 2012 14:18, Cecilia Chavana-Bryant
wrote:
> recommendations, it would have put me off. At the beginning of Chapter 8 -
> Moving around (pushd, popd) on Source: 13 exercise 8 I found this command:
> mkdir -p i/like/icecream. I am guessing that the -p stands for directory
>
Hola,
I'm going through the 'Command line crash course' by Zed Shaw, thanks to
the people that recommended this book, its quite a good course, I can see
what the author was going for with the title but if it wasn't for your
recommendations, it would have put me off. At the beginning of Chapter 8 -
On Wed, Aug 22, 2012 at 8:39 PM, Dave Angel wrote:
> On 08/22/2012 07:32 PM, Richard D. Moores wrote:
>>
>>
>> My code uses gmpy2.is_prime() (lines 79 and 89). is_prime() is VERY fast.
>
> You do know that this gmpy2 function is only statistically correct ?
Yes. See Steven's reply for the proba
On Thu, Aug 23, 2012 at 2:57 AM, Pete O'Connell wrote:
> On Thu, Aug 23, 2012 at 4:16 AM, Alan Gauld wrote:
>
>> theTextAsListNoVnOrVtOrEmptyLine = [x for x in theTextAsListStripped
>> if "vn" not in x
>>
On Wed, Aug 22, 2012 at 11:39:46PM -0400, Dave Angel wrote:
> On 08/22/2012 07:32 PM, Richard D. Moores wrote:
> >
> >
> > My code uses gmpy2.is_prime() (lines 79 and 89). is_prime() is VERY fast.
>
> You do know that this gmpy2 function is only statistically correct ? it
> can false positive.
On 23/08/12 07:12, rahool shelke wrote:
I want to take the list of files present in packages. On AIX we get the
files list present in packges using command "lslpp -f ".
Can you provide a short example of the output format from lslpp?
Now i want to format output of above command such that onl
64 matches
Mail list logo