Re: % operation
It also looks like you are using an old version of Python running on an old version of Linux. Time to upgrade? Christopher Koppler wrote: > On Wed, 05 Jan 2005 15:36:30 +0900, Daewon YOON wrote: > >> >> Python 1.5.2 (#1, Jul 5 2001, 03:02:19) [GCC 2.96 2731 (Red Hat >> Linux 7.1 2 on linux-i386 >> Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >> >>> x=9 >> >>> y=4 >> >>> x%y >> 1 >> >>> for z in range(44): >> ... z%9 >>File "", line 2 >> z%9 >> ^ >> SyntaxError: invalid syntax >> >> >> What's wrong with the above operation and how can I get the correct >> modulo result with Python? > > There's nothing wrong with the operation, but it looks like you forgot to > indent your loop body (which the interactive shell doesn't automagically > do for you): > for z in range(44): > ... z%9 > ... > > [result snipped] > -- http://mail.python.org/mailman/listinfo/python-list
Re: pulling info from website
Bob, Have a look at feedparser: http://www.feedparser.org/ http://diveintomark.org/projects/feed_parser/ For bbc news feeds, I use the following url: http://www.bbc.co.uk/syndication/feeds/news/ukfs_news/front_page/rss091.xml bob wrote: > i am trying to write a script for Xbox media center that will pull > information from the bbc news website and display the headlines , how do i > pull this info into a list??? -- http://mail.python.org/mailman/listinfo/python-list
Re: date diff calc
Here's how to do it as a one-liner: python -c "import datetime; import time; print 'Only %d days until Christmas' % (datetime.date(2004, 12, 25) - datetime.date.fromtimestamp(time.time())).days" Here's a slightly shorter way of doing it: python -c "import time; print 'Only %f more days until Christmas' % (float(time.mktime(time.strptime('2004-12-25', '%Y-%m-%d')) - time.time()) / 86400)" -- http://mail.python.org/mailman/listinfo/python-list
Re: jython and swing
Could it have something to do with your PATH or CLASSPATH settings? Here's a test script that works for me: #!/usr/bin/env jython from java import lang from javax import swing print "lang attributes: " for attr in dir(lang): print "\t%s" % attr print print "swing attributes: " for attr in dir(swing): print "\t%s" % attr print print "Good Bye!" Note: both #!/usr/bin/env jython and #!/bin/env jython seem to work on the OSU stdsun system... Nandan wrote: > hello, can I ask a jython question here? > > when I use the jython interpreter I have no problem with the statement: > > from java import lang > from javax import swing > > but when I put this in a script, I get a package not found error. > what am I doing wrong? > > the script header is #!/bin/env jython > > -- > Nandan Bagchee > Ohio State University > [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Put a file on an ftp server over ssl
Have a look at Putty's pscp and PySCP... http://www.chiark.greenend.org.uk/~sgtatham/putty/ http://py.vaults.ca/apyllo.py/990075885.195097684.69935243 Rick Lars wrote: > Daniel, > > Why don't you just use the 'sftp' command line program, it's available > for all unixes and I bet you can find a build for windows to? Then you > could just do an os.system(..) and be done with it. > > Cheers! > Lars -- http://mail.python.org/mailman/listinfo/python-list
Re: different time tuple format
Like the last poster said, use %Z. On my Mandriva Linux system I get the following results: >>> time.localtime() (2005, 6, 7, 15, 7, 12, 1, 158, 1) >>> time.strptime("2005-06-07 15:07:12 EDT", "%Y-%m-%d %H:%M:%S %Z") (2005, 6, 7, 15, 7, 12, 1, 158, 1) Rick Maksim Kasimov wrote: > hi all, sorry if i'm reposting > > why time.strptime and time.localtime returns tuple with different DST (9 > item of the tuple)? is there some of setting to fix the problem? > > > Python 2.2.3 (#1, May 31 2005, 11:33:52) > [GCC 2.95.4 20020320 [FreeBSD]] on freebsd4 > Type "help", "copyright", "credits" or "license" for more information. > >>> import time > >>> time.strptime("2005-06-07 21:00:00", "%Y-%m-%d %H:%M:%S") > (2005, 6, 7, 21, 0, 0, 6, 1, 0) > >>> time.localtime() > (2005, 6, 7, 21, 2, 39, 1, 158, 1) > >>> > > -- http://mail.python.org/mailman/listinfo/python-list