Questions about input lines (maximum length and continuation)

2007-07-03 Thread Robert Dodier
Hello,

I'm planning to write a program which automatically generates
Python code.

(1) Is there a limit on the length of a line in a Python program?

(2) From what I understand, symbols, operators, and numbers
cannot be broken across lines continued with the backslash
character. Is there any way to allow symbols, operators, and
numbers to be broken across lines?

Thanks a lot for any information. I appreciate your help.

Robert Dodier

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


Re: Combinatorics

2008-02-12 Thread Robert Dodier
Cameron Laird wrote:

> Should combinatorics be part of the standard library?  That's
> an aesthetic-pragmatic question I don't feel competent to
> answer; I look to timbot and Guido and so on for judgment there.
> It does occur to me, though, that even more widely applicable
> than the combinatorics module of Mathematica (if only because of
> its licensing) might be such resources as
[...]

Well, since Mathematica has been mentioned, I'll go ahead and
mention Maxima as well. Maxima is an open source (GPL) symbolic
computation system, which includes some functions for
combinatorics, among many other things. The relevant code is:
http://maxima.cvs.sourceforge.net/maxima/maxima/src/nset.lisp
(Oh, btw Maxima is written in Lisp.) The relevant documentation:
http://maxima.sourceforge.net/docs/manual/en/maxima_37.html

Sage can presumably access Maxima's combinatoric functions
(since Sage bundles Maxima along with other programs).
I don't know if there are combinatoric functions from other
packages in Sage.

FWIW

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


How to split a string containing nested commas-separated substrings

2008-06-18 Thread Robert Dodier
Hello,

I'd like to split a string by commas, but only at the "top level" so
to speak. An element can be a comma-less substring, or a
quoted string, or a substring which looks like a function call.
If some element contains commas, I don't want to split it.

Examples:

'foo, bar, baz' => 'foo' 'bar' 'baz'
'foo, "bar, baz", blurf' => 'foo' 'bar, baz' 'blurf'
'foo, bar(baz, blurf), mumble' => 'foo' 'bar(baz, blurf)' 'mumble'

Can someone suggest a suitable regular expression or other
method to split such strings?

Thank you very much for your help.

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


trying to find repeated substrings with regular expression

2006-03-13 Thread Robert Dodier
Hello all,

I'm trying to find substrings that look like 'FOO blah blah blah'
in a string. For example give 'blah FOO blah1a blah1b FOO blah2
FOO blah3a blah3b blah3b' I want to get three substrings,
'FOO blah1a blah1b', 'FOO blah2', and 'FOO blah3a blah3b blah3b'.

I've tried numerous variations on '.*(FOO((?!FOO).)*)+.*'
and everything I've tried either matches too much or too little.

I've decided it's easier for me just to search for FOO, and then
break up the string based on the locations of FOO.

But I'd like to better understand regular expressions.
Can someone suggest a regular expression which will return
groups corresponding to the FOO substrings above?

Thanks for any insights, I appreciate it a lot.

Robert Dodier

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