Re: [Tutor] raw_input into range() function

2007-04-18 Thread Ben Sherman
On 4/18/07, Guba <[EMAIL PROTECTED]> wrote: > Hello, > > I am trying to do the exercises in Michael Dawson's "Absolute Beginner" > book. In chapter four ("for Loops, Strings, and Tuples") one of the > challenges is: "Write a program that counts for the user. Let the user > enter the starting number

Re: [Tutor] scope/namespaces

2007-04-24 Thread Ben Sherman
Am I wrong in my memory? When I was a wee lad prior to 99 for sure), I thought I would initialize my loops with: for (int x=0; x <10; x++) { } I am rapidly veering off topic. On 4/24/07, Alan Gauld <[EMAIL PROTECTED]> wrote: > Correcting my own post! > > "Alan Gauld" <[EMAIL PROTECTED]> wrote

Re: [Tutor] Fixing garbled email addresses

2007-05-01 Thread Ben Sherman
On 5/1/07, Dotan Cohen <[EMAIL PROTECTED]> wrote: I have had the misfortune of having a university Windows machine garble all the email addresses in my addressbook (a txt file so that I can use it both on my home Fedora machine and on the university Windows machines). I figure this is as good a t

Re: [Tutor] Fixing garbled email addresses

2007-05-01 Thread Ben Sherman
On 5/1/07, Dotan Cohen <[EMAIL PROTECTED]> wrote: [snip] > > List comprehensions are the best thing ever! > > Happy to help, > Ben > With Gmail one must be careful and check that the To and Subject fields contain what you'd expect. Does 'list comprehension' mean a detailed explanation of the

Re: [Tutor] Aaagh! Stack arrays!?! calc average

2007-05-01 Thread Ben Sherman
On 5/1/07, John Washakie <[EMAIL PROTECTED]> wrote: Oops, I meant it crashes at line 7.. > > 1) tinit = data[0][0] > 2)for d in data: > 3)if d[0] <= tinit+60: > 4)sum = sum+d > 5)else: > 6)avg = sum/len(sum) > 7)newData = append([newData],

Re: [Tutor] Aaagh! Stack arrays!?! calc average

2007-05-01 Thread Ben Sherman
On 5/1/07, John Washakie <[EMAIL PROTECTED]> wrote: Ug, It still doesn't make sense due to the sum/cnt where cnt is just an int, and sum is a 1-dimensional array! I'm missing something here about working with numpy arrays... You need to add all of the numbers in your list - you can't just

Re: [Tutor] Aaagh! Stack arrays!?! calc average

2007-05-01 Thread Ben Sherman
On 5/1/07, John Washakie <[EMAIL PROTECTED]> wrote: It aint pretty! And if I had just walked away, it probably would've taken half the time in the morning, but here's what I've come up with (any suggestions for improvements, or course are welcome): for d in data: w = len(d)

Re: [Tutor] Learning to Debug?

2007-05-16 Thread Ben Sherman
On 5/16/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: I'm moving forward with my learning of Python, but I've decided it's finally time to address a problem that has haunted me in every language I've every tried to learn: debugging. I'm just not very good at it. Does anyone have recommendat

Re: [Tutor] encryption for files/passwords

2007-05-18 Thread Ben Sherman
On 5/18/07, Rohan Deshpande <[EMAIL PROTECTED]> wrote: Hey all, I am writing a small python script to maintain some passwords and identity info. All the data is in an external file. what is the best way to encrypt/decrypt this file's data using a key? I am new to encryption methods let alone

Re: [Tutor] String module; Count

2007-10-17 Thread Ben Sherman
You can only count one at a time. count = conversion(n).count("0") + conversion(n).count("1") count is a string method, so it operates directly on the string - you don't have to call it like you did. import string string.count(mystr, "cheese") is the same as mystr.count("cheese") At least it

[Tutor] List slicing and joining

2007-04-11 Thread Ben Sherman
I've got a list that contain a bunch of information, including the FQDN of a host. host_data=['foo.example.com', 'other unimportant data'] I need to seperate the hostname from the domain name. This is how I'm doing it, and it work, but it seems *really* hacky. Is there a better (or more pythony)

Re: [Tutor] please help me!

2007-04-12 Thread Ben Sherman
You On 4/12/07, suryo agung <[EMAIL PROTECTED]> wrote: > pleate tell me how to make > > input number=4 > result > > 1 > 22 > 333 > > > in python > please give me your answer. input_number = 4 for i in range(1,input_number + 1): print str(i) * i If this is homework, please tell your teach

[Tutor] Pulling items from a dict in a print command

2014-06-18 Thread Ben Sherman
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