Re: 2 daemons write to a single file /w python file IO

2007-09-11 Thread Evan Klitzke
On Tue, 2007-09-11 at 21:17 -0700, Andrey wrote:
> HI
> 
> i have a newbie question about the file() function.
> I have 2 daemons running on my linux box.
> 
> 1 will record the IDs to a file - logs.txt
> other 1 will open this file, read the IDs, and then "Clean up the 
> file" -logs.txt
> 
> Since these 2 daemons will run every 2-5mins, I think this will crash, isn't 
> it? When both daemons try to write to the file at the same time.

They will not crash. If you're writing a small amount of data using
os.write (e.g. a line or two at a time), the writes will probably end up
being atomic, and you don't have to worry about anything. This isn't
guaranteed of course, but if you're not writing out large buffers you
probably don't need to worry about it at all. The worst case scenario is
that the writes will be interleaved (e.g. daemon 1 writes "foo", daemon
2 writes "bar", and what ends up in the file is something like
"fbaroo"), there is not danger of crashing. The regular write method of
file objects is buffered, so I'd imagine that is more likely to have
this problem.

> I am wondering if this won't crash, OR if there is some simple high-level 
> functions can lock the file while writing...

There is a standard syscall in POSIX system that does real file locking
-- it's called flock. You can access it using the fcntl module as
fcntl.flock. The man page for flock has more details.

Basically what you need to do is call fcntl.flock before writing to the
file in each of your processes. The process will block until the lock is
released. On Linux the lock will be advisory only, so if you don't use
flock everywhere you can still have multiple processes with the file
descriptor open and writable at once.

> I also wonder if one side locked the file, what happens if the other side 
> try to open this locked file? raise error? so i also need to write a loop to 
> wait for the file to release locking?

The flock call will block if the file is already locked.

-- 
Evan Klitzke <[EMAIL PROTECTED]>

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


Re: Minor documentation bug

2007-09-11 Thread Frank Millman
On Sep 11, 4:55 pm, Tim Golden <[EMAIL PROTECTED]> wrote:
> Frank Millman wrote:
> > I spotted a minor bug in the documentation to SimpleXMLRPCServer. It
> > does not seem worth getting a login to the bugtracker just to enter
> > this, so if it is confirmed as a bug perhaps someone would be so kind
> > as to enter it for me.
>
> Frank, please do take the trouble to enter this. With the
> new roundup bugtracker, it's *really easy* to get a login.
>
> http://bugs.python.org
>
> TJG

You are right - it was pretty easy. I have entered the report.

Thanks, Tim

Frank


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


Re: Get the complete command line as-is

2007-09-11 Thread TheFlyingDutchman

>
> python.exe test.py  "\"abc def\" 123"
>
> import sys
> commandLine = "".join(sys.argv[1:])
>
> print commandLine
>
> gives:
>
> "abc def" 123

With the surrounding quotes you actually only need:

commandLine = sys.argv[1]

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


Re: Get the complete command line as-is

2007-09-11 Thread TheFlyingDutchman

>
> It seems that \" will retain the quote marks but then the spaces get
> gobbled.
>
> But if you replace the spaces with another character:
>
> python.exe test.py  \"abc#def\"#123
>
> then:
>
> import sys
> commandLine = "".join(sys.argv[1:])
>
> prints commandLine.replace('#',' ')
>
> gives:
>
> "abc def" 123
>
> Don't know if you can use that technique or not.

Came back for a second try and found out that:

python.exe test.py  "\"abc def\" 123"

import sys
commandLine = "".join(sys.argv[1:])

print commandLine

gives:

"abc def" 123

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


Re: Get the complete command line as-is

2007-09-11 Thread TheFlyingDutchman
On Sep 11, 8:33 pm, TheFlyingDutchman <[EMAIL PROTECTED]> wrote:
> On Sep 11, 8:00 pm, wangzq <[EMAIL PROTECTED]> wrote:
>
> > Hello,
>
> > I'm passing command line parameters to my browser, I need to pass the
> > complete command line as-is, for example:
>
> > test.py "abc def" xyz
>
> > If I use ' '.join(sys.argv[1:]), then the double quotes around "abc
> > def" is gone, but I need to pass the complete command line ("abc def"
> > xyz) to the browser, how can I do this?
>
> > I'm on Windows.
>
> > Thanks.
>
> I'm on Solaris and this works for me:
>
> test.py '"abc def" xyz'
>
> print sys.arv[1]
>
> "abc def" xyz

OK, now I'm on Windows XP and things aren't looking too good.

It seems that \" will retain the quote marks but then the spaces get
gobbled.

But if you replace the spaces with another character:

python.exe test.py  \"abc#def\"#123

then:

import sys
commandLine = "".join(sys.argv[1:])

prints commandLine.replace('#',' ')

gives:

"abc def" 123

Don't know if you can use that technique or not.

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


Re: Python 3K or Python 2.9?

2007-09-11 Thread Graham Dumpleton
On Sep 12, 2:14 pm, Ben Finney <[EMAIL PROTECTED]>
wrote:
> Paul Rubin  writes:
> > TheFlyingDutchman <[EMAIL PROTECTED]> writes:
> > > Python user and advocate Bruce Eckel is disappointed with the
> > > additions (or lack of additions) in Python 3:
>
> > >http://www.artima.com/weblogs/viewpost.jsp?thread=214112
>
> > That article is pretty weak.
>
> It is responded to by Guido here:
>
>"A Response to Bruce Eckel"
> http://www.artima.com/weblogs/viewpost.jsp?thread=214325>

In that blog, Guido says:

"""Concurrency: It seems we're now happily out exploring here. I'm
looking forward to benchmarks showing that PP or similar (or
dissimilar!) solutions actually provide a performance gain. Another
route I'd like to see explored is integrating one such solution into
an existing web framework (or perhaps as WSGI middleware) so that web
applications have an easy way out without redesigning their
architecture."""

Maybe I don't fully understand where Guido is coming from, but
solutions for spreading web applications across multiple processes
have been available for a long time in solutions such as mod_python
and mod_fastcgi. With a view to improving further on these solutions
mod_wsgi has also been created.

All these solutions either use the multi process nature of the web
server, or themselves use multiple daemon processes to which requests
are distributed by Apache. End result is that one can make better use
of multi processor or multi core machines. Also, when using multi
threaded Apache worker MPM, because a lot of stuff is not even done in
Python code, such as static file serving, multiple cores can even be
used within the same process. Thus, in the larger context of how
Apache is implemented and what web applications provide, the GIL isn't
as big a problem as some like to believe it is as far as preventing
proper utilisation of the machines resources.

FWIW, I have blogged my own response to Guido's comment above at:

http://blog.dscpl.com.au/2007/09/parallel-python-discussion-and-modwsgi.html

Now over the years I have seen a lot of Python developers showing
quite a dislike for using Python integrated with Apache. As a result
the last thing people seem to want to do is fix such solutions up and
make them work better. Reality is though that unless a very good
solution for hosting Python with Apache comes up, you will probably
never see good cheap commodity web hosting for Python. Older solutions
simply aren't safe to use or are hard to set up and manage.

Creating lots of distinct Python processes and proxying to them, like
the purists would like to see, simply isn't going to happen as such
setups are too hard to manage and use up too much resources on a large
scale. Web hosting companies want something simple which they can
integrate into their existing PHP focused Apache installations and
which don't chew up huge amounts of additional resources, thereby
forcing a reduction in their site densities. To that end, we still
have a way to go.

An older blog entry of mine where I have covered these problems is:

http://blog.dscpl.com.au/2007/07/commodity-shared-hosting-and-modwsgi.html

Graham


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


Re: Basic GUI

2007-09-11 Thread Michele Simionato
On Sep 11, 11:54 pm, Don Hanlen <[EMAIL PROTECTED]> wrote:
> I could solve my problems with the following psuedo-code made into
> real code:
> 
> import blah
>
> t = blah.fork(runthisprogram.py)
>
> #OK still in main
> t.sendinfo(info)
> info = t.receiveinfo()
> 
> #runthisprogram.py
> def sendinfobacktopapa():
> ? eventhere
> def getinfofrompapa():
> ? eventhere
> 
>
> It seems to me that propagating events *may* be the best way to
> communicate.  I'm wide open, including to non-multi-process solutions.
>
> Thanks for your comments, I searched old posts for a while, various
> other Python info-sources, and couldn't find an answer.
> --
> don

Have a look at the 'processing' module.

Michele Simionato

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


Generating HTML

2007-09-11 Thread Sebastian Bassi
Hello,

What are people using these days to generate HTML? I still use
HTMLgen, but I want to know if there are new options. I don't
want/need a web-framework a la Zope, just want to produce valid HTML
from Python.
Best,
SB.

-- 
Sebastián Bassi (セバスティアン). Diplomado en Ciencia y Tecnología.
Curso Biologia molecular para programadores: http://tinyurl.com/2vv8w6
GPG Fingerprint: 9470 0980 620D ABFC BE63 A4A4 A3DE C97D 8422 D43D
-- 
http://mail.python.org/mailman/listinfo/python-list

2 daemons write to a single file /w python file IO

2007-09-11 Thread Andrey
HI

i have a newbie question about the file() function.
I have 2 daemons running on my linux box.

1 will record the IDs to a file - logs.txt
other 1 will open this file, read the IDs, and then "Clean up the 
file" -logs.txt

Since these 2 daemons will run every 2-5mins, I think this will crash, isn't 
it? When both daemons try to write to the file at the same time.

I am wondering if this won't crash, OR if there is some simple high-level 
functions can lock the file while writing...
I also wonder if one side locked the file, what happens if the other side 
try to open this locked file? raise error? so i also need to write a loop to 
wait for the file to release locking?

seems a basic easy thing but i just cannot find an simple answer.
I always advoid this issue by putting them in mysql (well, fast and hassle 
free for locking)

Thanks
Jay



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


Re: Python 3K or Python 2.9?

2007-09-11 Thread Ben Finney
Paul Rubin  writes:

> TheFlyingDutchman <[EMAIL PROTECTED]> writes:
> > Python user and advocate Bruce Eckel is disappointed with the
> > additions (or lack of additions) in Python 3:
> > 
> > http://www.artima.com/weblogs/viewpost.jsp?thread=214112
> 
> That article is pretty weak.

It is responded to by Guido here:

   "A Response to Bruce Eckel"
http://www.artima.com/weblogs/viewpost.jsp?thread=214325>

-- 
 \  "The trouble with eating Italian food is that five or six days |
  `\ later you're hungry again."  -- George Miller |
_o__)  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Basic GUI

2007-09-11 Thread Don Hanlen
I'm writing a simple GUI that:
..gets info via telnet protocol (and sends)
..gets info via http (and sends)
..gets user-info from (currently)
...Tkinter Text windoze
...Tkinter buttons and such
..displays info in various Tkinter windoze
...graphic AND text...

I can accomplish all of these functions individually and now seem to
need to set up multi-processes to combine 'em.  Back in my C days, I'd
have used fork/exec to do so, but I'm confused by the number of
modules available in Python.  Is there a "best" for portability and
simplicity?  (Or am I on the wrong track here?)

I could solve my problems with the following psuedo-code made into
real code:

import blah

t = blah.fork(runthisprogram.py)

#OK still in main
t.sendinfo(info)
info = t.receiveinfo()

#runthisprogram.py
def sendinfobacktopapa():
? eventhere
def getinfofrompapa():
? eventhere


It seems to me that propagating events *may* be the best way to
communicate.  I'm wide open, including to non-multi-process solutions.

Thanks for your comments, I searched old posts for a while, various
other Python info-sources, and couldn't find an answer.
--
don

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


Re: Python 3K or Python 2.9?

2007-09-11 Thread Paul Rubin
TheFlyingDutchman <[EMAIL PROTECTED]> writes:
> Python user and advocate Bruce Eckel is disappointed with the
> additions (or lack of additions) in Python 3:
> 
> http://www.artima.com/weblogs/viewpost.jsp?thread=214112

That article is pretty weak.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: need scsh in a wikip article

2007-09-11 Thread Xah Lee
On Sep 11, Xah Lee wrote:
i was browsinghttp://en.wikipedia.org/wiki/Comparison_of_computer_shells

quite fucking ridiculous that it contains Python shell and Ruby shell,
and, there's no mentioning of scsh.

Fuck the schemer morons.

someone please add scsh there.

--

2007-09-11, Addendum:

It should be noted, that “Python shell” and “Ruby shell” should be
removed from that page. Because, these are not command line interfaces
to a OS.

While, scsh, is designed, to be a shell in the traditional sense of
being a command line interface to OS (unixes).

Also note, from the perspective of sociology, that the fact Python and
Ruby langs are added to that page, is a indication of the
motherfucking computer language fanatism at play. If we were to
condone or further this enthusiasm, i suggest Commond Lispers, and
Emacs lispers, also added a CL Shell and Emacs Lisp shell to that
page, since for all practical purposes, these langs provide the same
interactive facilities as Python and Ruby. Also, Haskell enthus should
add Haskell shell there too.

Also note, such fanatical bias are exhibited in severe degrees in
respective language's articles in wikipedia, in particular: the
article on Python and Perl. (and undoubtly others too in various
degrees but these 2 in particular i personally know well) To actually
fix these articles to rid of bias, marketing, fanatism, is nigh
impossible due to the nature of wikipedia and the army of respective
lang's advocates. The inaccuracy and warring nature, is analogous to
controversial articles on wikip, and perhaps it would fix itself over
the years as wikipedia have matured in incredible ways in the mere few
years in the past. However, the article on comparison of shell as
cited in the above, could probably be fixed now without reaching a
impasse or war, since the article contains multitudes of shells/langs
(thus in not horded by one exclusive army faction), and the factual
error of Python/Ruby there is relatively plain.

  Xah
  [EMAIL PROTECTED]
∑ http://xahlee.org/

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

Re: Get the complete command line as-is

2007-09-11 Thread TheFlyingDutchman
On Sep 11, 8:00 pm, wangzq <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I'm passing command line parameters to my browser, I need to pass the
> complete command line as-is, for example:
>
> test.py "abc def" xyz
>
> If I use ' '.join(sys.argv[1:]), then the double quotes around "abc
> def" is gone, but I need to pass the complete command line ("abc def"
> xyz) to the browser, how can I do this?
>
> I'm on Windows.
>
> Thanks.

I'm on Solaris and this works for me:

test.py '"abc def" xyz'



print sys.arv[1]

"abc def" xyz

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


Python 3K or Python 2.9?

2007-09-11 Thread TheFlyingDutchman
Python user and advocate Bruce Eckel is disappointed with the
additions (or lack of additions) in Python 3:

http://www.artima.com/weblogs/viewpost.jsp?thread=214112

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


Re: Get the complete command line as-is

2007-09-11 Thread Steve Holden
wangzq wrote:
> Hello,
> 
> I'm passing command line parameters to my browser, I need to pass the
> complete command line as-is, for example:
> 
> test.py "abc def" xyz
> 
> If I use ' '.join(sys.argv[1:]), then the double quotes around "abc
> def" is gone, but I need to pass the complete command line ("abc def"
> xyz) to the browser, how can I do this?
> 
> I'm on Windows.
> 
> Thanks.
> 
You can't. The quotes are gobbled  by the command-line processor before 
your program ever gets the chance to see them. You could try writing 
your own command shell ... or learn how to quote the quotes.

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden
--- Asciimercial --
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
--- Thank You for Reading -

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


Re: function to do dynamic import?

2007-09-11 Thread Steve Holden
bambam wrote:
[...]
> def gim(self):
> for gamel in self.gamel_list:
> __import__(gamel['file'])
> 
> Works as hoped for. I did a web search for 'dynamic import' and
> the only examples I found used exec.
> 
> Thanks
> 
Cool. You're getting there!

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden
--- Asciimercial --
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
--- Thank You for Reading -

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


Re: "Variable variable name" or "variable lvalue"

2007-09-11 Thread Roberto Bonvallet
On Aug 15, 4:19 pm, Peter Otten <[EMAIL PROTECTED]> wrote:
> If you want to simplify things somewhat you can merge the two loops into
> one:
>
> numbers = [12.5, 25, 12.5]
> accu = Material(numbers[0])
> for x in numbers[1:]:
> accu += Material(x)
> period = Slab(accu)

Better to use the `sum' builtin and a generator expression:

period = Slab(sum(Material(x)) for x in numbers)

--
Roberto Bonvallet

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


Get the complete command line as-is

2007-09-11 Thread wangzq
Hello,

I'm passing command line parameters to my browser, I need to pass the
complete command line as-is, for example:

test.py "abc def" xyz

If I use ' '.join(sys.argv[1:]), then the double quotes around "abc
def" is gone, but I need to pass the complete command line ("abc def"
xyz) to the browser, how can I do this?

I'm on Windows.

Thanks.

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


Re: function to do dynamic import?

2007-09-11 Thread bambam

"Steve Holden" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> bambam wrote:
>> import works in the main section of the module, but does
>> not work as I hoped when run inside a function.
>>
>> That is, the modules import correctly, but are not visible to
>> the enclosing (global) scope.
>>
>> Questions:
>> (1) Where can I read an explanation of this?
>> (2) Is there a work around?
>>
>> BTW, sys.modules("filename") shows that the module is
>> loaded, I just don't know how to use it when loaded that
>> way.  Also, if I import again at the global scope, the module
>> name becomes available.
>>
> There's not much wrong with doing this, since it gives you the best of 
> both worlds. But you mean sys.modules["filename"], don't you?
>
> def gim():
>> ... exec "import gamel"
>> ...
> gim()
> sys.modules["gamel"]
>> 
> gamel
>> NameError: name 'gamel' is not defined
> exec "import gamel"
> gamel
>> 
> Whoa there! There's a lot of difference between "importing a module inside 
> a function" and "executing an import statement inside a function".
>
> If you want to do dynamic imports then the __import__ function is what you 
> need. Trying to use exec like that is a bad idea unless you clearly 
> understand the relationship between the different namespaces involved. In 
> fact, trying to use exec at all is a bad idea until you understand Python 
> better, and even then it's not often a terrific idea.
>
> Think of exec more as a hack of last resort than the first tool to reach 
> for to solve a problem.
>
> regards
>  Steve
> -- 
> Steve Holden+1 571 484 6266   +1 800 494 3119
> Holden Web LLC/Ltd   http://www.holdenweb.com
> Skype: holdenweb  http://del.icio.us/steve.holden
> --- Asciimercial --
> Get on the web: Blog, lens and tag the Internet
> Many services currently offer free registration
> --- Thank You for Reading -
>

Yes, sys.modules["filename"], unfortunately, same mistake
made already 4 or 5 times before I typed this, and still hadn't
learned...many years working in an environment where the
distinction was not important. Sorry.

def gim(self):
for gamel in self.gamel_list:
__import__(gamel['file'])

Works as hoped for. I did a web search for 'dynamic import' and
the only examples I found used exec.

Thanks

Steve. 


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


Get Only the Last Items in a Traceback

2007-09-11 Thread [EMAIL PROTECTED]
I'm running code via the "exec in context" statement within a much
larger program.  What I would like to do is capture any possible
errors and show a pretty traceback just like the Python interactive
interpreter does, but only show the part of the traceback relating to
the code sent to exec.

For example here is the code I'm using:

try:
exec code
except Exception,Err:
traceback.print_exc()

Which gives me something like this when it catches an exception:

Traceback (most recent call last):
  File "/py", line 843, in run
semi_safe_exec.safe_eval(code.replace('\r',''),context,5)
  File ".py", line 400, in safe_eval
exec_timed(code, context, timeout_secs)
  File ".py", line 353, in exec_timed
exec code in context
  File "", line 7, in ?
  File "", line 5, in func2
  File "", line 2, in func1
ZeroDivisionError: integer division or modulo by zero

What I want to print instead is just something like:

Traceback (most recent call last):
  File "", line 7, in ?
  File "", line 5, in func2
  File "", line 2, in func1
ZeroDivisionError: integer division or modulo by zero

Thanks in advance for the help.

-Greg

P.S. if it matters, for this example, code in exec code is:

def func1():
print 7/0

def func2():
func1()

func2()

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


Re: function to do dynamic import?

2007-09-11 Thread bambam

"J. Cliff Dyer" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> bambam wrote:
>> import works in the main section of the module, but does
>> not work as I hoped when run inside a function.
>>
>> That is, the modules import correctly, but are not visible to
>> the enclosing (global) scope.
>>
>> Questions:
>> (1) Where can I read an explanation of this?
>> (2) Is there a work around?
>>
>> BTW, sys.modules("filename") shows that the module is
>> loaded, I just don't know how to use it when loaded that
>> way.  Also, if I import again at the global scope, the module
>> name becomes available.
>>
>> Steve.
>>
>> ---
>>
> def gim():
>
>> ... exec "import gamel"
>> ...
>>
> All you have done in this function is bind the module to the name gamel
> within the scope of the function.  As soon as the function exits, the
> module goes out of scope.  If you want to use it externally, return the
> module.
>
> def: gim():
>import gamel
>return gamel
> gim()
>
> This will have to change to
>
> gamel = gim()
>
> and the rest should work as expected.
> sys.modules["gamel"]
>
>> 
>>
> gamel
>
>> NameError: name 'gamel' is not defined
>>
> exec "import gamel"
> gamel
>
>> 
>>
>>
>>
>

 def: gim():
import gamel
return gamel

Unfortunately, it needs to do dynamic import: I can't list
all of the possible import modules because they are unknown
until runtime.

Steve. 


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


Re: function to do dynamic import?

2007-09-11 Thread bambam

<[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> On Sep 10, 10:52 pm, "bambam" <[EMAIL PROTECTED]> wrote:
>> import works in the main section of the module, but does
>> not work as I hoped when run inside a function.
>>
>> That is, the modules import correctly, but are not visible to
>> the enclosing (global) scope.
>>
>> Questions:
>> (1) Where can I read an explanation of this?
>> (2) Is there a work around?
>>
>> BTW, sys.modules("filename") shows that the module is
>> loaded, I just don't know how to use it when loaded that
>> way.  Also, if I import again at the global scope, the module
>> name becomes available.
>>
>> Steve.
>
>
>
> (snipped)
>
> This was recently discussed:
>
>http://groups.google.com/group/comp.lang.python/msg/f6fcdf49710cb833
>
> --
> Hope this helps,
> Steven
>

def gim():
exec "global gamel"
exec "import gamel"

Unfortunately, does not have the desired effect.
Steve.


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


Re: cpython list __str__ method for floats

2007-09-11 Thread [david]
Bjoern Schliessmann wrote:
> [david] wrote:
>> returns poorly formatted values:
> 
> Please explain.
> 
>>  >>>str(13.3)
>> '13.3'
>>  >>>str([13.3])
>> '[13.301]'
> 
> This is quite a FAQ.
> 
> str of a float returns the float, rounded to decimal precision.
> 
> str of a list returns a square brackets enclosed enumeration of the
> contents (using repr on them). repr of a float returns the float in
> full precision.
> 
> Regards,
> 
> 
> Björn
> 

 > contents (using repr on them). repr of a float returns the float in
 > full precision.

But of course it doesn't, as illustrated, which is the whole point.

It returns a string at greater than full precision.

Leaving aside the question of why str should return repr,
13.301 is not 'the float in full precision':
it is an arbitrary translation of the float.

The idea that 13.3 is a 'rounded' value for the number,
and that 13.301 is not a 'rounded' value of
the number, is a common error of intuitive mathematics.

I hope that when you say that this is a FAQ, you don't
mean that the community has solidified on this naive
interpretation :~)


[david]


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


Re: "Variable variable name" or "variable lvalue"

2007-09-11 Thread inmmike
On Aug 19, 1:10 pm, Gary Herron <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > On Aug 15, 1:42 pm, mfglinux <[EMAIL PROTECTED]> wrote:
>
> >> Hello to everybody
>
> >> I would like to know how to declare in python a "variable name" that
> >> it is in turn a variable
> >> In bash shell I would wrote sthg like:
>
> >> for x in `seq 1 3`
> >> do
> >>   M$i=Material(x)  #Material is a python class
> >> done
>
> >> Why I need this? Cause I have a python module that obliges me to build
> >> a variable called Period, which should have a variable name of
> >> summands (depends on the value of x)
>
> >> #Let's say x=3, then Period definition is
> >> Period=Slab(Material1(12.5)+Material2(25)+Material3(12.5)) #Slab is a
> >> python class
>
> >> I dont know how to automatize last piece of code for any x
>
> >> thank you
>
> >> Marcos
>
> > Regardless of whether or not this is a "best practice" sometimes it is
> > necessary. For example, I am looping through a dictionary to set some
> > class properties. Anyway, here is what I finally came up with:
>
> > exec "self.%s = '%s'" % (item, plist[item])
>
> Yuck!  Not at all necessary.  Use setattr instead:
>
>setattr(self, item, plist[item])
>
> That's much cleaner then an exec or eval.  You may also find getattr and
> hasattr useful.
>
> Gary Herron
>
> > A more simple example for setting a variable outside of a class...
>
> > exec '%s = '%s'" % ('variableName', 'variable value')
>
> > Cheers!
> > Mike

Thanks! I'm still getting used to Python's nifty features.

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


Re: python 2.5 problems

2007-09-11 Thread Brian
Was not specific about my process. Yes, I did use the 
'formal' windoze uninstall using Add/Remove Programs.

I ran the same code and idle at work (XP Pro/SP2/Python 
2.4) with no problems. My next step is to install 
python 2.5 at work.

My Linux partition has Python 2.4, and I do not use 
idle on Linux, so the test would probably not be legit.

any ideas/suggestions ???

Ant wrote:
> On Sep 9, 6:57 pm, "O.R.Senthil Kumaran" <[EMAIL PROTECTED]> wrote:
>>> Finally deleted 2.2 and loaded 2.5 (see below), using
>> Dont delete. Uninstall python 2.2 and additional modules if you have 
>> installed them.
> 
> But since you've already deleted 2.2, download and reinstall 2.2,
> uninstall 2.2 and 2.5 via Add/Remove Programs and then reinstall 2.5
> again.
> 
> --
> Ant...
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: wx module?

2007-09-11 Thread Dotan Cohen
False alarm, found it, sorry...
-- 
http://mail.python.org/mailman/listinfo/python-list


wx module?

2007-09-11 Thread Dotan Cohen
Where can I find a wx module for Python? I'm trying to run taskcoach,
but I cannot find this package. Thanks.

[EMAIL PROTECTED]:~/Desktop/todo-manager-0.75.1/todo-manager-0.75.1$
taskcoach.py
Traceback (most recent call last):
  File "/usr/bin/taskcoach.py", line 24, in 
import wx
ImportError: No module named wx
[EMAIL PROTECTED]:~/Desktop/todo-manager-0.75.1/todo-manager-0.75.1$


Dotan Cohen

http://what-is-what.com
http://gibberish.co.il
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Difference between two times (working ugly code, needs polish)

2007-09-11 Thread Shawn Milochik
>
> I suppose really oneDay should be a global (i.e. outside the function
> definition). Apart from that it would be hard to improve on: obvious,
> easy to read, in short - pythonic.
>
> Are you concerned about daylight savings? That could certainly introduce
> a whole new level of complexity into the problem. Let's hope not ...

I'm not concerned with DST; this is a script which checks my Ebay
auctions (I have some things for sale), and sends me e-mail whenever
someone bids. It's run by cron every half hour -- it keeps me from
compulsively checking my auctions. ^_^

In any case, DST isn't an issue because the same machine generates
both timestamps, and all I use it for is to stop displaying auctions
after they are 10 days old, so I don't get all my old crap filling up
the alert e-mail or skewing the total dollar amount for all active
auctions.

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


Re: Help With PyParsing of output from win32pdhutil.ShowAllProcesses()

2007-09-11 Thread Steve
Hi All,

I did a lot of digging into the code in the module, win32pdhutil, and
decided to create some custom methods.


added to : import win32pdhutil



def ShowAllProcessesAsList():

object = find_pdh_counter_localized_name("Process")
items, instances =
win32pdh.EnumObjectItems(None,None,object,win32pdh.PERF_DETAIL_WIZARD)

# Need to track multiple instances of the same name.
instance_dict = {}
all_process_dict = {}

for instance in instances:
try:
instance_dict[instance] = instance_dict[instance] + 1
except KeyError:
instance_dict[instance] = 0

# Bit of a hack to get useful info.

items = [find_pdh_counter_localized_name("ID Process")] + items[:
5]
#print items
#print "Process Name", string.join(items,",")

all_process_dict['Headings'] = items# add
headings to dict

for instance, max_instances in instance_dict.items():

for inum in xrange(max_instances+1):
hq = win32pdh.OpenQuery()
hcs = []
row = []

for item in items:
path =
win32pdh.MakeCounterPath( (None,object,instance,None, inum, item) )
hcs.append(win32pdh.AddCounter(hq, path))

win32pdh.CollectQueryData(hq)
# as per 
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q262938,
some "%" based
# counters need two collections
time.sleep(0.01)
win32pdh.CollectQueryData(hq)
#print "%-15s\t" % (instance[:15]),

row.append(instance[:15])

for hc in hcs:
type, val = win32pdh.GetFormattedCounterValue(hc,
win32pdh.PDH_FMT_LONG)
#print "item : %5d" % (val),
row.append(val)
win32pdh.RemoveCounter(hc)

#print
#print ' row = ', instance ,row
all_process_dict[instance] = row# add
current row to dict

win32pdh.CloseQuery(hq)

return all_process_dict


def ShowSingleProcessAsList(sProcessName):

object = find_pdh_counter_localized_name("Process")
items, instances =
win32pdh.EnumObjectItems(None,None,object,win32pdh.PERF_DETAIL_WIZARD)

# Need to track multiple instances of the same name.
instance_dict = {}
all_process_dict = {}

for instance in instances:
try:
instance_dict[instance] = instance_dict[instance] + 1
except KeyError:
instance_dict[instance] = 0

# Bit of a hack to get useful info.

items = [find_pdh_counter_localized_name("ID Process")] + items[:
5]
#print items
#print "Process Name", string.join(items,",")

#all_process_dict['Headings'] = items# add
headings to dict

#print 'instance dict = ', instance_dict
#print

if sProcessName in instance_dict:
instance = sProcessName
max_instances = instance_dict[sProcessName]
#print sProcessName, '  max_instances = ', max_instances

for inum in xrange(max_instances+1):
hq = win32pdh.OpenQuery()
hcs = []
row = []

for item in items:
path =
win32pdh.MakeCounterPath( (None,object,instance,None, inum, item) )
hcs.append(win32pdh.AddCounter(hq, path))

try:
  win32pdh.CollectQueryData(hq)
except:
  all_process_dict[sProcessName] =
[0,0,0,0,0,0,0]  # process not found - set to all zeros
  break

# as per 
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q262938,
some "%" based
# counters need two collections
time.sleep(0.01)
win32pdh.CollectQueryData(hq)
#print "%-15s\t" % (instance[:15]),

row.append(instance[:15])

for hc in hcs:
type, val = win32pdh.GetFormattedCounterValue(hc,
win32pdh.PDH_FMT_LONG)
#print "item : %5d" % (val),
row.append(val)
win32pdh.RemoveCounter(hc)

#print
#print ' row = ', instance ,row
all_process_dict[instance] = row# add
current row to dict

win32pdh.CloseQuery(hq)
else:
  all_process_dict[sProcessName] = [0,0,0,0,0,0,0]  #
process not found - set to all zeros

return all_process_dict

=

Demo :

import win32pdhutil  # with customized methods in win32pdhutil
(above)


###
#  GetMemoryStats #
###

def GetMemoryStats(sProcessName, iPauseTime):

  Memory_Dict = {}

## Headings   ['ProcessName', '% Processor Time', '% User Time', '%
Privileged Time', 'Virtual Bytes Peak', 'Virtual Bytes']
##machine process  =  {'firefox': ['firefox',

Re: common/static code

2007-09-11 Thread Steve Holden
brien colwell wrote:
> hey all,
> 
> I have a slew of functions that are shared across several scripts. 
> What's the best way to factor them out into a single location?
> 
> many thanks
> 

Define the functions in a module (e.g. myModule.py) then import them as

from myModule inport fun1, fun2, fun3

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden
--- Asciimercial --
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
--- Thank You for Reading -
-- 
http://mail.python.org/mailman/listinfo/python-list


__getattr__ and static vs. instantiated

2007-09-11 Thread tvaughan
Hi,

Let's say I have:

class Persistable(object):

__attrs__ = {}

def __getattr__(self, name):
if name in self.__attrs__:
return self.__attrs__[name]['value']
else:
return Object.__getattr__(self, name)

def __setattr__(self, name, value):
if name in self.__attrs__:
self.__attrs__[name]['value'] = value
else:
Object.__setattr__(self, name, value)

And the I have:

class Person(Persistable):

__storm_table__ = 'person'

id = Int(primary=True)

__attrs__ = {
'name': {
'lang': 'en',
'value': Unicode(),
},
}

def __init__(self):
self.id = int(random.random() * 1000)

I can do this:

person = Person()
person.name = 'Jane Smith'

But I cannot do:

Person.name = 'Jane Smith'

or use Person.name in a Storm query like:

Person.name == 'Jane Smith'

__getattr__ is only called when using an instantiated class, and
never, it seems, in a static case. Why? How do I work around this?
Thanks.

-Tom

P.S. This is Python 2.5 on Ubuntu Feisty x86.

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


Re: How to insert in a string @ a index

2007-09-11 Thread Karthik Gurusamy
On Sep 8, 11:02 am, [EMAIL PROTECTED] wrote:
> Hi;
>
> I'm trying to insert XYZ before a keyword in a string. The first and
> the last occurence of hello in the string t1 (t1="hello world hello.
> hello \nwhy world hello") are keywords. So after the insertion of XYZ
> in this string, the result should be t1 = "XYZhello world hello. hello
> \nwhy world XYZhello"
>
> The python doesn't supports t1[keyword_index]="XYZhello" (string
> object assignment is not supported). How do I get to this problem? Any
> sugguestions?

Yet another solution using re

>>> t1 = 'hello world hello. hello. \nwhy world hello'

>>> import re
>>> l1 =  re.split('hello', t1)
>>> l1[0] = 'XYZ' + l1[0]
>>> l1[-2] += 'XYZ'
>>> 'hello'.join(l1)
'XYZhello world hello. hello. \nwhy world XYZhello'
>>>

If there are less than two 'hello', you'll get exception and needs
special handling.

Karthik

>
> -a.m.

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


Twisted Life version 1.0.0 (stable) released

2007-09-11 Thread Paul Reiners
Version 1.0.0 of Twisted Life has just been released. Twisted Life is
a video game that uses a variant of Conway's Life cellular automaton
as its universe.

In Twisted Life, you try to navigate to the center of the Twisted Life
universe without colliding into any of the malevolent, evil Life forms
circling the center.

I wrote this application as an entry to the PyWeek competition:

http://www.pyweek.org/

You can download Twisted Life from SourceForge.net:

http://sourceforge.net/projects/twisted-life/

Twisted Life is released under the GNU General Public License (GPL).

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


Re: Python Problem

2007-09-11 Thread Wiseman

 Hi,

OK - it works in WindowsXP.
I installed "enchant" on my SuSE 10.0 (using YAST). 
The enchant Suse package looks like a general Linux package, not a
Python specific.

Running the program in Python I am getting the same error message from
the line: "import enchant".

ImportError: No module named enchant

What am I missing?

 Thanks

 ((:-()  Meir


>Hi,
>
>The line:
>
>import enchant
>
>works perfectly OK when I call a Python progrma (sp.py) from IDLE
>(WInXP). When I try to run it ftom the command line (python sp.py) the
>response is:
>
>Traceback (most recent call last):
>   File "sp.py", line 3, in 
> import enchant
>ImportError: No module named enchant
>
>Searching my computer (the whole of drive c:\) I could not find ANY
>file called enchant.*.
>
>Does anyone know what is wrong?
>
>Thanks
>
>((:-()  Meir
>

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


common/static code

2007-09-11 Thread brien colwell
hey all,

I have a slew of functions that are shared across several scripts. What's
the best way to factor them out into a single location?

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

Re: Speed of Python

2007-09-11 Thread Dick Moores
At 09:42 AM 9/7/2007, wang frank wrote:
>Are there any way to speed it up?

How about psyco?

Dick Moores
XP, Python 2.5.1, editor is Ulipad


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


Re: Enum class with ToString functionality

2007-09-11 Thread Steven D'Aprano
On Mon, 10 Sep 2007 18:03:11 -0700, TheFlyingDutchman wrote:

>> I'd like to know if the Cheeseshop package 'enum' is useful to you. Any
>> constructive feedback would be appreciated.
>>
>> http://cheeseshop.python.org/pypi/enum/>
> 
> Looking at the documentation it looks excellent. But I don't understand
> the 0.4.2 version number, particularly when you refer to it as robust.

Perhaps Ben should have followed the usual practice of commercial, closed-
source software developers and started counting his version numbers at 
one instead of zero, miss a few releases, use randomly large increments 
occasionally, and ended up with a current version number of 2.7.1 for the 
exact same level of functionality.

Or he could have called it "Enum XP" (for "eXtra Programming" perhaps) or 
"Enum 2007". The next minor release could be "Enum 2008", and the next 
major update could be called "Enum Professional Capowie!!!".


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


Re: Need a KDE app, where to find a coder?

2007-09-11 Thread Dotan Cohen
On 11/09/2007, Diez B. Roggisch <[EMAIL PROTECTED]> wrote:
> Dotan Cohen schrieb:
> > I need an application, and I'd like it to be written in Python with QT
> > as I am a KDE user. I simply don't have the time to code it myself, as
> > I've been trying to find the time for half a year now.
> >
> > What are some reputable websites for finding Python coders? If anyone
> > on the list wants the job, this is what I need:
> >
> > I need a hierarchical list manager, similar to ListPro
> > (http://www.iliumsoft.com/site/lp/listpro.htm) which is the app that
> > I'm replacing. Specifically, I need the checkmark (boolen), item
> > (string), date, amount (int/100), and notes fields. As KDE is moving
> > to QT4 in December (with the release of KDE4) it would be best if the
> > app were coded with this in mind. As the application is for my own
> > personal use, I will try to maintain it with the little python that I
> > know, but I may need help along the way.
>
> There are a few places to ask - like guru.com.
>
> But you most probably will have to make a financial offer.
>
> Apart from that - do you know basket? It's integrated into kontact, and
> maybe does what you want.
>
> Diez

Thanks, I will look at guru.com. I have tried Basket, and found that
it is very difficult for me to use. It seems to cater to those who
find presentation more important that data structure. It does have
checkmark functions, but it is impossible to use in an efficient
manner.

Dotan Cohen

http://what-is-what.com
http://gibberish.co.il
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python.org mirror

2007-09-11 Thread Steve Holden
Stream Service || Mark Scholten wrote:
> Dear sir, madam,
>  
> Stream Service would be happy to provide a free mirror for python.org. 
> We also host nl.php.net for free and we are happy to support more 
> opensource websites with free hosting.
>  
> Could you inform me about the options to become an officiel python.org 
> mirror?
>  
You may or may not be aware that the main Python site is hosted in the 
Netherlands.

Many thanks for your offer, but we have in any case discontinued the 
addition of new mirrors. See item 14 in

   http://www.python.org/psf/records/board/minutes/2007-03-12/

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden
--- Asciimercial --
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
--- Thank You for Reading -
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python.org mirror

2007-09-11 Thread Stream Service || Mark Scholten
Hello,

Thank you for the information, I will also contact them.

With kind regards, Met vriendelijke groet,

Mark Scholten
Stream Service
Web: http://www.streamservice.nl/
E-mail: [EMAIL PROTECTED]
NOC: http://www.mynoc.eu/
NOC e-mail: [EMAIL PROTECTED]
Tel.: +31 (0)642 40 86 02
Fax: +31 (0)20 20 101 57
KVK: 08141074
BTW: NL104278274B01

Stream Service ondersteund de opensource gemeenschap met de gratis hosting 
van http://nl.php.net/ .
Stream Service is supporting the opensource community by hosting 
http://nl.php.net/ for free.
- Original Message - 
From: "Terry Reedy" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, September 11, 2007 11:42 PM
Subject: Re: Python.org mirror


> |Could you inform me about the options to become an officiel python.org
> mirror?
>
> The main python.org site maintainers do not necessarily read this
> group/list.
>
> If no response here, try [EMAIL PROTECTED]
>
>
>
> 

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


Re: Difference between two times (working ugly code, needs polish)

2007-09-11 Thread Steve Holden
Shawn Milochik wrote:
> On 9/11/07, Grant Edwards <[EMAIL PROTECTED]> wrote:
>> On 2007-09-11, Shawn Milochik <[EMAIL PROTECTED]> wrote:
>>
>>> I have done what I wanted, but I think there must be a much better way.
>> See the strptime() function in either the time or the datetime
>> modules:
>>
>> http://docs.python.org/lib/module-time.html
>> http://docs.python.org/lib/module-datetime.html
>>
> 
> 
> Grant:
> 
> Thanks, this works, and is much shorter. Any further improvements, anyone?
> 
> def isOld(lastUpdate, runTimeStamp):
> 
>oneDay = 60 * 60 * 24
> 
>lastUpdate = time.mktime(time.strptime(lastUpdate, "%Y-%m-%d_%H:%M"))
>runTimeStamp = time.mktime(time.strptime(runTimeStamp, "%Y-%m-%d_%H:%M"))
> 
>return (runTimeStamp - lastUpdate) / oneDay

I suppose really oneDay should be a global (i.e. outside the function 
definition). Apart from that it would be hard to improve on: obvious, 
easy to read, in short - pythonic.

Are you concerned about daylight savings? That could certainly introduce 
a whole new level of complexity into the problem. Let's hope not ...


-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden
--- Asciimercial --
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
--- Thank You for Reading -

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


Re: Python Database Apps

2007-09-11 Thread Steve Holden
Harry George wrote:
> Tom Brown <[EMAIL PROTECTED]> writes:
> 
>> On Monday 10 September 2007 19:52, [EMAIL PROTECTED] wrote:
>>> Kindof a poll, kindof curiosity...
>>>
>>> What is your favorite python - database combination?  I'm looking to
>>> make an app that has a local DB and a server side DB.  I'm looking at
>>> python and sqlite local side and sql server side.
>>>
>>> Any suggestions
>> I have had a lot of good luck with PostgreSQL. It is easy to install and 
>> use. 
>> It is also very stable. It maybe overkill for a client side database. The 
>> psycopg package makes interfacing to PostgreSQL very easy and there is a 
>> package for Linux and Windows to make cross-platform development a breeze.
>>
>> -Tom
> 
> I use postgresql as well.  I wonder if Pythonistas do so out of
> concern for rigor, clarity, and scalability.  It works fine for a
> quick one-off effort and still works fine after scaling to a DBMS
> server supporting lots of clients, and running 10's of GBs of data.
> 
> If an app comes already designed for mysql, oracle, sqlite, db2, dbm,
> etc I'll use those.  But for my own projects, it is postgresql, with
> maybe SQLAlchemy (I'm back and forth on that.  Mostly stay with
> straight SQL).
> 
> Of course, as long as you write DBI2 compliant code, your app doesn't
> much care which DBMS you use.  The postgresql payoff is in admin
> functionality and scaling and full ACID.
> 
I also have a tendency to prefer PostgreSQL over MySQL, though I run and 
use both from time to time as an exercise in application portability.

Don't forget, there is absolutely no need to use the same database 
technology for the client-side and the central repository - sqlite is 
hard to beat for its simplicity and ease of installations on the client 
side, and you could look at PostgreSQL for the repository as and when 
that became a practical proposition.

regards
  Steve

-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden
--- Asciimercial --
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
--- Thank You for Reading -

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


Re: Python Database Apps

2007-09-11 Thread Harry George
Tom Brown <[EMAIL PROTECTED]> writes:

> On Monday 10 September 2007 19:52, [EMAIL PROTECTED] wrote:
>> Kindof a poll, kindof curiosity...
>>
>> What is your favorite python - database combination?  I'm looking to
>> make an app that has a local DB and a server side DB.  I'm looking at
>> python and sqlite local side and sql server side.
>>
>> Any suggestions
>
> I have had a lot of good luck with PostgreSQL. It is easy to install and use. 
> It is also very stable. It maybe overkill for a client side database. The 
> psycopg package makes interfacing to PostgreSQL very easy and there is a 
> package for Linux and Windows to make cross-platform development a breeze.
>
> -Tom

I use postgresql as well.  I wonder if Pythonistas do so out of
concern for rigor, clarity, and scalability.  It works fine for a
quick one-off effort and still works fine after scaling to a DBMS
server supporting lots of clients, and running 10's of GBs of data.

If an app comes already designed for mysql, oracle, sqlite, db2, dbm,
etc I'll use those.  But for my own projects, it is postgresql, with
maybe SQLAlchemy (I'm back and forth on that.  Mostly stay with
straight SQL).

Of course, as long as you write DBI2 compliant code, your app doesn't
much care which DBMS you use.  The postgresql payoff is in admin
functionality and scaling and full ACID.

-- 
Harry George
PLM Engineering Architecture
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python.org mirror

2007-09-11 Thread Terry Reedy
|Could you inform me about the options to become an officiel python.org 
mirror?

The main python.org site maintainers do not necessarily read this 
group/list.

If no response here, try [EMAIL PROTECTED]



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


Re: Python Database Apps

2007-09-11 Thread Bruno Desthuilliers
Tom Brown a écrit :
> On Monday 10 September 2007 19:52, [EMAIL PROTECTED] wrote:
> 
>>Kindof a poll, kindof curiosity...
>>
>>What is your favorite python - database combination?  I'm looking to
>>make an app that has a local DB and a server side DB.  I'm looking at
>>python and sqlite local side and sql server side.
>>
>>Any suggestions
> 
> 
> I have had a lot of good luck with PostgreSQL. It is easy to install and use. 

Well... For an experimented (or opiniated) Unix user, at least !-)

But I can only second : PgSql is probably one of the best free RDBMS 
around - one of my previous associates (and still friend !-), who has 
quite a few years of experience as an Oracle DBA, consider it (pg) as 
mostly as good as Oracle, and eventually better on some points. My own 
experience with Pg for web applications is that it JustWorks(tm) - never 
had a single problem with it. I wish I could say so about MySQL.

wrt/ sqlite, I've only used it for small web apps, and the only problem 
I had was a strange incompatibility bug with first PHP5 versions 
installed on the same machine. Since I doubt your users will have PHP5 
installed on the client machines (!), this should not be a problem.

And, while it may takes some time to learn, SQLAlchemy is a very great lib.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Database Apps

2007-09-11 Thread Ivo
[EMAIL PROTECTED] wrote:
> Kindof a poll, kindof curiosity...
> 
> What is your favorite python - database combination?  I'm looking to
> make an app that has a local DB and a server side DB.  I'm looking at
> python and sqlite local side and sql server side.
> 
> Any suggestions
> 
> Darien
> 
If you like to make a kind of stand alone app with a database, SQLite a 
good choice. It is easy to embed into your app. If you keep to ANSI SQL 
there should be no trouble changing databases at a later date.
I use SQLite for my WebSite http://IvoNet.nl and it performs great.
The whole database is less than 1Mb including the SQLite module for 
python. No 50Mb install needed if you just want a simple database.
It makes my website very portable and easy to install.

MySQL works great to. I have used it a lot and it is very available. 
Just about every provider can provide you one.

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


Re: Difference between two times (working ugly code, needs polish)

2007-09-11 Thread Shawn Milochik
On 9/11/07, Grant Edwards <[EMAIL PROTECTED]> wrote:
> On 2007-09-11, Shawn Milochik <[EMAIL PROTECTED]> wrote:
>
> > I have done what I wanted, but I think there must be a much better way.
>
> See the strptime() function in either the time or the datetime
> modules:
>
> http://docs.python.org/lib/module-time.html
> http://docs.python.org/lib/module-datetime.html
>


Grant:

Thanks, this works, and is much shorter. Any further improvements, anyone?

def isOld(lastUpdate, runTimeStamp):

   oneDay = 60 * 60 * 24

   lastUpdate = time.mktime(time.strptime(lastUpdate, "%Y-%m-%d_%H:%M"))
   runTimeStamp = time.mktime(time.strptime(runTimeStamp, "%Y-%m-%d_%H:%M"))

   return (runTimeStamp - lastUpdate) / oneDay
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Compiler Python

2007-09-11 Thread Bruno Desthuilliers
Bjoern Schliessmann a écrit :
> anton a wrote:
> 
>>Someone knows since as I can obtain the information detailed about
>>the compiler of Python? (Table of tokens, lists of productions of
>>the syntactic one , semantic restrictions...)
> 
> 
> I'm not really about the syntax of your question,

lol !-)


Sorry... Please don't take it as a personal offense (FWIW, my English is 
barely better than yours)

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


Re: Compiler Python

2007-09-11 Thread Martin v. Löwis
> Someone knows since as I can obtain the information detailed about the
> compiler of Python? (Table of tokens, lists of productions of the
> syntactic one , semantic restrictions...)

The EBNF grammar is in Grammar/Grammar; this also implies the list
of tokens. Another list of tokens in Include/token.h. The semantic
restrictions are mostly implemented as SyntaxError. These are
raised under various circumstances - search the code for SyntaxError,
for details.

Regards,
Martin
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Difference between two times (working ugly code, needs polish)

2007-09-11 Thread Bruno Desthuilliers
Shawn Milochik a écrit :
> I have done what I wanted, but I think there must be a much better way.
> 
> Given two timestamps in the following format, I just want to figure
> out how far apart they are (in days, seconds, whatever).
> 
> Format:
> 
> -MM-DD_MM:SS
> 
> Example:
> 2007-09-11_16:41
> 
> 
> It seems to me that to do what I want, I need to convert a string into
> a number (time.mktime()), such as this: 1189543487.0
> 
> Once I have that, I can just subtract one from the other and do
> whatever I want. The ugly part is converting something like
> 2007-09-11_16:41 to the numeric equivalent.
 >
> Below is my code. Any suggestions?

import time
print time.mktime(time.strptime("2007-09-11_16:41", '%Y-%m-%d_%H:%M'))
=> 1189521660.0

FWIW, you may also want to have a look at the datetime module, with 
special attention to the timedelta class.

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


Re: Py2.5.1 on Ubuntu AMD X2, unicode problems

2007-09-11 Thread Martin v. Löwis
> I'm building 2.5.1 from source, using the ubuntu(7.0.4)-provided gcc
> 4.1.2.

Something must be terribly wrong with your system if you have to go
through such hassles. It should build out of the box, and does for
me on Debian.

Regards,
Martin
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Database Apps

2007-09-11 Thread David
> It would help to get a feel of what is the most popular combination
> for people to develop their apps.  It's gonna be a desktop app.  The
> database engine is going to be the critical component.  I like sqlite
> so that I don't need a database server on the client side.  It would
> help though if there is a way to sync between multiple clients to a
> central server database.  That's the tough part.  To give you a better
> idea of what i'm trying to do, I am trying to write an app where
> multiple technicians have an issue tracker that is available both
> offline and online.  I was looking to use sqlite as the local side
> that would sync new and updated issues to a central server when
> online.  Any technician may work on any issue.  Generally they will
> not be working on the same issue at the same time.  The technicians
> are geographically diverse (anywhere in the southeast US, not in an
> office.)

If you have an offline mode then the most important thing to work out
is how to handle conflicts in your data synchronization. You need a
clear logic policy for this, and some means of conflict resolution.
Also all parties need to be consistent and not go out of sync too
badly. Maybe avoid conflicts altogether. eg define exactly what types
of updates can take place offline (record insertions only). Or a
policy where deletes+updates can only be made offline by the
technician that "owns" the issue/has locked it. This approach has a
few issues also.

If the database is relatively small and your data is simple then you
could get away with simple table record comparisons to do syncing
(only works properly for inserts, and you need 'natural keys' for
comparison - updates and deletes are more complicated).

Another (really complicated) way is to use a series of log events,
which your app can commit locally or to the server, and merge incoming
events from the server. This is similar in principle to a SCM like
CVS, subversion, git, bazaar, etc. SVK is probably the closest to your
model (centralised scm, with offline commit mode). This gets
complicated very quickly.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Difference between two times (working ugly code, needs polish)

2007-09-11 Thread Grant Edwards
On 2007-09-11, Shawn Milochik <[EMAIL PROTECTED]> wrote:

> I have done what I wanted, but I think there must be a much better way.

See the strptime() function in either the time or the datetime
modules:

http://docs.python.org/lib/module-time.html
http://docs.python.org/lib/module-datetime.html

-- 
Grant Edwards   grante Yow! Here we are in America
  at   ... when do we collect
   visi.comunemployment?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Car-ac-systems

2007-09-11 Thread John J. Lee
"John Timney (MVP)" <[EMAIL PROTECTED]> writes:
[...]
> I like top posted threads, its my preferred response method - and actually 
[...]

http://en.wikipedia.org/wiki/Apostrophe#English_language_usage


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


Re: Compiler Python

2007-09-11 Thread Bjoern Schliessmann
anton a wrote:
> Someone knows since as I can obtain the information detailed about
> the compiler of Python? (Table of tokens, lists of productions of
> the syntactic one , semantic restrictions...)

I'm not really about the syntax of your question, but I'd try
looking at the source code.

Regards,


Björn

-- 
BOFH excuse #228:

That function is not currently supported, but Bill Gates assures us
it will be featured in the next upgrade.

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


Re: creating really big lists

2007-09-11 Thread Bruno Desthuilliers
Dr Mephesto a écrit :
> On Sep 8, 8:06 pm, Bruno Desthuilliers
> <[EMAIL PROTECTED]> wrote:
> 
>>Dr Mephesto a écrit :
>>
>>
>>>Hi!
>>
>>>I would like to create a pretty big list of lists; a list 3,000,000
>>>long, each entry containing 5 empty lists. My application will append
>>>data each of the 5 sublists, so they will be of varying lengths (so no
>>>arrays!).
>>
>>>Does anyone know the most efficient way to do this?
>>
>>Hem... Did you consider the fact that RAM is not an unlimited resource?
>>
>>Let's do some simple math (please someone correct me if I'm going off
>>the road): if a Python (empty) list object required 256 bits (if I refer
>>to some old post by GvR, it's probably more - 384 bytes at least. Some
>>Python guru around ?), you'd need (1 + (300 * 5)) * 256 bits just to
>>build this list of lists. Which would make something around 3 Gb. Not
>>counting all other needed memory...
>>
>>FWIW, run the following code:
>>
>># eatallramthenswap.py
>>d = {}
>>for i in xrange(300):
>>   d[i] = ([], [], [], [], [])
>>
>>And monitor what happens with top...
> 
> 
> Unused ram is wasted ram :)

Indeed. But when your app eats all RAM and swap and brings the system 
down, users are usually a bit unhappy !-)

> I tried using MySQL, and it was to slow.

Possibly.

> and I have 4gb anyway...

*You* have 4gb. Yes, fine. But:

1/ please take time to re-read my post - the 3 gb is based on a very 
optimistic estimation (256 bits) of the size of an empty list. If you 
choose the (probably much closer to reality) estimate of 384 bits, then 
you need (1 + (300 * 5)) * 384, which makes =~ 5 gb. More than what 
*you* have. BTW, please remember that your OS and the Python interpreter 
are going to eat some of these 4 gb, and that you intend to actually 
*store* something - objects references - in these lists. Even if you do 
have a few shared references, this means that you'll have to have RAM 
space for *at least* 300 * 5 *more* Python objects (which make *1* 
object per list...). Which will *at minima* use about the same amount of 
RAM as the list of lists itself. Which take us to something like 10 
gb... for *1* object per list. I of course suppose you plan to store 
much more than 1 object per list !-)

2/ now ask yourself how many users of your application will have enough 
RAM to run it...

So IMVHO, the question is not how to build such a list in less than x 
minutes, but how to *not* build such a list. IOW, do you *really* need 
to store all that stuff in RAM ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Python.org mirror

2007-09-11 Thread Stream Service || Mark Scholten
Dear sir, madam,

Stream Service would be happy to provide a free mirror for python.org. We also 
host nl.php.net for free and we are happy to support more opensource websites 
with free hosting.

Could you inform me about the options to become an officiel python.org mirror?

With kind regards, Met vriendelijke groet,

Mark Scholten
Stream Service
Web: http://www.streamservice.nl/
E-mail: [EMAIL PROTECTED]
NOC: http://www.mynoc.eu/
NOC e-mail: [EMAIL PROTECTED]
Tel.: +31 (0)642 40 86 02
Fax: +31 (0)20 20 101 57
KVK: 08141074
BTW: NL104278274B01-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Car-ac-systems

2007-09-11 Thread J. Clifford Dyer
On Tue, Sep 11, 2007 at 07:50:33PM +0100, John Timney (MVP) wrote regarding Re: 
Car-ac-systems:
> 
> "Marc 'BlackJack' Rintsch" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
> > On Tue, 11 Sep 2007 17:42:53 +, Zentrader wrote:
> >
> >> 
> >> What is it about "please do not top-post" that you have difficulty
> >> understanding? Or do "MVP"s feel that their time is so much more
> >> valuable than anyone else's that they are free to ignore the norms?
> >>
> >> Who made this the norm?
> >
> > Common sense and (western) reading habits.
> >
> >> In my travels through web-land, it appears to be the opposite.
> >
> > You must travel strange territories.  ;-)
> >
> >> Don't waste space repeating everything in every post, and it wastes
> >> everyone's time by have to go over the same thing again and again.
> >
> > That's why you trim the quoted part to the minimum to understand what one
> > is answering.  Top posting and full quoting wastes time for people who
> > want to see the context because context and answer are way apart and in 
> > the
> > wrong order so one has to scroll back and forth to keep track of the
> > discussion.
> >
> > Ciao,
> > Marc 'BlackJack' Rintsch
> 
> 
> I like top posted threads, its my preferred response method - and actually 
> also how I prefer to read a thread.  Normally, I and the thread followers 
> are familiar with a threads context - and don't need to read down to get the 
> context of a response.  Not much of a hardship really and just as I give my 
> time freely in answering a thread - everyone else can chose freely to read 
> it or ignore.
> 
> I don't though have no issues with people who chose to bottom post, or 
> respond with the full thread if its relevent, or trim it.  If the answer is 
> relevent, I'll gladly spend the time reading it from any direction.
> 
> Regards
> 
> John Timney (MVP)

Thank you for your courtesy in bottom posting that comment, in spite of your 
personal preference.  It makes the group easier to follow.  

Personally, I have nothing against top-posted comments.  What really gets my 
panties in a bunch, however, are threads in which some replies are top-posted 
and some bottom posted.  Then, in order to get the full story you end up 
bouncing back and forth through the message and trying to remember how deeply 
nested the last post was.  

Cheers, and welcome to c.l.py.

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


Difference between two times (working ugly code, needs polish)

2007-09-11 Thread Shawn Milochik
I have done what I wanted, but I think there must be a much better way.

Given two timestamps in the following format, I just want to figure
out how far apart they are (in days, seconds, whatever).

Format:

-MM-DD_MM:SS

Example:
2007-09-11_16:41


It seems to me that to do what I want, I need to convert a string into
a number (time.mktime()), such as this: 1189543487.0

Once I have that, I can just subtract one from the other and do
whatever I want. The ugly part is converting something like
2007-09-11_16:41 to the numeric equivalent.

Below is my code. Any suggestions?

Thanks in advance.


Here is what I have (works):

#runTimeStamp is the current time, set when the script begins execution
def recAge(lastUpdate, runTimeStamp):

import re

oneDay = 60 * 60 * 24

lastUpdate = re.sub(r'\D+', ',', lastUpdate)
lastUpdate = lastUpdate + ",0,0,0,0"
lastUpdate = [int(x) for x in lastUpdate.split(',')]
lastUpdate = time.mktime(tuple(lastUpdate))

runTimeStamp = re.sub(r'\D+', ',', runTimeStamp)
runTimeStamp = runTimeStamp + ",0,0,0,0"
runTimeStamp = [int(x) for x in runTimeStamp.split(',')]
runTimeStamp = time.mktime(tuple(runTimeStamp))

return (runTimeStamp - lastUpdate) / oneDay
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Database Apps

2007-09-11 Thread Jonathan Gardner
On Sep 11, 1:39 pm, Jonathan Gardner
<[EMAIL PROTECTED]> wrote:
>
> For client-side apps, managing a PostgreSQL installation might be
> asking too much. But for a web site or web service, I absolutely
> recommend it.

I should mention that I wrote a medical billing software app (client
side--PyQt) in Python with a PostgreSQL backend and there were no
problems (aside from managing the database--which was easy.) That was
over 4 years ago though.

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


Compiler Python

2007-09-11 Thread anton a
Hello

Someone knows since as I can obtain the information detailed about the
compiler of Python? (Table of tokens, lists of productions of the
syntactic one , semantic restrictions...)

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


Re: Python Database Apps

2007-09-11 Thread Jonathan Gardner
On Sep 11, 1:07 pm, Tom Brown <[EMAIL PROTECTED]> wrote:
>
> I have had a lot of good luck with PostgreSQL. It is easy to install and use.
> It is also very stable. It maybe overkill for a client side database. The
> psycopg package makes interfacing to PostgreSQL very easy and there is a
> package for Linux and Windows to make cross-platform development a breeze.
>

SQLAlchemy works wonderfully with PostgreSQL. I absolutely love it.

For client-side apps, managing a PostgreSQL installation might be
asking too much. But for a web site or web service, I absolutely
recommend it.

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


Re: Python Database Apps

2007-09-11 Thread Tom Brown
On Monday 10 September 2007 19:52, [EMAIL PROTECTED] wrote:
> Kindof a poll, kindof curiosity...
>
> What is your favorite python - database combination?  I'm looking to
> make an app that has a local DB and a server side DB.  I'm looking at
> python and sqlite local side and sql server side.
>
> Any suggestions

I have had a lot of good luck with PostgreSQL. It is easy to install and use. 
It is also very stable. It maybe overkill for a client side database. The 
psycopg package makes interfacing to PostgreSQL very easy and there is a 
package for Linux and Windows to make cross-platform development a breeze.

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


Re: Best way to do attribute docstrings?

2007-09-11 Thread Ken Kuhlman

Thanks for the response!  It was just the kick I needed to realize
that I was letting my frustration get the best of me and that I was
going down a dead-end.  I blame the fact that I was coding on little
sleep :-)

I went with the solution of giving a naming convention to the
docstrings and relying on that for the introspection -- that's a lot
less of a kludge than what I was attempting.

I still think it would be great if you could do something like:
@doc('Animal has four legs')
four_legs = True

IMHO, that syntax is nice (which was the objection to PEP 224), but
I'm not going to try to propose another PEP over it.  My itch is
scratched for now -- if the naming convention hack gets under my skin
eventually I'll try going down a source parsing route next.

Thanks again for the help!
-Ken

PS:  I hope it's OK that I ignored your questions -- my initial
solution was just too hideous to be scrutinized too closely.

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


Re: Car-ac-systems

2007-09-11 Thread Dave Hansen
On Sep 11, 12:42 pm, Zentrader <[EMAIL PROTECTED]> wrote:
> 
> What is it about "please do not top-post" that you have difficulty
> understanding? Or do "MVP"s feel that their time is so much more
> valuable than anyone else's that they are free to ignore the norms?
>
> Who made this the norm?

http://www.ietf.org/rfc/rfc1855.txt

If you don't know what the IETF is, or what an RFC is, you should
educate yourself.
http://www.ietf.org/glossary.html#IETF is a good place to start.

>   In my travels through web-land, it appears to

Usenet is not "web-land".  And it is not Google Groups, either.  Look
up
http://www.faqs.org/faqs/usenet/welcome/part1/ for more info

> be the opposite.  Don't waste space repeating everything in every
> post, and it wastes everyone's time by have to go over the same thing
> again and again.  Perhaps this thread has a purpose after all, anyway
> it has been reported as spam.

You have much to learn.

Regards,

   -=Dave

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


Re: urllib2: handle an error (302)

2007-09-11 Thread Antoni Villalonga
2007/9/11, O.R.Senthil Kumaran:
> > When urllib2 libs visit a URL with 302 error follow the location
> > automatically. I need to get the location  in order to get the full
> > URL (not relative URL) parsing html code.
>
> urllib2 automatically handles the 302 redirection. What you get as the end 
> result is the 'redirected' page.
> - If all you want is the 'redirected' page. Blindly use urllib2, it handles 
> it.
> - If you want a 'smarter' way of handling redirection, then you might have to 
> extend the HTTPRedirectHandler.
>
> A very good example is provided by Mark Pilgrim in his 'Dive Into Python'.
> Have a look here:
> http://www.diveintopython.org/http_web_services/index.html
>
> Example 11.1 openanything.py
>
>
> Implement your program along those lines.
>
> Thanks,
> Senthil

Tnks It works!!

-- 
"Boring two-person multiplayer may turn friends into enemies."

Antoni Villalonga i Noceras
#Bloc# ~> http://friki.CAT
#Jabber# ~> [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Lost in __setstate__() in C++ and swig

2007-09-11 Thread Martin Drautzburg
I am trying to cPickle/unpickle a C++ extension class with some private
data members. I wrote __getstate__() and __setstate__ in C++ (I have
to, due to the private data). Pickling writes the following file:

ccopy_reg
_reconstructor
p1
(cpyramid
MidiBytes
p2
c__builtin__
object
p3
NtRp4
(S'some unknown MidiBytes'
I1
I2
I3
tb.

But when unpickling I get the following error

TypeError: in method 'MidiBytes___setstate__', argument 1 of type 
'pyramid::MidiBytes *'

I debugged the swig wrapper and indeed the wrapper is called with just
one tuple argument. No object seems to be present at the time.

All the examples I've seen use python functions for __getstate__ and
__setstate__ and it seems to me that the object itself is already there
when __setstate__ is called. 

In a moment of dispair I declared __setstate__() static and have it
create and return a MidiBytes object. 

MidiBytes *MidiBytes:: __setstate__ (PyObject * aTuple) {
return new MidiBytes();
}

Then unpickling no longer complains about "argument 1", but the
unpickled object does not work

>>> nn = cPickle.load(FILE)
>>> nn.len()
Traceback (most recent call last):
  File "", line 1, in ?
  File "/usr/src/sound.d/pyramid/pyramid.py", line 618, in len
return _pyramid.MidiBytes_len(*args)
TypeError: in method 'MidiBytes_len', argument 1 of
type 'pyramid::MidiBytes *'

whereas the original object behaves well

>>> n = pyramid.MidiBytes()
>>> n.len()
0

Am I missing something obvious ?









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


Re: Python Database Apps

2007-09-11 Thread [EMAIL PROTECTED]
On Sep 11, 9:25 am, Ed Leafe <[EMAIL PROTECTED]> wrote:
> On Sep 10, 2007, at 10:52 PM, [EMAIL PROTECTED] wrote:
>
> > Kindof a poll, kindof curiosity...
>
> > What is your favorite python - database combination?  I'm looking to
> > make an app that has a local DB and a server side DB.  I'm looking at
> > python and sqlite local side and sql server side.
>
> Are you asking for opinions on what sort of database engine to use?
> Or are you trying to get a feel for what people use to develop their
> apps? Are you looking for a web app, or a desktop app, or a non-UI app?
>
> -- Ed Leafe
> --http://leafe.com
> --http://dabodev.com

It would help to get a feel of what is the most popular combination
for people to develop their apps.  It's gonna be a desktop app.  The
database engine is going to be the critical component.  I like sqlite
so that I don't need a database server on the client side.  It would
help though if there is a way to sync between multiple clients to a
central server database.  That's the tough part.  To give you a better
idea of what i'm trying to do, I am trying to write an app where
multiple technicians have an issue tracker that is available both
offline and online.  I was looking to use sqlite as the local side
that would sync new and updated issues to a central server when
online.  Any technician may work on any issue.  Generally they will
not be working on the same issue at the same time.  The technicians
are geographically diverse (anywhere in the southeast US, not in an
office.)

Thanks for the feedback so far...

Darien

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


Re: Car-ac-systems

2007-09-11 Thread John Timney \(MVP\)

"Marc 'BlackJack' Rintsch" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> On Tue, 11 Sep 2007 17:42:53 +, Zentrader wrote:
>
>> 
>> What is it about "please do not top-post" that you have difficulty
>> understanding? Or do "MVP"s feel that their time is so much more
>> valuable than anyone else's that they are free to ignore the norms?
>>
>> Who made this the norm?
>
> Common sense and (western) reading habits.
>
>> In my travels through web-land, it appears to be the opposite.
>
> You must travel strange territories.  ;-)
>
>> Don't waste space repeating everything in every post, and it wastes
>> everyone's time by have to go over the same thing again and again.
>
> That's why you trim the quoted part to the minimum to understand what one
> is answering.  Top posting and full quoting wastes time for people who
> want to see the context because context and answer are way apart and in 
> the
> wrong order so one has to scroll back and forth to keep track of the
> discussion.
>
> Ciao,
> Marc 'BlackJack' Rintsch


I like top posted threads, its my preferred response method - and actually 
also how I prefer to read a thread.  Normally, I and the thread followers 
are familiar with a threads context - and don't need to read down to get the 
context of a response.  Not much of a hardship really and just as I give my 
time freely in answering a thread - everyone else can chose freely to read 
it or ignore.

I don't though have no issues with people who chose to bottom post, or 
respond with the full thread if its relevent, or trim it.  If the answer is 
relevent, I'll gladly spend the time reading it from any direction.

Regards

John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog


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


Re: ValueError: insecure string pickle ?

2007-09-11 Thread Steve Holden
robert wrote:
> cPickle.loads  raised "ValueError: insecure string pickle".
> The error is from a log file and I cannot reproduce it (quickly). 
> What can be the cause for that error?
> 
> Robert

Make sure that your pickle files are being read and written in binary 
mode ("rb" and "wb" as the second argument to open()).

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden
--- Asciimercial --
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
--- Thank You for Reading -

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


Re: Python 2 releases after 2.6

2007-09-11 Thread Steve Holden
slinkp wrote:
> This seems to be a bit of a FAQ (at least among worried Zope
> developers  :-) ...
> What  are the plans for Python 2 releases after Python 2.6 / Python 3
> are released?
> 
> First, in the 2006 State of Python, Guido said:
> 
> """
> # 2.7: likely; may contain some 3.0 backports
> # 2.9 is as far as we'll go (running out of digits :-)
> """
> 
> Then there's PEP 3000, which says:
> """
> I expect that there will be parallel Python 2.x and 3.x releases for
> some time; the Python 2.x releases will continue for a longer time
> than the traditional 2.x.y bugfix releases. Typically, we stop
> releasing bugfix versions for 2.x once version 2.(x+1) has been
> released. But I expect there to be at least one or two new 2.x
> releases even after 3.0 (final) has been released, probably well into
> 3.1 or 3.2. This will to some extent depend on community demand for
> continued 2.x support, acceptance and stability of 3.0, and volunteer
> stamina.
> """
> 
> Has any of that changed (insofar as anyone can predict the future of
> course)?
> 
Well, since Tim Peters isn't around to channel Guido, let me just say 
"no". The above remains the current intention. 2.6 is intended to 
backport as many as possible of 3.0's new features.

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden
--- Asciimercial --
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
--- Thank You for Reading -

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


Re: Car-ac-systems

2007-09-11 Thread Steve Holden
Zentrader wrote:
> 
> What is it about "please do not top-post" that you have difficulty
> understanding? Or do "MVP"s feel that their time is so much more
> valuable than anyone else's that they are free to ignore the norms?
> 
[Actually I wrote the bit above [to a third party], but apparently 
zentrader doesn't feel the need to conform with the norm about quoting 
other people's messages].

> Who made this the norm?  In my travels through web-land, it appears to
> be the opposite.  Don't waste space repeating everything in every
> post, and it wastes everyone's time by have to go over the same thing
> again and again.  Perhaps this thread has a purpose after all, anyway
> it has been reported as spam.
> 
I wasn't talking about "webland". I was talking about the 
comp.lang.python newsgroup/python-list mailing list. And please don;t 
complain that you don't have time to establish the norms for each group 
you post to, since it's long been accepted netiquette that you should 
*read* any group you intend to post to for a while, giving you time to 
discover what the accepted norms *are* ... and on c.l.py the norm is 
definitely "avoid top-posting".

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden
--- Asciimercial --
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
--- Thank You for Reading -

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


Re: Help With PyParsing of output from win32pdhutil.ShowAllProcesses()

2007-09-11 Thread David
On 9/11/07, Steve <[EMAIL PROTECTED]> wrote:
> Hi All (especially Paul McGuire!)
>
> Could you lend a hand in the grammar and paring of the output from the
> function win32pdhutil.ShowAllProcesses()?
>
> This is the code that I have so far (it is very clumsy at the
> moment) :

Any particular reason you need to use pyparsing? Seems like an
overkill for such simple data.

Here's an example:

import pprint

X="""Process Name   ID Process,% Processor Time,% User Time,%
Privileged Time,Virtual Bytes Peak,Virtual Bytes
PyScripter 2572 0 0 0 96370688 96370688
vmnetdhcp  1184 0 0 0 13942784 13942784
vmount2 780 0 0 0 40497152 3840
ipoint  260 0 0 0 63074304 58531840"""

data = []
for line in X.split('\n')[1:]: # Skip the first row
split = line.split()
row = [split[0]] # Get the process name
row += [int(x) for x in split[1:]] # Convert strings to int, fail
if any aren't.
data.append(row)

pprint.pprint(data)

# Output follows:
#
#[['PyScripter', 2572, 0, 0, 0, 96370688, 96370688],
# ['vmnetdhcp', 1184, 0, 0, 0, 13942784, 13942784],
# ['vmount2', 780, 0, 0, 0, 40497152, 3840],
# ['ipoint', 260, 0, 0, 0, 63074304, 58531840]]
#
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: mod_python and pysvn

2007-09-11 Thread Sjoerd
On Sep 11, 7:41 pm, Bjoern Schliessmann  wrote:
> Tim Golden wrote:
> > Sjoerd wrote:
> >> ClientError: Unable to open an ra_local session to URL
> >> Unable to open repository 'file:///P:/tools/builds/repository'
>
> >> does anyone know how I can fix this?
>
> > Usually means that the process which Apache is running under
> > (may well be LocalSystem) doesn't know about or doesn't have
> > access to p:/tools etc.
>
> Isn't this an SVN client error? Seems to me that the repository URL
> is invalid.
>
> Tim, try accessing the repository using svn list from the command
> line.
>
> Regards,
>
> Björn
>
> --
> BOFH excuse #350:
>
> paradigm shift...without a clutch

Thank you both for your replies!
I suspect that if I import the script that the script becomes local
for apache
Who tries to form the path.
The actual command:

client = Client()
repLog = client.log("\\P:\\tools\builds\publish\\")
I used an UNC path. The forming of the repository path must be inside
the pysvn
library.

When I run the script via the command console it returns the right
values.
So I think what Tim replies is quite acurate!
I'm going to try that tomorrow!

Cheers!
Sjoerd

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

Re: customizing a logging logger

2007-09-11 Thread David
On 9/11/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> I think the following question is clearer.
>
> I want to make it so that method1 below can be transformed:
>
> logger = logging.getLogger("somelogger")
> class SomeOp:
> def __init__(self, ctx):
> self.ctx = ctx
> def method1(self):
> logger.info("%s: here's a message", self.ctx)
> logger.debug("%s: msg #2", self.ctx)
> v = 'yessir'
> logger.debug("%s: msg #3 %s", self.ctx, v)
>
> into something like:
>
> def method1(self):
> logger.info("here's a message")
> logger.debug("msg #2")
> v = 'yessir'
> logger.debug("msg #3 %s", v)
>
>
> What is the best way to do this, so that I don't have to manually put
> the self.ctx in the log string in hundreds of different places?

One way to do it is to make a mixin class (eg: ContextLogging)  which
you construct with the context string. The mixin constructor has a
line like this:

self.logger = logging.getLogger(ctx).

(assuming your context string is appropriate for a logger name)

Then your methods call self.logger instead of the module-level logger.

Another method is also to use a mixin class, which provides methods
"log_debug", "log_info", etc methods which wrap calls to a logger
object.

Another (more advanced) method is to create a custom Logger class. It
uses the call stack to determine if it's caller has a "ctx" attribute,
and pushes the value of that attribute into the message string. Then
you call logging.setLoggerClass so that you get instances of your
custom logger class.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python code-writing for the blind. Was (Re: newbie: stani's pythoneditor if-else)

2007-09-11 Thread Bruno Desthuilliers
Hamilton, William a écrit :
>>From: madzientist
>>
>>Thanks, everybody, for the very very useful and kind responses.
>>
>>There is a second reason why I asked the question about automatic de-
>>indenting. I am teaching myself Python partly so I can then help my
>>technically astute, but blind friend learn programming. For the many
>>reasons that Pythonistas like to cite often, I thought Python would be
>>a good choice to learn programming, and that perhaps the indentation
>>problem would be solved by the use of an intelligent editor.
>>
>>But now I am not so sure, though I will try Emacs. Is there anyone
>>here with experience in such issues ? 

There has been recently a thread about the use of a preprocessor for 
blind Python programmers, you may want to have a look:
http://groups.google.fr/group/comp.lang.python/browse_thread/thread/80654a87bfa89e3b/de268f888d9cdf0e

(snip)
>>More seriously, the added issue is that SPE uses spaces, not a single
>>tab to indent the lines,

Most code editor let you configure this. wrt/ Python, just make sure you 
do not, never, mix tabs and spaces.

(snip)
-- 
http://mail.python.org/mailman/listinfo/python-list


Help With PyParsing of output from win32pdhutil.ShowAllProcesses()

2007-09-11 Thread Steve
Hi All (especially Paul McGuire!)

Could you lend a hand in the grammar and paring of the output from the
function win32pdhutil.ShowAllProcesses()?

This is the code that I have so far (it is very clumsy at the
moment) :


import string
import win32api
import win32pdhutil
import re
import pyparsing


process_info = win32pdhutil.ShowAllProcesses()

print process_info
print

## Output from ShowAllProcesses :

##Process Name   ID Process,% Processor Time,% User Time,% Privileged
Time,Virtual Bytes Peak,Virtual Bytes
##PyScripter 2572 0 0 0 96370688 96370688
##vmnetdhcp  1184 0 0 0 13942784 13942784
##vmount2 780 0 0 0 40497152 3840
##ipoint  260 0 0 0 63074304 58531840


sProcess_Info = str(process_info)
print('type = ', type(sProcess_Info))

## Try some test data :
test = ('Process Name   ID Process,% Processor Time,% User Time,%
Privileged Time,Virtual Bytes Peak,Virtual Bytes',
'PyScripter  2572 0 0 0 96370688 96370688',
'vmnetdhcp   1184 0 0 0 13942784 13942784',
'vmount2  780 0 0 0 40497152 3840',
'ipoint   260 0 0 0 63074304 58531840')

heading = pyparsing.Literal('Process Name   ID Process,% Processor
Time,% User Time,% Privileged Time,Virtual Bytes Peak,Virtual
Bytes').suppress()
integer = pyparsing.Word(pyparsing.nums)
process_name = pyparsing.Word(pyparsing.alphas)

#ProcessList = heading + process_name + pyparsing.OneOrMore(integer)
ProcessList = process_name + pyparsing.OneOrMore(integer)

# Now parse data and print results

for current_line in test :
print('Current line = %s') % (current_line)

try:
   data = ProcessList.parseString(current_line)
   print "data:", data
except:
   pass


print('\n\nParse Actual data : \n\n')
## Parse the actual data from ShowAllProcesses :

ProcessList = heading + process_name + pyparsing.OneOrMore(integer)
data = ProcessList.parseString(sProcess_Info)
print "data:", data
print "data.asList():",
print "data keys:", data.keys()



=

Output from run :


Process Name ID Process,% Processor Time,% User Time,% Privileged
Time,Virtual Bytes Peak,Virtual Bytes
PyScripter   2572 0 0 0 101416960 97730560
vmnetdhcp1184 0 0 0 13942784 13942784
vmount2   780 0 0 0 40497152 3840
ipoint260 0 0 0 65175552 58535936
DockingDirector   916 0 0 0 102903808 101695488
vmnat 832 0 0 0 15757312 15757312
svchost  1060 0 0 0 74764288 72294400
svchost  1120 0 0 0 46632960 45846528
svchost  1768 0 0 0 131002368 113393664
svchost  1988 0 0 0 33619968 31047680
svchost   236 0 0 0 39841792 39055360
System  4 0 0 0 3624960 1921024


None

('type = ', )
Current line = Process Name   ID Process,% Processor Time,% User Time,
% Privileged Time,Virtual Bytes Peak,Virtual Bytes
Current line = PyScripter2572 0 0 0 96370688
96370688
data: ['PyScripter', '2572', '0', '0', '0', '96370688', '96370688']
Current line = vmnetdhcp 1184 0 0 0 13942784
13942784
data: ['vmnetdhcp', '1184', '0', '0', '0', '13942784', '13942784']
Current line = vmount2780 0 0 0 40497152
3840
data: ['vmount', '2', '780', '0', '0', '0', '40497152', '3840']
Current line = ipoint 260 0 0 0 63074304
58531840
data: ['ipoint', '260', '0', '0', '0', '63074304', '58531840']


Parse Actual data :


Traceback (most recent call last):
  File "ProcessInfo.py", line 55, in 
data = ProcessList.parseString(sProcess_Info)
  File "C:\Python25\lib\site-packages\pyparsing.py", line 821, in
parseString
loc, tokens = self._parse( instring.expandtabs(), 0 )
  File "C:\Python25\lib\site-packages\pyparsing.py", line 712, in
_parseNoCache
loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "C:\Python25\lib\site-packages\pyparsing.py", line 1864, in
parseImpl
loc, resultlist = self.exprs[0]._parse( instring, loc, doActions,
callPreParse=False )
  File "C:\Python25\lib\site-packages\pyparsing.py", line 716, in
_parseNoCache
loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "C:\Python25\lib\site-packages\pyparsing.py", line 2106, in
parseImpl
return self.expr._parse( instring, loc, doActions,
callPreParse=False )
  File "C:\Python25\lib\site-packages\pyparsing.py", line 716, in
_parseNoCache
loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "C:\Python25\lib\site-packages\pyparsing.py", line 1118, in
parseImpl
raise exc
pyparsing.ParseException: Expected "Process Name   ID Process,%
Processor Time,% User Time,% Privileged Time,Virtual Bytes
Peak,Virtual Bytes" (at char 0), (l

Re: Car-ac-systems

2007-09-11 Thread J. Clifford Dyer
On Tue, Sep 11, 2007 at 05:50:43PM +, Marc 'BlackJack' Rintsch wrote 
regarding Re: Car-ac-systems:
> 
> On Tue, 11 Sep 2007 17:42:53 +, Zentrader wrote:
> 
> > 
> > What is it about "please do not top-post" that you have difficulty
> > understanding? Or do "MVP"s feel that their time is so much more
> > valuable than anyone else's that they are free to ignore the norms?
> > 
> > Who made this the norm?
> 
> Common sense and (western) reading habits.
> 

More to the point, one or more of the mailing lists to which you are posting.  
When in Rome, do as the Romans do.  If you don't know what the Romans do, 
you're probably cross-posting too broadly.

Cheers,
Cliff

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


Re: Car-ac-systems

2007-09-11 Thread Marc 'BlackJack' Rintsch
On Tue, 11 Sep 2007 17:42:53 +, Zentrader wrote:

> 
> What is it about "please do not top-post" that you have difficulty
> understanding? Or do "MVP"s feel that their time is so much more
> valuable than anyone else's that they are free to ignore the norms?
> 
> Who made this the norm?

Common sense and (western) reading habits.

> In my travels through web-land, it appears to be the opposite.

You must travel strange territories.  ;-)

> Don't waste space repeating everything in every post, and it wastes
> everyone's time by have to go over the same thing again and again.

That's why you trim the quoted part to the minimum to understand what one
is answering.  Top posting and full quoting wastes time for people who
want to see the context because context and answer are way apart and in the
wrong order so one has to scroll back and forth to keep track of the
discussion.

Ciao,
Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Car-ac-systems

2007-09-11 Thread Zentrader

What is it about "please do not top-post" that you have difficulty
understanding? Or do "MVP"s feel that their time is so much more
valuable than anyone else's that they are free to ignore the norms?

Who made this the norm?  In my travels through web-land, it appears to
be the opposite.  Don't waste space repeating everything in every
post, and it wastes everyone's time by have to go over the same thing
again and again.  Perhaps this thread has a purpose after all, anyway
it has been reported as spam.

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


Re: mod_python and pysvn

2007-09-11 Thread Bjoern Schliessmann
Tim Golden wrote:
> Sjoerd wrote:

>> ClientError: Unable to open an ra_local session to URL
>> Unable to open repository 'file:///P:/tools/builds/repository'
>> 
>> does anyone know how I can fix this?
> 
> Usually means that the process which Apache is running under
> (may well be LocalSystem) doesn't know about or doesn't have
> access to p:/tools etc. 

Isn't this an SVN client error? Seems to me that the repository URL
is invalid.

Tim, try accessing the repository using svn list from the command
line.

Regards,


Björn

-- 
BOFH excuse #350:

paradigm shift...without a clutch

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


Re: Python code-writing for the blind. Was (Re: newbie: stani's python editor if-else)

2007-09-11 Thread madzientist

Thanks, Gregor. Very helpful thread.

Suresh

On Sep 11, 1:26 pm, Gregor Horvath <[EMAIL PROTECTED]> wrote:
> madzientist schrieb:
>
>
>
> > Is Python a bad choice for the blind programmer, as a result of a
> > tight linkage between visual aspects of the code and its function ? I
> > wish the site blindprogramming.com weren't so lifeless...
>
> There was a thread regarding blind people and python indentation shortly:
>
> http://groups.google.com/group/comp.lang.python/browse_thread/thread/...
>
> Gregor


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


Re: unexpected behavior: did i create a pointer?

2007-09-11 Thread Peter Otten
Am Sat, 08 Sep 2007 09:44:24 + schrieb Steven D'Aprano:

> Ways that Python objects are not like C pointers:
> 
> (1) You don't have to manage memory yourself.
> 
> (2) You don't have typecasts. You can't change the type of the object you 
> point to.
> 
> (3) Python makes no promises about the memory location of objects.
> 
> (4) No pointer arithmetic.
> 
> (5) No pointers to pointers, and for old-school Mac programmers, no 
> handles.
> 
> (6) No dangling pointers. Ever.
> 
> (7) There's no null pointer. None is an object, just like everything else.
> 
> (8) You can't crash your computer by writing the wrong thing to the wrong 
> pointer. You're unlikely even to crash your Python session.
> 
> 
> 
> Ways that Python objects are like pointers:
> 
> (1) ... um... 
> 
> Oh yeah, if you bind the _same_ object to two different names, _and_ the 
> object is mutable (but not if it is immutable), mutating the object via 
> one name will have the same effect on the object -- the same object, 
> naturally -- bound to the other name.

Had you put it that way in the first place I would have stayed in in my
hole ;)

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


Re: Modul (%) in python not like in C?

2007-09-11 Thread Matthew Woodcraft
J. Cliff Dyer <[EMAIL PROTECTED]> wrote:
>Bryan Olson wrote:
>> Not true. Here it is again:
>>
>>  When integers are divided, the result of the / operator is
>>  the algebraic quotient with any fractional part discarded.(87)
>>  If the quotient a/b is representable, the expression
>>  (a/b)*b + a%b shall equal a.
>>  [...]
>>  87) This is often called 'truncation toward zero'
>>
>>  [International Standard ISO/IEC 9899:1999, Section 6.5.5
>>  Multiplicative operators, Paragraph 6 and footnote 87]


> But C was around for a long time before the 1999 standard.  C89,
> commonly called ANSI C, is still very commonly used in compilers, and
> K&R C goes back to 1972.  Is truncation toward 0 the standard for K&R C
> as well? 

As I remember, the behaviour for negative 'a' wasn't specified in K&R C
or in C89; the rule was tightened up for C99.

-M-

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


Re: Car-ac-systems

2007-09-11 Thread Rory Becker
> Thats all it is.  It may have been a usefully intended resource once,
> but they have no controls whatsoever.  Its time someone closed it
> down.

Some would say the same thing about email or the internet at large. 

It doesn't make it true.

Pick almost any community facility and you will find elements of the community 
that would vandelise it or treat it like Sh*t.

Luckily you don't have to subscribe to all the blogs on blogspot. you can 
pick just the ones that interest you.

:)

--
Rory


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


Re: Excel process still running after program completion.

2007-09-11 Thread Chris
On Sep 11, 1:26 pm, Chris <[EMAIL PROTECTED]> wrote:
> On Sep 11, 12:59 pm, "Hamilton, William " <[EMAIL PROTECTED]> wrote:
>
>
>
> > > From: Chris
>
> > > I have a python script that is driving Excel and using the win32com
> > > module. However, upon program completion there's still an Excel.exe
> > > process running in the background that I must terminate through Task
> > > Manager. Reading up on other threads indicate that maybe I still have
> > > some Excel objects referenced within my code. Is this why the process
> > > doesn't terminate?
>
> > > The related (I hope) parts of my code is here.
>
> > > x1App = Dispatch("Excel.Application")
> > > Book1 = x1App.Workbooks.Open(ExcelLogPath+"\\outputLog-template.xls")
> > > x1App.Visible = 1
> > > for sheets in Book1.Worksheets:
> > >  if sheets.Name == file_name:
> > >   sheetExists = True
> > > if sheetExists != True:
> > >  activeSheet =
> > > Book1.Worksheets.Add(After=Book1.Worksheets(1))
> > >  activeSheet.Name = file_name
> > >  testNum[file_name] = 0
> > > Book1.Worksheets(file_name).Select()
> > > Book1.ActiveSheet.Cells(1+(testNum[file_name]*20),1).Value = "Original
> > > File Name"
> > > Book1.ActiveSheet.Cells(2+(testNum[file_name]*20),1).Value =
> > > file_name
> > > Book1.ActiveSheet.Pictures().Insert(output).Select()
> > > Book1.SaveAs(Filename=path)
> > > x1App.ActiveWorkbook.Close(SaveChanges=0)
> > > x1App.Quit()
> > > del x1App
> > > del Book1
> > > del activeSheet
>
> > > What am I missing?
>
> > In my Excel projects, I terminate it with:
>
> > xlBook.Close()
> > xlApp.Quit()
>
> > I haven't had a problem with Excel staying open after the program ends.
>
> > (On a tangent, I want to find the person who thought it was a good idea
> > to use the same symbol in a font for 1, l, and I and do some unpleasant
> > things.)
>
> > --
> > -Bill Hamilton
>
> That doesn't really fix the problem as I'm pretty sure its identical
> code for
> x1App.ActiveWorkbook.Close(SaveChanges=0)
>
> I think where my problem lies is within my for each loop where I
> search to see if the worksheet with the name already exists
> for sheets in Book1.Worksheets:
>  if sheets.Name == file_name:
>sheetExists = True
>
> Since I'm assuming that it creates objects for each of the sheets and
> I don't delete them...

Which I'm right... I added this code and now there's no EXCEL.EXE
process after my script completes

for sheets in Book1.Worksheets:
  if sheets.Name == file_name:
sheetExists = True
  sheets = None
  del sheets

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


Re: Excel process still running after program completion.

2007-09-11 Thread Chris
On Sep 11, 12:59 pm, "Hamilton, William " <[EMAIL PROTECTED]> wrote:
> > From: Chris
>
> > I have a python script that is driving Excel and using the win32com
> > module. However, upon program completion there's still an Excel.exe
> > process running in the background that I must terminate through Task
> > Manager. Reading up on other threads indicate that maybe I still have
> > some Excel objects referenced within my code. Is this why the process
> > doesn't terminate?
>
> > The related (I hope) parts of my code is here.
>
> > x1App = Dispatch("Excel.Application")
> > Book1 = x1App.Workbooks.Open(ExcelLogPath+"\\outputLog-template.xls")
> > x1App.Visible = 1
> > for sheets in Book1.Worksheets:
> >  if sheets.Name == file_name:
> >   sheetExists = True
> > if sheetExists != True:
> >  activeSheet =
> > Book1.Worksheets.Add(After=Book1.Worksheets(1))
> >  activeSheet.Name = file_name
> >  testNum[file_name] = 0
> > Book1.Worksheets(file_name).Select()
> > Book1.ActiveSheet.Cells(1+(testNum[file_name]*20),1).Value = "Original
> > File Name"
> > Book1.ActiveSheet.Cells(2+(testNum[file_name]*20),1).Value =
> > file_name
> > Book1.ActiveSheet.Pictures().Insert(output).Select()
> > Book1.SaveAs(Filename=path)
> > x1App.ActiveWorkbook.Close(SaveChanges=0)
> > x1App.Quit()
> > del x1App
> > del Book1
> > del activeSheet
>
> > What am I missing?
>
> In my Excel projects, I terminate it with:
>
> xlBook.Close()
> xlApp.Quit()
>
> I haven't had a problem with Excel staying open after the program ends.
>
> (On a tangent, I want to find the person who thought it was a good idea
> to use the same symbol in a font for 1, l, and I and do some unpleasant
> things.)
>
> --
> -Bill Hamilton

That doesn't really fix the problem as I'm pretty sure its identical
code for
x1App.ActiveWorkbook.Close(SaveChanges=0)

I think where my problem lies is within my for each loop where I
search to see if the worksheet with the name already exists
for sheets in Book1.Worksheets:
 if sheets.Name == file_name:
   sheetExists = True


Since I'm assuming that it creates objects for each of the sheets and
I don't delete them...

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


Re: Python code-writing for the blind. Was (Re: newbie: stani's python editor if-else)

2007-09-11 Thread Gregor Horvath
madzientist schrieb:

> 
> Is Python a bad choice for the blind programmer, as a result of a
> tight linkage between visual aspects of the code and its function ? I
> wish the site blindprogramming.com weren't so lifeless...

There was a thread regarding blind people and python indentation shortly:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/80654a87bfa89e3b

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


RE: Python code-writing for the blind. Was (Re: newbie: stani's pythoneditor if-else)

2007-09-11 Thread Hamilton, William
> From: madzientist
> 
> Thanks, everybody, for the very very useful and kind responses.
> 
> There is a second reason why I asked the question about automatic de-
> indenting. I am teaching myself Python partly so I can then help my
> technically astute, but blind friend learn programming. For the many
> reasons that Pythonistas like to cite often, I thought Python would be
> a good choice to learn programming, and that perhaps the indentation
> problem would be solved by the use of an intelligent editor.
> 
> But now I am not so sure, though I will try Emacs. Is there anyone
> here with experience in such issues ? Maybe for her sake, I should
> switch to learning Perl ;) ;)
> 
> More seriously, the added issue is that SPE uses spaces, not a single
> tab to indent the lines, and I believe it is extremely tedious to use
> screen-readers to keep track of blank spaces at the beginning of each
> line. I have not tried it myself yet, but I will soon.
> 
> Is Python a bad choice for the blind programmer, as a result of a
> tight linkage between visual aspects of the code and its function ? I
> wish the site blindprogramming.com weren't so lifeless...
> 

Can you set SPE to use a single space rather than the typical four
spaces?  Python should accept it just fine.  You'll still have problems
reading other people's code.  Maybe you can write a quick script that
converts code down to one-space indents.


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


Re: ValueError: insecure string pickle ?

2007-09-11 Thread Peter Otten
Am Tue, 11 Sep 2007 17:19:36 +0200 schrieb robert:

> cPickle.loads  raised "ValueError: insecure string pickle".
> The error is from a log file and I cannot reproduce it (quickly). 
> What can be the cause for that error?

A corrupted pickle. The error is raised if a string in the dump does not
both start and end with " or '. One way to provoke the error:

>>> from cPickle import loads, dumps
>>> s = dumps("abc")
>>> s
"S'abc'\np1\n." # that's what it should look like
>>> loads("S'abc") # but make it too short
Traceback (most recent call last):
  File "", line 1, in 
ValueError: insecure string pickle

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


Python code-writing for the blind. Was (Re: newbie: stani's python editor if-else)

2007-09-11 Thread madzientist

Thanks, everybody, for the very very useful and kind responses.

There is a second reason why I asked the question about automatic de-
indenting. I am teaching myself Python partly so I can then help my
technically astute, but blind friend learn programming. For the many
reasons that Pythonistas like to cite often, I thought Python would be
a good choice to learn programming, and that perhaps the indentation
problem would be solved by the use of an intelligent editor.

But now I am not so sure, though I will try Emacs. Is there anyone
here with experience in such issues ? Maybe for her sake, I should
switch to learning Perl ;) ;)

More seriously, the added issue is that SPE uses spaces, not a single
tab to indent the lines, and I believe it is extremely tedious to use
screen-readers to keep track of blank spaces at the beginning of each
line. I have not tried it myself yet, but I will soon.

Is Python a bad choice for the blind programmer, as a result of a
tight linkage between visual aspects of the code and its function ? I
wish the site blindprogramming.com weren't so lifeless...

Thanks, Suresh

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


Re: creating really big lists

2007-09-11 Thread Dr Mephesto
On Sep 8, 8:06 pm, Bruno Desthuilliers
<[EMAIL PROTECTED]> wrote:
> Dr Mephesto a écrit :
>
> > Hi!
>
> > I would like to create a pretty big list of lists; a list 3,000,000
> > long, each entry containing 5 empty lists. My application will append
> > data each of the 5 sublists, so they will be of varying lengths (so no
> > arrays!).
>
> > Does anyone know the most efficient way to do this?
>
> Hem... Did you consider the fact that RAM is not an unlimited resource?
>
> Let's do some simple math (please someone correct me if I'm going off
> the road): if a Python (empty) list object required 256 bits (if I refer
> to some old post by GvR, it's probably more - 384 bytes at least. Some
> Python guru around ?), you'd need (1 + (300 * 5)) * 256 bits just to
> build this list of lists. Which would make something around 3 Gb. Not
> counting all other needed memory...
>
> FWIW, run the following code:
>
> # eatallramthenswap.py
> d = {}
> for i in xrange(300):
>d[i] = ([], [], [], [], [])
>
> And monitor what happens with top...

Unused ram is wasted ram :)

I tried using MySQL, and it was to slow. and I have 4gb anyway...

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

Re: Car-ac-systems

2007-09-11 Thread Hunter Gratzner
[top posting fixed]

> "Lew" <[EMAIL PROTECTED]> wrote in message
>
> news:[EMAIL PROTECTED]
> > I'm starting to see "blogspot" as a synonym for "spam".

On Sep 11, 4:33 pm, "John Timney \(MVP\)"
<[EMAIL PROTECTED]> wrote:
> Thats all it is.  It may have been a usefully intended resource once, but
> they have no controls whatsoever.  Its time someone closed it down.

Blogspot, aka blogger getting closed down is very unlikely. It is a
Google company. And just as Google doesn't care about Usenet spam
originating via Google Groups, Google also doesn't care about spammers
on Blogspot/Blogger. All they care about is making AdSense money.

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


RE: Excel process still running after program completion.

2007-09-11 Thread Hamilton, William
> From: Chris
>
> I have a python script that is driving Excel and using the win32com
> module. However, upon program completion there's still an Excel.exe
> process running in the background that I must terminate through Task
> Manager. Reading up on other threads indicate that maybe I still have
> some Excel objects referenced within my code. Is this why the process
> doesn't terminate?
> 
> The related (I hope) parts of my code is here.
> 
> x1App = Dispatch("Excel.Application")
> Book1 = x1App.Workbooks.Open(ExcelLogPath+"\\outputLog-template.xls")
> x1App.Visible = 1
> for sheets in Book1.Worksheets:
>  if sheets.Name == file_name:
>   sheetExists = True
> if sheetExists != True:
>  activeSheet =
> Book1.Worksheets.Add(After=Book1.Worksheets(1))
>  activeSheet.Name = file_name
>  testNum[file_name] = 0
> Book1.Worksheets(file_name).Select()
> Book1.ActiveSheet.Cells(1+(testNum[file_name]*20),1).Value = "Original
> File Name"
> Book1.ActiveSheet.Cells(2+(testNum[file_name]*20),1).Value =
> file_name
> Book1.ActiveSheet.Pictures().Insert(output).Select()
> Book1.SaveAs(Filename=path)
> x1App.ActiveWorkbook.Close(SaveChanges=0)
> x1App.Quit()
> del x1App
> del Book1
> del activeSheet
> 
> What am I missing?
> 

In my Excel projects, I terminate it with:

xlBook.Close()
xlApp.Quit()

I haven't had a problem with Excel staying open after the program ends.

(On a tangent, I want to find the person who thought it was a good idea
to use the same symbol in a font for 1, l, and I and do some unpleasant
things.)


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


Re: printing list containing unicode string

2007-09-11 Thread Sion Arrowsmith
Xah Lee  <[EMAIL PROTECTED]> wrote:
> "  It's very wasteful of space. In most texts, the majority of the
>code points are less than 127, or less than 255, so a lot of space is
>occupied by zero bytes. "
>
>Not true. In Asia, most chars has unicode number above 255. Considered
>globally, *possibly* today there are more computer files in Chinese
>than in all latin-alphabet based lang.

This doesn't hold water. There are many good reasons for preferring
UTF16 over UTF8, but unless you know you're only ever going to be
handling scripts from Unicode blocks above Arabic, it's reasonable
to assume that UTF8 will be at least as compact. Consider that
transcoding a Chinese file from UTF16 to UTF8 will probably increase
its size by 50% (the CJK ideograph blocks encode to 3 bytes). While
transcoding a document in a Western European langauge the other way
can be expected to increase its size by up to 100% (every single-
byte character is doubled). You'd have to be talking about double to
volume of CJK data before switching from UTF8 to UTF16 becomes even
a break-even proposition space-wise.

(It's curious to note that the average word length in English is
often taken to be 6 letters. Similarly, in UTF8-encoded Chinese the
average word length is 6 bytes)

-- 
\S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/
   "Frankly I have no feelings towards penguins one way or the other"
-- Arthur C. Clarke
   her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: customizing a logging logger

2007-09-11 Thread garyjefferson123
I think the following question is clearer.

I want to make it so that method1 below can be transformed:

logger = logging.getLogger("somelogger")
class SomeOp:
def __init__(self, ctx):
self.ctx = ctx
def method1(self):
logger.info("%s: here's a message", self.ctx)
logger.debug("%s: msg #2", self.ctx)
v = 'yessir'
logger.debug("%s: msg #3 %s", self.ctx, v)

into something like:

def method1(self):
logger.info("here's a message")
logger.debug("msg #2")
v = 'yessir'
logger.debug("msg #3 %s", v)


What is the best way to do this, so that I don't have to manually put
the self.ctx in the log string in hundreds of different places?

Thanks,
Gary

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


Re: Why zlib not included in Python tarball?

2007-09-11 Thread Milos Prudek

> Depends on the operating system and the Python version. On Unix, you
> need to install zlib first; if you install a precompiled zlib package,
> make sure you install the header files as well.

You were right. Thank you. 



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


Re: mod_python and pysvn

2007-09-11 Thread Tim Golden
Sjoerd wrote:
> Hello all,
> 
> I have a script that uses pySVN. It gets the latest build information.
> I want to create a call to that function in a PSP file but everytime I
> try I get an error message:
> 
> ClientError: Unable to open an ra_local session to URL
> Unable to open repository 'file:///P:/tools/builds/repository'
> 
> does anyone know how I can fix this?

Usually means that the process which Apache is running under
(may well be LocalSystem) doesn't know about or doesn't have
access to p:/tools etc. Assuming that P: is a network drive,
try using its UNC (\\server\share\tools etc.) but even there
I suspect you may have security issues. One way or the other,
you would need to give the Apache service enough security
access to that share/directory for it to do its job.

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


mod_python and pysvn

2007-09-11 Thread Sjoerd
Hello all,

I have a script that uses pySVN. It gets the latest build information.
I want to create a call to that function in a PSP file but everytime I
try I get an error message:

ClientError: Unable to open an ra_local session to URL
Unable to open repository 'file:///P:/tools/builds/repository'

does anyone know how I can fix this?

thanks in advance!
Sjoerd

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


  1   2   >