Re: variables exist

2005-04-17 Thread Peter Otten
Michael J. Fromberger wrote: > Would the following be a satisfactory implementation? > > def isset(varname, lloc = locals()): > return varname in lloc or varname in globals() > > I believe this works as desired: > > >>> x = 5 > >>> def f(y): > ... z = 10 > ... print isset('z')

Re: Canceling/interrupting raw_input

2005-04-17 Thread Daniel Cer
For what it's worth, this looks like a Windows specific problem. The code below seems to work as expected on a Linux box. That is, everything terminates, including the "inputLoop", after sys.exit() is called, without the user needing to press 'enter' one last time. However, if I try to run the c

Re: Slight discrepancy with filecmp.cmp

2005-04-17 Thread John Machin
On Sun, 17 Apr 2005 22:06:04 -0600, Ivan Van Laningham <[EMAIL PROTECTED]> wrote: [snip] > So I wrote a set of >programs to both index the disk versions with the cd versions, and to >compare, using filecmp.cmp(), the cd and disk version. Works fine. >Turned up several dozen files that had been in

Re: pre-PEP: Suite-Based Keywords

2005-04-17 Thread Shane Hathaway
Brian Sabbey wrote: > Maybe using '**' would be better than '...' since it already is used to > indicate keyword arguments. Example: > > class C(object): > x = property(**): >doc = "I'm the 'x' property." >def fget(self): > return self.__x >def fset(self, val

Re: pre-PEP: Suite-Based Keywords - syntax proposal

2005-04-17 Thread Kay Schluehr
Steven Bethard wrote: > So the object of a "where" is then always an ordered dict? Yes. > If so, then > I guess I like this proposal best so far. > > However, it does seem to have the problem that you can't have any > additional local variables so, for example, list comprehensions are > probably

Re: pre-PEP: Suite-Based Keywords - syntax proposal

2005-04-17 Thread Kay Schluehr
Bengt Richter wrote: > On 17 Apr 2005 09:27:34 -0700, "Kay Schluehr" <[EMAIL PROTECTED]> wrote: > > >> Exactly. Except the above example is from the day-old-bread > >items-tuple-returning version of :: ;-) > >> And with an ordered dict subtype there is no need for the generator > >expression either

Canceling/interrupting raw_input

2005-04-17 Thread J. W. McCall
I'm working on a MUD server and I have a thread that gets keyboard input so that you can enter commands from the command line while it's in its main server loop. Everything works fine except that if a player enters the 'shutdown' command, everything shuts down, but the input thread is still si

Re: Compute pi to base 12 using Python?

2005-04-17 Thread M.E.Farmer
>>PS. Redirecting with > from a script whose interpreter was started by >>windows extension association >>doesn't work on some version of windows. To be safe, invoke the >>interpreter explicitly, e.g., >> python myscript.py [whatever args here] > pi3003.txt >Thanks very much for this. >What ki

Slight discrepancy with filecmp.cmp

2005-04-17 Thread Ivan Van Laningham
Hi All-- I noticed recently that a few of the jpgs from my digital cameras have developed bitrot. Not a real problem, because the cameras are CD Mavicas, and I can simply copy the original from the cd. Except for the fact that I've got nearly 25,000 images to check. So I wrote a set of programs

Apache mod_python

2005-04-17 Thread Dan
I've been writing a server application in Python. The app listens on a socket and interfaces to a database. Now I'd like to write a web application to also access the database. It seems natural to use Python. I've installed mod_python (Debian libapache2-mod-python2.3, mod_python 3.1.3-4). My q

Re: Problem with unpack hex to decimal

2005-04-17 Thread Artie Gold
Jonathan Brady wrote: <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Hello, I was looking at this: http://docs.python.org/lib/module-struct.html and tried the following import struct struct.calcsize('h') 2 struct.calcsize('b') 1 struct.calcsize('bh') 4 I would have expected struct.

Re: pre-PEP: Simple Thunks

2005-04-17 Thread Bengt Richter
On Sun, 17 Apr 2005 15:32:56 -0700, Brian Sabbey <[EMAIL PROTECTED]> wrote: >Bengt Richter wrote: >> Hm, one thing my syntax does, I just noticed, is allow you >> to pass several thunks to a thunk-accepter, if desired, e.g., >> (parenthesizing this time, rather than ending (): with >> dedented com

Re: pre-PEP: Simple Thunks

2005-04-17 Thread Brian Sabbey
Ron_Adam wrote: def pickled_file(thunk, name): f = open(name, 'r') l = pickle.load(f) f.close() thunk(l) f = open(name, 'w') pickle.dump(l, f) f.close() Now I can re-use pickled_file whenever I have to modify a pickled file: do data in pickled

Re: pre-PEP: Suite-Based Keywords - syntax proposal

2005-04-17 Thread Steven Bethard
Kay Schluehr wrote: Hmmm ... now You eliminate "where" completely in favor for '::'. This may be reasonable because '::' is stronger and less context dependent. But on the other hand it may be also reasonable to eliminate '::' towards a stronger "where" ;) x = property(**kw) where kw: d

trying to parse a file...

2005-04-17 Thread bruce
hi, i'm trying to modify an app (gforge) that uses python to do some file parsing/processing... i have the following shell file that uses python. if i understand it correctly, it's supposed to modify the 'viewcvs.conf' file, and replace/update the section with 'svn_roots'. it isn't working corre

Re: python.exe on Mac OS X!?

2005-04-17 Thread Robert Kern
Rodney Maxwell wrote: executable produced was 'python.exe'. Can someone tell me whether this is a bug, feature, or UserError? I'm not sure. Why don't you grab the binary? http://www.python.org/ftp/python/2.4.1/MacPython-OSX-2.4.1-1 .dmg Because I need to keep multiple versions of Python on this

Re: pre-PEP: Simple Thunks

2005-04-17 Thread Steven Bethard
Brian Sabbey wrote: used, but rarely is because doing so would be awkward. Probably the simplest real-world example is opening and closing a file. Rarely will you see code like this: def with_file(callback, filename): f = open(filename) callback(f) f.close() def print_file(file):

Re: Finding name of running script

2005-04-17 Thread M.E.Farmer
runes wrote: > Thanks! > > That's os.path.basename() I guess. It's better, but still complex. Yea murphy's typo ;) > I have a > _nof_ = argv[0].split(sep)[-1] in my script template and use it under > the usage() function to tell what the script does, like: > "cf.py counts files in directory or d

Re: pre-PEP: Suite-Based Keywords - syntax proposal

2005-04-17 Thread Bengt Richter
On 17 Apr 2005 09:27:34 -0700, "Kay Schluehr" <[EMAIL PROTECTED]> wrote: >> Exactly. Except the above example is from the day-old-bread >items-tuple-returning version of :: ;-) >> And with an ordered dict subtype there is no need for the generator >expression either, >> since there is a values met

Re: Pattern Matching Given # of Characters and no String Input; use RegularExpressions?

2005-04-17 Thread John Machin
On 17 Apr 2005 18:12:19 -0700, [EMAIL PROTECTED] (Synonymous) wrote: > >I will look for a Left$(str) function that looks at the first X >characters for python :)). > Wild goose chase alert! AFAIK there isn't one. Python uses slice notation instead of left/mid/right/substr/whatever functions. I do

Re: ANN: Veusz 0.5 - a scientific plotting package

2005-04-17 Thread Dan Christensen
Jeremy Sanders <[EMAIL PROTECTED]> writes: > Veusz 0.5 > - > Velvet Ember Under Sky Zenith > - > http://home.gna.org/veusz/ > > Veusz is a scientific plotting package written in Python (currently > 100% Python). It uses PyQt for display and user-interfaces, and

Re: pre-PEP: Simple Thunks

2005-04-17 Thread Ron_Adam
On Sun, 17 Apr 2005 15:02:12 -0700, Brian Sabbey <[EMAIL PROTECTED]> wrote: Brian Sabbey wrote: > I'm kicking myself for the first example I gave in my original post in > this thread because, looking at it again, I see now that it really gives > the wrong impression about what I want thunks to

Re: Finding name of running script

2005-04-17 Thread runes
Thanks! That's os.path.basename() I guess. It's better, but still complex. I have a _nof_ = argv[0].split(sep)[-1] in my script template and use it under the usage() function to tell what the script does, like: "cf.py counts files in directory or directory structure" If I change the filename,

Re: python.exe on Mac OS X!?

2005-04-17 Thread Rodney Maxwell
> The default file system on MacOSX is case insensitive. As a result the .exe > extension is required to disambiguate the generated executable from the > Python directory in the source distro. OK. I got it. -- http://mail.python.org/mailman/listinfo/python-list

Re: python.exe on Mac OS X!?

2005-04-17 Thread Rodney Maxwell
>> executable produced was 'python.exe'. Can someone tell me whether this >> is a bug, feature, or UserError? > I'm not sure. Why don't you grab the binary? > http://www.python.org/ftp/python/2.4.1/MacPython-OSX-2.4.1-1 .dmg Because I need to keep multiple versions of Python on this machine, and

Re: Pattern Matching Given # of Characters and no String Input; use RegularExpressions?

2005-04-17 Thread Synonymous
tiissa <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > tiissa wrote: > > If you know the number of characters to match can't you just compare > > slices? > If you don't, you can still do it by hand: > > In [7]: def cmp(s1,s2): >: diff_map=[chr(s1[i]!=s2[i]) for i in

Re: python.exe on Mac OS X!?

2005-04-17 Thread Skip Montanaro
Rodney> I did a source code build of Python 2.4.1 on OS X (10.3.8) and Rodney> the executable produced was 'python.exe'. Can someone tell me Rodney> whether this is a bug, feature, or UserError? The default file system on MacOSX is case insensitive. As a result the .exe extension is

Re: Finding name of running script

2005-04-17 Thread M.E.Farmer
> print locals()['__file__'].split(sep)[-1] .split(sep)[-1] is pretty dense reading. try: print os.basename(locals()['__file__']) runes wrote: > Is it a more pythonic way of finding the name of the running script > than these? > > from os import sep > from sys import argv > > print argv[0].split(s

terminal shutdown

2005-04-17 Thread Dan Richert
i wrote a script that accesses files at random from the locatedb database. it then prints a random line from the file it's accessed to the terminal screen. this runs continuously and at times makes the terminal behave strangely (chaning font colors, output writing over itself on the screen, e

Re: python.exe on Mac OS X!?

2005-04-17 Thread Robert Kern
Rodney Maxwell wrote: I did a source code build of Python 2.4.1 on OS X (10.3.8) and the executable produced was 'python.exe'. Can someone tell me whether this is a bug, feature, or UserError? I'm not sure. Why don't you grab the binary? http://www.python.org/ftp/python/2.4.1/MacPython-OSX-2.4.1-1.

Re: MS SQL Server/ODBC package for Python

2005-04-17 Thread Peter Herndon
I switched around the order, both in the actual application and in my tests as replied to Francois Lepoutre above. Results were consistent, after the first run of any given test, which unsurprisingly took a bit longer. -- http://mail.python.org/mailman/listinfo/python-list

Re: MS SQL Server/ODBC package for Python

2005-04-17 Thread Peter Herndon
:) Knock away, as my info isn't scientific anyway. In my case, ASA is *not* local. The db is running on a 500MHz x 2 server with 768MB RAM, over 100BaseT connection. That same server is also running the MSSQL instance, and IIS. Running your benchmark, I ran into a couple of interesting points.

Finding name of running script

2005-04-17 Thread runes
Is it a more pythonic way of finding the name of the running script than these? from os import sep from sys import argv print argv[0].split(sep)[-1] # or print locals()['__file__'].split(sep)[-1] # or print globals()['__file__'].split(sep)[-1] -- http://mail.python.org/mailman/listinfo/python-l

Re: variables exist

2005-04-17 Thread Michael J. Fromberger
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (fabian) wrote: > how testing if a variable exists in python as isset in php?? > Would the following be a satisfactory implementation? def isset(varname, lloc = locals()): return varname in lloc or varname in globals() I believe this wor

python.exe on Mac OS X!?

2005-04-17 Thread Rodney Maxwell
I did a source code build of Python 2.4.1 on OS X (10.3.8) and the executable produced was 'python.exe'. Can someone tell me whether this is a bug, feature, or UserError? % ./configure % make % ./python.exe Python 2.4.1 (#1, Apr 17 2005, 12:14:12) [GCC 3.3 20030304 (Apple Computer, Inc. build 14

Re: pre-PEP: Simple Thunks

2005-04-17 Thread Brian Sabbey
Bengt Richter wrote: Hm, one thing my syntax does, I just noticed, is allow you to pass several thunks to a thunk-accepter, if desired, e.g., (parenthesizing this time, rather than ending (): with dedented comma) each( ((i): # normal thunk print i), ((j): # alternative

Re: pre-PEP: Suite-Based Keywords

2005-04-17 Thread Brian Sabbey
Brian Sabbey wrote: Does anyone know if the 'where' keyword is only for readability (or does it disambiguate the syntax in some situations)? I think I prefer leaving it off. To answer my own question, I see by reading the where threads that using the 'where' keyword allows things such as: # De

Re: pre-PEP: Suite-Based Keywords

2005-04-17 Thread Bengt Richter
On Sun, 17 Apr 2005 15:25:04 +0200, Reinhold Birkenfeld <[EMAIL PROTECTED]> wrote: >Bengt Richter wrote: > >> Stretching for it, using my latest and greatest ;-) >> >> y = f(**:: >>x = 1 >>y = 'y for f' >> )*g(**:: >>x = 'x for g' >>y =

Re: pre-PEP: Simple Thunks

2005-04-17 Thread Brian Sabbey
Ron_Adam wrote: On Sat, 16 Apr 2005 17:25:00 -0700, Brian Sabbey Yes, much of what thunks do can also be done by passing a function argument. But thunks are different because they share the surrounding function's namespace (which inner functions do not), and because they can be defined in a more r

Re: module to parse "pseudo natural" language?

2005-04-17 Thread bytecolor
Andrew E wrote: > Hi all > > I've written a python program that adds orders into our order routing > simulation system. It works well, and has a syntax along these lines: > > ./neworder --instrument NOKIA --size 23 --price MARKET --repeats 20 > > etc > > However, I'd like to add a mode that will

Re: Decorator Syntax For Recursive Properties

2005-04-17 Thread Jeffrey Froman
Peter Otten wrote: >> something like this didn't work for me: > But this will, I suppose: > > @property > def ancestors(self): > if self.parent: > return self.parent.ancestors + [self.parent] > return [] > > A non-recursive variant: > > @property > def ancestors(self): > r

Re: Problem with unpack hex to decimal

2005-04-17 Thread John Machin
On Sun, 17 Apr 2005 20:47:20 +0100, "Jonathan Brady" <[EMAIL PROTECTED]> wrote: > ><[EMAIL PROTECTED]> wrote in message >news:[EMAIL PROTECTED] >> Hello, >> >> I was looking at this: >> http://docs.python.org/lib/module-struct.html >> and tried the following >> > import struct > struct.ca

Re: pre-PEP: Suite-Based Keywords

2005-04-17 Thread Brian Sabbey
Oren Tirosh wrote: Take a look at Nick Coglan's "with" proposal: http://groups.google.co.uk/groups?selm=mailman.403.1105274631.22381.python-list%40python.org It addresses many of the same issues (e.g. easy definition of properties). It is more general, though: while your proposal only applies to ke

Re: distutils question: different projects under same namespace

2005-04-17 Thread F. Petitjean
Le 16 Apr 2005 01:20:34 -0700, Qiangning Hong a écrit : > To avoid namespace confliction with other Python packages, I want all > my projects to be put into a specific namespace, e.g. 'hongqn' package, > so that I can use "from hongqn.proj1 import module1", "from > hongqn.proj2.subpack1 import modu

Re: pydoc preference for triple double over triple single quotes-- anyreason?

2005-04-17 Thread Brian van den Broek
Kent Johnson said unto the world upon 2005-04-17 16:17: Brian van den Broek wrote: Kent Johnson said unto the world upon 2005-04-16 16:41: Brian van den Broek wrote: I've just spent a frustrating bit of time figuring out why pydoc didn't extract a description from my module docstrings. Even though

Re: re module methods: flags(), pattern()

2005-04-17 Thread Kay Schluehr
Xah Lee wrote: > Python re module has methods flags and pattern. How to use these > exactly? >From the Python 2.3 documentation, section 2.4.2 flags The flags argument used when the RE object was compiled, or 0 if no flags were provided. groupindex A dictionary mapping any symbolic group name

Re: Problem with unpack hex to decimal

2005-04-17 Thread Peter Hansen
Jonathan Brady wrote: ... I also find the following confusing: struct.calcsize('hb') 3 struct.calcsize('hb') == struct.calcsize('bh') False I could understand aligning to multiples of 4, but why is 'hb' different from 'bh'? Pad bytes have never been, as far as I know, added at the end of structs

Re: sscanf needed

2005-04-17 Thread Lee Harr
On 2005-04-17, Andrew E <[EMAIL PROTECTED]> wrote: > Uwe Mayer wrote: >> Hi, >> >> I've got a ISO 8601 formatted date-time string which I need to read into a >> datetime object. >> Is there a shorter way than using regular expressions? Is there a sscanf >> function as in C? > > in addition to the

Re: pysvn install on freebsd

2005-04-17 Thread Lee Harr
On 2005-04-17, Timothy Smith <[EMAIL PROTECTED]> wrote: > has anyone used or installed this on fbsd > the install for it is totally redundant. i get this error for it > > make -f freebsd.mak clean all test > cd ../Source && make -f pysvn_freebsd_py.mak clean > make: cannot open pysvn_freebsd_py.mak

Re: Accessing multidimensional lists with an index list

2005-04-17 Thread Kent Johnson
Gabriel Birke wrote: Given the multidimensional list l: l = [ {'v1': 1, 'v2': 2}, [ {'v1':4, 'v2': 7}, {'v1': 9, 'v2': 86}, [ {'v1': 77, 'v2': 88}] ] ] I want to access specific items the indices of which are stored in another list. For now,

Re: pydoc preference for triple double over triple single quotes-- anyreason?

2005-04-17 Thread Kent Johnson
Brian van den Broek wrote: Kent Johnson said unto the world upon 2005-04-16 16:41: Brian van den Broek wrote: I've just spent a frustrating bit of time figuring out why pydoc didn't extract a description from my module docstrings. Even though I had a well formed docstring (one line, followed by a

Re: pre-PEP: Simple Thunks

2005-04-17 Thread Ron_Adam
On 17 Apr 2005 01:46:14 -0700, "Kay Schluehr" <[EMAIL PROTECTED]> wrote: >Ron_Adam wrote: > >> I sort of wonder if this is one of those things that looks like it >> could be useful at first, but it turns out that using functions and >> class's in the proper way, is also the best way. (?) > >I thin

Re: Decorator Syntax For Recursive Properties

2005-04-17 Thread Peter Otten
Jeffrey Froman wrote: > it is the originating node (the node trying to find its ancestors). So > something like this didn't work for me: > > @property > def ancestors(self): > if self.parent is None: > return [self.name] > return [self.name] + self.parent.ancestors But this will,

Accessing multidimensional lists with an index list

2005-04-17 Thread Gabriel Birke
Given the multidimensional list l: l = [ {'v1': 1, 'v2': 2}, [ {'v1':4, 'v2': 7}, {'v1': 9, 'v2': 86}, [ {'v1': 77, 'v2': 88}] ] ] I want to access specific items the indices of which are stored in another list. For now, I created a function

Re: Problem with unpack hex to decimal

2005-04-17 Thread Jonathan Brady
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hello, > > I was looking at this: > http://docs.python.org/lib/module-struct.html > and tried the following > import struct struct.calcsize('h') > 2 struct.calcsize('b') > 1 struct.calcsize('bh') > 4 > > I would hav

Re: whitespace , comment stripper, and EOL converter

2005-04-17 Thread M.E.Farmer
I found the bug and hope I have squashed it. Single and qouble quoted strings that were assignments and spanned multilines using \ , were chopped after the first line. example: __date__ = 'Apr 16, 2005,' \ 'Jan 15 2005,' \ 'Oct 24 2004' became: __date__ = 'Apr 16, 2005,' \

Re: Problem with unpack hex to decimal

2005-04-17 Thread Fredrik Lundh
"[EMAIL PROTECTED]" wrote: I was looking at this: http://docs.python.org/lib/module-struct.html and tried the following import struct struct.calcsize('h') 2 struct.calcsize('b') 1 struct.calcsize('bh') 4 I would have expected struct.calcsize('bh') 3 what am I missing ? the sentence "By default,

Problem with unpack hex to decimal

2005-04-17 Thread [EMAIL PROTECTED]
Hello, I was looking at this: http://docs.python.org/lib/module-struct.html and tried the following >>> import struct >>> struct.calcsize('h') 2 >>> struct.calcsize('b') 1 >>> struct.calcsize('bh') 4 I would have expected >>> struct.calcsize('bh') 3 what am I missing ? Thanks in advance, Jak

Re: unicode "em space" in regex

2005-04-17 Thread "Martin v. LÃwis"
Xah Lee wrote: > Thanks. Is it true that any unicode chars can also be used inside regex > literally? > > e.g. > re.search(ur'â+',mystring,re.U) > > I tested this case and apparently i can. Yes. In fact, when you write u"\u2003" or u"â" doesn't matter to re.search. Either way you get a Unicode

Re: Python's use in RAD

2005-04-17 Thread James
[EMAIL PROTECTED] wrote: > Active State's Komodo IDE is very nice for python development. It > includes integration with pdb (python's debugger). The pro edition > also has a GUI designer, however I've never used it. The personal > version for non commercial use can be had for $30 (and there's a

Re: pydoc preference for triple double over triple single quotes -- anyreason?

2005-04-17 Thread Brian van den Broek
Kent Johnson said unto the world upon 2005-04-16 16:41: Brian van den Broek wrote: Hi all, I'm posting partly so my problem and solution might be more easily found by google, and partly out of mere curiosity. I've just spent a frustrating bit of time figuring out why pydoc didn't extract a descr

Re: pre-PEP: Suite-Based Keywords - syntax proposal

2005-04-17 Thread Kay Schluehr
> Exactly. Except the above example is from the day-old-bread items-tuple-returning version of :: ;-) > And with an ordered dict subtype there is no need for the generator expression either, > since there is a values method for dicts (which in the subtype would preserve order). E.g., > > x = prope

Re: module to parse "pseudo natural" language?

2005-04-17 Thread John Roth
"Andrew E" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Hi all I've written a python program that adds orders into our order routing simulation system. It works well, and has a syntax along these lines: ./neworder --instrument NOKIA --size 23 --price MARKET --repeats 20 etc However

Re: re module methods: flags(), pattern()

2005-04-17 Thread Reinhold Birkenfeld
Xah Lee wrote: > Python re module has methods flags and pattern. How to use these > exactly? > > e.g. i tried > > print patternObj.flags() > > and the error is some "int object is not callable". Where do you read "methods"? Reinhold -- http://mail.python.org/mailman/listinfo/python-list

How to compile ScientificPython-2.4.9 under XP cygwin environment?

2005-04-17 Thread Zhuanshi He
Dear All, I try to compile ScientificPython-2.4.9 (http://starship.python.net/~hinsen/ScientificPython/) under Windows XP cygwin environment using python 2.3.3 ,and gcc (GCC) 3.3.3 (cygwin special). The information shows as fillows: -- Usin

Re: sscanf needed

2005-04-17 Thread Andrew E
Uwe Mayer wrote: > Hi, > > I've got a ISO 8601 formatted date-time string which I need to read into a > datetime object. > Is there a shorter way than using regular expressions? Is there a sscanf > function as in C? in addition to the other comments... I like re, because it gives me the most con

Re: sscanf needed

2005-04-17 Thread Kent Johnson
Uwe Mayer wrote: Hi, I've got a ISO 8601 formatted date-time string which I need to read into a datetime object. Something like this (adjust the format to suit): import datetime, time dt = datetime.datetime(*time.strptime(data, "%Y-%m-%d %H:%M:%S")[:6]) Kent -- http://mail.python.org/mailman/listin

How to compile ScientificPython-2.4.9 under XP cygwin environment?

2005-04-17 Thread Zhuanshi He
I try to compile ScientificPython-2.4.9 (http://starship.python.net/~hinsen/ScientificPython/) under Windows XP cygwin environment using python 2.3.3 ,and gcc (GCC) 3.3.3 (cygwin special). The information shows as follows: -- Using netCDF in

Re: sscanf needed

2005-04-17 Thread Leif B. Kristensen
Uwe Mayer skrev: > Hi, > > I've got a ISO 8601 formatted date-time string which I need to read > into a datetime object. Look up time.strptime, it does exactly what you want. -- Leif Biberg Kristensen http://solumslekt.org/ -- http://mail.python.org/mailman/listinfo/python-list

Re: sscanf needed

2005-04-17 Thread Fredrik Lundh
Uwe Mayer wrote: I've got a ISO 8601 formatted date-time string which I need to read into a datetime object. import time help(time.strptime) Help on built-in function strptime in module time: strptime(...) strptime(string, format) -> struct_time Parse a string to a time tuple according to a

sscanf needed

2005-04-17 Thread Uwe Mayer
Hi, I've got a ISO 8601 formatted date-time string which I need to read into a datetime object. Is there a shorter way than using regular expressions? Is there a sscanf function as in C? Thanks, Uwe -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 2.4 killing commercial Windows Python development ?

2005-04-17 Thread Peter Lee
Terry Reedy writes: >> To put it another way, needing a Python interpreter to run .py files is no >> different from, for instance, needing a movie player to run .mpg files, and >> all Windows users are or need to become familiar with that general concept. The problem for win

re module methods: flags(), pattern()

2005-04-17 Thread Xah Lee
Python re module has methods flags and pattern. How to use these exactly? e.g. i tried print patternObj.flags() and the error is some "int object is not callable". newpattern=re.compile(ur'\w+',patternObj.flags()) also bad. similar error for patternObj.pattern(). (and i suppose the same for g

Re: module to parse "pseudo natural" language?

2005-04-17 Thread F. Petitjean
Le Sun, 17 Apr 2005 13:38:09 +0200, Andrew E a écrit : > Hi all > > I've written a python program that adds orders into our order routing > simulation system. It works well, and has a syntax along these lines: > > ./neworder --instrument NOKIA --size 23 --price MARKET --repeats 20 > > etc > >

ANN: Veusz 0.5 - a scientific plotting package

2005-04-17 Thread Jeremy Sanders
Veusz 0.5 - Velvet Ember Under Sky Zenith - http://home.gna.org/veusz/ Veusz is Copyright (C) 2003-2005 Jeremy Sanders <[EMAIL PROTECTED]> Licenced under the GPL (version 2 or greater) Veusz is a scientific plotting package written in Python (currently 100% Pyt

Re: unicode "em space" in regex

2005-04-17 Thread Fredrik Lundh
Xah Lee wrote: "Regular expression pattern strings may not contain null bytes, but can specify the null byte using the \number notation." What is meant by null bytes here? Unprintable chars?? no, null bytes. "\0". "\x00". ord(byte) == 0. chr(0). and the "\number" is meant to be decimal? octal.

Re: unicode "em space" in regex

2005-04-17 Thread Reinhold Birkenfeld
Xah Lee wrote: > "Regular expression pattern strings may not contain null bytes, but can > specify the null byte using the \number notation." > > What is meant by null bytes here? Unprintable chars?? and the "\number" > is meant to be decimal? and in what encoding? The null byte is a byte with t

Re: module to parse "pseudo natural" language?

2005-04-17 Thread Diez B. Roggisch
> > Question is - is there a module out there that will already handle this > approach? Try the python nltk. I haven't done stuff with it so far, but I'd certainly give it a try when I need natural language support. http://nltk.sourceforge.net/ -- Regards, Diez B. Roggisch -- http://mail.py

Re: [perl-python] Python documentation moronicities (continued)

2005-04-17 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2005-04-17 14:59:50 +0200: > Roman Neuhauser wrote: > > >>Here's a puzzle for you: Where does this list appear? What's missing? > >> > >>"..., Mullender, Nagata, Ng, Oner, Oppelstrup, ..." > > > > Sorry, I don't have time for puzzles. > > nor for contributing, it seems. o

Re: unicode "em space" in regex

2005-04-17 Thread Xah Lee
Thanks. Is it true that any unicode chars can also be used inside regex literally? e.g. re.search(ur'â+',mystring,re.U) I tested this case and apparently i can. But is it true that any unicode char can be embedded in regex literally. (does this apply to the esoteric ones such as other non-printin

Re: [perl-python] Python documentation moronicities (continued)

2005-04-17 Thread Fredrik Lundh
Roman Neuhauser wrote: Here's a puzzle for you: Where does this list appear? What's missing? "..., Mullender, Nagata, Ng, Oner, Oppelstrup, ..." Sorry, I don't have time for puzzles. nor for contributing, it seems. otherwise, your name would be on that list. -- http://mail.python.org/mailman/l

Re: [perl-python] Python documentation moronicities (continued)

2005-04-17 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2005-04-13 08:07:06 +1000: > On Tue, 12 Apr 2005 13:06:36 +0200, Roman Neuhauser > <[EMAIL PROTECTED]> wrote: > > >Unfortunately, the python community seems to bathe in the > >misorganized half-documentation, see e. g. > >http://marc.theaimsgroup.com/?l=python-lis

Re: pre-PEP: Suite-Based Keywords

2005-04-17 Thread Reinhold Birkenfeld
Bengt Richter wrote: > Stretching for it, using my latest and greatest ;-) > > y = f(**:: >x = 1 >y = 'y for f' > )*g(**:: >x = 'x for g' >y = 'y for g' >def foo(): return 'foo for g' > ) > > Note that there is no pr

Re: Compute pi to base 12 using Python?

2005-04-17 Thread Dick Moores
Paul Rubin wrote at 02:35 4/17/2005: Dick Moores <[EMAIL PROTECTED]> writes: > >C:\cygwin\bin\bc -l > pi12.txt > > But how or when do you enter the lines > > scale = 3000 > obase = 12 > print 4 * a(1) You could put them into a file, say pi.bc. Then run bc -l pi.bc OK, now that I've got Textpad t

module to parse "pseudo natural" language?

2005-04-17 Thread Andrew E
Hi all I've written a python program that adds orders into our order routing simulation system. It works well, and has a syntax along these lines: ./neworder --instrument NOKIA --size 23 --price MARKET --repeats 20 etc However, I'd like to add a mode that will handle, say: ./neworder buy 2

Re: Compute pi to base 12 using Python?

2005-04-17 Thread Dick Moores
Bengt Richter wrote at 02:26 4/17/2005: >Could someone remind me how to get the output of bc -l into a text file >on Windows? (I've tried employing " > pi3003.txt" in various ways) OR, >how to copy and paste from the command line window, or whatever that >window is called? (Sorry for the OT questio

Re: Pattern Matching Given # of Characters and no String Input; useRegularExpressions?

2005-04-17 Thread Kent Johnson
tiissa wrote: Synonymous wrote: Can regular expressions compare file names to one another. It seems RE can only compare with input i give it, while I want it to compare amongst itself and give me matches if the first x characters are similiar. Do you have to use regular expressions? If you know the

Re: XML parsing per record

2005-04-17 Thread Fredrik Lundh
William Park wrote: You may want to try Expat (www.libexpat.org) or Python wrapper to it. Python comes with a low-level expat wrapper (pyexpat). however, if you want performance, cElementTree (which also uses expat) is a lot faster than pyexpat. (see my other post for links to benchmarks and code)

Re: Pattern Matching Given # of Characters and no String Input; use RegularExpressions?

2005-04-17 Thread tiissa
tiissa wrote: If you know the number of characters to match can't you just compare slices? If you don't, you can still do it by hand: In [7]: def cmp(s1,s2): : diff_map=[chr(s1[i]!=s2[i]) for i in range(min(len(s1), len(s2)))] : diff_index=''.join(diff_map).find(chr(True)) .

Re: Pattern Matching Given # of Characters and no String Input; use RegularExpressions?

2005-04-17 Thread tiissa
Synonymous wrote: Can regular expressions compare file names to one another. It seems RE can only compare with input i give it, while I want it to compare amongst itself and give me matches if the first x characters are similiar. Do you have to use regular expressions? If you know the number of cha

Re: whitespace , comment stripper, and EOL converter

2005-04-17 Thread M.E.Farmer
Google has now 'fixed' there whitespace issue and now has an auto-quote issue argggh! The script is located at: http://bellsouthpwp.net/m/e/mefjr75/python/stripper.py M.E.Farmer -- http://mail.python.org/mailman/listinfo/python-list

Re: Compute pi to base 12 using Python?

2005-04-17 Thread Paul Rubin
Dick Moores <[EMAIL PROTECTED]> writes: > >C:\cygwin\bin\bc -l > pi12.txt > > But how or when do you enter the lines > > scale = 3000 > obase = 12 > print 4 * a(1) You could put them into a file, say pi.bc. Then run bc -l pi.bc -- http://mail.python.org/mailman/listinfo/python-list

Pattern Matching Given # of Characters and no String Input; use RegularExpressions?

2005-04-17 Thread Synonymous
Hello, Can regular expressions compare file names to one another. It seems RE can only compare with input i give it, while I want it to compare amongst itself and give me matches if the first x characters are similiar. For example: cccat cccap cccan dddfa dddfg dddfz Would result in the 'ddd' a

Re: whitespace , comment stripper, and EOL converter

2005-04-17 Thread M.E.Farmer
MrJean1 wrote: > There is an issue with both my and your code: it only works if doc > strings are triple quoted and if there are no other triple quoted > strings in the Python code. I had not considered single quoted strings ;) > A triple quoted string used in an assignment will be removed, for > e

Re: Compute pi to base 12 using Python?

2005-04-17 Thread Dick Moores
Roel Schroeven wrote at 01:45 4/17/2005: Dick Moores wrote: M.E.Farmer wrote at 23:18 4/14/2005: > >Using the GNU "bc" utility: > > > > $ bc -l > > bc 1.06 > > Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc. > > This is free software with ABSOLUTELY NO WARRANTY. > > F

Re: Compute pi to base 12 using Python?

2005-04-17 Thread Bengt Richter
On Sun, 17 Apr 2005 01:00:46 -0700, Dick Moores <[EMAIL PROTECTED]> wrote: >M.E.Farmer wrote at 23:18 4/14/2005: >> > >Using the GNU "bc" utility: >> > > >> > > $ bc -l >> > > bc 1.06 >> > > Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, >>Inc. >> > > This is free software

Re: pre-PEP: Simple Thunks

2005-04-17 Thread Kay Schluehr
Ron_Adam wrote: > I sort of wonder if this is one of those things that looks like it > could be useful at first, but it turns out that using functions and > class's in the proper way, is also the best way. (?) I think Your block is more low level. It is like copying and pasting code-fragments tog

Re: Compute pi to base 12 using Python?

2005-04-17 Thread Roel Schroeven
Dick Moores wrote: M.E.Farmer wrote at 23:18 4/14/2005: > >Using the GNU "bc" utility: > > > > $ bc -l > > bc 1.06 > > Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc. > > This is free software with ABSOLUTELY NO WARRANTY. > > For details type `warranty'. > > scale =

Re: new to mac OS10

2005-04-17 Thread Robert Kern
Maurice LING wrote: Robert Kern wrote: 3. Apple-installed Python's command line tools are symlinked from /usr/bin to /System/Library/Frameworks/Python.framework but the OSX installer for Python 2.4.1 places the commandline tools in /usr/local/bin and symlinked to /Library/Frameworks/Python.frame

Re: pre-PEP: Suite-Based Keywords - syntax proposal

2005-04-17 Thread Bengt Richter
On 16 Apr 2005 23:43:03 -0700, "Kay Schluehr" <[EMAIL PROTECTED]> wrote: > >Robert Brewer wrote: >> Bengt Richter wrote: >> > The '::' unary suite operator should return an ordered dict >> > subtype representing the bindings >> >> Why ordered? > >Because You can't otherwise guarantee to feed optio

  1   2   >