Re: Which way is best to execute a Python script in Excel?

2012-07-05 Thread Terry Reedy
On 7/5/2012 10:30 PM, Karim wrote: An excellent link to derived all code example to python: http://www.pitonyak.org/AndrewMacro.sxw. Even though he only writes in OOBasic, you are right that he explains the basic concepts needed for accessing the api from any language. He is also honest. Wr

Re: Which way is best to execute a Python script in Excel?

2012-07-05 Thread Karim
Le 06/07/2012 07:09, Terry Reedy a écrit : On 7/5/2012 10:30 PM, Karim wrote: An excellent link to derived all code example to python: http://www.pitonyak.org/AndrewMacro.sxw. Even though he only writes in OOBasic, you are right that he explains the basic concepts needed for accessing the a

Re: Apology for OT posts

2012-07-05 Thread Simon Cropper
On 06/07/12 12:06, John O'Hagan wrote: On Tue, 03 Jul 2012 23:39:20 -0600 "Littlefield, Tyler" wrote: On 7/3/2012 10:55 PM, Simon Cropper wrote: Some questions to Tyler Littlefield, who started this thread. Q1 -- Did you get any constructive feedback on your code? I did get some, which I a

tkFileDialogs

2012-07-05 Thread brandon harris
I'm wanting to allow users to select hidden directories in windows and it seems that using the tkFileDialog.askdirectory() won't allow for that. It's using the tkFileDialog.Directory class which calls an internal command 'tk_chooseDirectory' . However the file selector dialogs (askopenfilename

Re: Help: PYMALLOC_DBUG and PIL

2012-07-05 Thread tom z
Thanks Roman. of course, i use PYMALLOC_DEBUG with PYMALLOC. -- http://mail.python.org/mailman/listinfo/python-list

Re: simpler increment of time values?

2012-07-05 Thread Steven D'Aprano
On Thu, 05 Jul 2012 11:15:04 -0700, rurpy wrote: > On Thursday, July 5, 2012 11:34:16 AM UTC-6, John Nagle wrote: >>[...] >>You can also call time.time(), and get the number of seconds >> since the epoch (usually 1970-01-01 00:00:00 UTC). That's just a >> number, and you can do arithmetic on t

Re: Which way is best to execute a Python script in Excel?

2012-07-05 Thread Karim
Le 05/07/2012 23:20, Terry Reedy a écrit : On 7/5/2012 5:12 AM, Thomas Jollans wrote: On 07/05/2012 09:26 AM, Karim wrote: Look at PyUNO from OpenOffice very large API: http://www.openoffice.org/api/docs I use to create all my documention (Excell, Writer, etc...) on this API. Note that this

Apology for OT posts (was: code review)

2012-07-05 Thread John O'Hagan
On Tue, 03 Jul 2012 23:39:20 -0600 "Littlefield, Tyler" wrote: > On 7/3/2012 10:55 PM, Simon Cropper wrote: > > Some questions to Tyler Littlefield, who started this thread. > > > > Q1 -- Did you get any constructive feedback on your code? > > I did get some, which I appreciated. someone mention

Re: Confusing datetime.datetime

2012-07-05 Thread Damjan
from datetime import datetime, timedelta, tzinfo ZERO = timedelta(0) HOUR = timedelta(hours=1) class UTC(tzinfo): def utcoffset(self, dt): return ZERO def tzname(self, dt): return "UTC" def dst(self, dt): return ZERO utc = UTC() t1 = datetime.now(tz=utc)

Re: Confusing datetime.datetime

2012-07-05 Thread Steven D'Aprano
On Fri, 06 Jul 2012 00:55:48 +0200, Damjan wrote: > Also this: > > #! /usr/bin/python2 > # retardations in python's datetime > > import pytz > TZ = pytz.timezone('Europe/Skopje') > > from datetime import datetime > > x1 = datetime.now(tz=TZ) > x2 = datetime(x1.year, x1.month, x1.day, tzinfo=TZ)

Re: 2 + 2 = 5

2012-07-05 Thread Steven D'Aprano
On Thu, 05 Jul 2012 16:46:48 -0500, Evan Driscoll wrote: > On 01/-10/-28163 01:59 PM, Alexander Blinne wrote: >> 5+0 is actually 4+0, because 5 == 4, so 5+0 gives 4. 5+1 is actually >> 4+1, which is 5, but 5 is again 4. 5+2 is 4+2 which is 6. > > Now all I can think is "Hoory for new math, new-ho

Re: Confusing datetime.datetime

2012-07-05 Thread Damjan
On 05.07.2012 16:10, Damjan wrote: I've been struggling with an app that uses Postgresql/Psycopg2/SQLAlchemy and I've come to this confusing behaviour of datetime.datetime. Also this: #! /usr/bin/python2 # retardations in python's datetime import pytz TZ = pytz.timezone('Europe/Skopje') fr

Re: 2 + 2 = 5

2012-07-05 Thread Andrew Cooper
On 05/07/2012 22:46, Evan Driscoll wrote: > On 01/-10/-28163 01:59 PM, Alexander Blinne wrote: >> 5+0 is actually 4+0, because 5 == 4, so 5+0 gives 4. >> 5+1 is actually 4+1, which is 5, but 5 is again 4. >> 5+2 is 4+2 which is 6. > > Now all I can think is "Hoory for new math, new-hoo-hoo math" :

Re: 2 + 2 = 5

2012-07-05 Thread Rhodri James
On Wed, 04 Jul 2012 20:37:25 +0100, Paul Rubin wrote: I just came across this (https://gist.github.com/1208215): import sys import ctypes pyint_p = ctypes.POINTER(ctypes.c_byte*sys.getsizeof(5)) five = ctypes.cast(id(5), pyint_p) print(2 + 2 == 5) # False five.content

Re: Re: 2 + 2 = 5

2012-07-05 Thread Evan Driscoll
On 01/-10/-28163 01:59 PM, Alexander Blinne wrote: 5+0 is actually 4+0, because 5 == 4, so 5+0 gives 4. 5+1 is actually 4+1, which is 5, but 5 is again 4. 5+2 is 4+2 which is 6. Now all I can think is "Hoory for new math, new-hoo-hoo math" :-) Evan -- http://mail.python.org/mailman/listinfo/py

Re: Which way is best to execute a Python script in Excel?

2012-07-05 Thread Terry Reedy
On 7/5/2012 5:12 AM, Thomas Jollans wrote: On 07/05/2012 09:26 AM, Karim wrote: Look at PyUNO from OpenOffice very large API: http://www.openoffice.org/api/docs I use to create all my documention (Excell, Writer, etc...) on this API. Note that this API is for OpenOffice, not Microsoft Excel.

Re: 2 + 2 = 5

2012-07-05 Thread Hans Mulder
On 5/07/12 19:03:57, Alexander Blinne wrote: > On 05.07.2012 16:34, Laszlo Nagy wrote: > five.contents[five.contents[:].index(5)] = 4 > 5 >> 4 > 5 is 4 >> True > That's surprising, because even after changing 5 to 4 both objects still > have different id()s (tested on Py2.7), so 5 is 4

Re: simpler increment of time values?

2012-07-05 Thread rurpy
On Thursday, July 5, 2012 11:34:16 AM UTC-6, John Nagle wrote: >[...] >You can also call time.time(), and get the number of seconds > since the epoch (usually 1970-01-01 00:00:00 UTC). That's just > a number, and you can do arithmetic on that. > >Adding a datetime.time to a datetime.timede

Re: OAuth 2.0 implementation

2012-07-05 Thread Demian Brecht
On Thursday, 5 July 2012 08:19:41 UTC-7, Alec Taylor wrote: > On Fri, Jul 6, 2012 at 12:06 AM, Demian Brecht wrote: > > FWIW, this package has undergone a major overhaul (474 LOC down to much > > happier 66) and is available at https://github.com/demianbrecht/sanction. > > Also available from P

Re: Question about weakref

2012-07-05 Thread Dieter Maurer
Frank Millman writes: > On 05/07/2012 10:46, Dieter Maurer wrote: >> Instead of the low level "weakref", you might use a "WeakKeyDictionary". >> > > Thanks, Dieter. I could do that. > > In fact, a WeakSet suits my purposes better. I tested it with my > original example, and it works correctly. It

Re: simpler increment of time values?

2012-07-05 Thread John Nagle
On 7/4/2012 5:29 PM, Vlastimil Brom wrote: Hi all, I'd like to ask about the possibilities to do some basic manipulation on timestamps - such as incrementing a given time (hour.minute - string) by some minutes. Very basic notion of "time" is assumed, i.e. dateless, timezone-unaware, DST-less etc.

Re: simpler increment of time values?

2012-07-05 Thread Chris Angelico
On Fri, Jul 6, 2012 at 3:06 AM, Ian Kelly wrote: > The "+ 86400" is redundant; you'll get the same answer with or without > it. There is nothing to fear from going negative when doing modulo > arithmetic, because unlike C, Python actually has well-defined > semantics regarding modulo division of

Re: simpler increment of time values?

2012-07-05 Thread Ian Kelly
On Thu, Jul 5, 2012 at 7:56 AM, Chris Angelico wrote: > I'm not familiar with the Python classes (I tend to think in terms of > language-agnostic algorithms first, and specific libraries/modules/etc > second), but if you're working with simple integer seconds, your > datelessness is just modulo ar

Re: 2 + 2 = 5

2012-07-05 Thread Alexander Blinne
On 05.07.2012 16:34, Laszlo Nagy wrote: five.contents[five.contents[:].index(5)] = 4 5 > 4 5 is 4 > True That's surprising, because even after changing 5 to 4 both objects still have different id()s (tested on Py2.7), so 5 is 4 /should/ still be False (But isn't on my 2.7). But that

Re: 2 + 2 = 5

2012-07-05 Thread Steven D'Aprano
On Thu, 05 Jul 2012 15:57:53 +0200, Hans Mulder wrote: > On 5/07/12 07:32:48, Steven D'Aprano wrote: >> On Wed, 04 Jul 2012 23:38:17 -0400, Terry Reedy wrote: >> >>> If I run the script in 3.3 Idle, I get the same output you got. If I >>> then enter '5-2' interactively, I still get 3. Maybe the c

Re: how to interact with Windows cmd?

2012-07-05 Thread Nobody
On Wed, 04 Jul 2012 20:10:47 -0700, self.python wrote: > 2. after this, I typed like "cd .." but I/O is already closed so I > can't do another things.. Don't use .communicate() if you want to keep the child process alive. Write to p.stdin and read p.stdout and p.stderr. In general, you'll need t

Re: simpler increment of time values?

2012-07-05 Thread Chris Angelico
On Fri, Jul 6, 2012 at 1:39 AM, Rick Johnson wrote: > On Jul 5, 10:19 am, Steven D'Aprano +comp.lang.pyt...@pearwood.info> wrote: >> The number of seconds in a day (true solar day) varies by between 13 and >> 30 seconds depending on the time of the year and the position of the sun. > > Indeed. Wh

Re: simpler increment of time values?

2012-07-05 Thread Chris Angelico
On Fri, Jul 6, 2012 at 1:19 AM, Steven D'Aprano wrote: > On Thu, 05 Jul 2012 23:56:37 +1000, Chris Angelico wrote: > >> (The "magic number" 86400 is a well-known number, being seconds in a >> day. > > Does that include leap seconds? No it doesn't, hence... >> Feel free to replace it with 24*60*6

Re: simpler increment of time values?

2012-07-05 Thread Rick Johnson
On Jul 5, 10:19 am, Steven D'Aprano wrote: > The number of seconds in a day (true solar day) varies by between 13 and > 30 seconds depending on the time of the year and the position of the sun. Indeed. Which proves that a time keeping system based on the haphazard movements of celestial bodies is

Re: Help: PYMALLOC_DBUG and PIL

2012-07-05 Thread Roman Putilov
2012/7/5 tom z > Hi~ all, > I encounter a odd problem, when i compile Python with PYMALLOC_DEBUG, the > PIL module can't work fine, it always make core-dump like this > > [Switching to Thread 182897301792 (LWP 16102)] > 0x004df264 in PyObject_Malloc (nbytes=64) at Objects/obmalloc.c:804 >

Re: 2 + 2 = 5

2012-07-05 Thread Devin Jeanpierre
On Thu, Jul 5, 2012 at 10:34 AM, Laszlo Nagy wrote: 5+1 > 4 4 + 1 is 5 is 4. (e.g. try 2+3 as well). -- Devin -- http://mail.python.org/mailman/listinfo/python-list

Re: simpler increment of time values?

2012-07-05 Thread Steven D'Aprano
On Thu, 05 Jul 2012 23:56:37 +1000, Chris Angelico wrote: > (The "magic number" 86400 is a well-known number, being seconds in a > day. Does that include leap seconds? > Feel free to replace it with 24*60*60 if it makes you feel better; > I'm pretty sure Python will translate it into a constan

Re: 2 + 2 = 5

2012-07-05 Thread MRAB
On 05/07/2012 15:34, Laszlo Nagy wrote: On 2012-07-04 21:37, Paul Rubin wrote: I just came across this (https://gist.github.com/1208215): import sys import ctypes pyint_p = ctypes.POINTER(ctypes.c_byte*sys.getsizeof(5)) five = ctypes.cast(id(5), pyint_p) print(2 + 2 ==

Re: OAuth 2.0 implementation

2012-07-05 Thread Alec Taylor
On Fri, Jul 6, 2012 at 12:06 AM, Demian Brecht wrote: > FWIW, this package has undergone a major overhaul (474 LOC down to much > happier 66) and is available at https://github.com/demianbrecht/sanction. > Also available from PyPI. Thanks for this, I've now shared it on my favourite web-framewo

Re: 2 + 2 = 5

2012-07-05 Thread Laszlo Nagy
On 2012-07-04 21:37, Paul Rubin wrote: I just came across this (https://gist.github.com/1208215): import sys import ctypes pyint_p = ctypes.POINTER(ctypes.c_byte*sys.getsizeof(5)) five = ctypes.cast(id(5), pyint_p) print(2 + 2 == 5) # False five.contents[five.conten

Re: Which way is best to execute a Python script in Excel?

2012-07-05 Thread Mark Shroyer
On Thu, Jul 05, 2012 at 03:22:01AM -0400, Maurizio Spadaccino wrote: > Hi all > > I'm new to Python but soon after a few days of studying its features I > find it my favourite mean of programming scripts to allow for data > storing and mining. My idea would be to inplement python scripts from > in

Re: Creating an instance when the argument is already an instance.

2012-07-05 Thread Hans Mulder
On 5/07/12 12:47:52, Chris Angelico wrote: > On Thu, Jul 5, 2012 at 8:29 PM, Olive wrote: >> I am creating a new class: package (to analyse the packages database in >> some linux distros). I have created a class package such that >> package("string") give me an instance of package if string is a c

Re: Using a CMS for small site?

2012-07-05 Thread Alex Clark
On 7/5/12 4:27 AM, Dieter Maurer wrote: Gilles writes: The site is just... - a few web pages that include text (in four languages) and pictures displayed in a Flash slide show - a calendar to show availability - a form to send e-mail with anti-SPAM support - (ASAP) online payment Out of curio

Re: Discussion on some Code Issues

2012-07-05 Thread subhabangalore
Dear Peter, That is a nice one. I am thinking if I can write "for lines in f" sort of code that is easy but then how to find out the slices then, btw do you know in any case may I convert the index position of file to the list position provided I am writing the list for the same file we are read

Re: Which way is best to execute a Python script in Excel?

2012-07-05 Thread Emile van Sebille
On 7/5/2012 12:22 AM Maurizio Spadaccino said... Hi all I'm new to Python but soon after a few days of studying its features I find it my favourite mean of programming scripts to allow for data storing and mining. My idea would be to inplement python scripts from inside an excel sheet that would

Re: OAuth 2.0 implementation

2012-07-05 Thread Demian Brecht
FWIW, this package has undergone a major overhaul (474 LOC down to much happier 66) and is available at https://github.com/demianbrecht/sanction. Also available from PyPI. -- http://mail.python.org/mailman/listinfo/python-list

Confusing datetime.datetime

2012-07-05 Thread Damjan
I've been struggling with an app that uses Postgresql/Psycopg2/SQLAlchemy and I've come to this confusing behaviour of datetime.datetime. First of all, the "Seconds since Epoch" timestamps are always in UTC, so shouldn't change with timezones. So I'd expect that a round trip of a timestamp

Re: simpler increment of time values?

2012-07-05 Thread rurpy
On Wednesday, July 4, 2012 6:29:10 PM UTC-6, Vlastimil Brom wrote: > Hi all, > I'd like to ask about the possibilities to do some basic manipulation > on timestamps - such as incrementing a given time (hour.minute - > string) by some minutes. > Very basic notion of "time" is assumed, i.e. dateless,

Re: 2 + 2 = 5

2012-07-05 Thread Hans Mulder
On 5/07/12 07:32:48, Steven D'Aprano wrote: > On Wed, 04 Jul 2012 23:38:17 -0400, Terry Reedy wrote: > >> If I run the script in 3.3 Idle, I get the same output you got. If I >> then enter '5-2' interactively, I still get 3. Maybe the constant folder >> is always on now. > > Yes, I believe consta

Re: simpler increment of time values?

2012-07-05 Thread Chris Angelico
On Thu, Jul 5, 2012 at 11:18 PM, Vlastimil Brom wrote: > Yes, the calculations with seconds since the Unix epoch is very > convenient for real times, but trying to make it dateless seemed to > make it more complicated for me. > > The expected output for the increments asked by Jason was already >

Re: simpler increment of time values?

2012-07-05 Thread Vlastimil Brom
Many thanks to all for your suggestions! @ChrisA Yes, the calculations with seconds since the Unix epoch is very convenient for real times, but trying to make it dateless seemed to make it more complicated for me. The expected output for the increments asked by Jason was already correctly stated

Re: Using a CMS for small site?

2012-07-05 Thread Gilles
On Thu, 05 Jul 2012 10:27:40 +0200, Dieter Maurer wrote: >There is also "Plone" ("http://plone.org";) -- easy to set up. > >You likely need third party extensions for the "anti-SPAM" support >and the onlie payment. I'll see what extensions it offers. Thanks. -- http://mail.python.org/mailman/lis

Re: Using a CMS for small site?

2012-07-05 Thread Gilles
On Wed, 4 Jul 2012 17:09:40 -0700 (PDT), alex23 wrote: >Not necessarily! There are several static site generators written in >Python :) > >One that I see being updating a lot is Nikola: http://nikola.ralsina.com.ar/ I'll check it out, thanks. -- http://mail.python.org/mailman/listinfo/python-lis

Re: Creating an instance when the argument is already an instance.

2012-07-05 Thread Steven D'Aprano
On Thu, 05 Jul 2012 12:29:24 +0200, Olive wrote: > I am learning python -:) > > I am creating a new class: package (to analyse the packages database in > some linux distros). I have created a class package such that > package("string") give me an instance of package if string is a correct > repre

Re: Question about weakref

2012-07-05 Thread Frank Millman
On 05/07/2012 10:46, Dieter Maurer wrote: Frank Millman writes: I have a situation where I thought using weakrefs would save me a bit of effort. Instead of the low level "weakref", you might use a "WeakKeyDictionary". Thanks, Dieter. I could do that. In fact, a WeakSet suits my purposes

Re: Creating an instance when the argument is already an instance.

2012-07-05 Thread Chris Angelico
On Thu, Jul 5, 2012 at 8:29 PM, Olive wrote: > I am creating a new class: package (to analyse the packages database in > some linux distros). I have created a class package such that > package("string") give me an instance of package if string is a correct > representation of a package. I would li

Creating an instance when the argument is already an instance.

2012-07-05 Thread Olive
I am learning python -:) I am creating a new class: package (to analyse the packages database in some linux distros). I have created a class package such that package("string") give me an instance of package if string is a correct representation of a package. I would like that if pack is already a

Re: adding a simulation mode

2012-07-05 Thread andrea crotti
2012/7/5 Dieter Maurer : > > There is a paradigm called "inversion of control" which can be used > to handle those requirements. > > With "inversion of control", the components interact on the bases > of interfaces. The components themselves do not know each other, they > know only the interfaces t

Re: Which way is best to execute a Python script in Excel?

2012-07-05 Thread Thomas Jollans
On 07/05/2012 09:26 AM, Karim wrote: > Look at PyUNO from OpenOffice very large API: > http://www.openoffice.org/api/docs > > I use to create all my documention (Excell, Writer, etc...) on this API. Note that this API is for OpenOffice, not Microsoft Excel. However, as you probably know, you can

Re: Question about weakref

2012-07-05 Thread Dieter Maurer
Frank Millman writes: > I have a situation where I thought using weakrefs would save me a bit > of effort. Instead of the low level "weakref", you might use a "WeakKeyDictionary". -- http://mail.python.org/mailman/listinfo/python-list

Re: adding a simulation mode

2012-07-05 Thread Dieter Maurer
andrea crotti writes: > I'm writing a program which has to interact with many external > resources, at least: > - mysql database > - perforce > - shared mounts > - files on disk > > And the logic is quite complex, because there are many possible paths to > follow depending on some other parameter

Re: Using a CMS for small site?

2012-07-05 Thread Dieter Maurer
Gilles writes: > The site is just... > - a few web pages that include text (in four languages) and pictures > displayed in a Flash slide show > - a calendar to show availability > - a form to send e-mail with anti-SPAM support > - (ASAP) online payment > > Out of curiosity, are there CMS/framewor

Re: Discussion on some Code Issues

2012-07-05 Thread Peter Otten
subhabangal...@gmail.com wrote: > On Thursday, July 5, 2012 4:51:46 AM UTC+5:30, (unknown) wrote: >> Dear Group, >> >> I am Sri Subhabrata Banerjee trying to write from Gurgaon, India to >> discuss some coding issues. If any one of this learned room can shower >> some light I would be helpful eno

Re: Which way is best to execute a Python script in Excel?

2012-07-05 Thread Karim
Le 05/07/2012 09:22, Maurizio Spadaccino a écrit : Hi all I'm new to Python but soon after a few days of studying its features I find it my favourite mean of programming scripts to allow for data storing and mining. My idea would be to inplement python scripts from inside an excel sheet that

Which way is best to execute a Python script in Excel?

2012-07-05 Thread Maurizio Spadaccino
Hi all I'm new to Python but soon after a few days of studying its features I find it my favourite mean of programming scripts to allow for data storing and mining. My idea would be to inplement python scripts from inside an excel sheet that would store and fetch data from a Mysql database. So i n