"shawn bright" <[EMAIL PROTECTED]> wrote
> i am wondering, what would be the simplest way to get a true/false
> am i connected to the internet ?
>
> right now i am using httplib to fetch a webpage every 20 minutes to
> see, but
> i am thinking that there is a better way,
You don't need to fetch
I can't recall how to do this:
I want:
a = [int(x) for x in tmp]
but, my tmp has some empty elements, so it fails...
Therefore I want to be able to say:
a = [int(x) for x in tmp IF x in tmp]
I know there's a way! Ive seen it before, but now cannot find it! 'if'
is a pretty generic thing to se
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 time as any to start
learning python and fix the file
John Washakie wrote:
> I can't recall how to do this:
>
> I want:
> a = [int(x) for x in tmp]
>
> but, my tmp has some empty elements, so it fails...
>
> Therefore I want to be able to say:
>
> a = [int(x) for x in tmp IF x in tmp]
That's almost right, except it checks the wrong thing. Try
a
Thanks
>
> Depending on what an 'empty' element is you may have to refine that.
>
I also noted, if I used:
tmp = data[6].strip().split()
rather than:
tmp = data[6].strip().split(' ')
I eliminated the 'empty' elements...
___
Tutor maillist - Tuto
good enough, i suppose i can use a try, except to test if i am online and
from that have a true / false.
That is what i was looking for. I just didn't think it necessary to pull a
webpage every 20 minutes.
thanks
shawn k
On 5/1/07, Alan Gauld <[EMAIL PROTECTED]> wrote:
"shawn bright" <[EMAIL P
I know this seems elementary, but if I write a program and save it as a .py
file, how do I then run that program on the command line or in the Python Shell
(GUI)? Or is there something I'm missing? I swear I was able to do this once,
and now I can't remember what I did...
Jessica Brink
Bus
Jessica,
Assuming you have python installed on your system (Windows?, *nix?),
then all you have to do is double click the .py file and it will run.
If you want, you can run it from the command line:
C:\> python yourfile.py
On 5/1/07, Jessica Brink <[EMAIL PROTECTED]> wrote:
>
>
> I know thi
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
On 01/05/07, Ben Sherman <[EMAIL PROTECTED]> wrote:
> Hey there - it would be better if you replied to the list - that way the
> answers below could help others..
>
> On 5/1/07, Dotan Cohen <[EMAIL PROTECTED]> wrote:
> [snip]
>
> > > # Then filter each line of the file through the regex, discarding
"John Washakie" <[EMAIL PROTECTED]> wrote
> Therefore I want to be able to say:
>
> a = [int(x) for x in tmp IF x in tmp]
>
x will always be in tmp - thats where it comes from!
You want to check if its non null.
a = [int(x) for x in tmp if x]
Alan G
___
"Jessica Brink" <[EMAIL PROTECTED]> wrote
> I know this seems elementary, but if I write a program and
> save it as a .py file, how do I then run that program on the
> command line
Just type "python script.py" at the OS prompt
Or in *nix you can just type script.py if you havbe a shebang
li
"Dotan Cohen" <[EMAIL PROTECTED]> wrote
> Does 'list comprehension' mean a detailed explanation of the code?
No its a programming construct found in Function programming
languages such as Haskell (Python is partially functional in nature).
Basically a list comprehension builds a list
lc = [
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
I am wondering how look for a key in a dictionary, given a value.
I have a dictionary similar to this:
a = { 'a1':1, 'a2':2, 'a3':3, 'a4'.:4}
If I have the value of 2, how would I look at the dictionary to turn
that into 'a2'.
___
Tutor maillist - Tut
Tony Waddell wrote:
> I am wondering how look for a key in a dictionary, given a value.
>
> I have a dictionary similar to this:
> a = { 'a1':1, 'a2':2, 'a3':3, 'a4'.:4}
>
> If I have the value of 2, how would I look at the dictionary to turn
> that into 'a2'.
You have to search the values. This
Hi Dotan,
Just for reference, the weirdness that you're seeing before the email
addresses in your text file are "MIME-encoded" strings.
http://en.wikipedia.org/wiki/MIME
Concretely, the string
"=?UTF-8?B?157XqNeZ15Qg15nXoNeY16bXnw==?="
is an encoding of a string in MIME format, and
On 01/05/07, Daniel Yoo <[EMAIL PROTECTED]> wrote:
> Hi Dotan,
>
>
> Just for reference, the weirdness that you're seeing before the email
> addresses in your text file are "MIME-encoded" strings.
>
> http://en.wikipedia.org/wiki/MIME
>
> Concretely, the string
>
> "=?UTF-8?B?157XqNeZ15Qg
Hello, I'm trying to calculate an average for columns in my
array(data), there's a catch though, I want to create a new array of
shorter length (NOTE: this crashes at line 8):
1) tinit = data[0][0]
2)for d in data:
3)if d[0] <= tinit+60:
4)sum = sum+d
5)else:
6)
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],[avg],axis=0)
> 8)tinit = d[0]
>
>
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],
John Washakie wrote:
> Hello, I'm trying to calculate an average for columns in my
> array(data), there's a catch though, I want to create a new array of
> shorter length (NOTE: this crashes at line 8):
>
> 1) tinit = data[0][0]
> 2)for d in data:
> 3)if d[0] <= tinit+60:
> 4)
Thanks for the feedback,
The average was a little bit goofed up. Here's what I have now:
for d in data:
if d[0] <= tinit+60:
d = column_stack(d)
cnt=cnt+1
sum = sum+d
else:
avg = sum/cnt
if init==0:
newData = av
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...
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/
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
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)
if d[0] <= tinit+60:
d = column_stack(d)
And of course, thanks all!
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
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)
On 02/05/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):
I'm still not sure exactly what you want
29 matches
Mail list logo