Re: calculate difference between two timestamps [newbie]

2011-12-17 Thread Vince
On Sat, Dec 17, 2011 at 02:19:44AM -0800, nukeymusic wrote:
> I'm trying to calculate the difference in seconds between two
> timestamps, but I'm totally stuck:
> date1="Dec-13-09:47:12"
> date2="Dec-13-09:47:39"
> >>> diff=datetime.date(date2)-datetime.date(date1)
> Traceback (most recent call last):
>   File "", line 1, in 
> TypeError: an integer is required
> 
> struct_date1=time.strptime(date1, "%b-%d-%H:%M:%S")
> struct_date2=time.strptime(date2, "%b-%d-%H:%M:%S")
> >>> diff=datetime.date(struct_date2)-datetime.date(struct_date1)
> Traceback (most recent call last):
>   File "", line 1, in 
> TypeError: an integer is required

You're trying to compare two time.struct_time types when they need to be 
datetime.datetime types.

This will do the conversion for you:

import datetime,time

date1="Dec-13-09:47:12"
date2="Dec-13-09:47:39"

struct_date1=datetime.datetime(*time.strptime(date1, "%b-%d-%H:%M:%S")[:6])
struct_date2=datetime.datetime(*time.strptime(date2, "%b-%d-%H:%M:%S")[:6])

print struct_date2 - struct_date1
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: gc question

2008-03-09 Thread Vince
On Mar 9, 1:51 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> On Sun, 09 Mar 2008 01:42:01 -0800, vpalexander wrote:
> > I keep seeing destructor calls in wx for ad hoc dialogs and wonder if
> > this is required, and if so, why would normal gc flow not be good?
>
> Because there is no guarantee when `__del__()` is called or if it is
> called *at all*.
>
> Ciao,
> Marc 'BlackJack' Rintsch

Well, that suits me. The most unnatural thing about Python was
adapting to the idea of just letting unreleased resources go jogging
off wherever. :)

"Where's the f.close?"
"You don't need it!"

Hmmm!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help xxx.py Program Recognition problem

2008-03-09 Thread Vince
On Mar 8, 9:48 am, [EMAIL PROTECTED] wrote:
> Hi...
>
> I was using Python 2.4 and installed 2.5...I copied all my .py files
> from the Python24\ root directory to the Python25\ root
> directory...when I try to run them by double clicking I get:
> "X.py is not a valid Win32 application"...
>
> Also, the files do not appear to be associated with python...?
>
> I can run them from IDLE...but that is it...
>
> How do I fix this...?
>
> Thanks..
>
> Dave

It sounds like you just want the dbl-click Explorer association ...
that it should establish by default ... you can use Explorer -> Tools -
> Folder Options -> File Types to indicate that you want Idle to
launch .py files.

Also, probably a silly question, but did you verify the download was
the right Win OS version?
-- 
http://mail.python.org/mailman/listinfo/python-list


distribute and reference static content in a python package

2012-02-02 Thread Vince Forgetta
Hi,

I have developed a python program that contains multiple python modules
and static content in the form of fonts (pil,pbm and tff files),  html,
images, css and javascript.

I want to share the program with others as a python package. I have
followed the instructions at 

http://guide.python-distribute.org/creation.html

I have created an identical structure (apart from directory naming) as
specified in the link, with the exception of a "static" directory within
the module directory (towelstuff in the example). Within this directory
are sub-directories named "css", "html", "images", "fonts" and "js".

TowelStuff/
bin/
run.py
CHANGES.txt
docs/
LICENSE.txt
MANIFEST.in
README.txt
setup.py
towelstuff/
__init__.py
module1.py
module2.py
static/
images/someimage.png
css/
html/
js/
fonts/


When the user install the program using "python setup.py install", the
modules (in towelstuff) are copied to the common python library path
(e.g. /usr/lib/python2.7/site-packages/), but the static content is not
(understandably).

What is common method to distribute static content, and how to I make
reference to it in my python program?

For programs in TowelStuff/bin (i.e. run.py), I currently make reference
to the static content like so:

sys.path[0] + "../towelstuff/static/images/someimage.png"

I am sure there is a more pythonic way of doing this ...

Thanks in advance for the help.

Vince

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: distribute and reference static content in a python package

2012-02-02 Thread Vince Forgetta
I assume this is an appropriate solution to my problem:

http://docs.python.org/distutils/setupscript.html#installing-additional-files



On Thu, 2012-02-02 at 13:42 -0500, Vince Forgetta wrote:
> Hi,
> 
> I have developed a python program that contains multiple python modules
> and static content in the form of fonts (pil,pbm and tff files),  html,
> images, css and javascript.
> 
> I want to share the program with others as a python package. I have
> followed the instructions at 
> 
> http://guide.python-distribute.org/creation.html
> 
> I have created an identical structure (apart from directory naming) as
> specified in the link, with the exception of a "static" directory within
> the module directory (towelstuff in the example). Within this directory
> are sub-directories named "css", "html", "images", "fonts" and "js".
> 
> TowelStuff/
> bin/
> run.py
> CHANGES.txt
> docs/
> LICENSE.txt
> MANIFEST.in
> README.txt
> setup.py
> towelstuff/
> __init__.py
> module1.py
> module2.py
> static/
> images/someimage.png
> css/
> html/
> js/
> fonts/
> 
> 
> When the user install the program using "python setup.py install", the
> modules (in towelstuff) are copied to the common python library path
> (e.g. /usr/lib/python2.7/site-packages/), but the static content is not
> (understandably).
> 
> What is common method to distribute static content, and how to I make
> reference to it in my python program?
> 
> For programs in TowelStuff/bin (i.e. run.py), I currently make reference
> to the static content like so:
> 
> sys.path[0] + "../towelstuff/static/images/someimage.png"
> 
> I am sure there is a more pythonic way of doing this ...
> 
> Thanks in advance for the help.
> 
> Vince


-- 
http://mail.python.org/mailman/listinfo/python-list


Custom PYTHONPATH not being seen by -m

2007-09-18 Thread Vince Castellano
Hello,

I am running RHEL5, with Python 2.4.3. I do not experience this
problem on my other machines, which are 2.5.

The following should demonstrate my issue:

[16:38][vince:~]$ python -m srctools.symbol_replace -h
python: module srctools.symbol_replace not found
[16:40][vince:~]$ python
Python 2.4.3 (#1, Dec 11 2006, 11:38:52)
[GCC 4.1.1 20061130 (Red Hat 4.1.1-43)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import srctools.symbol_replace
>>> srctools.symbol_replace

>>>
[16:41][vince:~]$ echo $PYTHONPATH
/usr/local/pymodules


Thank you,
Vince

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Tutor] Help required

2009-09-25 Thread vince spicer
On Fri, Sep 25, 2009 at 1:56 PM, waqas ahmad  wrote:

>
>
>  Hi,
>
> I dont know it is the right place to post this question. I need help to
> change one search code line . can you help me please.
>
> here is my search method code:
>
> search=re.compile("^#acl InternationalGroup.*\n", re.M).search(pagetext)
> if search:
> ret=search.group()
> else:
> ret='not defined'
> return ret
>
> here i am searching for "#acl InternationalGroup" in the pageText and when
> it true is then give me search group.
>
>
> I want to change this for following requirement:
>
> I want to search  for "#acl InternationalGroup" and  "CatInternational" for
> both in the pageText.
> when "#acl InternationalGroup" is not there but only "CatInternational" is
> there. then return me search group.
>
> I shall be thankful to you for any help.
>
> Best Regards,
> Waqas
>
>
>
> --
> What can you do with the new Windows Live? Find 
> out
>
> ___
> Tutor maillist  -  tu...@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>
i think this is what you are looking for:



search=re.compile("(#acl\sInternationalGroup|CatInternational).*\n",
re.M).search(pagetext)
if search:
ret=search.findall()
else:
ret='not defined'
return ret
-- 
http://mail.python.org/mailman/listinfo/python-list