python datetime

2010-09-14 Thread Von
Hi, How to determine a date is just the 7th day after today ie: today is 14 Sep the 7th day is 14+7 = 21,but assume today is 28 Sep the 7th day is 5 Oct,is there simple way to do this work? I wish I explained clear Bests, -- http://mail.python.org/mailman/listinfo/python-list

Re: python datetime

2010-09-14 Thread Peter Otten
Von wrote: > How to determine a date is just the 7th day after today > ie: today is 14 Sep the 7th day is 14+7 = 21,but assume today is 28 Sep > the 7th day is 5 Oct,is there simple way to do this work? > I wish I explained clear The datetime module takes care of this >>> import datetime as dt

Re: python datetime

2010-09-14 Thread Michael Ricordeau
# Determine diff days between two dates import datetime now = datetime.date(2010, 9, 28) next = datetime.date(2010, 10, 5) delta = next - now #delta is datetime.timedelta type. #(You can extract days diff) # Determine date in 7 days import datetime now = datetime.date(2010, 9, 28) delta = dateti

Re: python datetime

2010-09-14 Thread Von
Thank you,the timedelta class is awesome. On Tue, Sep 14, 2010 at 3:50 PM, Michael Ricordeau < michael.ricord...@gmail.com> wrote: > > # Determine diff days between two dates > import datetime > now = datetime.date(2010, 9, 28) > next = datetime.date(2010, 10, 5) > delta = next - now > > #delta i

Re: Converting an ugly path to a shell path

2010-09-14 Thread Lawrence D'Oliveiro
In message , amfr...@web.de wrote: > The shell don't understand the special chars so i have to escape them with > "\" . > Is there a function that does this ? You could get the shell (at least if it’s Bash) itself to do this. Try the following script: import sys import os import sub

Re: Expected bahaviour of os.chroot and os.getcwd

2010-09-14 Thread Nobody
On Mon, 13 Sep 2010 19:04:53 +0100, r0g wrote: > i.e. So do I always have to change directory after changing into a chroot? You don't *have* to change the directory, but not doing so probably defeats the point of performing a chroot(). > The reason I ask is because an app I was running inside th

python tkinter Listbox

2010-09-14 Thread Von
Hi all, I am building a simple tool using tkinter,and need multiselection checklist.I find that Listbox with option selectmode=tkinter.MULTIPLE could do this for me. But when I have two Listboxs,I do some selection with one,then do selection with another one,the previous listbox get cleared.I wo

Re: Converting an ugly path to a shell path

2010-09-14 Thread Nobody
On Tue, 14 Sep 2010 01:07:48 +0200, AmFreak wrote: > im using a QFileDialog to let the user select a path that is used later in > a command send to the shell like this: > > retcode = Popen(command + " " + path, shell=True, stdout = PIPE, stderr = > PIPE) > > The problem that occurs now is wh

help removing pyQt dll from dist created with py2exe

2010-09-14 Thread Carlos Grohmann
Hello all, i've been trying to build an .exe with py2exe. After many tentatives, it worked, but the total space used by the app goes to 30Mb. It is a simple app, that uses wxpython, matplotlib and numpy. I checked the library.zip file and notived that there is a pyQt-related file there: Pyqt - Qt

Re: help removing pyQt dll from dist created with py2exe

2010-09-14 Thread Almar Klein
Hi, Have you tried adding "PyQt4", "PyQt4.QtGui" and "PyQt4.QtCore" to your list of excludes? (Maybe only "PyQt4.QtGui" is sufficient.) Almar On 14 September 2010 13:02, Carlos Grohmann wrote: > Hello all, > > i've been trying to build an .exe with py2exe. After many tentatives, > it worked,

Re: Expected bahaviour of os.chroot and os.getcwd

2010-09-14 Thread r0g
On 14/09/10 11:19, Nobody wrote: On Mon, 13 Sep 2010 19:04:53 +0100, r0g wrote: i.e. So do I always have to change directory after changing into a chroot? You don't *have* to change the directory, but not doing so probably defeats the point of performing a chroot(). Thanks for the info 'No

Install python-mcrypt on Ubuntu

2010-09-14 Thread lsolesen
I am trying to install python-mcrypt (http://labix.org/python-mcrypt) on Ubuntu, but I cannot get it to work. I have the following python installed: Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) [GCC 4.4.3] on linux2 I get the following message when trying to install. lsole...@lsolesen-lenovo

Re: Install python-mcrypt on Ubuntu

2010-09-14 Thread Christian Heimes
Am 14.09.2010 16:14, schrieb lsolesen: > I am trying to install python-mcrypt (http://labix.org/python-mcrypt) > on Ubuntu, but I cannot get it to work. I have the following python > installed: sudo apt-get install python-dev Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: Install python-mcrypt on Ubuntu

2010-09-14 Thread lsolesen
Tried on another machine, but with this error: lsole...@lsolesen-toshiba:~/Desktop/python-mcrypt-1.1$ python setup.py install running install running build running build_ext building 'mcrypt' extension gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall - Wstrict-prototypes -fPIC -DVER

help with calling a static method in a private class

2010-09-14 Thread lallous
How can I keep the class private and have the following work: [code] class __internal_class(object): @staticmethod def meth1(s): print "meth1:", s @staticmethod def meth2(s): print "meth2:", __internal_class.meth1(s) x = __internal_class() x.meth2('sdf')

Re: help with calling a static method in a private class

2010-09-14 Thread Diez B. Roggisch
lallous writes: > How can I keep the class private and have the following work: > > [code] > class __internal_class(object): > @staticmethod > def meth1(s): > print "meth1:", s > > @staticmethod > def meth2(s): > print "meth2:", > __internal_class.meth1(s)

Re: Install python-mcrypt on Ubuntu

2010-09-14 Thread Christian Heimes
Am 14.09.2010 16:26, schrieb lsolesen: > Tried on another machine, but with this error: > > lsole...@lsolesen-toshiba:~/Desktop/python-mcrypt-1.1$ python setup.py > install > running install > running build > running build_ext > building 'mcrypt' extension > gcc -pthread -fno-strict-aliasing -DNDE

Re: Install python-mcrypt on Ubuntu

2010-09-14 Thread Benjamin Kaplan
On Tue, Sep 14, 2010 at 10:26 AM, lsolesen wrote: > > mcrypt.c:23:20: error: mcrypt.h: No such file or directory Well, there's your problem. You don't have the mcrypt headers installed. sudo apt-get install libmcrypt-dev -- http://mail.python.org/mailman/listinfo/python-list

Re: help with calling a static method in a private class

2010-09-14 Thread Bruno Desthuilliers
Diez B. Roggisch a écrit : lallous writes: How can I keep the class private and have the following work: [code] class __internal_class(object): @staticmethod def meth1(s): print "meth1:", s @staticmethod def meth2(s): print "meth2:", __internal_class.m

Re: help removing pyQt dll from dist created with py2exe

2010-09-14 Thread Carlos Grohmann
many thanks Almar. No more pyqt stuff in my dist. cheers carlos On Tue, Sep 14, 2010 at 09:21, Almar Klein wrote: > Hi, > > Have you tried adding "PyQt4", "PyQt4.QtGui" and "PyQt4.QtCore" to your list > of excludes? > (Maybe only "PyQt4.QtGui" is sufficient.) > >   Almar > > > On 14 September

String formatting with the format string syntax

2010-09-14 Thread Andre Alexander Bell
Hello, I'm used to write in Python something like >>> s = 'some text that says: %(hello)s' and then have a dictionary like >>> english = { 'hello': 'hello' } and get the formatted output like this: >>> s % english Occasionally I want to extract the field names from the template string. I w

Re: String formatting with the format string syntax

2010-09-14 Thread Miki
You can use ** syntax: >>> english = {'hello':'hello'} >>> s.format(**english) On Sep 14, 9:59 am, Andre Alexander Bell wrote: > Hello, > > I'm used to write in Python something like > >  >>> s = 'some text that says: %(hello)s' > > and then have a dictionary like > >  >>> english = { 'hello': 'h

Cross Compiling Python for ARM

2010-09-14 Thread Neil Benn
Hello, I've been working on an embedded ARM system which boots up quick (a beagleboard running a skinnied down version of Angstrom). For this I need to compile a lot of libraries from scratch. One of the things I need is Python; I've cross compiled Python and it works OK when I try to ru

Re: Cross Compiling Python for ARM

2010-09-14 Thread Thomas Jollans
On Tuesday 14 September 2010, it occurred to Neil Benn to exclaim: > # > ./python > > -sh: ./python: not found I'm guessing either there is no file ./python, or /bin/sh is fundamentally broken. -- http://mail.python.org/mailman/listinfo/python-list

Re: String formatting with the format string syntax

2010-09-14 Thread Thomas Jollans
On Tuesday 14 September 2010, it occurred to Miki to exclaim: > You can use ** syntax: > >>> english = {'hello':'hello'} > >>> s.format(**english) No, you can't. This only works with dicts, not with arbitrary mappings, or dict subclasses that try to do some kind of funny stuff. > > On Sep 14,

Re: WMI in Python

2010-09-14 Thread bli
On Sep 14, 7:46 am, KING LABS wrote: > On Sep 14, 10:39 am, KING LABS wrote: > > > > > > > > > > > On Sep 13, 8:31 pm, Jerry Hill wrote: > > > > On Mon, Sep 13, 2010 at 8:45 AM, KING LABS wrote: > > > > Hi All, > > > > > I am new to programming and python, Being a system administrator I > > > >

Re: String formatting with the format string syntax

2010-09-14 Thread Benjamin Kaplan
On Tue, Sep 14, 2010 at 3:20 PM, Thomas Jollans wrote: > On Tuesday 14 September 2010, it occurred to Miki to exclaim: >> You can use ** syntax: >> >>> english = {'hello':'hello'} >> >>> s.format(**english) > > No, you can't. This only works with dicts, not with arbitrary mappings, or > dict subcl

Re: Cross Compiling Python for ARM

2010-09-14 Thread David Boddie
On Tuesday 14 September 2010 21:19, Thomas Jollans wrote: > On Tuesday 14 September 2010, it occurred to Neil Benn to exclaim: >> # >> ./python >> >> -sh: ./python: not found > > > I'm guessing either there is no file ./python, or /bin/sh is fundamentally > broken. Yes, it may be instructive t

Default python compile options

2010-09-14 Thread James Matthews
Hi, I am trying to compile Python 2.7 on Ubuntu and I am wondering what are the default compile options (i.e ./configure ..) for ubuntu. I just want the standard ones that are included with the python2.6 version on ubuntu. Can someone please shed some light? Thanks, James -- http://www.goldwatc

python27.exe vs python2.7.exe ...

2010-09-14 Thread Sridhar Ratnakumar
Hi, As you may already know, ActivePython provides versioned Python executables that makes it possible to invoke a particular X.Y version from the command line directly if you have multiple Python versions on PATH. Eg: C:\Python27\python26.exe C:\Python27\python27.exe C:\Python31\pytho

Re: scp with paramiko

2010-09-14 Thread Alexander Gattin
Hello, On Wed, Sep 01, 2010 at 09:56:18AM -0700, cerr wrote: > I want to download a file from a client using > paramiko. I found plenty of ressources using > google on how to send a file but none that > would describe how to download files from a > client. Download files from remote to local? Ge

Re: Default python compile options

2010-09-14 Thread James Mills
On Wed, Sep 15, 2010 at 7:25 AM, James Matthews wrote: > I am trying to compile Python 2.7 on Ubuntu and I am wondering what are the > default compile options (i.e ./configure ..) for ubuntu. I just want the > standard ones that are included with the python2.6 version on ubuntu. Can > someone plea

Re: python27.exe vs python2.7.exe ...

2010-09-14 Thread James Mills
On Wed, Sep 15, 2010 at 7:25 AM, Sridhar Ratnakumar wrote: > Thoughts? I've never been a Windows developer (probably never will be), but I have one thought: Why has ActivePython not been doing this all along ? cheers James -- -- James Mills -- -- "Problems are solved by method" -- http://mai

Re: python27.exe vs python2.7.exe ...

2010-09-14 Thread Trent Mick
On 10-09-14 2:52 PM, James Mills wrote: On Wed, Sep 15, 2010 at 7:25 AM, Sridhar Ratnakumar wrote: Thoughts? I've never been a Windows developer (probably never will be), but I have one thought: Why has ActivePython not been doing this all along ? Hind sight is 20/20 is all I can say. :)

Re: python27.exe vs python2.7.exe ...

2010-09-14 Thread James Mills
On Wed, Sep 15, 2010 at 8:31 AM, Trent Mick wrote: > Hind sight is 20/20 is all I can say. :) Perhaps having 1/60 sight is better ? :) > When I added support for "pythonXY.exe" instead of "pythonX.Y.exe" I was > trying to add an out-of-the-box equivalent for what I saw some core > developers do

Re: String formatting with the format string syntax

2010-09-14 Thread Andre Alexander Bell
On 09/14/2010 08:20 PM, Miki wrote: You can use ** syntax: english = {'hello':'hello'} s.format(**english) Thanks for your answer. Actually your answer tells me that my example was misleading. Consider the template s = 'A template with {variable1} and {variable2} placeholders.' I'm seeking

webcam in gtalk/xmpp

2010-09-14 Thread Astan Chee
Hi, I was wondering if there is an implementation in any of the xmpp python API (e.g. xmpppy, etc) that implements broadcasting webcam (as well as audio-chat). The documentation on xmpppy doesn't show me how this can be done. Is this even possible? Thanks Astan -- http://mail.python.org/mailma

Numpy: Multiplying arrays of matrices

2010-09-14 Thread Gregory Ewing
Suppose I have two N+2 dimensional arrays, representing N-d arrays of 2-d matrices. I want to perform matrix multiplication between corresponding matrices in these arrays. I had thought that dot() might do this, but it appears not, because e.g. applying it to two 3-d arrays gives a 4-d array, not

Re: Default python compile options

2010-09-14 Thread James Matthews
Thanks James, I did try the plain old configure but I was missing compression zlib and I wanted to make sure that I wasn't going to be be running in circles having to run ./configure a bunch of times so I decided to ask) James On Tue, Sep 14, 2010 at 2:50 PM, James Mills wrote: > On Wed, Sep 15

Re: Default python compile options

2010-09-14 Thread James Mills
On Wed, Sep 15, 2010 at 10:20 AM, James Matthews wrote: > Thanks James, > I did try the plain old configure but I was missing compression zlib and I > wanted to make sure that I wasn't going to be be running in circles having > to run ./configure a bunch of times so I decided to ask) You might ne

Re: palindrome iteration

2010-09-14 Thread Bearophile
Baba: > def i_palindrome(pal): > while len(pal)>1: > if pal[0] == pal[-1]: >pal=pal[1:-1] > return True > > print i_palindrome('annab') In normal programming a significant percentage of the time is spent debugging. Experience shows that even short functions may be buggy. If you don't wan

This is Vegas - Get $2400 Free

2010-09-14 Thread http://thisisvegas.com/get/a/179639
This is Vegas - Get $2400 Free http://thisisvegas.com/get/a/179639 Click here to download over 400 Free Games http://thisisvegas.com/get/wd/206052 -- http://mail.python.org/mailman/listinfo/python-list

distutils, cygwin, 'not a regular file'

2010-09-14 Thread Paul Watson
So, what is not a regular file about this? Is there any way to find out which files are being considered irregular? $ uname -a CYGWIN_NT-6.0-WOW64 pwatson 1.7.7(0.230/5/3) 2010-08-31 09:58 i686 Cygwin $ cat setup.py from distutils.core import setup setup( name='xlsexport', version='0

can not import hashlib

2010-09-14 Thread ch huang
i have a big problem,here is and any can help me? Python 2.6.5 (r265:79063, Apr 1 2010, 05:22:20) [GCC 4.4.3 20100316 (prerelease)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import hashlib Traceback (most recent call last): File "", line 1, in File

Re: Bit fields in python?

2010-09-14 Thread Eli Bendersky
> Hi, > > I'm trying to use the construct library, but encountered a problem. May I > know how do I implement the following using the construct library? > > typedef struct > { > unsigned short size; > . > . > }CodecInfo; > > typedef struct > { > unsigned short size; > CodecInfo

Re: can not import hashlib

2010-09-14 Thread Xia, Zhen
Your python is compiled without md5. Maybe your system misses some libraries and you have to re-compile the python. On Wed, 15 Sep 2010 11:03:40 +0800 ch huang wrote: > i have a big problem,here is > and any can help me? > > Python 2.6.5 (r265:79063, Apr 1 2010, 05:22:20) > [GCC 4.4.3 201003

python call a procedure at the specified time

2010-09-14 Thread Von
Hi, I have a python script running behind the scene,and I need it to call a method on sunday 9 o'clock. I get an idea,that I get the current time,and calculate the seconds to sunday 9 o'clock, then sleep these seconds and call my method,I think there could be an elegant way to resolve this. Regard

Re: python call a procedure at the specified time

2010-09-14 Thread Nitin Pawar
are you looking for something like cron? On Wed, Sep 15, 2010 at 11:43 AM, Von wrote: > Hi, > I have a python script running behind the scene,and I need it to call a > method on sunday 9 o'clock. > I get an idea,that I get the current time,and calculate the seconds to > sunday 9 o'clock, > then

Re: python call a procedure at the specified time

2010-09-14 Thread Von
Hi Nitin,I need a python solution for that. On Wed, Sep 15, 2010 at 2:15 PM, Nitin Pawar wrote: > are you looking for something like cron? > > On Wed, Sep 15, 2010 at 11:43 AM, Von wrote: > >> Hi, >> I have a python script running behind the scene,and I need it to call a >> method on sunday 9 o'

Re: python call a procedure at the specified time

2010-09-14 Thread Nitin Pawar
I think to do so either you will need to schedule a cron or write a daemon process which will run continuously. Assuming that its running only once a day or say timely manner daemon will be a costly affair for system resources To schedule crons for python, this might be useful (using yaml) http:/

Re: String formatting with the format string syntax

2010-09-14 Thread Peter Otten
Andre Alexander Bell wrote: > On 09/14/2010 08:20 PM, Miki wrote: >> You can use ** syntax: > english = {'hello':'hello'} > s.format(**english) > > Thanks for your answer. Actually your answer tells me that my example > was misleading. Consider the template > > s = 'A template with {vari