Re: Encoding / decoding strings

2007-01-05 Thread [EMAIL PROTECTED]
Basically, I want to encode an email address so that it looks something like 8d2e23c0a835598510c88a758c6b215a - this way the user does not know the email address they are looking at. They are public-facing views and they are to get info about other users, therefore anonymity is important. Any sugg

elementtree.SimpleXMLWriter and xmlcharrefreplace

2007-01-05 Thread [EMAIL PROTECTED]
I'll try to explain my problem with code. The problem is the output msg = u"Södertälje & Borås" # latin1 unicode string with a & from elementtree.SimpleXMLWriter import XMLWriter from cStringIO import StringIO out = StringIO() w = XMLWriter(out) body = w.start("body") w.element("text", msg) w.clo

Re: elementtree.SimpleXMLWriter and xmlcharrefreplace

2007-01-05 Thread [EMAIL PROTECTED]
My current version of SimpeXMLWriter is: $Id: SimpleXMLWriter.py 1862 2004-06-18 07:31:02Z Fredrik $ I'm testing this on in python2.3.5 and python2.4.3. [EMAIL PROTECTED] wrote: > I'll try to explain my problem with code. > The problem is the output > > msg = u"S

Re: Undefined symbol __pure_virtual when importing MySQLdb

2007-01-05 Thread [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote: > Fredrik Lundh wrote: > > [EMAIL PROTECTED] wrote: > > > > > I have googled hard, and did see someone asking the same question, but > > > haven't found a good solution to this problem. Could anyone give me a > > > hint?

Re: Encoding / decoding strings

2007-01-05 Thread [EMAIL PROTECTED]
Marc 'BlackJack' Rintsch wrote: > In <[EMAIL PROTECTED]>, > [EMAIL PROTECTED] wrote: > > > Basically, I want to encode an email address so that it looks something > > like 8d2e23c0a835598510c88a758c6b215a - this way the user does not know > > the email a

Re: MySQLdb windows binaries for Python 2.5?? Yes, but from a World of Warcraft guild.

2007-01-05 Thread [EMAIL PROTECTED]
Anyone have a binary they want to share? /Martin -- http://mail.python.org/mailman/listinfo/python-list

Re: What is proper way to require a method to be overridden?

2007-01-05 Thread [EMAIL PROTECTED]
Patrick Down wrote: > jeremito wrote: > > I am writing a class that is intended to be subclassed. What is the > > proper way to indicate that a sub class must override a method? > > > > Thanks, > > Jeremy > > Decorators to the rescue? > > def must_override(f): > def t(*args): > raise N

Re: Doing date/time + TZ math in python

2007-01-06 Thread [EMAIL PROTECTED]
Joshua J. Kugler wrote: > I've read docs (datetime, time, pytz, mx.DateTime), googled, and > experimented. I still don't know how to accomplish what I want to > accomplish. > > I'm loading up a bunch of date/time data that I then need to do math on to > compare it to the current date/time. I can

Why less emphasis on private data?

2007-01-06 Thread [EMAIL PROTECTED]
Coming from a C++ / C# background, the lack of emphasis on private data seems weird to me. I've often found wrapping private data useful to prevent bugs and enforce error checking.. It appears to me (perhaps wrongly) that Python prefers to leave class data public. What is the logic behind that ch

Got questions to pose to the Python-Dev panel at PyCon?

2007-01-07 Thread [EMAIL PROTECTED]
On the first conference day of PyCon after lunch there is going to be a discussion panel for Python-Dev (see http://us.pycon.org/apps07/schedule/ for the schedule). It is going to be moderated by Steve Holden and is slated to have myself (Brett Cannon), Andrew Kuchling (AMK), Neal Norwitz, and Jer

Table

2007-01-07 Thread [EMAIL PROTECTED]
Hello Someone know how do I get the collunm's number of a gkt.Table ? -- http://mail.python.org/mailman/listinfo/python-list

Re: C++/Python programmers for a MUD's gamedriver wanted.

2007-01-07 Thread [EMAIL PROTECTED]
Paul McGuire wrote: > Have you considered whether the C++ Driver is even necessary? Python's > run-time engine already implements the memory and process management tasks, > and does so in compiled C code (and has been tested and retested by > hundreds, nay thousands, perhaps even millions of Pyth

Module to read svg

2007-01-07 Thread [EMAIL PROTECTED]
I'm looking for a module to load an SVG document so that I can read out its contents in some graphics-centric way. For example, path elements store their vertices in a long attribute string you need to parse. An ideal module would get me these vertices in a list. SVGdraw seems to only write, but n

Maybe a little bug of ipython 0.7.3 ?

2007-01-08 Thread [EMAIL PROTECTED]
I'm new to ipython, and i found it a very cool product. $ ipython Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] Type "copyright", "credits" or "license" for more information. IPython 0.7.3 -- An enhanced Interactive Python. In [8]: a = range(1000) In [9]: a? Type:

Re: sys.exit versus raise SystemExit

2007-01-08 Thread [EMAIL PROTECTED]
Will McGugan wrote: > Hi, > > Is there any difference between calling sys.exit() and raise SystemExit? > Should I prefer one over the other? > > Regards, > > Will McGugan > -- > blog: http://www.willmcgugan.com sys.exit() raises a SystemExit, see http://docs.python.org/lib/module-sys.html -- ht

Re: Why less emphasis on private data?

2007-01-08 Thread [EMAIL PROTECTED]
Wow, I got a lot more feedback than I expected! I can see both sides of the argument, both on technical merits, and more philosophical merits. When I first learned C++ I felt setters/getters were a waste of my time and extra code. When I moved to C# I still felt that, and with their 'Property" s

tkinter with wck

2007-01-08 Thread [EMAIL PROTECTED]
I am playing around with this code but I am having trouble getting my x to be bigger it only seems to redraw when it becomes smaller than the original size up to full size (in ui_handle_repair). At other window sizes it just seems to center it.. I tried playing around with resize but never got th

Re: Bitwise expression

2007-01-08 Thread [EMAIL PROTECTED]
Gigs_ wrote: > Can someone explain me bitwise expression? > few examples for every expression will be nice > > x << y Left shift > x >> y Right shift > x & y Bitwise AND > x | y Bitwise OR > x ^ y Bitwise XOR (exclusive OR) > ~x Bitwise negation > > > thanks people Here's some examples: ##W

Re: Colons, indentation and reformatting. (2)

2007-01-08 Thread [EMAIL PROTECTED]
Paddy wrote: > I was just perusing a Wikipedia entry on the "off side rule" at > http://en.wikipedia.org/wiki/Off-side_rule . > It says that the colon in Python is purely for readability, and cites > our FAQ entry > http://www.python.org/doc/faq/general.html#why-are-colons-required-fo... > . > Ho

Re: General Question About Python

2007-01-09 Thread [EMAIL PROTECTED]
Enteng wrote: > To those who program in python, what programs do you do? Some Unix TCP servers, some data-driven command line apps, and some web stuff. > Also what community projects are you involved in(OSS probably)? None that are Python-based, aside from the occasional patch to support new Pyt

Re: Execute binary code

2007-01-09 Thread [EMAIL PROTECTED]
Jorgen Grahn wrote: > On 8 Jan 2007 12:29:36 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > For what it's worth[1], under Unix it /is/ impossible. The only way to bring > in > new code (short of dynamic libraries) is to call exec(2) or its variations, > and all

distutils and ctypes

2007-01-09 Thread [EMAIL PROTECTED]
Hi all, I suspect that I'm doing something stupid, I would like some other opinions though. I'm getting started with ctypes and am trying to use distutils to help build my module. At the moment I simply want distutils to build a shared c library (not a python extension!). Under linux, the followin

Re: Making dir's

2006-01-22 Thread [EMAIL PROTECTED]
yawgmoth7 wrote: > And so on. That is not very practical, and I wish to change it. I was > wondering if there were any other methods to which I could do this, I > was thinking maybe I could put the dir names in a dictionary then have > something like: > os.mkdir(thedictname) Why not use a loop? d

Re: Some thougts on cartesian products

2006-01-23 Thread [EMAIL PROTECTED]
Steven D'Aprano wrote: > On Mon, 23 Jan 2006 18:17:08 +, Bryan Olson wrote: > > > Steven D'Aprano wrote: > >> Bryan Olson wrote: > >> > >> > > [Christoph Zwerschke had written:] > What I expect as the result is the "cartesian product" of the strings. > >>> > >>>There's no such thing; you'd

Re: IPython 0.7.1 is out.

2006-01-24 Thread [EMAIL PROTECTED]
Fernando Perez wrote: > IPython's homepage is at: > > http://ipython.scipy.org > > and downloads are at: > > http://ipython.scipy.org/dist And if you have easy_install ( install it by running http://peak.telecommunity.com/dist/ez_setup.py if you already haven't done it), you can just say: easy_i

Re: Creating a more random int?

2006-01-24 Thread [EMAIL PROTECTED]
Steven Macintyre wrote: > Hi all, > > I need to retrieve an integer from within a range ... this works ... below > is my out puts ... it just does not seem so random ... What's wrong with it? > > Is there perhaps a suggestion out there to create a more random int ...? What do you think the outp

Re: getting a KeyError:'href' any ideas?

2006-01-24 Thread [EMAIL PROTECTED]
what is the syntax used to find a child of td? Mike Meyer wrote: > "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > > Please use less whitespace in your posts in the future. There's really > no need to put two blank lines between sections. > > >

Re: getting a KeyError:'href' any ideas?

2006-01-24 Thread [EMAIL PROTECTED]
ok the syntax for next is this: b = n.findNext LordLaraby wrote: > You wrote: > > i have an > > href which looks like this: > > > > http://www.cnn.com";> > > > > here is my code > > for incident in row('td', {'class':'all'}): > > n = incident.findNextSibling('a', {

Re: Loading a Python collection from an text-file

2006-01-24 Thread [EMAIL PROTECTED]
Maybe YAML is what youre looking for... http://yaml.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Dynamic pull down menus (CGI)

2006-01-24 Thread [EMAIL PROTECTED]
You will be quite limited without the use of JavaScript to perform this kind of dynamic functionality. HTML alone cannot do this. You can use dynamically generated Javascript, AJAX, Flash or Java. One possible would be to just use HTML forms and add in an extra button click after the user makes th

Re: customized instance dictionaries, anyone?

2006-01-25 Thread [EMAIL PROTECTED]
thx! indeed, it worked -- took me some time to figure out how to implement the setting of attributes, too. i finally managed to get that done using super: custom dictionary, unchanged:: class CustomDict( dict ): defaultValue = 'THIS ITEM NOT AVAILABLE' def __getitem__( self,

Sample code to handle cookie based login/password forms automatically?

2006-01-25 Thread [EMAIL PROTECTED]
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/391929 has a mechanize based script to handle login/password forms but I can't get it to work. Anyone else got sample code that does this? Chris -- http://mail.python.org/mailman/listinfo/python-list

Problem compiling Tkinter program with bmp images using py2

2006-01-25 Thread [EMAIL PROTECTED]
Problem compiling Tkinter program with bmp images (using py2exe) I have a Tkinter gui program that uses bmp as backgrounds. The program itself works when I run from the source. I placed the .bmp files in the same folder as the script. I run my .py script (from IDLE) and all the backgrounds are lo

Re: history

2006-01-26 Thread [EMAIL PROTECTED]
yqyq22 wrote: > Dear all, > another little question, I use idle 1.1.2, is there a way to use a > history for the command line? Cursor up to a previously entered line and hit return. The line will be repeated, allowing editing. If the "line" was an entire block, the entire block will be repeated.

Automatic Logging

2006-01-26 Thread [EMAIL PROTECTED]
Sorry if this is a FAQ but Google returns a *lot* of results for Python Logging :-) I am looking for a tool that will automatically add logging to existing code e.g. Function Entries and Exits, Return values etc. Thanks, Davy Mitchell Mood News - BBC News Headlines Auto-Classified as Good,

Re: Are there memory limits for external C modules?

2006-01-26 Thread [EMAIL PROTECTED]
Fredrik Lundh wrote: > [EMAIL PROTECTED] wrote: > > > I've been working on an external C module for Python in order to use > > some of the functionality from Ethereal. Right now I'm getting > > segfaults originating from within the Ethereal source code, but the

Re: problems with documentation

2006-01-27 Thread [EMAIL PROTECTED]
Set PYTHONDOCS to "C:\Python24\Doc\Python-Docs-2.4.2", and that should work. -- http://mail.python.org/mailman/listinfo/python-list

Re: str as param for timedelta

2006-01-27 Thread [EMAIL PROTECTED]
Philipp wrote: > from datetime import * > > def f(gap): > print (datetime.now() + datetime.timedelta(gap)) > > f('hours = -8') When you need a flexible input format, consider keyword arguments. In this case, I would pass along the inputs to timedelta: def from_now(**kwargs): return da

We have zipimport, how about dllimport?

2006-01-27 Thread [EMAIL PROTECTED]
I may be on particularly potent crack, but I was wondering whether it would make sense to distribute python code in DLLs so that the memory occupied by the bytecode would be consumed only once even if there were multiple processes using the same bytecode. Or is there another way to accomplish code

Re: Automatic Logging

2006-01-27 Thread [EMAIL PROTECTED]
Thanks very much. I found a good example of using sys.settrace at http://effbot.org/librarybook/sys.htm Cheers, Davy Mitchell Mood News - BBC News Headlines Auto-Classified as Good, Bad or Neutral. http://www.latedecember.com/sites/moodnews/ -- http://mail.python.org/mailman/listinfo/p

Re: Checking free disk space on Win32 ?

2006-01-28 Thread [EMAIL PROTECTED]
You might find the following interesting too http://unpythonic.net/jeff/tkdu/ Cheers, Davy Mitchell Mood News - BBC News Headlines Auto-Classified as Good, Bad or Neutral. http://www.latedecember.com/sites/moodnews/ -- http://mail.python.org/mailman/listinfo/python-list

Data Crunching and Charting....

2006-01-28 Thread [EMAIL PROTECTED]
Hi all. Question: I have a project nearly complete written in VB.Net using charts from 3rd party vendors...expensive, yes, fast, not really. The data I am plotting is about 30 columns by 3000-9000 rows, all in a tab delimited file(43 files total). My question is whether or not I can accomplish the

Re: Data Crunching and Charting....

2006-01-28 Thread [EMAIL PROTECTED]
Thanks for the response. I did look at the plot class for wxpython and that looks worth checking out too. I really just need to plot the data, optionally print, and save each as an image. Sounds like from what you've done it is alot faster than what Im doing now. Thanks again. -- http://mail.pyt

Hostname

2006-01-29 Thread [EMAIL PROTECTED]
Hi Iam new in Python. I want to know for my first Project in Python how i can get the Hostname from a URL? Thanks for Help -- http://mail.python.org/mailman/listinfo/python-list

Re: Hostname

2006-01-29 Thread [EMAIL PROTECTED]
Wow! This was a fast answer and it works. -- http://mail.python.org/mailman/listinfo/python-list

Help saving output onto a text file

2006-01-29 Thread [EMAIL PROTECTED]
I have been learning python during the past weeks and I have been able to program some interesting things. Python is my first and only programing language from which I wish to enter the programing world. My question was: if I have a simple program that for example calculates the squares of 2 to 10

Re: Help saving output onto a text file

2006-01-29 Thread [EMAIL PROTECTED]
I tried using the sys.stdout method and it worked. It seems pretty simple but I dont understand the simple method you posted. Thanks for the help, I'll mess around with it and keep on learning. -- http://mail.python.org/mailman/listinfo/python-list

Re: webbrowser module + urls ending in .py = a security hole?

2006-01-30 Thread [EMAIL PROTECTED]
Does that only happen when you open file:// urls? You already have local access from Python, so it'd be more concerning if it happened with Python files on remote servers. - Jason -- http://mail.python.org/mailman/listinfo/python-list

Re: triple quoted strings as comments

2006-01-30 Thread [EMAIL PROTECTED]
as i know, the triple quoted string does cause a runtime construction, and will not be discarded, and it's a benefit of python language. here is sth. useful. _http://diveintopython.org/power_of_introspection/index.html best regard -- http://mail.python.org/mailman/listinfo/python-list

Re: loading modules in debug

2006-01-30 Thread [EMAIL PROTECTED]
[I haven't seen an answer for this older question, so I figured I'd go ahead and post one] Andras Balogh wrote: > > The problem is that, in debug mode, Python expects every module name to > be postfixed with _d, which makes my dynamic loading (using LoadLibrary) > not work, unless I #ifdef it ever

Re: Request for suggesstions and comments

2006-01-31 Thread [EMAIL PROTECTED]
Hi, the advice is free, so tkae it for what it's worth. Q. Is it possible to write an application for this kind of server activity in Python? I mean whether Python will be suitable for this kind of high activity load, real time app? - Absolutely, Look at Zope or Cheetah for examples of fairly larg

Re: wxPython Conventions

2006-01-31 Thread [EMAIL PROTECTED]
I'm also fairly new to wxPython, but I've done GUI's in a variety of languages.I'm not sure about putting the systray - haven't had to do it. But your second question, put it in it's own class. For desktop apps I almost allways do a limited M/V/C pattern - M/VC - ok so I mung the view and con

Re: binascii in C++

2006-01-31 Thread [EMAIL PROTECTED]
Jeremy wrote: > I'm working on a project to create a keyfinder program that finds the > Windows CD Key in the registry and decodes it. I prototyped it in > Python and it worked great but for several reasons I've decided to > rewrite it in C++. I use the module binascii extensively in the Python

Parsing sizes

2006-02-01 Thread [EMAIL PROTECTED]
I want to be able to parse sizes in bytes in several formats, such as "1048576", "1024K", "1024KB", "1M" etc. Is there a module that will help me with that? /David -- http://mail.python.org/mailman/listinfo/python-list

learning python, using string help

2006-02-02 Thread [EMAIL PROTECTED]
hi all, I have a simple snippet I am trying to keep the format the same as plain text, though I want to embed it in html ... basically, print "Content-type:text/plain\n\n"; getrup = os.popen('ruptime').read() print getrup is the same format as if I ran 'ruptime' from the command line. If I use

Re: learning python, using string help

2006-02-02 Thread [EMAIL PROTECTED]
Well, I did want to add some formatting for example STATUS = "up" getrup = os.popen('ruptime').read() show = getrup.splitlines() gethost = show[0] hostname = gethost.split() print hostname[0] getstatus = hostname[1] if getstatus.find("STATUS"): print STATUS else: print "HOST DOWN

Re: learning python, using string help

2006-02-02 Thread [EMAIL PROTECTED]
thanks tom, I am running OpenBSD, NetBSD as well as OS X (FreeBSD) My first python script #!/usr/local/bin/python print "Content-type:text/html\n\n"; import os, string getrup = os.popen('ruptime').read() show = getrup.splitlines() for line in show: if line.find("up" or "down"):

Re: learning python, using string help

2006-02-02 Thread [EMAIL PROTECTED]
Tom, the script you referenced me errored ... But I will see if I can get it working. -- http://mail.python.org/mailman/listinfo/python-list

Re: learning python, using string help

2006-02-02 Thread [EMAIL PROTECTED]
silly newbie mistake your code runs fine on my openbsd box. ( I didnt uncomment the return map(...) line thanks for the awesome example! --mike -- http://mail.python.org/mailman/listinfo/python-list

web.py + cheetah delivering incomplete pages

2006-02-03 Thread [EMAIL PROTECTED]
hi, yesterday i started with web.py / flup / cheetah, and managed to get a first webpage to diaplay on my windows box running apache. unfortunately, the following code import web urls = ( '(.*)', 'view' ) class view: def GET( self, name ): web.render( 'view.html' ) web.in

Re: web.py + cheetah delivering incomplete pages

2006-02-03 Thread [EMAIL PROTECTED]
yeah, posted it there too, but, you see, there are but 95 members in that group -- guess it's more productive to ask this right here. we'll see. _w. -- http://mail.python.org/mailman/listinfo/python-list

Re: fairly large webapp: from Java to Python. experiences?

2006-02-03 Thread [EMAIL PROTECTED]
To replace a large framework you will probably need a framework. Take a look at http://www.djangoproject.com or http://www.turbogears.org. They both use some of the tools you mention but operate on a higher level. I find Python fairly easy to maintain. Unfortunatly, I do not find it easy to take a

Re: Fatal Python error: Py_EndInterpreter: thread still has a frame

2006-02-04 Thread [EMAIL PROTECTED]
Thomas Korimort wrote: > Hi! > > Does anyone know the precise circumstances when the error > > "Fatal Python error: Py_EndInterpreter: thread still has a frame" > > does occur. I checked the source code of pythonrun.c, which tells me > that this error message is thrown in Py_EndInterpreter, when >

Re: Most prominent Tkinter applications?

2006-02-05 Thread [EMAIL PROTECTED]
I use this TKinter app almost everyday. Great simple GUI and looks good too. http://www.podblogger.de/mp3stick Take care, Davy Mitchell Mood News - BBC News Headlines Auto-Classified as Good, Bad or Neutral. http://www.latedecember.com/sites/moodnews/ -- http://mail.python.org/mailman/

script to read emails and extract attachments from cron

2006-02-06 Thread [EMAIL PROTECTED]
Hi: I am looking for advice on the best way to set up a process to read incoming emails (from a normal unix mailbox on the same host) containing a gzipped telemetry attachment. I'd like the script to extract the attachment into a directory where another process will pick it up. I plan to run it ev

Re: in over my head ascii

2006-02-06 Thread [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote: > ok, part of what i have to do is know how many bytes will be sent. in > ascii is it one byte per character ? > like "password" would be 8 bytes long? Yes, but when someone says ASCII STX, they usually mean the single byte control character. This

Re: in over my head ascii

2006-02-06 Thread [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote: > i know that those characters exist, the docs say that the server does > not want the special "ETX" and "STX" characters, but the 3 ascii > characters "STX" and "ENX" i am not sure why. What do you bet the server soft

Re: how to copy a Python object

2006-02-07 Thread [EMAIL PROTECTED]
[EMAIL PROTECTED] a écrit : > Hi, > > I am new to Python and OO programming. > I need to copy a Python object (of a class I made myself). > new_obj = old_object doesn't seem to work since apparently new_obj is > then a referrence to old_obj. it is > > I found out

python-ldap

2006-02-07 Thread [EMAIL PROTECTED]
y0! where can i get module of python-ldap to work with eclipse ide on windows? tks! -- http://mail.python.org/mailman/listinfo/python-list

python-ldap

2006-02-07 Thread [EMAIL PROTECTED]
y0! where can i get module of python-ldap to work with eclipse ide on windows? tks! -- http://mail.python.org/mailman/listinfo/python-list

python-ldap

2006-02-07 Thread [EMAIL PROTECTED]
y0! where can i get module of python-ldap to work with eclipse ide on windows? tks! -- http://mail.python.org/mailman/listinfo/python-list

Re: python-ldap

2006-02-07 Thread [EMAIL PROTECTED]
_)_ -- http://mail.python.org/mailman/listinfo/python-list

Re: python-ldap

2006-02-07 Thread [EMAIL PROTECTED]
_)_ -- http://mail.python.org/mailman/listinfo/python-list

Re: Too Many if Statements?

2006-02-07 Thread [EMAIL PROTECTED]
slogging_away wrote: > Hmmm - good responses all around. Thank you all for your valued > feedback. > > Perhaps it's too may 'if' statements under the for XXX in range(x,x,x) Have you tried xrange() instead of range()? > statement as most of the 'if' statements appear there. It could be > somet

Re: Too Many if Statements?

2006-02-07 Thread [EMAIL PROTECTED]
Alan Morgan wrote: > > generated (I'm ashamed to admit) by a perl script. Is there any good reason > why > it is failing? I'd prefer a "Too many silly walks in your program. Reduce!" > to > a crash. Everyone, Please file a bug report anytime you make Python crash! http://sourceforge.net

Re: Too Many if Statements?

2006-02-08 Thread [EMAIL PROTECTED]
> > I made a script with 100,000 if's, (code below) and it appears > > to work on a couple systems, including Python 2.4.2 on Win32-XP. > > So at first cut, it doesn't seem to be just the if-count that > > triggers the bug. > > I tried that code. It runs fine. > > However, the following gives a Sy

Re: Number Format function

2006-02-08 Thread [EMAIL PROTECTED]
Your code has a little bug, I highly recommend to add a test to your code, for an idea see below - I fixed your code as well. #!/usr/bin/env python import math def number_format(num, places=0): """Format a number with grouped thousands and given decimal places""" #is_negative = (num < 0)

Re: Number Format function

2006-02-08 Thread [EMAIL PROTECTED]
This is a little faster: def number_format(num, places=0): """Format a number according to locality and given places""" locale.setlocale(locale.LC_ALL, "") return locale.format("%.*f", (places, num), True) I tested this ok with my test -- http://mail.python.org/mailman/listinfo/pyth

Re: What editor shall I use?

2006-02-08 Thread [EMAIL PROTECTED]
I use JEdit and I like it very much. http://www.jedit.org/ Uros -- http://mail.python.org/mailman/listinfo/python-list

Re: Too Many if Statements?

2006-02-08 Thread [EMAIL PROTECTED]
Juho Schultz wrote: > > However, the following gives a SystemError with only 2500 elif's. SystemErrors should never occur, if you see one it's a bug. [valid program which demonstrates a python bug] > Traceback (most recent call last): >File "iftest.py", line 10, in ? > exec prog > Syste

Re: Inserting record with Microsoft Access

2006-02-09 Thread [EMAIL PROTECTED]
I can't remember the detail right now but look at SELECT @@IDENTITY. Cheers, Davy M -- http://mail.python.org/mailman/listinfo/python-list

CGI Python FTP

2006-02-09 Thread [EMAIL PROTECTED]
I know PHP has support for uploading files from the browser to the server, but does python (not mod_py) have any modules for going about this? If not post your ideas on how I should do this. Thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: Test indexers...how do they work?

2006-02-09 Thread [EMAIL PROTECTED]
Raja Raman Sundararajan wrote: > I wanted to know how the algorithm of indexers look like. I have heard > people talking about B-Trees. But this info. is simply know enough. I > would like to know exactly each part of the indexing flow and the > algorightm behind it work. Get the book "Managing Gi

Re: Pulling all n-sized combinations from a list

2006-02-09 Thread [EMAIL PROTECTED]
Jack Diederich wrote: > On Wed, Feb 08, 2006 at 12:50:19PM -0800, Swroteb wrote: > > Hi there, > > > > I've got a reasonably sized list of objects that I'd like to pull out > > all combinations of five elements from. Right now I have a way to do > > this that's quite slow, but manageable. I know

Re: Pulling all n-sized combinations from a list

2006-02-09 Thread [EMAIL PROTECTED]
Fredrik Lundh wrote: > [EMAIL PROTECTED] wrote: > > > > It is a C extension that does permutations & combinations and is > > > about 10x faster than doing it in pure python [I'm the author]. > > > It is also the 3rd result for "python combination&qu

Re: Pulling all n-sized combinations from a list

2006-02-09 Thread [EMAIL PROTECTED]
Magnus Lycka wrote: > [EMAIL PROTECTED] wrote: > > Fredrik Lundh wrote: > >>Windows don't support C ? that was a new one. > > > > > > Windows comes with a C compiler? That's news to me. > > It doesn't come with Python either. Both

Re: Pulling all n-sized combinations from a list

2006-02-09 Thread [EMAIL PROTECTED]
Jack Diederich wrote: > On Thu, Feb 09, 2006 at 10:23:12AM -0800, [EMAIL PROTECTED] wrote: > > Jack Diederich wrote: > > > On Wed, Feb 08, 2006 at 12:50:19PM -0800, Swroteb wrote: > > > > Hi there, > > > > > > > > I've got a reasonably

Re: Determining an operating system's default browser

2006-02-09 Thread [EMAIL PROTECTED]
Larry Bates wrote: > You don't have to determine it. Just os.startfile('page1.html') > and let the OS figure it out. Note that this only works on Windows. -- http://mail.python.org/mailman/listinfo/python-list

Re: Pulling all n-sized combinations from a list

2006-02-09 Thread [EMAIL PROTECTED]
Jack Diederich wrote: > liberally snipped out parts > On Thu, Feb 09, 2006 at 03:25:18PM -0800, [EMAIL PROTECTED] wrote: > > Jack Diederich wrote: > > > > > On Wed, Feb 08, 2006 at 12:50:19PM -0800, Swroteb wrote: > > > > > > > > > > >

is there a better way?

2006-02-10 Thread [EMAIL PROTECTED]
Problem: You have a list of unknown length, such as this: list = [X,X,X,O,O,O,O]. You want to extract all and only the X's. You know the X's are all up front and you know that the item after the last X is an O, or that the list ends with an X. There are never O's between X's. I have been using

Re: Are there memory limits for external C modules?

2006-02-10 Thread [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote: > I was able to modify my C code so that instead of being a Python > module, it runs as a standalone binary, and it works as it should. > Calling it with os.spawn* works. The two versions are essentially the > same, the primary differences being the necessar

Re: Pulling all n-sized combinations from a list

2006-02-10 Thread [EMAIL PROTECTED]
Magnus Lycka wrote: > [EMAIL PROTECTED] wrote: > > But using the free SDK compiler from MS? That seems elusive. > > Have you seen this? > http://www.vrplumber.com/programming/mstoolkit/ I have, although I haven't tried it as I was able to get a GMPY Windows binary from

Socket Programming - Question

2006-02-10 Thread [EMAIL PROTECTED]
I am relatively new to Python, and wanted to see if this is even possible, and if so how to go about implementing it. What I'm looking to do is create a client/server application that does the following: 1) System2 listens on port > 1023 2) System1 connects to System2 and sends traffic to it -

Re: Socket Programming - Question

2006-02-10 Thread [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote: > An example of what I am looking to use this for is for remote virus > scanning. So System2 listens, System1 connects and sends it the Just found this through OSNews: http://rpyc.sourceforge.net/ It actually seems to be a perfect fit for your job. Lorenzo --

Re: Yet another GUI toolkit question...

2006-02-11 Thread [EMAIL PROTECTED]
What's wrong with wxPython? (http://www.wxpython.org) Didn't see it mentioned here. David Berlin http://farpy.holev.com - Python GUI Editor -- http://mail.python.org/mailman/listinfo/python-list

Re: Shortest prime number program

2006-02-11 Thread [EMAIL PROTECTED]
swisscheese wrote: > I figured someone out there must have written a minimal code size prime > number generator. I did not find one after a bit of searching around. > For primes up to 100 the best I could do was 70 characters (including > spaces): > > r=range(2,99) > m=[x*y for x in r for y in r]

Re: installing python on a server?

2006-02-11 Thread [EMAIL PROTECTED]
I'm wondering whether you couldnn't use MovPy for this purpose - a situation where you don't have root access. You can install the whole MovPy package in your home directory; it provides a self-contained environment. At the moment I think it only runs on Windows boxen, but that may change. --

Re: installing python on a server?

2006-02-11 Thread [EMAIL PROTECTED]
I'm wondering whether you couldnn't use MovPy for this purpose - a situation where you don't have root access. You can install the whole MovPy package in your home directory; it provides a self-contained environment. At the moment I think it only runs on Windows boxen, but that may change. --

Re: Tracking down memory leaks?

2006-02-12 Thread [EMAIL PROTECTED]
I *think* Python uses reference counting for garbage collection. I've heard talk of people wanting to change this (to mark and sweep?). Anyway, Python stores a counter with each object. Everytime you make a reference to an object this counter is increased. Everytime a pointer to the object is de

Re: Tracking down memory leaks?

2006-02-12 Thread [EMAIL PROTECTED]
MKoool wrote: > I have an application with one function called "compute", which given a > filename, goes through that file and performs various statistical > analyses. It uses arrays extensively and loops alot. it prints the > results of it's statistical significance tests to standard out. Sinc

<    18   19   20   21   22   23   24   25   26   27   >