Re: Speed of Python

2007-09-07 Thread Marc 'BlackJack' Rintsch
On Fri, 07 Sep 2007 23:53:48 +, wang frank wrote: >>From: "Marc 'BlackJack' Rintsch" <[EMAIL PROTECTED]> >>To: python-list@python.org >>Subject: Re: Speed of Python >>Date: 7 Sep 2007 23:17:55 GMT >> >>On Fri, 07 Sep 2007 22:59:26 +, wang frank wrote: >> >> > I also have tried to use numpy

Re: pdb question - spew out "steps" until crash needed

2007-09-07 Thread Paul Rubin
James Stroud <[EMAIL PROTECTED]> writes: > How do I get pdb to just run my program and spew out what's happening > until it crashes/freezes? (This is a malloc error in a library > somewhere and I can't figure out where--no exceptions thrown, etc.) Maybe you want: http://docs.python.org/lib/module-

Re: MySQLdb: ValueError Something Stupid

2007-09-07 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, mcl wrote: > ValueError: invalid literal for int(): 0- Could it be you have a MySQL column that is declared as some integer type, but contains this funny "0-" value? So when MySQLdb tries to return it as a Python integer, it fails to convert. -- http://mail.python

Re: exponential float formmating

2007-09-07 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote: > In all cases I need the number to start with 0 > 0.13000E+01 So why not move the decimal point left one, and add one to the exponent. -- http://mail.python.org/mailman/listinfo/python-list

Re: platform system may be Windows or Microsoft since Vista

2007-09-07 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote: > I'm thinking no priority because there is no fixing this. Why are you bothering to check an informational string? Why not check directly for the functionality you need? -- http://mail.python.org/mailman/listinfo/python-list

pdb question - spew out "steps" until crash needed

2007-09-07 Thread James Stroud
How do I get pdb to just run my program and spew out what's happening until it crashes/freezes? (This is a malloc error in a library somewhere and I can't figure out where--no exceptions thrown, etc.) I think I might need to live a lot longer to simply hit 's' [enter] until I get to the crash.

Re: Generating a unique identifier

2007-09-07 Thread Paul Rubin
Steven D'Aprano <[EMAIL PROTECTED]> writes: > > Sorry, make that 32 or 40 instead of 10, if the number of id's is large, > > to make birthday collisions unlikely. > > I did a small empirical test, and with 16 million ids, I found no > collisions. 16 million 32-byte ids? With string and dictiona

Re: exponential float formmating

2007-09-07 Thread Steven D'Aprano
On Fri, 07 Sep 2007 13:42:30 +, Marc 'BlackJack' Rintsch wrote: > On Fri, 07 Sep 2007 06:08:19 -0700, zunbeltz wrote: > >> For compatibility reasons with an old program I have to format string >> in exponential format with the following format >> >> 0.xE-yy >> >> This means that the num

Re: Generating a unique identifier

2007-09-07 Thread Steven D'Aprano
On Fri, 07 Sep 2007 19:17:44 -0700, Paul Rubin wrote: >> Here's something which is a little less predictable than a straight >> counter: > > It's still very easy to generate valid id's from that, or guess the next > one with non-negligible probability. Well, in my specific application, the only

Re: Python Problem

2007-09-07 Thread Carsten Haese
On Fri, 2007-09-07 at 21:58 -0400, Wiseman wrote: > 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

Re: Generating a unique identifier

2007-09-07 Thread Steven D'Aprano
On Fri, 07 Sep 2007 08:47:58 -0700, Paul Rubin wrote: > Paul Rubin writes: >> def unique_id(): >>return os.urandom(10).encode('hex') > > Sorry, make that 32 or 40 instead of 10, if the number of id's is large, > to make birthday collisions unlikely. I did a small e

Re: Is a Borg rebellion possible? (a metaclass question)

2007-09-07 Thread BartlebyScrivener
On Sep 7, 1:53 pm, Steve Holden <[EMAIL PROTECTED]> wrote: > All you really need is to create your SplinterBorgs with appropriate > group names, you don't neef subclasses at all: oops, I tried this once and the link broke. I'll try tinyurl. Dang. With that subject heading I thought this was abou

Re: Is a Borg rebellion possible? (a metaclass question)

2007-09-07 Thread BartlebyScrivener
On Sep 7, 1:53 pm, Steve Holden <[EMAIL PROTECTED]> wrote: > All you really need is to create your SplinterBorgs with appropriate > group names, you don't neef subclasses at all: > Dang. With that subject heading I thought this was about some post- Singularity, Python-programmed cyborgs rising up

Re: subprocess.communicate messes things up

2007-09-07 Thread Gabriel Genellina
En Fri, 07 Sep 2007 22:51:34 -0300, <[EMAIL PROTECTED]> escribi�: > problem is that the first time I press a key, it works, but after it > just print the keys I press, the annoying line being the one with > communicate, any idea of what is happening ? > > child1 = subprocess.Popen("/usr/bin/

Re: Subprocess module and unicode input

2007-09-07 Thread Gabriel Genellina
En Fri, 07 Sep 2007 18:46:26 -0300, Matthew Lausch <[EMAIL PROTECTED]> escribi�: > I'd like to use the subprocess module with upper level characters in > the process name or in the arguments to the process. Something like > this: > > cmd = [ u'test_\u65e5\u672c\u8a9e_exec.bat', u'arg1', u'arg2'

Re: Generating a unique identifier

2007-09-07 Thread Steve Holden
Paul Rubin wrote: > Paul Rubin writes: >> the probability is about exp(-(2**60 / 2*2**160)) = 1/exp(2**101) > > Bah. Got that backwards and calculated wrong. The probability of no > collisions is > > exp(-(2**60) / (2*2**160)) = exp(-(2**-101)) = approx (1 - 2**-1

Re: Generating a unique identifier

2007-09-07 Thread Paul Rubin
Paul Rubin writes: > the probability is about exp(-(2**60 / 2*2**160)) = 1/exp(2**101) Bah. Got that backwards and calculated wrong. The probability of no collisions is exp(-(2**60) / (2*2**160)) = exp(-(2**-101)) = approx (1 - 2**-101) which is very close to 1.

Re: Generating a unique identifier

2007-09-07 Thread Paul Rubin
Steven D'Aprano <[EMAIL PROTECTED]> writes: > > unique_id = itertools.count(1234567890) > > Sweet! > > I really must make itertools second-nature. I always forget it. Beware that count() output (like enumerate) is always <= sys.maxint. It raises an exception if it overflows. IMO this is a bug.

Re: Checking if elements are empty

2007-09-07 Thread Wildemar Wildenburger
Lawrence D'Oliveiro wrote: if y[0]: >>> Not a good idea. >> Why not? > > Because there is a situation where your version of the test will fail even > if the first element of y is non-null. Such as? Seriously people, a little more verbosity wouldn't hurt here. This isn't a mystery game. /W

Python Problem

2007-09-07 Thread Wiseman
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 enc

subprocess.communicate messes things up

2007-09-07 Thread KingShivan
please could you take a look at this piece of code ? what I'd like is typically a sound boc : press one key, and get the associated sound. for this I place the sound files in different directories (easy to move and modify) and when a key is pressed I grab the first file of the corresponding direct

Re: Generating a unique identifier

2007-09-07 Thread Paul Rubin
Ben Finney <[EMAIL PROTECTED]> writes: > > http://docs.python.org/lib/module-uuid.html > I second this recommendation. If you want arbitrary unique IDs that > are not a function of the data they identify, the simplest solution is > a monotonically-increasing serial number. If you want more than

Re: Generating a unique identifier

2007-09-07 Thread Steven D'Aprano
On Fri, 07 Sep 2007 08:42:45 -0700, Paul Rubin wrote: > Steven D'Aprano <[EMAIL PROTECTED]> writes: >> def unique_id(): >> n = 1234567890 >> while True: >> yield n >> n += 1 > > unique_id = itertools.count(1234567890) Sweet! I really must make itertools second-nature. I

Re: creating really big lists

2007-09-07 Thread Gabriel Genellina
En Fri, 07 Sep 2007 16:16:46 -0300, Dr Mephesto <[EMAIL PROTECTED]> escribi�: > hey, that defaultdict thing looks pretty cool... > > whats the overhead like for using a dictionary in python? Dictionaries are heavily optimized in Python. Access time is O(1), adding/removing elements is amortiz

Re: Best way to do attribute docstrings?

2007-09-07 Thread Gabriel Genellina
En Fri, 07 Sep 2007 17:06:07 -0300, Ken Kuhlman <[EMAIL PROTECTED]> escribi�: > What's the best method for annotating attributes with a docstring? > I'm looking to be able to introspect my class & get the comments back > out. I don't know which is the *best* method. Perhaps you might use proper

Re: How to determine the bool between the strings and ints?

2007-09-07 Thread Steven D'Aprano
On Fri, 07 Sep 2007 17:40:44 +0200, Jorgen Bodde wrote: > is the bool derived from 'int' in some way? Yes. >>> issubclass(bool, int) True > What is the best way to > check if the config I want to write is an int or a bool ? if isinstance(value, bool): print "it's a bool, or a subclass of

Re: Is a Borg rebellion possible? (a metaclass question)

2007-09-07 Thread Carsten Haese
On Fri, 2007-09-07 at 14:54 -0600, Steven Bethard wrote: > Carsten Haese wrote: > > [slightly convoluted example...] > > I think I would probably write that as:: > [concise example...] > > That is, I don't think there's really a need for __new__ if you're using > a metaclass. Just set the instan

Re: Speed of Python

2007-09-07 Thread Carl Banks
On Sep 7, 12:42 pm, "wang frank" <[EMAIL PROTECTED]> wrote: > Hi, > > While comparing the speed of octave and matlab, I decided to do a similar > test for python and matlab. The result shows that python is slower than > matlab by a factor of 5. It is not bad since octave is about 30 time slower > t

Re: application version checking against database

2007-09-07 Thread Gabriel Genellina
En Fri, 07 Sep 2007 10:12:09 -0300, Hamilton, William <[EMAIL PROTECTED]> escribi�: >> We are trying to implement a system that checks the version of the >> application against a version number stored in the database. We don't >> want the app and the db don't become out of sync. >> >> We have

Re: Speed of Python

2007-09-07 Thread Terry Reedy
"wang frank" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] |z=log(j); This matlab code is faster in part than your Python equivalent: | > > z=math.log(m) because of the repeated lookup of log in the math module. So, replace | > > import math with

Re: Best practice prompting for password

2007-09-07 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, GiBo wrote: > what's the best practice to securely prompt user for password on console > in Python? IIRC some programs like SSH do a lot to ensure that the input > comes from TTY and is not redirected from somewhere and several other > checks. Does it? Why bother?

Re: Checking if elements are empty

2007-09-07 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Wildemar Wildenburger wrote: > Lawrence D'Oliveiro wrote: > >> In message <[EMAIL PROTECTED]>, Chris >> Mellon wrote: >> >>> On 9/5/07, Steve Holden <[EMAIL PROTECTED]> wrote: Doran, Harold wrote: > > Is there a way to check if the first element of y i

Re: unexpected behavior: did i create a pointer?

2007-09-07 Thread Steven D'Aprano
On Fri, 07 Sep 2007 15:59:53 +0200, Wildemar Wildenburger wrote: > I just thought I'd go along with the analogy the OP created as that was > his mindset and it would make things easier to follow if I didn't try to > forcibly change that. My reaction to somebody trying to reason with the wrong ana

Re: Speed of Python

2007-09-07 Thread wang frank
I am just trying to compare the speed with matlab. The arrange is used for another test, that is why it shows up in the mail. Thanks Frank From: "Marc 'BlackJack' Rintsch" <[EMAIL PROTECTED]> To: python-list@python.org Subject: Re: Speed of Python Date: 7 Sep 2007 23:17:55 GMT On Fri, 07 Se

Re: Generating a unique identifier

2007-09-07 Thread Ben Finney
Will Maier <[EMAIL PROTECTED]> writes: > On Fri, Sep 07, 2007 at 12:03:23PM -, Steven D'Aprano wrote: > [...] > > which is easy enough, but I thought I'd check if there was an > > existing solution in the standard library that I missed. Also, for > > other applications, I might want them to be

Re: Speed of Python

2007-09-07 Thread Marc 'BlackJack' Rintsch
On Fri, 07 Sep 2007 22:59:26 +, wang frank wrote: > I also have tried to use numpy to speed it up. However, surprisingly, it is > slower than the pure python code. > > Here is the code: > import numpy > arange=numpy.arange > nlog=numpy.log > def bench6(n): > for i in xrange(n): >

Re: why should I learn python

2007-09-07 Thread 7stud
On Sep 6, 10:51 pm, James Stroud <[EMAIL PROTECTED]> wrote: > BartlebyScrivener wrote: > > On Sep 6, 5:36 pm, André <[EMAIL PROTECTED]> wrote: > > >> Easy to read, easy to write, good libraries and, I have found, an > >> extremely helpful community. > > >> Hobbyists (like me) can work on projects w

Re: why should I learn python

2007-09-07 Thread 7stud
On Sep 6, 9:20 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Thu, 06 Sep 2007 23:34:10 -0300, Grant Edwards <[EMAIL PROTECTED]> > escribi?: > > > On 2007-09-06, Torsten Bronger <[EMAIL PROTECTED]> wrote: > >> Hallöchen! > > >> Tom Brown writes: > > >>> [...] Python has been by far the e

Re: What does this thread have to do with classical music,

2007-09-07 Thread ah
Art Deco wrote: > ah <[EMAIL PROTECTED]> wrote: >>Art Deco wrote: >>> ah <[EMAIL PROTECTED]> wrote: Art Deco wrote: > ah <[EMAIL PROTECTED]> wrote: >>Art Deco wrote: >>> ah <[EMAIL PROTECTED]> wrote: Art Deco wrote: > ah <[EMAIL PROTECTED]> wrote: >>Art Deco

Re: Speed of Python

2007-09-07 Thread wang frank
I also have tried to use numpy to speed it up. However, surprisingly, it is slower than the pure python code. Here is the code: import numpy arange=numpy.arange nlog=numpy.log def bench6(n): for i in xrange(n): for j in xrange(1000): m=j+1

Re: why should I learn python

2007-09-07 Thread Ricardo Aráoz
Tom Brown wrote: > On Thursday 06 September 2007 15:44, Torsten Bronger wrote: >> Hallöchen! >> >> Tom Brown writes: >>> [...] Python has been by far the easiest to develop in. Some >>> people might say it is not "real programming" because it is so >>> easy. >> I can't believe this. Have you real

Re: Finding specific date ranges

2007-09-07 Thread Ricardo Aráoz
Tim Golden wrote: > [EMAIL PROTECTED] wrote: >> Hi, >> >> I am working on a timesheet application in which I need to to find the >> first pay period in a month that is entirely contained in that month >> to calculate vacation time. Below are some example date ranges: >> >> >> December 31, 2006J

Subprocess module and unicode input

2007-09-07 Thread Matthew Lausch
I'd like to use the subprocess module with upper level characters in the process name or in the arguments to the process. Something like this: cmd = [ u'test_\u65e5\u672c\u8a9e_exec.bat', u'arg1', u'arg2' ] subprocess.call(cmd) But this gives the error: UnicodeEncodeError: 'ascii' codec can't en

Re: How to convert None to null value

2007-09-07 Thread Steve Holden
Carsten Haese wrote: > On Fri, 2007-09-07 at 12:10 -0700, Dennis Lee Bieber wrote: >> On Fri, 07 Sep 2007 09:07:49 -0400, Carsten Haese <[EMAIL PROTECTED]> >> declaimed the following in comp.lang.python: >> >> >>> doesn't have a parameter binding mechanism, you should throw it away and >>> replace

Re: Is a Borg rebellion possible? (a metaclass question)

2007-09-07 Thread Steven Bethard
Carsten Haese wrote: > Indeed, if you have an __init__ method that shouldn't see the "group" > argument, you need a metaclass after all so you can yank the "group" > argument between __new__ and __init__. The following code seems to work, > but it's making my brain hurt: > > class SplinterBorgMeta

Re: Python and Cron

2007-09-07 Thread Shawn Milochik
Any chance your import statements aren't coming in properly due to something in your environment in Python that's not being inherited by your cron job? -- http://mail.python.org/mailman/listinfo/python-list

Re: Speed of Python

2007-09-07 Thread wang frank
Thanks for all your help. Using Istvan Albert's suggestion, I have recompared the speed of the following funciton: matlab: function [z]=bench2(n) for i=1:n, j=(0:999); z=log(j+1); end python: from numpy import arange, log def bench4(n): for i in xrange(n): nums = arange( n )

Re: How to determine the bool between the strings and ints?

2007-09-07 Thread Marc 'BlackJack' Rintsch
On Fri, 07 Sep 2007 12:26:46 -0700, Zentrader wrote: > Looks like a "feature" of isinstance() is to consider both True and 1 as > booleans, but type() distinguishes between the two. That's not a "feature", it is just OOP. `bool` is a subclass of `int` therefore every `bool` instance is also an i

Best way to do attribute docstrings?

2007-09-07 Thread Ken Kuhlman
What's the best method for annotating attributes with a docstring? I'm looking to be able to introspect my class & get the comments back out. The technique I'm using is a little hoaky, but works.. basically I create subclasses of the builtin types that I want to be able to use & then instantiate

Re: Python and CUDO

2007-09-07 Thread Robert Kern
Paddy wrote: > On Sep 6, 10:12 pm, Robert Kern <[EMAIL PROTECTED]> wrote: >> Veronika Lindstrand Kant wrote: >>> Hi! >>> I just wonder if there are any plans for building any support using >>> NIVIDAS CUDO plattform into python? >> Not into Python itself, but we are working on interfacing with NVID

Re: Speed of Python

2007-09-07 Thread ajaksu
On Sep 7, 2:37 pm, "wang frank" <[EMAIL PROTECTED]> wrote: > I am not familiar with python, so I just simply try to reproduce the same > code in python. Seems almost correct, but from what I guess of MatLab, George's suggestions make it a bit more fair. > If you think that my python script is not

Re: How to determine the bool between the strings and ints?

2007-09-07 Thread Zentrader
On Sep 7, 11:30 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Fri, 07 Sep 2007 18:49:12 +0200, Jorgen Bodde wrote: > > As for why caring if they are bools or not, I write True and False to > > the properties, the internal mechanism works like this so I need to > > make that distincti

Re: creating really big lists

2007-09-07 Thread Dr Mephesto
On 6 Sep., 09:30, Paul McGuire <[EMAIL PROTECTED]> wrote: > On Sep 6, 12:47 am, Dr Mephesto <[EMAIL PROTECTED]> wrote: > > > > > I need some real speed! a database is waaay to slow for the algorithm > > im using. and because the sublists are of varying size, i dont think I > > can use an array...-

Re: Is a Borg rebellion possible? (a metaclass question)

2007-09-07 Thread André
On Sep 7, 4:00 pm, Carsten Haese <[EMAIL PROTECTED]> wrote: > On Fri, 2007-09-07 at 15:54 +, André wrote: > > Unfortunately, it fails. Here's what I tried, followed by the > > traceback > > class SplinterBorg(object): > > _shared_states = {} > > def __new__(cls, *a, **k): > > g

Re: unexpected behavior: did i create a pointer?

2007-09-07 Thread Steve Holden
Grant Edwards wrote: > On 2007-09-07, Peter Otten <[EMAIL PROTECTED]> wrote: >> Am Fri, 07 Sep 2007 10:40:47 + schrieb Steven D'Aprano: >> >>> Python doesn't have any pointers. >> Thinking of python variables or "names" as pointers should >> get you a long way when trying to understand python's

Re: How to convert None to null value

2007-09-07 Thread Carsten Haese
On Fri, 2007-09-07 at 12:10 -0700, Dennis Lee Bieber wrote: > On Fri, 07 Sep 2007 09:07:49 -0400, Carsten Haese <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > > > doesn't have a parameter binding mechanism, you should throw it away and > > replace it with a DB-API complain

Re: Is a Borg rebellion possible? (a metaclass question)

2007-09-07 Thread André
On Sep 7, 3:53 pm, Steve Holden <[EMAIL PROTECTED]> wrote: > André wrote: > > On Sep 7, 10:27 am, Carsten Haese <[EMAIL PROTECTED]> wrote: > >> On Fri, 2007-09-07 at 12:31 +, André wrote: > >>> In my application, I make use of the Borg idiom, invented by Alex > >>> Martelli. > >>> class Borg(ob

Re: Python and Cron

2007-09-07 Thread Greg Lindstrom
> "Shawn Milochik" <[EMAIL PROTECTED]> > Could you send the output of "crontab -l" and the script you're running? > > It's probably an environment issue of some kind, but it's hard to say > what blindly. # run client pricing at 0215 (p) Monday-Friday 15 2 * * 1-5 cd /m01/edith/src && /usr/bin/py

Re: unexpected behavior: did i create a pointer?

2007-09-07 Thread Steve Holden
Steven D'Aprano wrote: > On Fri, 07 Sep 2007 11:46:38 +0200, Wildemar Wildenburger wrote: > >> gu wrote: >>> hi to all! >>> after two days debugging my code, i've come to the point that the >>> problem was caused by an unexpected behaviour of python. or by lack of >>> some information about the pr

Re: Python and Cron

2007-09-07 Thread Greg Lindstrom
> Can you post the Python script? Not the whole thing; it's quite long. But here's the relevant parts. We're using the ado database interface into postgres (that's what the results.EOFis all about) output_file = file(output_path, 'w') # output_path = /my_path/data/work/my_file.txt while not

Re: Organizing Code - Packages

2007-09-07 Thread Wildemar Wildenburger
Paul Rudin wrote: > xkenneth <[EMAIL PROTECTED]> writes: > >>> Ah, yes, a couple of things: >>> - avoid the 'one-class-per-file' syndrom. It's perfectly ok to have tens >> Yes but i find it hard to edit classes easily when I have more than >> one class per file. > > Why? Scroll-Blindness would be

Re: Is a Borg rebellion possible? (a metaclass question)

2007-09-07 Thread Carsten Haese
On Fri, 2007-09-07 at 15:54 +, André wrote: > Unfortunately, it fails. Here's what I tried, followed by the > traceback > class SplinterBorg(object): > _shared_states = {} > def __new__(cls, *a, **k): > group = k.pop("group","BORG") > obj = object.__new__(cls, *a, **k)

Re: Speed of Python

2007-09-07 Thread Istvan Albert
On Sep 7, 12:42 pm, "wang frank" <[EMAIL PROTECTED]> wrote: > Is my conclusion correct that Python is slower than matlab? There are ways to speed up code execution, but to see substantial improvement you'll need to use numpy and rework the code to operate on vectors/matrices rather than building

Re: Speed of Python

2007-09-07 Thread George Sakkis
On Sep 7, 12:42 pm, "wang frank" <[EMAIL PROTECTED]> wrote: > Is my conclusion correct that Python is slower than matlab? Are there any > way to speed it up? Yes, use Numpy for any non trivial number-crunching task: http://numpy.scipy.org/. Even if you don't, you can speed up the original functi

Re: Is a Borg rebellion possible? (a metaclass question)

2007-09-07 Thread Steve Holden
André wrote: > On Sep 7, 10:27 am, Carsten Haese <[EMAIL PROTECTED]> wrote: >> On Fri, 2007-09-07 at 12:31 +, André wrote: >>> In my application, I make use of the Borg idiom, invented by Alex >>> Martelli. >>> class Borg(object): >>> '''Borg Idiom, from the Python Cookbook, 2nd Edition, p:

Re: why should I learn python

2007-09-07 Thread Shawn Milochik
I wholeheartedly second the recommendation of this article: http://www.linuxjournal.com/article/3882 -- http://mail.python.org/mailman/listinfo/python-list

Re: Python and Cron

2007-09-07 Thread Paul McNett
Greg Lindstrom wrote: > This may be more of a Linux question, but I'm hoping some of you may be > able to help me. > > I have a python (2.4) routine running on Gentoo Linux. It creates a > file and, after the file is complete, renames the file using the > os.rename() command. When I run the f

Re: How to determine the bool between the strings and ints?

2007-09-07 Thread Marc 'BlackJack' Rintsch
On Fri, 07 Sep 2007 18:49:12 +0200, Jorgen Bodde wrote: > As for why caring if they are bools or not, I write True and False to > the properties, the internal mechanism works like this so I need to > make that distinction. Really? Can't you just apply the `int()` function? In [52]: map(int, [1,

Re: Python and Cron

2007-09-07 Thread Shawn Milochik
Could you send the output of "crontab -l" and the script you're running? It's probably an environment issue of some kind, but it's hard to say what blindly. -- http://mail.python.org/mailman/listinfo/python-list

RE: passing command line arguments

2007-09-07 Thread Brian McCann
Darren, Thanks From: [EMAIL PROTECTED] on behalf of darren kirby Sent: Fri 9/7/2007 1:58 PM To: python-list@python.org Subject: Re: passing command line arguments quoth the Brian McCann: > Hi, > > when I run the script show_args2.py > > # ./show_args2.py 1

Re: Speed of Python

2007-09-07 Thread Roberto Bonvallet
On Sep 7, 1:37 pm, "wang frank" <[EMAIL PROTECTED]> wrote: > Hi, > Here is the matlab code: > function [z]=bench1(n) > for i=1:n, > for j=1:1000, > z=log(j); > z1=log(j+1); > z2=log(j+2); > z3=log(j+3); > z4=log(j+4); > z5=log(j+5); > z6=l

Re: passing command line arguments

2007-09-07 Thread darren kirby
quoth the Brian McCann: > Hi, > > when I run the script show_args2.py > > # ./show_args2.py 1 2 3 > > I get the following error > > Traceback (most recent call last): > File "./show_args2.py", line 4, in ? > print 'The arguments of %s are "%s"' %s \ > NameError: name 's' is not defined >

Re: py2exe - change name of exe created

2007-09-07 Thread Thomas Heller
imageguy schrieb: [...] >> > Note that every thing works fine with this and creates an exe program >> > called >> > "myprogram.exe" >> >> > I would like to setup program to create an output called; >> > "MyBestProgram.exe" >> >> > IS that at all possible ? >> >> Yes. Use a 'dest_base' key in the d

Re: passing command line arguments

2007-09-07 Thread Carsten Haese
On Fri, 2007-09-07 at 12:47 -0400, Brian McCann wrote: > > Hi, > > when I run the script show_args2.py > > # ./show_args2.py 1 2 3 > > I get the following error > > Traceback (most recent call last): > File "./show_args2.py", line 4, in ? > print 'The arguments of %s are "%s"' %s \ >

Example script -- Group Project Task Scheduler

2007-09-07 Thread nickel_and_dime_2death
Hello, trying to get UpToSpeed with a cross-platform application that would mimic capabilities like Microsoft Project. Playing around with code is what works for me. Searching is a mangled process, i.e. I've banged around terms like: "project", "scheduler", "class scheduler", "student calendar" ...

Re: getting the current function

2007-09-07 Thread Arnaud Delobelle
On Sep 7, 5:19 pm, Gary Robinson <[EMAIL PROTECTED]> wrote: > > This all seems a bit too complicated. Are you sure you want to do > > this? Maybe you need to step back and rethink your problem. > > In version 2.1 Python added the ability to add function attributes -- > seehttp://www.python.org/dev

Re: Speed of Python

2007-09-07 Thread wang frank
Hi, Here is the matlab code: function [z]=bench1(n) for i=1:n, for j=1:1000, z=log(j); z1=log(j+1); z2=log(j+2); z3=log(j+3); z4=log(j+4); z5=log(j+5); z6=log(j+6); z7=log(j+7); z8=log(j+8); z9=log(j+9); end end z = z9;

Re: startswith( prefix[, start[, end]]) Query

2007-09-07 Thread Steve Holden
Bruno Desthuilliers wrote: > Steve Holden a écrit : [...] >> >> Probably not really necessary, though, and they do say that premature >> optimization is the root of all evil ... > > I wouldn't call this one "premature" optimization, since it doesn't > change the algorithm, doesn't introduce (muc

Re: Why 'class spam(object)' instead of class spam(Object)' ?

2007-09-07 Thread Steve Holden
Carl Banks wrote: > On Fri, 07 Sep 2007 01:30:00 -0500, Sergio Correia wrote: >> Hi, I'm kinda new to Python (that means, I'm a total noob here), but >> have one doubt which is more about consistency that anything else. >> >> Why if PEP 8 says that "Almost without exception, class names use the >>

Re: library to launch program in linux

2007-09-07 Thread Neil Cerutti
On 2007-09-07, Lawrence D'Oliveiro <[EMAIL PROTECTED]> wrote: > In message <[EMAIL PROTECTED]>, Laszlo Nagy > wrote: > >> Grant Edwards wrote: >> >>> On 2007-09-06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >>> I'm a new user. What library should I use so that I can launch program i

Re: interesting puzzle......try this you will be rewarded...

2007-09-07 Thread Neil Cerutti
On 2007-09-07, Gabriel Genellina <[EMAIL PROTECTED]> wrote: > En Thu, 06 Sep 2007 22:57:21 -0300, Basilisk96 <[EMAIL PROTECTED]> > escribi?: > >> I got to 14 :) >> >> It's rather silly. >> >> I remember seeing a more elaborate puzzle that involved coding, >> cryptography knowledge, etc. to get th

Python and Cron

2007-09-07 Thread Greg Lindstrom
This may be more of a Linux question, but I'm hoping some of you may be able to help me. I have a python (2.4) routine running on Gentoo Linux. It creates a file and, after the file is complete, renames the file using the os.rename() command. When I run the file from the command line everything

Re: Speed of Python

2007-09-07 Thread Roberto Bonvallet
On Sep 7, 12:42 pm, "wang frank" <[EMAIL PROTECTED]> wrote: > Here is the bench1.py: > import math > def bench1(n): > for i in range(n): > for j in range(1000): > m=j+1 > z=math.log(m) > z1=math.log(m+1)

Re: Speed of Python

2007-09-07 Thread S bastien Boisg rault
On Sep 7, 6:42 pm, "wang frank" <[EMAIL PROTECTED]> wrote: Matlab (aka MATrix LABoratory) has been designed with numeric computations in mind (every object being natively a n-dim array). If you wish to develop that kind of applications in Python, consider using the numerical array structure provi

Re: concise code (beginner)

2007-09-07 Thread Rhamphoryncus
On Sep 6, 1:56 pm, Karthik Gurusamy <[EMAIL PROTECTED]> wrote: > That said, it may be a good future language enhancement to define a > reasonable consistent behavior for an iterator over a changing > collection. This occurs quite common when we walk a collection and > usually delete the current ite

Re: How to determine the bool between the strings and ints?

2007-09-07 Thread Jorgen Bodde
Awesome! Thanks you! As for why caring if they are bools or not, I write True and False to the properties, the internal mechanism works like this so I need to make that distinction. Thanks again guys, - Jorgen ps. Sorry TheFlyingDutch for mailing you personally, I keep forgetting this mailinglis

passing command line arguments

2007-09-07 Thread Brian McCann
Hi, when I run the script show_args2.py # ./show_args2.py 1 2 3 I get the following error Traceback (most recent call last): File "./show_args2.py", line 4, in ? print 'The arguments of %s are "%s"' %s \ NameError: name 's' is not defined #

Re: Organizing Code - Packages

2007-09-07 Thread Paul Rudin
xkenneth <[EMAIL PROTECTED]> writes: >> Ah, yes, a couple of things: >> - avoid the 'one-class-per-file' syndrom. It's perfectly ok to have tens > > Yes but i find it hard to edit classes easily when I have more than > one class per file. Why? -- http://mail.python.org/mailman/listinfo/python-li

Speed of Python

2007-09-07 Thread wang frank
Hi, While comparing the speed of octave and matlab, I decided to do a similar test for python and matlab. The result shows that python is slower than matlab by a factor of 5. It is not bad since octave is about 30 time slower than matlab. Here is the result in matlab: Elapsed time is 0.01538

Re: Organizing Code - Packages

2007-09-07 Thread xkenneth
> Ah, yes, a couple of things: > - avoid the 'one-class-per-file' syndrom. It's perfectly ok to have tens Yes but i find it hard to edit classes easily when I have more than one class per file. Regards, Ken -- http://mail.python.org/mailman/listinfo/python-list

Re: How to determine the bool between the strings and ints?

2007-09-07 Thread TheFlyingDutchman
On Sep 7, 8:40 am, "Jorgen Bodde" <[EMAIL PROTECTED]> wrote: > Hi All, > > I have a dictionary with settings. The settinfgs can be strings, ints > or bools. I would like to write this list dynamically to disk in a big > for loop, unfortunately the bools need to be written as 0 or 1 to the > config

Re: py2exe - change name of exe created

2007-09-07 Thread imageguy
On Sep 7, 11:22 am, Thomas Heller <[EMAIL PROTECTED]> wrote: > imageguy schrieb: > > > > > > > Sorry for the double post, sent it to quickly. > > > I have a setup script like this; > > > setup(windows = [{"script":"myprogram.py", > >"icon_resources":[(0,"nabbitt.ico")], > >

re: getting the current function

2007-09-07 Thread Gary Robinson
> This all seems a bit too complicated. Are you sure you want to do > this? Maybe you need to step back and rethink your problem. In version 2.1 Python added the ability to add function attributes -- see http://www.python.org/dev/peps/pep-0232/ for the justifications. A counter probably isn't on

Re: why should I learn python

2007-09-07 Thread JeffHua
In a message dated 2007-9-7 7:50:32, [EMAIL PROTECTED] writes: Tom Brown wrote: > On Thursday 06 September 2007 15:44, Torsten Bronger wrote: >> Hallöchen! >> >> Tom Brown writes: >> > [...] Python has been by far the easiest to develop in. Some >> > people might say it is not "real progra

Re: Is a Borg rebellion possible? (a metaclass question)

2007-09-07 Thread André
On Sep 7, 10:27 am, Carsten Haese <[EMAIL PROTECTED]> wrote: > On Fri, 2007-09-07 at 12:31 +, André wrote: > > In my application, I make use of the Borg idiom, invented by Alex > > Martelli. > > > class Borg(object): > > '''Borg Idiom, from the Python Cookbook, 2nd Edition, p:273 > > >

Re: How to determine the bool between the strings and ints?

2007-09-07 Thread Bruno Desthuilliers
Jorgen Bodde a écrit : > Hi All, > > I have a dictionary with settings. The settinfgs can be strings, ints > or bools. I would like to write this list dynamically to disk in a big > for loop, unfortunately the bools need to be written as 0 or 1 to the > config with WriteInt, the integers also with

Re: Generating a unique identifier

2007-09-07 Thread Paul Rubin
Paul Rubin writes: > def unique_id(): >return os.urandom(10).encode('hex') Sorry, make that 32 or 40 instead of 10, if the number of id's is large, to make birthday collisions unlikely. If you don't want the id's to be that large, you can implement a Feistel cipher

Re: Generating a unique identifier

2007-09-07 Thread Paul Rubin
Steven D'Aprano <[EMAIL PROTECTED]> writes: > def unique_id(): > n = 1234567890 > while True: > yield n > n += 1 unique_id = itertools.count(1234567890) > which is easy enough, but I thought I'd check if there was an existing > solution in the standard library that I miss

Re: Organizing Code - Packages

2007-09-07 Thread Bruno Desthuilliers
xkenneth a écrit : > All, > > I apologize if this is a commonly asked question, but I didn't > find anything that answered my question while searching. > > So what I have right now is a few packages that contain some commonly > used functions and another package that contains all of my custom

How to determine the bool between the strings and ints?

2007-09-07 Thread Jorgen Bodde
Hi All, I have a dictionary with settings. The settinfgs can be strings, ints or bools. I would like to write this list dynamically to disk in a big for loop, unfortunately the bools need to be written as 0 or 1 to the config with WriteInt, the integers also with WriteInt and the strings with a si

  1   2   >