Re: MySQLdb insert HTML code error

2012-12-10 Thread Anatoli Hristov
> >First thing -- DON'T put quotes around the %s place-holders... The > whole purpose of using the parameterized .execute() is to let the > database adapter properly escape the parameters before putting them into > the SQL (since MySQL didn't have prepared statements before v5, it was > produci

Re: problem with usbtmc-communication

2012-12-10 Thread Jean Dubois
On 10 dec, 16:34, w...@mac.com wrote: > On Dec 10, 2012, at 8:31 AM, Jean Dubois wrote: > > [byte] > > > > > > > > > > > As you can see this approach suffers from the same "buffer problem" as > > the approach with readline did. One now good argue as a workaround: > > get rid of the first data pair

Re: ANNOUNCE: Thesaurus - a recursive dictionary subclass using attributes

2012-12-10 Thread Ian Kelly
On Mon, Dec 10, 2012 at 8:48 PM, Dave Cinege wrote: > Thesaurus: A different way to call a dictionary. > > Thesaurus is a new a dictionary subclass which allows calling keys as > if they are class attributes and will search through nested objects > recursively when __getitem__ is called. > > You w

Re: strptime - dates formatted differently on different computers

2012-12-10 Thread Michael Torrie
On 12/10/2012 02:18 PM, noydb wrote: > Follow-on question to this earlier topic - > https://groups.google.com/d/topic/comp.lang.python/wnUlPBBNah8/discussion > > Was curious to know if there was a way to handle different user computers > with different operating system set date formats. 2/10/2

Re: ANNOUNCE: Thesaurus - a recursive dictionary subclass using attributes

2012-12-10 Thread Jason Friedman
> Thesaurus is a new a dictionary subclass which allows calling keys as > if they are class attributes and will search through nested objects > recursively when __getitem__ is called. Good stuff. You might consider: 1) Licensing under an OSI-approved license (http://opensource.org/licenses/index.

ANNOUNCE: Thesaurus - a recursive dictionary subclass using attributes

2012-12-10 Thread Dave Cinege
Thesaurus: A different way to call a dictionary. Thesaurus is a new a dictionary subclass which allows calling keys as if they are class attributes and will search through nested objects recursively when __getitem__ is called. You will notice that the code is disgusting simple. However I have fou

Re: strptime - dates formatted differently on different computers

2012-12-10 Thread Steven D'Aprano
On Mon, 10 Dec 2012 16:36:37 -0500, Dave Angel wrote: > When accepting input from a user, consider their environment. Perhaps > they're in a different timezone than your program (or your native > location), or use some other ordering for the date (for example, the > Japanese sensibly put year fir

Re: accessing an OLE Automation (IDispatch) server from python which requires the use of "out params"

2012-12-10 Thread Mark Hammond
On 11/12/2012 8:39 AM, bitbucket wrote: On Monday, December 10, 2012 3:58:33 PM UTC-5, Terry Reedy wrote: I believe the easiest way to do that is to install the pywin extensions http://sourceforge.net/projects/pywin32/?source=directory I assume it can handle out params. That definitely looks

Re: MySQLdb insert HTML code error

2012-12-10 Thread Anatoli Hristov
> You're using a parametrised query (which is good :-)), but you've included > quotes around the placeholders. There's no need to do that. They'll be > quoted automatically when necessary: > > sql = "INSERT INTO product_description (product_id, language_id, name, > description) VALUES (%s,%s,%s,%s)

Re: MySQLdb insert HTML code error

2012-12-10 Thread MRAB
On 2012-12-11 00:04, Anatoli Hristov wrote: Hi all, I'm facing an issue inserting an html code into the DB, it comes out with a syntax error but I face it only when I have html code. Could help me escape the error somehow ? Here is my code def InsertSpecsDB(product_id, spec, lang, name):

Re: MySQLdb insert HTML code error

2012-12-10 Thread Mark Lawrence
On 11/12/2012 00:29, Anatoli Hristov wrote: As much use as a chocolate teapot, all you've given is a function/method definition. No indication of your OS, Python version, calling code, what you expect to happen, what actually happened, apart from that your request for assistance is perfect. Usu

Re: MySQLdb insert HTML code error

2012-12-10 Thread Anatoli Hristov
On Tue, Dec 11, 2012 at 1:29 AM, Anatoli Hristov wrote: >> As much use as a chocolate teapot, all you've given is a function/method >> definition. No indication of your OS, Python version, calling code, what >> you expect to happen, what actually happened, apart from that your request >> for assi

Re: MySQLdb insert HTML code error

2012-12-10 Thread Anatoli Hristov
> As much use as a chocolate teapot, all you've given is a function/method > definition. No indication of your OS, Python version, calling code, what > you expect to happen, what actually happened, apart from that your request > for assistance is perfect. Usually I'd be able to help but sadly my

Re: MySQLdb insert HTML code error

2012-12-10 Thread Mark Lawrence
On 11/12/2012 00:04, Anatoli Hristov wrote: Hi all, I'm facing an issue inserting an html code into the DB, it comes out with a syntax error but I face it only when I have html code. Could help me escape the error somehow ? Here is my code def InsertSpecsDB(product_id, spec, lang, name):

Re: open URL in the current tab

2012-12-10 Thread Chris Angelico
On Tue, Dec 11, 2012 at 11:05 AM, Jabba Laci wrote: > Hi, > >> If this is for use on somebody else's system, *please don't*. My > > This is for me. I have a simple GUI that produces some URL that I want > to open in the current tab. Since I want to verify several URLs, I > don't want to open dozen

MySQLdb insert HTML code error

2012-12-10 Thread Anatoli Hristov
Hi all, I'm facing an issue inserting an html code into the DB, it comes out with a syntax error but I face it only when I have html code. Could help me escape the error somehow ? Here is my code def InsertSpecsDB(product_id, spec, lang, name): db = MySQLdb.connect("localhost","getit","openc

Re: open URL in the current tab

2012-12-10 Thread Jabba Laci
Hi, > If this is for use on somebody else's system, *please don't*. My This is for me. I have a simple GUI that produces some URL that I want to open in the current tab. Since I want to verify several URLs, I don't want to open dozens of new tabs. Here is my working solution. It requires the Moz

Re: String manipulation in python..NEED HELP!!!!

2012-12-10 Thread Chris Angelico
On Tue, Dec 11, 2012 at 9:38 AM, wrote: > I need help with a program i am doing. it is a cryptography program. i am > given a regular alphabet and a key. i need to use the user input and use the > regular alphabet and use the corresponding letter in the key and that becomes > the new letter. i

Re: String manipulation in python..NEED HELP!!!!

2012-12-10 Thread Vlastimil Brom
2012/12/10 : > I need help with a program i am doing. it is a cryptography program. i am > given a regular alphabet and a key. i need to use the user input and use the > regular alphabet and use the corresponding letter in the key and that becomes > the new letter. i have the basic code but nee

Re: open URL in the current tab

2012-12-10 Thread Chris Angelico
On Tue, Dec 11, 2012 at 9:27 AM, Jabba Laci wrote: > Hi, > > With the webbrowser module you can open a URL in a new tab. But how > could I tell Firefox from Python to open a URL in the _current_ tab? If this is for use on somebody else's system, *please don't*. My current tab is my business, not

Re: String manipulation in python..NEED HELP!!!!

2012-12-10 Thread John Gordon
In qbai...@ihets.org writes: > """ crypto.py > Implements a simple substitution cypher > """ > alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" > key = "XPMGTDHLYONZBWEARKJUFSCIQV" > def main(): > keepGoing = True > while keepGoing: > response = menu() > if response == "1": > plain

Re: open URL in the current tab

2012-12-10 Thread Jabba Laci
Thanks. I've found something interesting since then: https://addons.mozilla.org/en-US/firefox/addon/mozrepl/ https://github.com/bard/mozrepl/wiki It allows you to connect to your Firefox via telnet. Then changing the URL: content.location.href = However, for this you need to install this add-o

Re: open URL in the current tab

2012-12-10 Thread Boris FELD
Don't think that it's possible with webbrowser, you should try with Selenium. For example with sst (Simple Selenium Test), it open url in current tab or create a new one if no one exists: from sst.actions import * go_to('http://www.ubuntu.com/') 2012/12/10 Jabba Laci : > Hi, > > With the webbrow

String manipulation in python..NEED HELP!!!!

2012-12-10 Thread qbailey
I need help with a program i am doing. it is a cryptography program. i am given a regular alphabet and a key. i need to use the user input and use the regular alphabet and use the corresponding letter in the key and that becomes the new letter. i have the basic code but need help with how to mai

Re: open URL in the current tab

2012-12-10 Thread Joel Goldstick
On Mon, Dec 10, 2012 at 5:27 PM, Jabba Laci wrote: > Hi, > > With the webbrowser module you can open a URL in a new tab. But how > could I tell Firefox from Python to open a URL in the _current_ tab? > > The docs say this: webbrowser.open_new(*url*) Open *url* in a new window of the default brow

open URL in the current tab

2012-12-10 Thread Jabba Laci
Hi, With the webbrowser module you can open a URL in a new tab. But how could I tell Firefox from Python to open a URL in the _current_ tab? Thanks, Laszlo -- http://mail.python.org/mailman/listinfo/python-list

Re: accessing an OLE Automation (IDispatch) server from python which requires the use of "out params"

2012-12-10 Thread bitbucket
On Monday, December 10, 2012 3:58:33 PM UTC-5, Terry Reedy wrote: > I believe the easiest way to do that is to install the pywin extensions > > http://sourceforge.net/projects/pywin32/?source=directory > > I assume it can handle out params. That definitely looks like a good starting point. Just

Re: strptime - dates formatted differently on different computers

2012-12-10 Thread Dave Angel
On 12/10/2012 04:18 PM, noydb wrote: > Follow-on question to this earlier topic - > https://groups.google.com/d/topic/comp.lang.python/wnUlPBBNah8/discussion For those who avoid googlegroups with a passion, and/or don't have internet access, the subject of that thread is "date-time comparison, a

Re: strptime - dates formatted differently on different computers

2012-12-10 Thread noydb
NTFS partition Windows 7 Python 2.7 -- http://mail.python.org/mailman/listinfo/python-list

Re: date-time comparison, aware vs naive

2012-12-10 Thread noydb
> > > > > > > > http://docs.python.org/2/library/datetime > > """ An object of type *time* or *datetime* may be naive or *aware" > > > > aware refers to time-zone and daylight savings time, such political > > ephemerals. Two times can only be changed if one knows they're both in > > the

strptime - dates formatted differently on different computers

2012-12-10 Thread noydb
Follow-on question to this earlier topic - https://groups.google.com/d/topic/comp.lang.python/wnUlPBBNah8/discussion Was curious to know if there was a way to handle different user computers with different operating system set date formats. 2/10/2006 vs 2-10-2006, for example. Not an issue f

Re: date-time comparison, aware vs naive

2012-12-10 Thread Dave Angel
On 12/10/2012 03:52 PM, Steven D'Aprano wrote: > On Mon, 10 Dec 2012 11:57:37 -0800, noydb wrote: > >> I want to compare a user entered date-and-time against the date-and-time >> of a pdf file. I posted on this (how to get a file's date-time) before, >> was advised to do it like: >> >> import date

Re: date-time comparison, aware vs naive

2012-12-10 Thread noydb
On Monday, December 10, 2012 3:52:55 PM UTC-5, Steven D'Aprano wrote: > On Mon, 10 Dec 2012 11:57:37 -0800, noydb wrote: > > > > > I want to compare a user entered date-and-time against the date-and-time > > > of a pdf file. I posted on this (how to get a file's date-time) before, > > > was a

Re: accessing an OLE Automation (IDispatch) server from python which requires the use of "out params"

2012-12-10 Thread Terry Reedy
On 12/10/2012 2:13 PM, bitbucket wrote: I have an existing Windows application which provides an OLE Automation (IDispatch) interface. I'm not able to change that interface. I'd like to call it from a scripting language. I figure this would provide a nice quick way to invoke on the app. I be

Re: date-time comparison, aware vs naive

2012-12-10 Thread Steven D'Aprano
On Mon, 10 Dec 2012 11:57:37 -0800, noydb wrote: > I want to compare a user entered date-and-time against the date-and-time > of a pdf file. I posted on this (how to get a file's date-time) before, > was advised to do it like: > > import datetime, os, stat > mtime = os.lstat(filename)[stat.ST_MT

Re: About open file for Read

2012-12-10 Thread Steven D'Aprano
On Mon, 10 Dec 2012 08:36:22 -0800, moonhkt wrote: > Hi All > > I am new in Python. When using open and then for line in f . > > Does it read all the data into f object ? or read line by line ? Have you read the Fine Manual? http://docs.python.org/2/library/stdtypes.html#file-objects If you h

Matplotlib/Pylab Error

2012-12-10 Thread subhabangalore
Dear Group, I am trying to enumerate few interesting errors on pylab/matplotlib. If any of the learned members can kindly let me know how should I address them. I am trying to enumerate them as follows. i) >>> import numpy >>> import pylab >>> t = numpy.arange(0.0, 1.0+0.01, 0.01) >>> s = numpy

Re: date-time comparison, aware vs naive

2012-12-10 Thread noydb
Found this, and it solved my problem http://blogs.law.harvard.edu/rprasad/2011/09/21/python-string-to-a-datetime-object/ -- http://mail.python.org/mailman/listinfo/python-list

Re: date-time comparison, aware vs naive

2012-12-10 Thread John Gordon
In <21eb3e6f-9a82-47aa-93ff-8f4083d18...@googlegroups.com> noydb writes: > I want to compare a user entered date-and-time against the date-and-time of > a pdf file. I posted on this (how to get a file's date-time) before, was > advised to do it like: > import datetime, os, stat > mtime = os.ls

date-time comparison, aware vs naive

2012-12-10 Thread noydb
I want to compare a user entered date-and-time against the date-and-time of a pdf file. I posted on this (how to get a file's date-time) before, was advised to do it like: import datetime, os, stat mtime = os.lstat(filename)[stat.ST_MTIME] // the files modification time dt = datetime.dateti

Re: Using poplib to parse headers - Thank You All!

2012-12-10 Thread asklucas
Hello Jean-Claude! Thank you for your post, it helped me a lot! I'm not too new to Python but still struggling to make use of that great language's features. I haven't tested it but since you are interested in syntactic subtleties, I think you can save one iterator (k): for j in popconnection.

accessing an OLE Automation (IDispatch) server from python which requires the use of "out params"

2012-12-10 Thread bitbucket
I have an existing Windows application which provides an OLE Automation (IDispatch) interface. I'm not able to change that interface. I'd like to call it from a scripting language. I figure this would provide a nice quick way to invoke on the app. I initially tried this with Windows Powershe

Re: About open file for Read

2012-12-10 Thread Peter Otten
Dave Angel wrote: > On 12/10/2012 11:36 AM, moonhkt wrote: >> Hi All >> >> I am new in Python. When using open and then for line in f . >> >> Does it read all the data into f object ? or read line by line ? >> >> >> f=open(file, 'r') >>for line in f: >> if userstring in

Re: About open file for Read

2012-12-10 Thread Dave Angel
On 12/10/2012 11:36 AM, moonhkt wrote: > Hi All > > I am new in Python. When using open and then for line in f . > > Does it read all the data into f object ? or read line by line ? > > > f=open(file, 'r') >for line in f: > if userstring in line: > print

Re: forking and avoiding zombies!

2012-12-10 Thread peter
On 12/10/2012 12:42 PM, andrea crotti wrote: So I implemented a simple decorator to run a function in a forked process, as below. It works well but the problem is that the childs end up as zombies on one machine, while strangely I can't reproduce the same on mine.. I know that this is not the p

About open file for Read

2012-12-10 Thread moonhkt
Hi All I am new in Python. When using open and then for line in f . Does it read all the data into f object ? or read line by line ? f=open(file, 'r') for line in f: if userstring in line: print "file: " + os.path.join(root,file) brea

Re: using smtp sent large file upto 60MB

2012-12-10 Thread moonhkt
On 12月5日, 下午11時01分, Michael Torrie wrote: > On 12/04/2012 05:54 PM, moonhkt wrote: > > > Our SMTP can send file more than 60MB. But our notes server can > > configured 100MB,30MB or 10MB. My notes Mail box can receive 100MB. > > > In UNIX, by below command send  smtp mail. > > uuencode $xfn $xfn |

Re: problem with usbtmc-communication

2012-12-10 Thread wrw
On Dec 10, 2012, at 8:31 AM, Jean Dubois wrote: [byte] > As you can see this approach suffers from the same "buffer problem" as > the approach with readline did. One now good argue as a workaround: > get rid of the first data pair and add an extra measure command for > the missing data pair, how

Re: The Zen of Zope, by Alex Clark

2012-12-10 Thread Alex Clark
On 2012-12-10 04:24:00 +, Steven D'Aprano said: On Sun, 09 Dec 2012 20:13:43 -0500, Alex Clark wrote: import other The Zen of Zope, by Alex Clark I expect that I would find that hilarious if I knew anything about Zope :) Well, you are in luck! Because it's a tutorial too: https://gi

Re: problem with usbtmc-communication

2012-12-10 Thread Jean Dubois
On 7 dec, 14:46, Jean Dubois wrote: > On 6 dec, 21:15, w...@mac.com wrote: > > > On Dec 6, 2012, at 2:41 PM, Jean Dubois wrote: > > > > On 6 dec, 15:50, w...@mac.com wrote: > > >> On Dec 6, 2012, at 8:50 AM, Jean Dubois wrote: > > > >> [byte] > > > >>> It seems there is some misunderstanding her

Re: why the conut( ) can not get the number?

2012-12-10 Thread Peter Otten
水静流深 wrote: > i wnat to get the number of a atrributes in a xpath,here is my code,why i > can not get the number ? import urllib > import lxml.html > down="http://python-gtk-3-tutorial.readthedocs.org/en/latest/index.html"; > file=urllib.urlopen(down).read() > root=lxml.html.document_fromstring(f

why the conut( ) can not get the number?

2012-12-10 Thread ????????
i wnat to get the number of a atrributes in a xpath,here is my code,why i can not get the number ? import urllib import lxml.html down="http://python-gtk-3-tutorial.readthedocs.org/en/latest/index.html"; file=urllib.urlopen(down).read() root=lxml.html.document_fromstring(file) for order,node i

Dropbox Hires Away Google’s Guido Van Rossum

2012-12-10 Thread Rodrick Brown
http://techcrunch.com/2012/12/07/dropbox-guido-van-rossum-python/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Noob Question.

2012-12-10 Thread Alexander Blinne
Am 05.12.2012 21:24, schrieb Owatch: > Thanks a TON for your answer thought, this is exactly what I really hoped for. > The problem for me is that I don't actually know anything about writing a > function that opens a network socket, and "connects to that plugin und asks > it for the > informati

Re: A question about readability

2012-12-10 Thread rusi
On Dec 10, 3:03 pm, Jean-Michel Pichavant wrote: > - Original Message - > > On Dec 7, 6:46 pm, Marco wrote: > > > Hi all, do you think this code: > > > > $ more myscript.py > > > for line in open('data.txt'): > > >      result = sum(int(data) for data in line.split(';')) > > >      print(

Re: A question about readability

2012-12-10 Thread Jean-Michel Pichavant
- Original Message - > On Dec 7, 6:46 pm, Marco wrote: > > Hi all, do you think this code: > > > > $ more myscript.py > > for line in open('data.txt'): > >      result = sum(int(data) for data in line.split(';')) > >      print(result) > > > > that sums the elements of the lines of this