Re: [Tutor] subprocess module: when to _NOT_ use shell=True

2013-03-11 Thread akleider
Thank you "Eryksun" and "EikeWek" for your responses. It is this sort of thing that begins to pull one out of the newbie into the intermediate category. I'm grateful. alex > I've not found anywhere a clear explanation of when not to set shell=True. > If the command line must be interpreted by the

[Tutor] subprocess module: when to _NOT_ use shell=True

2013-03-10 Thread akleider
I've not found anywhere a clear explanation of when not to set shell=True. If the command line must be interpreted by the shell then clearly this must be set. So the question that comes up is why not set it always? In an effort to investigate, I came up with the following script that indicates tha

Re: [Tutor] if/else option for making a choice

2013-02-18 Thread akleider
> On Mon, Feb 18, 2013 at 10:22 AM, Niclas Rautenhaus > wrote: > >> Hello folks, >> >> ** ** >> >> I would be very pleased if someone is able to help me. >> >> I wrote a small programm, to calculate the grand total for a car. >> >> A basic price can be entered. Given that basic price, a

Re: [Tutor] Through a glass, darkly: the datetime module

2012-10-06 Thread akleider
> On 10/06/2012 07:19 PM, Richard D. Moores wrote: >> On Fri, Oct 5, 2012 at 7:15 AM, Walter Prins wrote: >> >>> Does this hint help? >>> >> import datetime >> mydate = datetime.date(2012,10,5) >> mydate = mydate + datetime.timedelta(days=30) >> print mydate >>> 2012-11-04 >> Yes!

[Tutor] "ImportError: _strptime not supported"

2012-10-02 Thread akleider
The following code was recently suggested as an example of how the datetime module could be used to solve a problem. Not having access to Python at work, I found http://pythontutor.com/visualize.html thinking it would allow me to "play with Python" when I have a free moment. from datetime import

Re: [Tutor] All possible 16 character alphanumeric strings?

2012-09-15 Thread akleider
> Akleider, you didn't include attribution for the person you are quoting, > which is a bit rude and also means I can't be sure who it was. From > context, I *think* it is the original poster Scott: > > On 16/09/12 13:06, aklei...@sonic.net wrote: >>> I'm us

Re: [Tutor] All possible 16 character alphanumeric strings?

2012-09-15 Thread akleider
> On 09/15/2012 10:03 PM, Scurvy Scott wrote: >>> >>> That list would fill all the PC's on the planet a few billions times. >>> The number of items in the list has 25 digits in it. print 32**16 >>> >> > > I can't see any reason why it changes anything. The world doesn't have > enough disk space t

Re: [Tutor] All possible 16 character alphanumeric strings?

2012-09-15 Thread akleider
>> Hello again python tutor list. >> I have what I see as a somewhat complicated problem which I have no idea >> where to begin. I'm hoping you fine folks can help me. >> >> I'm trying to generate a list of every possible 16 character string >> containing only 2-7 and a-z lowercase. I've seen some

Re: [Tutor] All possible 16 character alphanumeric strings?

2012-09-15 Thread akleider
> possible = "234567abcdefghijklmnopqrstuvwxyz" > word_length = 16 > print 'Running "every.py"' > word_list = [] > def add_word(word): > if len(word)==word_length: > word_list.append(word) > print word > else: > for c in possible: > new_word = word + c >

Re: [Tutor] All possible 16 character alphanumeric strings?

2012-09-15 Thread akleider
#!/usr/bin/env python # file : every.py print 'Running "every.py"' possible = "234567abcdefghijklmnopqrstuvwxyz" word_length = 16 word_list = [] def add_word(word): if len(word)==word_length: word_list.append(word) print word # There may come a time you won't want this li

Re: [Tutor] All possible 16 character alphanumeric strings?

2012-09-15 Thread akleider
> Hello again python tutor list. > I have what I see as a somewhat complicated problem which I have no idea > where to begin. I'm hoping you fine folks can help me. > > I'm trying to generate a list of every possible 16 character string > containing only 2-7 and a-z lowercase. I've seen some exampl

Re: [Tutor] Cube root

2012-09-15 Thread akleider
> On Sat, Sep 15, 2012 at 5:36 PM, Dave Angel wrote: >> On 09/15/2012 05:28 PM, Amanda Colley wrote: >>> Ok, I have to get input from a user ('enter a number') and then get >>> the >>> cube root of that number. I am having trouble with the code to get the >>> cube root. If anyone can help me sol

Re: [Tutor] Cube root

2012-09-15 Thread akleider
> On Sat, Sep 15, 2012 at 5:36 PM, Dave Angel wrote: >> On 09/15/2012 05:28 PM, Amanda Colley wrote: >>> Ok, I have to get input from a user ('enter a number') and then get >>> the >>> cube root of that number. I am having trouble with the code to get the >>> cube root. If anyone can help me sol

Re: [Tutor] index of elements in numpy array

2012-09-13 Thread akleider
> On 13 September 2012 21:16, Bala subramanian > wrote: > >> Friends, >> I have a 2D matrix (a numpy array) and i am looping over each row in >> the matrix. I would like to know how i can find the index of each >> element in a while looping a row. Is there any function in numpy. >> > > Your questio

Re: [Tutor] Print List

2012-09-12 Thread akleider
> On 12/09/12 16:36, Ashley Fowler wrote: > >> def printList(lists): >> print("First Name\tLast Name\tCredits\tGPA") >> for i in lists: >> print (i) >> >> >> Any Suggestions or Corrections? > > The input parameter is called 'lists' which implies that the input is > more than one

Re: [Tutor] running more than one python program at the same time

2012-08-28 Thread akleider
> On 08/28/2012 03:30 PM, Benjamin Fishbein wrote: >> Hello, >> I wrote a program that I want to have running 24/7. But the problem is >> that I also want to write and run other programs. I'm using Idle and it >> won't let me run more than one script at a time. Do you know if there's >> a way to do

Re: [Tutor] reason(s) for trailing comma in dict declarations

2012-08-25 Thread akleider
Thanks for the clarification. Now it is clear. ak > On Sat, Aug 25, 2012 at 11:53 AM, wrote: >> >> Put each entry on its own line, indented by two spaces, and leave a >> trailing comma on the last entry. The latter is especially important >> in sequences of strings to prevent them from being >>

[Tutor] reason(s) for trailing comma in dict declarations

2012-08-25 Thread akleider
Part of a previous post: """ Here's the style I'd use: combos = { 0: 'id', 2: 'country', 3: 'type', 5: 'lat', 6: 'lon', 12: 'name', } Put each entry on its own line, indented by two spaces, and leave a trailing comma on the last entry. The latter is especially important in sequences o

Re: [Tutor] Python working with Bash....arrrggggh!

2012-08-23 Thread akleider
> 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

Re: [Tutor] how to split/partition a string on keywords?

2012-08-23 Thread akleider
> 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

Re: [Tutor] how to split/partition a string on keywords?

2012-08-23 Thread akleider
> 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

Re: [Tutor] how to split/partition a string on keywords?

2012-08-23 Thread akleider
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

Re: [Tutor] (no subject)- finding/deleting files

2012-08-19 Thread akleider
> On 08/19/2012 03:29 PM, Selby Rowley Cannon wrote: >> OK, I have some code, and it uses glob.glob('*.py') to find all the >> python files in the current directory. >> Just thought i'd ask, would: >> >> glob.glob('C:\*.py') (Windows), or >> >> glob.glob('/*.py') (*nix) >> >> find all the python fi