Re: Python Programming Contest

2005-07-15 Thread Simon Dahlbacka
Are you aware of http://mathschallenge.net/index.php?section=project ?

The "The focus will be on algorithms that require a bit of thought
to design but not much code to implement." part seems common, although
your problem domain probably is larger.

/Simon

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


Re: Documenting extension modules?

2005-07-15 Thread Simon Dahlbacka
Re: assigning a PyStr object to __doc__, take a look at Py_InitModule3,
which does that for you.

Then you have the PyDoc_STRVAR macro in python.h that you might want to
use (see definition below). But as Robert already told you, you'll need
to provide the necessary information about i.e. parameters yourself in
the docstrings.

/* Define macros for inline documentation. */
#define PyDoc_VAR(name) static char name[]
#define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str)
#ifdef WITH_DOC_STRINGS
#define PyDoc_STR(str) str
#else
#define PyDoc_STR(str) ""
#endif

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


Re: Efficiently Split A List of Tuples

2005-07-18 Thread Simon Dahlbacka
Oooh.. you make my eyes bleed. IMO that proposal is butt ugly (and
looks like the C++.NET perversions.)

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


Re: Problem with threads

2005-07-18 Thread Simon Dahlbacka
You cannot really do that*. Use a flag or something that the thread
checks if it should shut down.

/Simon

* well actually you can, sort of by using
int PyThreadState_SetAsyncExc( long id, PyObject *exc) from C API.
However, if you do that you swap one problem for a sh*tload of others,
because of the *async* part.

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


Re: Image orientation and color information with PIL?

2005-07-18 Thread Simon Dahlbacka
if you mean that you want to figure out which way the image is
depending on the actual data in the image, then you'll most likely get
to do the image processing yourself, on the other hand, if you are
talking jpegs from a relatively new camera then I suppose that you
should be able to get that info by looking at the EXIF information.
AFAIK you can read exif with PIL, but not write.

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


Re: Documentation bug: Python console behaviour changed

2005-07-19 Thread Simon Dahlbacka
My console follows documentation:


C:\tmp\GspRegTestApp>c:\Python24\python
ActivePython 2.4.1 Build 245 (ActiveState Corp.) based on
Python 2.4.1 (#65, Mar 30 2005, 09:33:37) [MSC v.1310 32 bit (Intel)]
on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> ^Z


C:\tmp\GspRegTestApp>c:\Python24\python
ActivePython 2.4.1 Build 245 (ActiveState Corp.) based on
Python 2.4.1 (#65, Mar 30 2005, 09:33:37) [MSC v.1310 32 bit (Intel)]
on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> ^D
  File "", line 1
♦
^
SyntaxError: invalid syntax
>>>

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

Re: How to send a query to the browser from time to time?

2005-07-19 Thread Simon Dahlbacka
Short answer: Not using HTTP.

However, you can use something like AJAX to just load new data from
time to time and not the entire page.

Or you might be able to keep the connection alive and occationally send
stuff to the client using chunked transfer.

I'd go for the ajax route if you don't need to support old browsers.

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


Re: Printing a variable's name not its value

2005-07-20 Thread Simon Dahlbacka
as you have been told, there is no way to get a variable's name, take a
look at http://effbot.org/zone/python-objects.htm to find out why this
is so.

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


Re: wxPython && wxGlade

2005-07-20 Thread Simon Dahlbacka
basically, you can just stack an outer vertical box sizer with two
items and in the upper "slot" you put a horizontal box sizer with your
two buttons and in the bottom slot you put the big button

hope this helps

/Simon

ps. as this is a wxpython related question, you might get better
answers on the wxpython mailinglist (but afaik, this is the way this
particular thing is done).

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


spurious syntax error when updating to 2.4 ?

2005-07-21 Thread Simon Dahlbacka
Hi,

I'm doing some preparation for a hopefully upcoming transition to
python 2.4 (from 2.3.4) on winxp platform

However, I'm getting SyntaxErrors in files that worked fine in 2.3, it
tells me that e.g.

newLanguage.language =
languageElement[0].firstChild.data.encode("ascii")

this line is broken

However, if I modify my file just for the heck of it and comment that
particular line, I still might get syntax error on that particular
line, or if I insert a line before that particular line I might get
away with it?

Has anyone seen anything similar, or even better knows what causes
this?

/Simon

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


Re: spurious syntax error when updating to 2.4 ?

2005-07-21 Thread Simon Dahlbacka
Replying to self,

it seems to be related to
https://sourceforge.net/tracker/index.php?func=detail&aid=1163244&group_id=5470&atid=105470
(Syntax error on large file with MBCS encoding)
even though my files had # -*- coding: ascii -*-
However, if I removed this explicit ascii encoding then I did not get
any syntax error.

/Simon

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


Re: functions without parentheses

2005-07-28 Thread Simon Dahlbacka
If you actually want that kind of syntax, then why don't you use Visual
Basic? ;)

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


Re: exceptions from logging on Windows

2005-09-12 Thread Simon Dahlbacka
I ended up monkey-patching doRollover to do a number of retries before
giving up. (In our case the failures is due to our log browser
happening to read the latest changes when logging wants to rollover)

(Actually, I implemented a simple QueueHandler and do all file
operations from a different logging thread)

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


Re: How do I parse this ? regexp ? [slighly OT]

2005-04-28 Thread Simon Dahlbacka

> >>> safetyChecker = re.compile(r"^[-\[\]0-9,. ]*$")

..doesn't the dot (.) in your character class mean that you are allowing
EVERYTHING (except newline?)

(you would probably want \. instead)

/Simon


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


logging problems

2005-04-28 Thread Simon Dahlbacka
Hi,

I'm currently using python 2.3.4 and I'm having problem with the logging module.

Occasionally when logging something with exc_info=True it just hangs, nothing is
logged, and software cannot continue executing.

By drilling down into logging package and adding rather many print statements
into  logging/__init__.py it seems like the "import traceback" in
formatException(self, ei) fails.

I.e.

print sys.modules["traceback"]
import traceback
print "Hello World"
sys.stdout.flush()

just renders:  in the
console, and no "Hello World"

I'm running out of ideas what to try next, so suggestions/ideas appreciated!

/Simon

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


Re: Using ElementTree to tidy up an XML string to my liking

2006-02-23 Thread Simon Dahlbacka
..I hope that you are aware that xml is *case sensitive*

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