Re: Is there a list comprehension for this?

2006-11-22 Thread Peter Otten
liam_herron wrote: > > Given: > dw = [ 1, -1.1, +1.2 ] > > Suppose I want to create a list 'w' that is defined as > > w[0] = dw[0], > w[1] = w[0] + dw[1], > w[2] = w[1] + dw[2] > > Is there a list comprehension or map expression to do it in one or 2 > lines. >>> from itertools import * >>> da

Re: Is python for me?

2006-11-22 Thread cyberco
One resource you should always keep at hand is this extremely useful Quick Reference: http://rgruet.free.fr/PQR24/PQR2.4.html Study it carefully, there is a lot in there that can teach you about how Python works. Fire up IPython as well and start hacking! 2B -- http://mail.python.org/mailman/l

Re: Quadratic Optimization Problem

2006-11-22 Thread Stefan Behnel
[EMAIL PROTECTED] wrote: > I need to do a quadratic optimization problem in python where the > constraints are quadratic and objective function is linear. > > What are the possible choices to do this. Too bad these homework assignments get trickier every time, isn't it? Stefan -- http://mail.py

Re: re.match -- not greedy?

2006-11-22 Thread Ant
EXI-Andrews, Jack wrote: > the '*' and '+' don't seem to be greedy.. they will consume less in > order to match a string: > > >>> import re;re.match('(a+)(ab)','aaab').groups() > ('aa', 'ab') > > this is the sort of behaviour i'd expect from >'(a+?)(ab)' > > a+ should greedily consume a's at

Re: Trying to understand Python objects

2006-11-22 Thread Fredrik Lundh
walterbyrd wrote: > 1) Can attributes can added just anywhere? I create an object called > point, then I can add attributes any time, and at any place in the > program? in general, yes, but that should be done sparingly. > 2) Are classes typically created like this: > > class Point: > pass >

Re: Parsing/Splitting Line

2006-11-22 Thread Fredrik Lundh
Noah Rawlins wrote: > I'm a nut for regular expressions and obfuscation... > > import re > def splitline(line, size=4): > return re.findall(r'.{%d}' % size, line) > > >>> splitline("helloiamsuperman") > ['hell', 'oiam', 'supe', 'rman'] there are laws against such use of regular expressio

file backup in windows

2006-11-22 Thread k.i.n.g.
Hi ALL, I am a newbee programmer and started of with python recently. I am trying write a script which backups outlook (.pst ) files everytime I shutdown my system. I have writtern following code after some findings on net. My .pst file path is as follows " c:\documents and settings\060577\Local

Re: How to sort list

2006-11-22 Thread Fredrik Lundh
Klaus Alexander Seistrup wrote: > Decorate-sort-undecorate? > > #v+ > > array = [] > > for addr in Emails: > (user, domain) = addr.split('@') > array.append((domain, user, addr)) > # end for > > array.sort() > > SortedEmails = [addr for (user, domain, addr) in array] > > #v- note that D

Python visual IDE

2006-11-22 Thread king kikapu
Hi to all, i am not sure if this question really belongs here but anyway, here it goes: I have seen a lot of IDEs for Python, a lot of good stuff but actually none of them has what, for example, Visual Studio has: a Visual Editor (with the ability to place controls on forms etc etc), or RAD I k

Re: Parsing/Splitting Line

2006-11-22 Thread Georg Brandl
Fredrik Lundh schrieb: > Noah Rawlins wrote: > > >> I'm a nut for regular expressions and obfuscation... >> >> import re >> def splitline(line, size=4): >> return re.findall(r'.{%d}' % size, line) >> >> >>> splitline("helloiamsuperman") >> ['hell', 'oiam', 'supe', 'rman'] > > there are l

Pyparsing Question.

2006-11-22 Thread Ant
I have a home-grown Wiki that I created as an excercise, with it's own wiki markup (actually just a clone of the Trac wiki markup). The wiki text parser I wrote works nicely, but makes heavy use of regexes, tags and stacks to parse the text. As such it is a bit of a mantainability nightmare - addin

Re: file backup in windows

2006-11-22 Thread Fredrik Lundh
k.i.n.g. wrote: > how can i make the following code work, I have probelm with filepath > declaration. http://effbot.org/pyfaq/tutor-i-need-help-im-getting-an-error-in-my-program-what-should-i-do -- http://mail.python.org/mailman/listinfo/python-list

gopherlib deprecated in 2.5

2006-11-22 Thread Szabolcs Nagy
I've just seen that gopherlib is deprecated in python 2.5 http://docs.python.org/lib/module-gopherlib.html we still use this protocol (though there are only few working gopher servers are left on the net) My friend just wrote a standard compliant gopher server (pygopherd had some problems oslt) a

RE: file backup in windows

2006-11-22 Thread Tim Golden
| " c:\documents and settings\060577\Local Settings\Application | Data\Microsoft\Outlook " | where 060577 represents username. I want my script to | identigy the user | logged in and go to the resp outlook folder or should be able to read | outlook store directory path from registry and the copy t

Re: file backup in windows

2006-11-22 Thread John Machin
k.i.n.g. wrote: > Hi ALL, > > I am a newbee programmer and started of with python recently. I am > trying write a script which backups outlook (.pst ) files everytime I > shutdown my system. I have writtern following code after some findings > on net. My .pst file path is as follows > > " c:\docume

Re: Is there a list comprehension for this?

2006-11-22 Thread Steven D'Aprano
On Tue, 21 Nov 2006 21:00:02 -0800, John Machin wrote: > Steven D'Aprano wrote: > > [snip] > >> def running_sum(dw): >> """Return a list of the running sums of sequence dw""" >> rs = [0]*len(dw) >> for i in range(len(dw)): >> rs[i] = dw[i] + rs[i-1] > > Please explain to the

Re: Is there a list comprehension for this?

2006-11-22 Thread John Machin
Steven D'Aprano wrote: > On Tue, 21 Nov 2006 21:00:02 -0800, John Machin wrote: > > > Steven D'Aprano wrote: > > > > [snip] > > > >> def running_sum(dw): > >> """Return a list of the running sums of sequence dw""" > >> rs = [0]*len(dw) > >> for i in range(len(dw)): > >> rs[i] =

Re: Is there a list comprehension for this?

2006-11-22 Thread Steven D'Aprano
On Wed, 22 Nov 2006 02:28:04 -0800, John Machin wrote: > > Steven D'Aprano wrote: >> On Tue, 21 Nov 2006 21:00:02 -0800, John Machin wrote: >> >> > Steven D'Aprano wrote: >> > >> > [snip] >> > >> >> def running_sum(dw): >> >> """Return a list of the running sums of sequence dw""" >> >> rs

text file parsing (awk -> python)

2006-11-22 Thread Daniel Nogradi
Hi list, I have an awk program that parses a text file which I would like to rewrite in python. The text file has multi-line records separated by empty lines and each single-line field has two subfields: node 10 x -1 y 1 node 11 x -2 y 1 node 12 x -3 y 1 and this I would like to parse into a l

RE: file backup in windows

2006-11-22 Thread Tim Golden
[... snip ...] | --- | how can i make the following code work, I have probelm with filepath | declaration. | --- | import os, shutil | filepath = ' C:\\Documents and Settings\\060577\\Local | Settings\\

Re: Trying to understand Python objects

2006-11-22 Thread Bruno Desthuilliers
walterbyrd wrote: > Reading "Think Like a Computer Scientist" I am not sure I understand > the way it describes the way objects work with Python. > > 1) Can attributes can added just anywhere? I create an object called > point, then I can add attributes any time, and at any place in the > program?

Re: file backup in windows

2006-11-22 Thread k.i.n.g.
Thank You all for reply's so far > > import os, sys > from win32com.shell import shell, shellcon > > local_app_data = shell.SHGetSpecialFolderPath (0, > shellcon.CSIDL_LOCAL_APPDATA) > outlook_path = os.path.join (local_app_data, "Microsoft", "Outlook") > > print outlook_path > > The above code

File upload from client application (non-form based upload)

2006-11-22 Thread stuart
Hi I'm trying to write a Python script to receive and save a file on a web server that has been POST'ed from a client application. In essence, this is similar to handling a file upload from an HTML form. However, I can't use: form = cgi.FieldStorage() fileitem = form['file'] since the file is n

Re: Python visual IDE

2006-11-22 Thread Bruno Desthuilliers
king kikapu wrote: > Hi to all, > > i am not sure if this question really belongs here but anyway, here it > goes: I have seen a lot of IDEs for Python, a lot of good stuff but > actually none of them has what, for example, Visual Studio has: a > Visual Editor (with the ability to place controls

Re: file backup in windows

2006-11-22 Thread Mikael Olofsson
k.i.n.g. wrote: > [snip code] > The above code was fine while printing, when I am trying to use this > (outlook_path) to use as source path it is giving file permission error > can you please clarify this Did you follow the link that Fredrik Lundh gave you? /MiO -- http://mail.python.org/mailman

Data not flushed at the moment

2006-11-22 Thread MindClass
I've to modifying a file, then I use a method imported that access to that file and has to read the new data, but they are not read ( as if the data were not flushed at the moment even using .close() explicitly). --- ... ... # If it is not installed,

Re: file backup in windows

2006-11-22 Thread k.i.n.g.
Hi , I am sorry I am providing the code i used as it is. Being newbee to programming I have tinkerd with various options i found on the net. start of the code --

RE: file backup in windows

2006-11-22 Thread Tim Golden
| > | > import os, sys | > from win32com.shell import shell, shellcon | > | > local_app_data = shell.SHGetSpecialFolderPath (0, | > shellcon.CSIDL_LOCAL_APPDATA) | > outlook_path = os.path.join (local_app_data, "Microsoft", "Outlook") | > | > print outlook_path | > | > | | The above code was fin

PyQt app in seperate thread

2006-11-22 Thread anders
I am writing a plugin for a piece of software in python, and I want to start up a PyQt GUI in the plugin, without stalling the main thread while the gui is running (later i will want to pass messages between the main thread and the gui thread). I'm new to pyqt, so I'm probably doing something very

Capture file descriptors while running an external program

2006-11-22 Thread jfigueiras
Hi all! I have a problem with the module subprocess! The problem is that the external software that I am running under subprocess.Popen opens stdin, stdout, stderr, and other file descriptors to write and read in the hard drive. I know how to capture stdin, stdout and stderr, what I cannot do is t

RE: file backup in windows

2006-11-22 Thread Tim Golden
| I am sorry I am providing the code i used as it is. Being newbee to | programming I have tinkerd with various options i found on the net. Thanks. That makes it a lot easier [... snip ...] | source = outlook_path | #source = outlook_path +'\\*' | print source [...] | win32file.CopyFile (sourc

Re: Python visual IDE

2006-11-22 Thread king kikapu
hmmm,,,ok, i see your point. As i understand it, as a newcomer, it is a little cumbersome to right the code in one ide, "glue" the UI from another toll and all that stuff. I know it works but if someone is coming from VS.Net, it seems a little strange, at first. I also saw that the wxWidgets is

Re: text file parsing (awk -> python)

2006-11-22 Thread Peter Otten
Daniel Nogradi wrote: > I have an awk program that parses a text file which I would like to > rewrite in python. The text file has multi-line records separated by > empty lines and each single-line field has two subfields: > > node 10 > x -1 > y 1 > > node 11 > x -2 > y 1 > > node 12 > x -3 > y

XML Validation in Python using XSV

2006-11-22 Thread bmichel
I'd like to use XSV for validating an XML file in Python. I am working on Linux Debian platform. I'm not sure how to install XSV and how to configure it. My goal is to be able to import the XSV library in Python and be able to use it's functions. XSV v2.10 for Debian available here: ftp://ftp.cogs

Getting exceptions back from calls to embedded python

2006-11-22 Thread john . pye
Hi all, I have an application that is using embedded python to offer some scripting ability. An API is exposed via SWIG, and I am accessing that API from my embedded python interpreter. Scripts are present as separate files, and I'm invoking them at present using the following: iserr = P

Re: PyQt app in seperate thread

2006-11-22 Thread Phil Thompson
On Wednesday 22 November 2006 12:37 pm, anders wrote: > I am writing a plugin for a piece of software in python, and I want to > start up a PyQt GUI in the plugin, without stalling the main thread > while the gui is running (later i will want to pass messages between > the main thread and the gui t

Re: How to sort list

2006-11-22 Thread Klaus Alexander Seistrup
Fredrik Lundh wrote: > note that DSU is built into Python these days: > > L.sort(key=transform) Sweet, thanks for the hint. Cheers, -- Klaus Alexander Seistrup http://klaus.seistrup.dk/ -- http://mail.python.org/mailman/listinfo/python-list

Re: XML Validation in Python using XSV

2006-11-22 Thread Stefan Behnel
[EMAIL PROTECTED] wrote: > I'd like to use XSV for validating an XML file in Python. > I am working on Linux Debian platform. > I'm not sure how to install XSV and how to configure it. My goal is to > be able to import the XSV library in Python and be able to use it's > functions. You can use "dpk

Re: Pyparsing Question.

2006-11-22 Thread Stefan Behnel
Ant wrote: > So I thought I'd look into the pyparsing module, but can't find a > simple example of processing random text. Have you looked at the examples on the pyparsing web page? Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: XML Validation in Python using XSV

2006-11-22 Thread bmichel
No particular reason for XSV I just want to validate XML files against an XML schema through Python. If you can suggest any other package for debian, I'll be glad to try it. Michel Stefan Behnel wrote: > [EMAIL PROTECTED] wrote: > > I'd like to use XSV for validating an XML file in Python. > > I

Method argument names

2006-11-22 Thread [EMAIL PROTECTED]
Hi Having a method: def method(self,x,y): is it possible to discover, from outside the method, that the methods arguments are ['self', 'x', 'y']? Thanks. /Martin -- http://mail.python.org/mailman/listinfo/python-list

Re: Quadratic Optimization Problem

2006-11-22 Thread Beliavsky
Stefan Behnel wrote: > [EMAIL PROTECTED] wrote: > > I need to do a quadratic optimization problem in python where the > > constraints are quadratic and objective function is linear. > > > > What are the possible choices to do this. > > Too bad these homework assignments get trickier every time, isn

Re: Method argument names

2006-11-22 Thread Bruno Desthuilliers
[EMAIL PROTECTED] wrote: > Hi > > Having a method: > > def method(self,x,y): > > is it possible to discover, from outside the method, that the methods > arguments are ['self', 'x', 'y']? import inspect help(inspect.getargspec) HTH -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[

Re: PyQt app in seperate thread

2006-11-22 Thread anders
Phil Thompson wrote: > On Wednesday 22 November 2006 12:37 pm, anders wrote: > > I am writing a plugin for a piece of software in python, and I want to > > start up a PyQt GUI in the plugin, without stalling the main thread > > while the gui is running (later i will want to pass messages between >

Re: text file parsing (awk -> python)

2006-11-22 Thread Daniel Nogradi
> > I have an awk program that parses a text file which I would like to > > rewrite in python. The text file has multi-line records separated by > > empty lines and each single-line field has two subfields: > > > > node 10 > > x -1 > > y 1 > > > > node 11 > > x -2 > > y 1 > > > > node 12 > > x -3 >

What's going on here?

2006-11-22 Thread Dale Strickland-Clark
Python 2.4.2 (#1, Oct 13 2006, 17:11:24) [GCC 4.1.0 (SUSE Linux)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> a = object() >>> a >>> a.spam = 1 Traceback (most recent call last): File "", line 1, in ? AttributeError: 'object' object has no attribute 'spam

Re: PyQt app in seperate thread

2006-11-22 Thread Phil Thompson
On Wednesday 22 November 2006 2:06 pm, anders wrote: > Phil Thompson wrote: > > On Wednesday 22 November 2006 12:37 pm, anders wrote: > > > I am writing a plugin for a piece of software in python, and I want to > > > start up a PyQt GUI in the plugin, without stalling the main thread > > > while th

Re: Python visual IDE

2006-11-22 Thread Steve
I haven't used it but Komodo (Professional version) says it has: ActiveState GUI Builder (Komodo Professional only) Enhance your applications with GUI dialogs: Simple, Tk-based dialog builder with seamless round-trip integration, for Perl, Python, Ruby, and Tcl. -- http://mail.python.org/mailma

Re: XML Validation in Python using XSV

2006-11-22 Thread Stefan Behnel
> [EMAIL PROTECTED] wrote: > Stefan Behnel wrote: >> BTW: any reason you need to use XSV? There are some other libraries out there >> that can validate XML based on XML Schema and RelaxNG, e.g. lxml. They are >> much more powerful than XSV. > > No particular reason for XSV > I just want to validate

Re: Trying to understand Python objects

2006-11-22 Thread walterbyrd
Thanks everybody. I will sort all of this out, but right now my head is spinning. Is there some book, or other reference, that explains of this? I was thinking about "Python for Dummies." The "Think like a Computer Scientist" book, and "Dive into Python" book don't seem to explain Python's object

Re: Python visual IDE

2006-11-22 Thread king kikapu
I have already downloaded and seen the trial of Komodo Professional. Indeed it has a simple Gui Builder but one can only use TKinter on it. No wxWidgets support and far from truly RAD, but it is the only "integrated" GUI builder in these IDEs... On Nov 22, 4:31 pm, "Steve" <[EMAIL PROTECTED]> wr

Re: PyQt app in seperate thread

2006-11-22 Thread anders
Phil Thompson wrote: > On Wednesday 22 November 2006 2:06 pm, anders wrote: > > Phil Thompson wrote: > > > On Wednesday 22 November 2006 12:37 pm, anders wrote: > > > > I am writing a plugin for a piece of software in python, and I want to > > > > start up a PyQt GUI in the plugin, without stallin

Re: PyQt app in seperate thread

2006-11-22 Thread Chris Mellon
On 22 Nov 2006 06:43:55 -0800, anders <[EMAIL PROTECTED]> wrote: > > Phil Thompson wrote: > > On Wednesday 22 November 2006 2:06 pm, anders wrote: > > > Phil Thompson wrote: > > > > On Wednesday 22 November 2006 12:37 pm, anders wrote: > > > > > I am writing a plugin for a piece of software in pyth

ANN: PyVISA 1.1 -- GPIB, USB, RS232 instrument control

2006-11-22 Thread Torsten Bronger
Hallöchen! At http://pyvisa.sourceforge.net you can find information about the PyVISA package. It realises Python bindings for the VISA library functions, which enables you to control GPIB, USB, and RS232-serial measurement devices via Python. Yesterday I released version 1.1, which works much b

Re: What's going on here?

2006-11-22 Thread Scott David Daniels
Dale Strickland-Clark wrote: > Python 2.4.2 (#1, Oct 13 2006, 17:11:24) a = object() a.spam = 1 > Traceback (most recent call last): > File "", line 1, in ? > AttributeError: 'object' object has no attribute 'spam' class B(object): pass a = B() a.spam = 1 > > What i

Re: What's going on here?

2006-11-22 Thread Richie Hindle
> What is subclassing adding to the class here? A __dict__: >>> o = object() >>> dir(o) ['__class__', '__delattr__', '__doc__', '__getattribute__', '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__'] >>> class C(object): pass ... >>> c = C() >>

Re: What's going on here?

2006-11-22 Thread Fredrik Lundh
Dale Strickland-Clark wrote: > Why can't I assign to attributes of an instance of object? it doesn't have any attribute storage. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python visual IDE

2006-11-22 Thread hg
king kikapu wrote: > I have already downloaded and seen the trial of Komodo Professional. > Indeed it has a simple Gui Builder but one can only use TKinter on it. > No wxWidgets support and far from truly RAD, but it is the only > "integrated" > GUI builder in these IDEs... > > > On Nov 22, 4:31

Re: XML Validation in Python using XSV

2006-11-22 Thread bmichel
I've read a bit about lxml, didn't found anything related to validating XML schema... Maybe you can give more details on how to install lxml and use it in Python to validate XML files against an XML Schema I'm going to ask the server administrator to install lxml, so I can't play around a lot with

Re: XML Validation in Python using XSV

2006-11-22 Thread Stefan Behnel
[EMAIL PROTECTED] wrote: > Stefan Behnel wrote: >>> [EMAIL PROTECTED] wrote: >>> Stefan Behnel wrote: BTW: any reason you need to use XSV? There are some other libraries out there that can validate XML based on XML Schema and RelaxNG, e.g. lxml. They are much more powerful than

Re: What's going on here?

2006-11-22 Thread Gerald Klix
Perhaps this piece of code might explain the behaviour: >>> class C( object ): ... __slots__ = () ... >>> o = C() >>> o.a = 1 Traceback (most recent call last): File "", line 1, in ? AttributeError: 'C' object has no attribute 'a' object behaves like having an implict __slots__ attrib

Re: file backup in windows

2006-11-22 Thread MC
Hi! " are your friend. See, also: filepath = '"%HOMEPATH%\\LocalSettings\\Application Data\\Microsoft\\Outlook\\*"' and %USERPROFILE% %APPDATA% etc. -- @-salutations Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list

Re: XML Validation in Python using XSV

2006-11-22 Thread bmichel
This works for me. You were very helpful, thank you! Michel Stefan Behnel wrote: > [EMAIL PROTECTED] wrote: > > Stefan Behnel wrote: > >>> [EMAIL PROTECTED] wrote: > >>> Stefan Behnel wrote: > BTW: any reason you need to use XSV? There are some other libraries out > there > that c

Re: Pyparsing Question.

2006-11-22 Thread Paul McGuire
"Ant" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >I have a home-grown Wiki that I created as an excercise, with it's own > wiki markup (actually just a clone of the Trac wiki markup). The wiki > text parser I wrote works nicely, but makes heavy use of regexes, tags > and stacks to

Re: file backup in windows

2006-11-22 Thread Fredrik Lundh
"MC" wrote: > " are your friend. to be precise, list2cmdline is your friend. see discussion and examples here: http://effbot.org/pyfaq/why-can-t-raw-strings-r-strings-end-with-a-backslash.htm -- http://mail.python.org/mailman/listinfo/python-list

Re: Python visual IDE

2006-11-22 Thread king kikapu
I didn't know about this product you mention (wxDesigner). I download the trial and it seems pretty good, reminds me the wxGlade. So you make the GUI in this, generate Python code and import the module on your main project and reference it respectively ?? On Nov 22, 4:58 pm, hg <[EMAIL PROTECTE

Re: Python visual IDE

2006-11-22 Thread johnf
king kikapu wrote: > > Hi to all, > > i am not sure if this question really belongs here but anyway, here it > goes: I have seen a lot of IDEs for Python, a lot of good stuff but > actually none of them has what, for example, Visual Studio has: a > Visual Editor (with the ability to place contr

Re: Data not flushed at the moment

2006-11-22 Thread MindClass
Here it's very well explained: http://groups.google.com/group/django-developers/browse_thread/thread/7bcb01ec38e7e6cd syncdb() method: http://code.djangoproject.com/browser/django/trunk/django/core/management.py#L435 But I'm not sure if is a django problem or from python. MindClass ha escrito:

Re: Python visual IDE

2006-11-22 Thread hg
Yes, Actually when you create the project from wxDesigner, the "main" will also be generated for you ... then you include the correct files in eclipse (note that one file never needs to be edited ... like glade). I went for wxDesigner years ago when wxglade was fairly unstable ... have not tested

Re: Caution newbie question: python window to stay open ?

2006-11-22 Thread jim-on-linux
Michael, put this at the top of your code. After the window closes read the testLog.out file. It may give you a clue as to what is happening. sys.stdout = open('testLog.out', 'w') jim-on-linux http://www.inqvista.com On Tuesday 21 November 2006 22:20, mkengel wrote: > Caution: newbie q

Re: PyQt app in seperate thread

2006-11-22 Thread Diez B. Roggisch
> OK I see that now. Thanks for pointing that out. So basically, I can't > do what I want at all. That's a bit of a pain. Is there no way of > tricking Qt into thinking I'm running it in the main thread? Maybe you can either invert the thread-roles - that is, run your "main" application in a threa

Re: PyQt app in seperate thread

2006-11-22 Thread anders
Diez B. Roggisch wrote: > > OK I see that now. Thanks for pointing that out. So basically, I can't > > do what I want at all. That's a bit of a pain. Is there no way of > > tricking Qt into thinking I'm running it in the main thread? > > Maybe you can either invert the thread-roles - that is, run

Re: PyQt app in seperate thread

2006-11-22 Thread Diez B. Roggisch
anders wrote: > > Diez B. Roggisch wrote: >> > OK I see that now. Thanks for pointing that out. So basically, I can't >> > do what I want at all. That's a bit of a pain. Is there no way of >> > tricking Qt into thinking I'm running it in the main thread? >> >> Maybe you can either invert the thre

Re: Note about getattr and '.'

2006-11-22 Thread Carl Banks
Steven D'Aprano wrote: > On Tue, 21 Nov 2006 22:39:09 +0100, Mathias Panzenboeck wrote: > > Yes, this is known. I think IronPython uses a specialized dictionary for > > members, which prohibits > > malformed names. I don't know if there will be such a dictionary in any > > future CPython version

Re: text file parsing (awk -> python)

2006-11-22 Thread bearophileHUGS
Peter Otten, your solution is very nice, it uses groupby splitting on empty lines, so it doesn't need to read the whole files into memory. But Daniel Nogradi says: > But the names of the fields (node, x, y) keeps changing from file to > file, even their number is not fixed, sometimes it is (node,

PyParsing and Headaches

2006-11-22 Thread Hugo Ferreira
Hi, I'm trying to construct a parser, but I'm stuck with some basic stuff... For example, I want to match the following: letter = "A"..."Z" | "a"..."z" literal = letter+ include_bool := "+" | "-" term = [include_bool] literal So I defined this as: literal = Word(alphas) include_bool = Optional

Re: Programmatically replacing an API for another module

2006-11-22 Thread Chris Lambacher
On Tue, Nov 21, 2006 at 05:00:32PM -0800, Tom Plunket wrote: > Bruno Desthuilliers wrote: > > > > I've got a bunch of code that runs under a bunch of unit tests. It'd > > > be really handy if when testing I could supply replacement > > > functionality to verify that the right things get called wi

Re: Programmatically replacing an API for another module

2006-11-22 Thread Chris Lambacher
> > I'm just a bit loathe to download and install more stuff when > > something simpler appears to be near-at-hand. ...especially > > considering the page describing this module doesn't offer any download > > links! http://python-mock.sourceforge.net/ > How about mini-mock: > http://blog.ianbicki

KeyboardInterrupt from syscalls

2006-11-22 Thread Fredrik Tolf
Dear List, I was writing a Python extension module, including a sleeping call to poll(2), and noticed, to my great surprise (and joy), that even when blocking there, KeyboardInterrupt still worked properly when sending SIGINTs to the interpreter. It really got me wondering how it works, though. I

utf - string translation

2006-11-22 Thread hg
Hi, I'm bringing over a thread that's going on on f.c.l.python. The point was to get rid of french accents from words. We noticed that len('à') != len('a') and I found the hack below to fix the "problem" ... yet I do not understand - especially since 'à' is included in the extended ASCII table,

How to pass a boolean to a stored proc using Cx_Oracle?

2006-11-22 Thread JG
Hi, I am using Python 2.4 and cx_Oracle. I have a stored proc that takes two arguments. First is an NUMBER, second is a BOOLEAN. How do you call that stored procedure? After properly extablishing a connection, I have something like this: cursor = con.cursor() cursor.callproc("testproc",[123,Tr

Re: KeyboardInterrupt from syscalls

2006-11-22 Thread Fredrik Lundh
Fredrik Tolf wrote: > So how does it work? Does my code get to return Py_FALSE, and the > interpreter ignores it, seeing that an exception is set? Is a non-local > exit performed right over my call stack (in which case my next question > would be how to clean up resources being used from my C code

Re: utf - string translation

2006-11-22 Thread Fredrik Lundh
hg wrote: > We noticed that len('à') != len('a') sounds odd. >>> len('à') == len('a') True are you perhaps using an UTF-8 editor? to keep your sanity, no matter what editor you're using, I recommend adding a coding directive to the source file, and using *only* Unicode string literals for n

Re: utf - string translation

2006-11-22 Thread hg
Fredrik Lundh wrote: > hg wrote: > >> We noticed that len('à') != len('a') > > sounds odd. > len('à') == len('a') > True > > are you perhaps using an UTF-8 editor? > > to keep your sanity, no matter what editor you're using, I recommend > adding a coding directive to the source file, and

Re: utf - string translation

2006-11-22 Thread hg
hg wrote: > Fredrik Lundh wrote: >> hg wrote: >> >>> We noticed that len('à') != len('a') >> sounds odd. >> > len('à') == len('a') >> True >> >> are you perhaps using an UTF-8 editor? >> >> to keep your sanity, no matter what editor you're using, I recommend >> adding a coding directive to the

Re: A python IDE for teaching that supports cyrillic i/o

2006-11-22 Thread od
tool69 wrote: > Sorry, but did someone knows if Pida works under Windows ? > Thanks. No, it doesn't really. You can start it up with a bit of hacking, and I have seen screenshots around, but only with the scintilla-based editor. We are waiting for SVG support in GTK on windows. Writing a vim-win

Re: utf - string translation

2006-11-22 Thread Duncan Booth
hg <[EMAIL PROTECTED]> wrote: >> or in other words, put this at the top of your file (where "utf-8" is >> whatever your editor/system is using): >> >># -*- coding: utf-8 -*- >> >> and use >> >>u'' >> >> for all non-ASCII literals. >> >> >> > > Hi, > > The problem is that: > > # -

Re: utf - string translation

2006-11-22 Thread hg
Duncan Booth wrote: > hg <[EMAIL PROTECTED]> wrote: > >>> or in other words, put this at the top of your file (where "utf-8" is >>> whatever your editor/system is using): >>> >>># -*- coding: utf-8 -*- >>> >>> and use >>> >>>u'' >>> >>> for all non-ASCII literals. >>> >>> >>> >> Hi, >> >>

Re: utf - string translation

2006-11-22 Thread Fredrik Lundh
hg wrote: > How would you handle the string.maketrans then ? maketrans works on bytes, not characters. what makes you think that you can use maketrans if you haven't gotten the slightest idea what's in the string? if you want to get rid of accents in a Unicode string, you can do the approach

PyParsing and Headaches

2006-11-22 Thread Bytter
Hi, I'm trying to construct a parser, but I'm stuck with some basic stuff... For example, I want to match the following: letter = "A"..."Z" | "a"..."z" literal = letter+ include_bool := "+" | "-" term = [include_bool] literal So I defined this as: literal = Word(alphas) include_bool = Optional(

Re: Programmatically replacing an API for another module

2006-11-22 Thread Tom Plunket
Chris Lambacher wrote: > > > I'm just a bit loathe to download and install more stuff when > > > something simpler appears to be near-at-hand. ...especially > > > considering the page describing this module doesn't offer any download > > > links! http://python-mock.sourceforge.net/ > > Oh yeah,

Re: utf - string translation

2006-11-22 Thread hg
Fredrik Lundh wrote: > hg wrote: > >> How would you handle the string.maketrans then ? > > maketrans works on bytes, not characters. what makes you think that you > can use maketrans if you haven't gotten the slightest idea what's in the > string? > > if you want to get rid of accents in a Unic

regex problem

2006-11-22 Thread km
Hi all, line is am trying to match is 1959400|Q2BYK3|Q2BYK3_9GAMM Hypothetical outer membra29.90.00011 1 regex i have written is re.compile (r'(\d+?)\|((P|O|Q)\w{5})\|\w{3,6}\_\w{3,5}\s+?.{25}\s{3}(\d+?\.\d)\s+?(\d\.\d+?)') I am trying to extract 0.0011 value from the above line. why

Re: utf - string translation

2006-11-22 Thread John Machin
hg wrote: > Duncan Booth wrote: > > hg <[EMAIL PROTECTED]> wrote: > > > >>> or in other words, put this at the top of your file (where "utf-8" is > >>> whatever your editor/system is using): > >>> > >>># -*- coding: utf-8 -*- > >>> > >>> and use > >>> > >>>u'' > >>> > >>> for all non-ASCII

Re: PyParsing and Headaches

2006-11-22 Thread Chris Lambacher
On Wed, Nov 22, 2006 at 11:17:52AM -0800, Bytter wrote: > Hi, > > I'm trying to construct a parser, but I'm stuck with some basic > stuff... For example, I want to match the following: > > letter = "A"..."Z" | "a"..."z" > literal = letter+ > include_bool := "+" | "-" > term = [include_bool] liter

Re: gopherlib deprecated in 2.5

2006-11-22 Thread Terry Reedy
"Szabolcs Nagy" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I've just seen that gopherlib is deprecated in python 2.5 > http://docs.python.org/lib/module-gopherlib.html > > we still use this protocol (though there are only few working gopher > servers are left on the net) > > My

Re: Protecting against SQL injection

2006-11-22 Thread Christoph Zwerschke
Tor Erik Soenvisen wrote: > How safe is the following code against SQL injection: > > # Get user privilege > digest = sha.new(pw).hexdigest() > # Protect against SQL injection by escaping quotes > uname = uname.replace("'", "''") > sql = 'SELECT privilege FR

Re: regex problem

2006-11-22 Thread Tim Chase
> line is am trying to match is > 1959400|Q2BYK3|Q2BYK3_9GAMM Hypothetical outer membra29.90.00011 1 > > regex i have written is > re.compile > (r'(\d+?)\|((P|O|Q)\w{5})\|\w{3,6}\_\w{3,5}\s+?.{25}\s{3}(\d+?\.\d)\s+?(\d\.\d+?)') > > I am trying to extract 0.0011 value from the above line

Re: utf - string translation

2006-11-22 Thread Dan
Thank you for your answers. In fact, I'm getting start with Python. I was looking for transform a text through elementary cryptographic processes (Vigenère). The initial text is in a file, and my system is under UTF-8 by default (Ubuntu) -- http://mail.python.org/mailman/listinfo/python-list

Re: regex problem

2006-11-22 Thread km
HI Tim, oof! thats true! thanks a lot. Is there any tool to simplify building the regex ? regards, KM On 11/23/06, Tim Chase <[EMAIL PROTECTED]> wrote: > line is am trying to match is > 1959400|Q2BYK3|Q2BYK3_9GAMM Hypothetical outer membra29.90.00011 1 > > regex i have written is >

  1   2   >