Use Regular Expressions to extract URL's

2010-04-29 Thread Jimbo
Hello I am using regular expressions to grab URL's from a string(of HTML code). I am getting on very well & I seem to be grabbing the full URL [b]but[/b] I also get a '"' character at the end of it. Do you know how I can get rid of the '"' char at the end of my URL [b]Example of problem:[/b] [quo

Re: [melbourne-pug] array matching

2010-04-29 Thread Terry Reedy
Anyone responding to this thread, please delete python-dev and gmane.comp.python.dev from the followup list of where your response is sent. It should never have been part of this overly cross-posted thread. -- http://mail.python.org/mailman/listinfo/python-list

Re: replacing words in HTML file

2010-04-29 Thread Cameron Simpson
On 30Apr2010 07:15, Stefan Behnel wrote: | Cameron Simpson, 30.04.2010 00:47: | >Here's a function from a script I wrote to bulk edit a web site. I was | >replacing OBJECT and EMBED nodes with modern versions: | > | > def recurse(node): | > global didmod | > [...] | > didmod=Tr

Re: replacing words in HTML file

2010-04-29 Thread Stefan Behnel
Cameron Simpson, 30.04.2010 00:47: Here's a function from a script I wrote to bulk edit a web site. I was replacing OBJECT and EMBED nodes with modern versions: def recurse(node): global didmod [...] didmod=True continue recurse(O) > The calling end

Re: Ignoring XML Namespaces with cElementTree

2010-04-29 Thread Stefan Behnel
dmtr, 30.04.2010 04:57: I'm referring to xmlns/URI prefixes. Here's a code example: from xml.etree.cElementTree import iterparse from cStringIO import StringIO xml = """http://www.very_long_url.com";>""" for event, elem in iterparse(StringIO(xml)): print event, elem The output is: endh

Re: How to pretty-print cyclic dictionaries?

2010-04-29 Thread Dietrich Bollmann
Hi Robert, On Thu, 2010-04-29 at 11:56 -0500, Robert Kern wrote: > On 4/29/10 11:23 AM, Dietrich Bollmann wrote: > > Hi, > > > > I would like to represent graphs as cyclic dictionaries in Python. > > > > The python code for the graphs is generated by some other program > > (written in lisp) and I

Re: find integers in f.readline()

2010-04-29 Thread Tommy Grav
On Apr 29, 2010, at 10:22 PM, elsa wrote: > Hi people, > > I'm having a problem getting the info I need out of a file. > > I've opened the file with f=open('myFile','r'). > > Next, I take out the first line with line=f.readline() > > line looks like this: > > '83927 300023_25_5_09_FL 9086 91

RESOLVED Re: dll errors in compiled python program

2010-04-29 Thread Alex Hall
Thanks for the suggestion. It turns out that the problem was a copy of fowprof.dll, or something like that, which win7 included in my compiled program's dir. I was testing the program on xp, which has its own version of this dll, so deleting the dll from the dir solved it. On 4/29/10, alex23 wrot

Re: How to pretty-print cyclic dictionaries?

2010-04-29 Thread Dietrich Bollmann
Hi Chris and Garrick :) On Thu, 2010-04-29 at 18:09 +, Garrick P wrote: > Chris Rebert rebertia.com> writes: > > ... > > > If you want a prettier print, you could try serializing it to YAML and > > printing the result out; YAML has syntax for "tags". > > > > Cheers, > > Chris > > -- > > ht

Re: Default if none

2010-04-29 Thread Steven D'Aprano
On Thu, 29 Apr 2010 04:12:29 -0700, Astley Le Jasper wrote: > ... oh ... that simple. Now I feel dumb. It's really difficult to tell what you're talking about, but I assume that you're talking about Chris' solution: x or y or z Be careful, as Chris' solution is rather risky (read his disclaime

Re: assigning multi-line strings to variables

2010-04-29 Thread Steven D'Aprano
On Fri, 30 Apr 2010 05:41:26 +1000, Lie Ryan wrote: > On 04/29/10 20:40, Gregory Ewing wrote: >> Lie Ryan wrote: >>> No, the implicit concatenation is there because Python didn't always >>> have triple quoted string. Nowadays it's an artifact and triple quoted >>> string is much preferred. >> >>

Re: dll errors in compiled python program

2010-04-29 Thread alex23
Alex Hall wrote: > I am stumped. The compiled version of my project works on my pc, but > when I put it on a thumb drive and try it on a laptop without python > installed I get this: > ImportError: DLL load failed: The specified procedure could not be found. Are you using py2exe? If so, are you i

Re: Komodo Edit: Editor settings?

2010-04-29 Thread alex23
On Apr 30, 8:43 am, John Doe wrote: > I would very much like to stop code from expanding automatically. > Like when several consecutive lines of code have a plus sigh in the > left margin, meaning they are collapsed, when I go to copy or cut one > of those collapsed lines, the collapsed lines that

Re: Ignoring XML Namespaces with cElementTree

2010-04-29 Thread dmtr
I'm referring to xmlns/URI prefixes. Here's a code example: from xml.etree.cElementTree import iterparse from cStringIO import StringIO xml = """http://www.very_long_url.com";>""" for event, elem in iterparse(StringIO(xml)): print event, elem The output is: end http://www.very_long_url.com}ch

Re: find integers in f.readline()

2010-04-29 Thread Alf P. Steinbach
On 30.04.2010 04:22, * elsa: Hi people, I'm having a problem getting the info I need out of a file. I've opened the file with f=open('myFile','r'). Next, I take out the first line with line=f.readline() line looks like this: '83927 300023_25_5_09_FL 9086 9134 F3LQ2BE01AQLXF 1 49 + 80 ZA8Z89H

find integers in f.readline()

2010-04-29 Thread elsa
Hi people, I'm having a problem getting the info I need out of a file. I've opened the file with f=open('myFile','r'). Next, I take out the first line with line=f.readline() line looks like this: '83927 300023_25_5_09_FL 9086 9134 F3LQ2BE01AQLXF 1 49 + 80 ZA8Z89HIB7M' I then split it into par

Re: assigning multi-line strings to variables

2010-04-29 Thread Alf P. Steinbach
On 30.04.2010 01:29, * Carl Banks: On Apr 28, 11:16 am, "Alf P. Steinbach" wrote: On 28.04.2010 18:54, * Lie Ryan: Python have triple-quoted string when you want to include large amount of text; Yes, that's been mentioned umpteen times in this thread, including the *very first* quoted sent

dll errors in compiled python program

2010-04-29 Thread Alex Hall
Hi all, I am stumped. The compiled version of my project works on my pc, but when I put it on a thumb drive and try it on a laptop without python installed I get this: Traceback (most recent call last): File "sw.pyw", line 3, in File "modes\arm.pyc", line 4, in File "dependencies\wmi1_3\wm

RE: [melbourne-pug] array matching

2010-04-29 Thread Filip
You could use dictionary of lists test = { A: [1, 3], B: [2, 4] } print test[A] [1, 3] test[A].append(5) print test[A] [1, 3, 5] Cheers, Fil _ From: melbourne-pug-bounces+filipz=3g.nec.com...@python.org [mailto:melbourne-pug-bounces+fil

Re: Email attachment problem

2010-04-29 Thread Alan Harris-Reid
Chris Rebert wrote: On Thu, Apr 29, 2010 at 1:06 PM, Alan Harris-Reid wrote: Hi there, I want to send an email with an attachment using the following code (running under Python 3.1, greatly simplified to show example) from email.mime.multipart import MIMEMultipart from email.mime.text

Re: assigning multi-line strings to variables

2010-04-29 Thread Carl Banks
On Apr 28, 11:16 am, "Alf P. Steinbach" wrote: > On 28.04.2010 18:54, * Lie Ryan: > > Python have triple-quoted string when you want to include large amount > > of text; > > Yes, that's been mentioned umpteen times in this thread, including the *very > first* quoted sentence above. > > It's IMHO

Re: using python2.6 on windows without installation

2010-04-29 Thread Christian Heimes
Mirko Vogt wrote: Hey, is there a way to use python2.6 without having used the installation routine? When I install python2.6 and copy over the python-directory (C:\programs \python2.6) to another windows host and trying to execute python.exe there, I get an error that python26.dll could not be

Re: Performance of list.index - how to speed up a silly algorithm?

2010-04-29 Thread Mensanator
On Apr 29, 5:21 pm, Laszlo Nagy wrote: > I have some ten thousand rows in a table. E.g. > > columns = ["color","size","weight","value"] > rows = [ >      [ "Yellow", "Big", 2, 4 ], >      [ "Blue", "Big", 3, -4 ], >      [ "Blue", "Small", 10, 55 ], >      ... > ] > > Some columns are dimensions,

Re: using python2.6 on windows without installation

2010-04-29 Thread John Yeung
On Apr 29, 4:32 pm, Terry Reedy wrote: > > Try Movable Python - The Portable Python Distribution. > www.voidspace.org.uk/python/movpy/ You could also try Portable Python, which is somewhat newer and has 2.5, 2.6, and 3.0: http://www.portablepython.com/ John -- http://mail.python.org/mailman/

Re: Performance of list.index - how to speed up a silly algorithm?

2010-04-29 Thread MRAB
Laszlo Nagy wrote: I have some ten thousand rows in a table. E.g. columns = ["color","size","weight","value"] rows = [ [ "Yellow", "Big", 2, 4 ], [ "Blue", "Big", 3, -4 ], [ "Blue", "Small", 10, 55 ], ... ] Some columns are dimensions, others are measures. I want to convert this

Re: replacing words in HTML file

2010-04-29 Thread Cameron Simpson
On 29Apr2010 05:03, james_027 wrote: | On Apr 29, 5:31 am, Cameron Simpson wrote: | > On 28Apr2010 22:03, Daniel Fetchinson wrote: | > | > Any idea how I can replace words in a html file? Meaning only the | > | > content will get replace while the html tags, javascript, & css are | > | > remain

Komodo Edit: Editor settings?

2010-04-29 Thread John Doe
Komodo Edit 5.1 I would very much like to stop code from expanding automatically. Like when several consecutive lines of code have a plus sigh in the left margin, meaning they are collapsed, when I go to copy or cut one of those collapsed lines, the collapsed lines that follow that line automa

Performance of list.index - how to speed up a silly algorithm?

2010-04-29 Thread Laszlo Nagy
I have some ten thousand rows in a table. E.g. columns = ["color","size","weight","value"] rows = [ [ "Yellow", "Big", 2, 4 ], [ "Blue", "Big", 3, -4 ], [ "Blue", "Small", 10, 55 ], ... ] Some columns are dimensions, others are measures. I want to convert this to an indexed vers

Re: Python's regular expression help

2010-04-29 Thread goldtech
On Apr 29, 11:49 am, Tim Chase wrote: > On 04/29/2010 01:00 PM, goldtech wrote: > > > Trying to start out with simple things but apparently there's some > > basics I need help with. This works OK: > import re > p = re.compile('(ab*)(sss)') > m = p.match( 'absss' ) > > f=r'abss'

Re: CGI python 3 write RAW BINARY

2010-04-29 Thread Dodo
Le 29/04/2010 18:33, Dodo a écrit : Le 29/04/2010 17:07, Antoine Pitrou a écrit : Le Thu, 29 Apr 2010 12:53:53 +0200, Dodo a écrit : @Antoine : It not sys.stdout.buffer.write but sys.stdout.write() instead. But it still doesn't work, now I have empty content Let me insist: please use sys.std

Re: CGI python 3 write RAW BINARY

2010-04-29 Thread Dodo
Le 29/04/2010 22:21, Antoine Pitrou a écrit : Le Thu, 29 Apr 2010 18:33:08 +0200, Dodo a écrit : Oh, I tested on my windows machine avec sys.stdout.buffer.write() didn't work. I just tested on my linux server, and it works So, let's modify the script sys.stdout.buffer.write

Re: modifying open office spreadsheet (with OO installed)

2010-04-29 Thread Jim Byrnes
News123 wrote: Mumbling to myself, perhaps somebody else is interested. Yes I am. News123 wrote: Hi, I wanted to know who can recommend a good module/library, that allows to modify an Open Office spreadsheet. One can assume, that Open Office is installed on the host. Following url give

Re: array matching

2010-04-29 Thread cjw
On 29-Apr-10 14:46 PM, MRAB wrote: Bill Jordan wrote: Hey guys, I am sorry if this is not the right list to post some questions. I have a simple question please and would appreciate some answers as I am new to Python. I have 2 D array: test = [[A,1],[B,2],[A,3][B,4]] I want to arrang this arra

Re: http://pypi.python.org/pypi

2010-04-29 Thread James Mills
On Fri, Apr 30, 2010 at 5:53 AM, gert wrote: > How do you upload a plain text .py file as a source file? http://lmgtfy.com/?q=python+distutils+tutorial -- http://mail.python.org/mailman/listinfo/python-list

Upgrading from Python 2.6.4 to 2.6.5 on Windows OS

2010-04-29 Thread python
I have a bunch of 3rd party packages loaded in my site-packages folder. Will these packages be affected if I upgrade my Python (32-bit Windows) installation from 2.6.4 to 2.6.5? Are there any gotchas I should watch out for when performing this type of upgrade? Does it ever make sense (and is it ev

Re: Add a method to a gtk class?

2010-04-29 Thread Wolfnoliir
On 29/04/2010 17:22, Michael Torrie wrote: > On 04/29/2010 10:03 AM, Wolfnoliir wrote: >> On 29/04/2010 17:03, Joe Riopel wrote: >>> On Thu, Apr 29, 2010 at 11:43 AM, Wolfnoliir wrote: I would like to add a method to the gtk.TextBuffer class to save a text buffer to a file, but I get an

Re: Email attachment problem

2010-04-29 Thread Chris Rebert
On Thu, Apr 29, 2010 at 1:06 PM, Alan Harris-Reid wrote: > Hi there, > > I want to send an email with an attachment using the following code (running > under Python 3.1, greatly simplified to show example) > >   from email.mime.multipart import MIMEMultipart >   from email.mime.text import MIMETex

Re: using python2.6 on windows without installation

2010-04-29 Thread Terry Reedy
On 4/29/2010 11:25 AM, Mirko Vogt wrote: Hey, is there a way to use python2.6 without having used the installation routine? When I install python2.6 and copy over the python-directory (C:\programs \python2.6) to another windows host and trying to execute python.exe there, I get an error that py

Re: modifying open office spreadsheet (with OO installed)

2010-04-29 Thread News123
Mumbling to myself, perhaps somebody else is interested. News123 wrote: > Hi, > > > I wanted to know who can recommend a good module/library, that allows to > modify an Open Office spreadsheet. > > One can assume, that Open Office is installed on the host. > > Following url gives a small intr

Re: Default if none

2010-04-29 Thread Chris Rebert
On Thu, Apr 29, 2010 at 12:01 PM, Michel Claveau - MVP wrote: > Hi! > >> print x or y or z >> If none of the potential values are considered boolean false > > But : >  a=None >  b=False >  c=None >  print a or b or c >  > None Consider: def read_default_from_config(cfg_file): #pseudocode

Re: matching strings in a large set of strings

2010-04-29 Thread Terry Reedy
On 4/29/2010 5:38 AM, Karin Lagesen wrote: Hello. I have approx 83 million strings, all 14 characters long. I need to be able to take another string and find out whether this one is present within the 83 million strings. If the 'other string' is also 14 chars, so that you are looking for exac

Re: CGI python 3 write RAW BINARY

2010-04-29 Thread Antoine Pitrou
Le Thu, 29 Apr 2010 18:33:08 +0200, Dodo a écrit : > Oh, I tested on my windows machine avec sys.stdout.buffer.write() didn't > work. > I just tested on my linux server, and it works > > So, let's modify the script > > sys.stdout.buffer.write( f.read() ) > sys.stdo

Re: assigning multi-line strings to variables

2010-04-29 Thread Lie Ryan
On 04/29/10 16:34, Steven D'Aprano wrote: > On Thu, 29 Apr 2010 02:16:46 +0100, MRAB wrote: > >> Steven D'Aprano wrote: >>> On Thu, 29 Apr 2010 06:17:42 +1000, Lie Ryan wrote: >>> > Consider that the concatenation language feature probably is there > because it's useful (e.g. it preserves

Email attachment problem

2010-04-29 Thread Alan Harris-Reid
Hi there, I want to send an email with an attachment using the following code (running under Python 3.1, greatly simplified to show example) from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText msg = MIMEMultipart() msg['From'] = from_addr msg['To

Re: ooolib, reading writing a spread sheet and keep formatting

2010-04-29 Thread News123
cjw wrote: > On 28-Apr-10 23:18 PM, Kushal Kumaran wrote: >> On Thu, Apr 29, 2010 at 5:46 AM, News123 wrote: >>> Hi, >>> >>> I'm making first attempts to modify a few cells of an openoffice >>> spreadsheet. >>> >> >> Try the xlrd and xlwt modules, and the documentation at >> http://www.python-exce

http://pypi.python.org/pypi

2010-04-29 Thread gert
How do you upload a plain text .py file as a source file? I get Error processing form invalid distribution file -- http://mail.python.org/mailman/listinfo/python-list

Re: assigning multi-line strings to variables

2010-04-29 Thread Lie Ryan
On 04/29/10 20:40, Gregory Ewing wrote: > Lie Ryan wrote: >> No, the implicit concatenation is there because Python didn't always >> have triple quoted string. Nowadays it's an artifact and triple quoted >> string is much preferred. > > I don't agree. I often use implicit concatenation when I'm >

Re: Issues while building pyfsevents in python 3.1

2010-04-29 Thread Terry Reedy
On 4/29/2010 2:30 AM, mathan kumar wrote: I m trying port pyfsevents coded in python2.6 to python3.1. Specifying system and compiler/version might help responders. -- http://mail.python.org/mailman/listinfo/python-list

Re: Default if none

2010-04-29 Thread Michel Claveau - MVP
Re! Look also : >>> print False or None None >>> print None or False False -- MCI -- http://mail.python.org/mailman/listinfo/python-list

Re: Default if none

2010-04-29 Thread Michel Claveau - MVP
Hi! > print x or y or z > If none of the potential values are considered boolean false But : a=None b=False c=None print a or b or c > None @-salutations -- Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list

Re: print executed query

2010-04-29 Thread someone
On Apr 29, 7:23 pm, Miki wrote: > > Is there a way to print a query for logging purpose as it was or will > > be sent to database, if I don't escape values of query by myself? > > ... > > Im using psycopg2, btw > > http://initd.org/psycopg/docs/advanced.html#connection-and-cursor-fac... > > HTH, >

Re: Python's regular expression help

2010-04-29 Thread Tim Chase
On 04/29/2010 01:00 PM, goldtech wrote: Trying to start out with simple things but apparently there's some basics I need help with. This works OK: import re p = re.compile('(ab*)(sss)') m = p.match( 'absss' ) f=r'abss' f 'abss' m = p.match( f ) m.group(0) Traceback (most recent call last):

Re: array matching

2010-04-29 Thread MRAB
Bill Jordan wrote: Hey guys, I am sorry if this is not the right list to post some questions. I have a simple question please and would appreciate some answers as I am new to Python. I have 2 D array: test = [[A,1],[B,2],[A,3][B,4]] I want to arrang this array in different arrays so each on

Re: Python's regular expression help

2010-04-29 Thread MRAB
goldtech wrote: Hi, Trying to start out with simple things but apparently there's some basics I need help with. This works OK: import re p = re.compile('(ab*)(sss)') m = p.match( 'absss' ) m.group(0) 'absss' m.group(1) 'ab' m.group(2) 'sss' ... But two questions: How can I operate a regex

Re: How to pretty-print cyclic dictionaries?

2010-04-29 Thread Garrick P
Chris Rebert rebertia.com> writes: ... > If you want a prettier print, you could try serializing it to YAML and > printing the result out; YAML has syntax for "tags". > > Cheers, > Chris > -- > http://blog.rebertia.com Works fairly well. $ python Python 2.6.4 (r264:75706, Mar 1 2010, 14:28:0

Re: Python's regular expression help

2010-04-29 Thread Dodo
Le 29/04/2010 20:00, goldtech a écrit : Hi, Trying to start out with simple things but apparently there's some basics I need help with. This works OK: import re p = re.compile('(ab*)(sss)') m = p.match( 'absss' ) m.group(0) 'absss' m.group(1) 'ab' m.group(2) 'sss' ... But two questions: Ho

Python's regular expression help

2010-04-29 Thread goldtech
Hi, Trying to start out with simple things but apparently there's some basics I need help with. This works OK: >>> import re >>> p = re.compile('(ab*)(sss)') >>> m = p.match( 'absss' ) >>> m.group(0) 'absss' >>> m.group(1) 'ab' >>> m.group(2) 'sss' ... But two questions: How can I operate a regex

array matching

2010-04-29 Thread Bill Jordan
Hey guys, I am sorry if this is not the right list to post some questions. I have a simple question please and would appreciate some answers as I am new to Python. I have 2 D array: test = [[A,1],[B,2],[A,3][B,4]] I want to arrang this array in different arrays so each one will have what is att

Re: matching strings in a large set of strings

2010-04-29 Thread Miki
> I have approx 83 million strings, all 14 characters long. I need to be > able to take another string and find out whether this one is present > within the 83 million strings. Have a look at the shelve module. If you want to write the algorithm yourself, I suggest http://en.wikipedia.org/wiki/Tr

Re: building python 3 -- _dbm necessary bits

2010-04-29 Thread James Mills
On Fri, Apr 30, 2010 at 3:00 AM, Mark Olbert wrote: > Okay. But I compiled & installed gdbm from source obtained from the gnu > archive, so I presume the necessary files would be included > (this is on a linux system). Perhaps check where gdbm has installed it's development sources and whether o

Re: print executed query

2010-04-29 Thread Miki
> Is there a way to print a query for logging purpose as it was or will > be sent to database, if I don't escape values of query by myself? > ... > Im using psycopg2, btw http://initd.org/psycopg/docs/advanced.html#connection-and-cursor-factories HTH, -- Miki http://pythonwise.blogspot.com -- ht

Re: using python2.6 on windows without installation

2010-04-29 Thread Miki
> Is it possible to include python26.dll in the application folder or tell > python not to look in C:\windows\system32 for its library? The needed DLLs should be in the PATH. The simplest way is to place all the required DLLs next to the python executable. You can use http://www.dependencywalker.

Re: assigning multi-line strings to variables

2010-04-29 Thread goldtech
Thank you to posters for help to my question. Seems I had trouble with triple quotes strings in the PythonWin shell. But using the Idle shell things work as expected. But this is probably another issue...any way, w/Idle's shell I got the "action" regarding multiline strings I expected. -- http://m

Re: building python 3 -- _dbm necessary bits

2010-04-29 Thread Mark Olbert
On Thu, 29 Apr 2010 15:51:26 +1000, James Mills wrote: >On Thu, Apr 29, 2010 at 1:12 PM, Mark Olbert > wrote: >> I'm getting an error message about make not being able to find the necessary >> bits to build modules related to _dbm. Yet I have >> libgdbm installed installed on my system. Suggest

Re: How to pretty-print cyclic dictionaries?

2010-04-29 Thread Chris Rebert
On Thu, Apr 29, 2010 at 9:23 AM, Dietrich Bollmann wrote: > Hi, > > I would like to represent graphs as cyclic dictionaries in Python. > > The python code for the graphs is generated by some other program > (written in lisp) and I wonder what would be the best syntax for writing > the cycles in Py

Re: How to pretty-print cyclic dictionaries?

2010-04-29 Thread Robert Kern
On 4/29/10 11:23 AM, Dietrich Bollmann wrote: Hi, I would like to represent graphs as cyclic dictionaries in Python. The python code for the graphs is generated by some other program (written in lisp) and I wonder what would be the best syntax for writing the cycles in Python? You can impleme

Re: print executed query

2010-04-29 Thread Philip Semanchuk
On Apr 29, 2010, at 12:01 PM, someone wrote: Hello! Is there a way to print a query for logging purpose as it was or will be sent to database, if I don't escape values of query by myself? cursor.execute(query, [id, somestring]) I could print query and values separate, but it would be great,

Re: CGI python 3 write RAW BINARY

2010-04-29 Thread Dodo
Le 29/04/2010 17:07, Antoine Pitrou a écrit : Le Thu, 29 Apr 2010 12:53:53 +0200, Dodo a écrit : @Antoine : It not sys.stdout.buffer.write but sys.stdout.write() instead. But it still doesn't work, now I have empty content Let me insist: please use sys.stdout.buffer.write(). You'll also have

How to pretty-print cyclic dictionaries?

2010-04-29 Thread Dietrich Bollmann
Hi, I would like to represent graphs as cyclic dictionaries in Python. The python code for the graphs is generated by some other program (written in lisp) and I wonder what would be the best syntax for writing the cycles in Python? The following works: >>> a = {} >>> a['a'] = a As can be seen

print executed query

2010-04-29 Thread someone
Hello! Is there a way to print a query for logging purpose as it was or will be sent to database, if I don't escape values of query by myself? cursor.execute(query, [id, somestring]) I could print query and values separate, but it would be great, if I could see how query is constructed and can t

Re: replacing words in HTML file

2010-04-29 Thread Daniel Fetchinson
>> > | > Any idea how I can replace words in a html file? Meaning only the >> > | > content will get replace while the html tags, javascript, & css are >> > | > remain untouch. >> > | >> > | I'm not sure what you tried and what you haven't but as a first trial >> > | you might want to >> > | >> > |

using python2.6 on windows without installation

2010-04-29 Thread Mirko Vogt
Hey, is there a way to use python2.6 without having used the installation routine? When I install python2.6 and copy over the python-directory (C:\programs \python2.6) to another windows host and trying to execute python.exe there, I get an error that python26.dll could not be found. On the host

Re: Add a method to a gtk class?

2010-04-29 Thread Michael Torrie
On 04/29/2010 10:03 AM, Wolfnoliir wrote: > On 29/04/2010 17:03, Joe Riopel wrote: >> On Thu, Apr 29, 2010 at 11:43 AM, Wolfnoliir wrote: >>> I would like to add a method to the gtk.TextBuffer class to save a text >>> buffer to a file, but I get an error: >> >> I don't know gtk, but can you inheri

How to get ipRouteTable from Cisco router?

2010-04-29 Thread gvozdikov
Hello! I want to get route tables from Cisco routers in the network. What i have: import re from pysnmp.entity.rfc3413.oneliner import cmdgen s = r'(%s)' % ('(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.)\ {3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)') pattern = re.compile(s) file = 'routers.txt

Re: CGI python 3 write RAW BINARY

2010-04-29 Thread Antoine Pitrou
Le Thu, 29 Apr 2010 12:53:53 +0200, Dodo a écrit : > > @Antoine : It not sys.stdout.buffer.write but sys.stdout.write() > instead. But it still doesn't work, now I have empty content Let me insist: please use sys.stdout.buffer.write(). You'll also have to call sys.stdout.flush() before doing so.

Re: Add a method to a gtk class?

2010-04-29 Thread Wolfnoliir
On 29/04/2010 17:03, Joe Riopel wrote: > On Thu, Apr 29, 2010 at 11:43 AM, Wolfnoliir wrote: >> I would like to add a method to the gtk.TextBuffer class to save a text >> buffer to a file, but I get an error: > > I don't know gtk, but can you inherit from the TextBuffer class create > your own Te

Re: Add a method to a gtk class?

2010-04-29 Thread Joe Riopel
On Thu, Apr 29, 2010 at 11:43 AM, Wolfnoliir wrote: > I would like to add a method to the gtk.TextBuffer class to save a text > buffer to a file, but I get an error: I don't know gtk, but can you inherit from the TextBuffer class create your own TexBuffer subclass with the save_to_file method? --

Add a method to a gtk class?

2010-04-29 Thread Wolfnoliir
Hi, I would like to add a method to the gtk.TextBuffer class to save a text buffer to a file, but I get an error: line 22, in gtk.TextBuffer.save_to_file = gtk_TextBuffer_save_to_file TypeError: can't set attributes of built-in/extension type 'gtk.TextBuffer' Here is the code: 10 import gtk

Re: matching strings in a large set of strings

2010-04-29 Thread Duncan Booth
MRAB wrote: > Karin Lagesen wrote: >> Hello. >> >> I have approx 83 million strings, all 14 characters long. I need to >> be able to take another string and find out whether this one is >> present within the 83 million strings. >> >> Now, I have tried storing these strings as a list, a set and

Re: matching strings in a large set of strings

2010-04-29 Thread MRAB
Karin Lagesen wrote: Hello. I have approx 83 million strings, all 14 characters long. I need to be able to take another string and find out whether this one is present within the 83 million strings. Now, I have tried storing these strings as a list, a set and a dictionary. I know that finding t

Re: replacing words in HTML file

2010-04-29 Thread Iain King
On Apr 29, 10:38 am, Daniel Fetchinson wrote: > > | > Any idea how I can replace words in a html file? Meaning only the > > | > content will get replace while the html tags, javascript, & css are > > | > remain untouch. > > | > > | I'm not sure what you tried and what you haven't but as a first tr

Re: pyjamas 0.7 released

2010-04-29 Thread lkcl
On Apr 29, 6:37 am, Wolfgang Strobl wrote: > Look at it from the point of view of people walking by, trying to decide > whether they should invest some of their time into digging into yet > another framework and library. yes. _their_ time - not mine. the pyjamas project has always been done on

Re: ooolib, reading writing a spread sheet and keep formatting

2010-04-29 Thread cjw
On 28-Apr-10 23:18 PM, Kushal Kumaran wrote: On Thu, Apr 29, 2010 at 5:46 AM, News123 wrote: Hi, I'm making first attempts to modify a few cells of an openoffice spreadsheet. Try the xlrd and xlwt modules, and the documentation at http://www.python-excel.org/ The tutorial here is beautiful

Re: replacing words in HTML file

2010-04-29 Thread james_027
On Apr 29, 5:31 am, Cameron Simpson wrote: > On 28Apr2010 22:03, Daniel Fetchinson wrote: > | > Any idea how I can replace words in a html file? Meaning only the > | > content will get replace while the html tags, javascript, & css are > | > remain untouch. > | > | I'm not sure what you tried and

Re: Default if none

2010-04-29 Thread Astley Le Jasper
... oh ... that simple. Now I feel dumb. Thanks! ALJ -- http://mail.python.org/mailman/listinfo/python-list

Re: matching strings in a large set of strings

2010-04-29 Thread Mark Tolonen
"Karin Lagesen" wrote in message news:416f727c6f5b0edb932b425db9579808.squir...@webmail.uio.no... Hello. I have approx 83 million strings, all 14 characters long. I need to be able to take another string and find out whether this one is present within the 83 million strings. Now, I have trie

How to forward request through lighttpd server to xmlrpc server

2010-04-29 Thread Mishra Gopal-QBX634
Hi, I have Lighttpd web server running on port 80. and i have a xmlrpc web server running on port 8085 How i can send all my request/response to xmlrpc server through lighttpd server running on port 80? Thanks and regards, Gopal -- http://mail.python.org/mailman/listinfo/python-list

Re: CGI python 3 write RAW BINARY

2010-04-29 Thread Dodo
Le 29/04/2010 01:45, Antoine Pitrou a écrit : Le Wed, 28 Apr 2010 23:54:07 +0200, Dodo a écrit : Help! this is driving me crazy lol I want to print raw binary data to display an image file BUT python3 outputs b'' instead of so the browser can't read the image!! f = open("/some/path/%s"

Re: assigning multi-line strings to variables

2010-04-29 Thread Gregory Ewing
Lie Ryan wrote: No, the implicit concatenation is there because Python didn't always have triple quoted string. Nowadays it's an artifact and triple quoted string is much preferred. I don't agree. I often use implicit concatenation when I'm writing a format string that won't fit on one source l

Re: Default if none

2010-04-29 Thread Chris Rebert
On Thu, Apr 29, 2010 at 3:16 AM, Astley Le Jasper wrote: > I realise I could roll my own here, but I wondered if there was an > inbuilt version of this? > >>. > def default_if_none(*args): >    for arg in args: >        if arg: >            return arg >    r

Re: matching strings in a large set of strings

2010-04-29 Thread Stefan Behnel
Karin Lagesen, 29.04.2010 11:38: I have approx 83 million strings, all 14 characters long. I need to be able to take another string and find out whether this one is present within the 83 million strings. Now, I have tried storing these strings as a list, a set and a dictionary. I know that findi

Default if none

2010-04-29 Thread Astley Le Jasper
I realise I could roll my own here, but I wondered if there was an inbuilt version of this? >. def default_if_none(*args): for arg in args: if arg: return arg return None x = None y = 5 z = 6 print default_if_none(x,y,z) >> 5 >

Re: matching strings in a large set of strings

2010-04-29 Thread Peter Otten
Karin Lagesen wrote: > I have approx 83 million strings, all 14 characters long. I need to be > able to take another string and find out whether this one is present > within the 83 million strings. > > Now, I have tried storing these strings as a list, a set and a dictionary. > I know that findin

matching strings in a large set of strings

2010-04-29 Thread Karin Lagesen
Hello. I have approx 83 million strings, all 14 characters long. I need to be able to take another string and find out whether this one is present within the 83 million strings. Now, I have tried storing these strings as a list, a set and a dictionary. I know that finding things in a set and a di

Re: help req installing python 2.6

2010-04-29 Thread Peter Otten
James Mills wrote: > 2010/4/29 sanam singh : >> hi, >> it is saying >> sa...@ubuntu:~/Desktop/Python-2.6.5$ sudo apt-get install gdbm-dev >> Reading package lists... Done >> Building dependency tree >> Reading state information... Done >> E: Couldn't find package gdbm-dev > > I'm sorry, but I don

Re: replacing words in HTML file

2010-04-29 Thread Daniel Fetchinson
> | > Any idea how I can replace words in a html file? Meaning only the > | > content will get replace while the html tags, javascript, & css are > | > remain untouch. > | > | I'm not sure what you tried and what you haven't but as a first trial > | you might want to > | > | > | > | f = open( 'new

Re: dynamic function add to an instance of a class

2010-04-29 Thread News123
Peter Otten wrote: > News123 wrote: >>> >> The drawback would be, that >> b = A(123) >> b.f() >> would still be called with a as bound object. > > There is no b.f until you explicitly assign it with > > b.f = f you are sooo right. My fault. -- http://mail.python.org/mailman/listinfo/python-lis

Re: Remembering the context

2010-04-29 Thread Jean-Michel Pichavant
GZ wrote: Hi All, I am looking at the following code: def fn(): def inner(x): return tbl[x] tbl={1:'A', 2:'B'} f1 = inner # I want to make a frozen copy of the values of tbl in f1 tbl={1:'C', 2:'D'} f2 = inner return (f1,f2) f1,f2 = fn() f1(1) # output C f2

help req installing python 2.6

2010-04-29 Thread sanam singh
hi, i have tried sa...@ubuntu:~/Desktop/Python-2.6.5$ sudo apt-get build-dep python but still the problem persists . when i make the package i get : Failed to find the necessary bits to build these modules: _bsddb _curses_curses_panel _sqlite3 bsddb185

Re: dynamic function add to an instance of a class

2010-04-29 Thread Peter Otten
News123 wrote: > Peter Otten wrote: >> Richard Lamboj wrote: >> >>> i want to add functions to an instance of a class at runtime. The added >>> function should contain a default parameter value. The function name and >>> function default paramter values should be set dynamical. >> > class A(

  1   2   >