Re: Questions on XML

2009-08-22 Thread Emmanuel Surleau
On Saturday 22 August 2009 08:13:33 joy99 wrote: > On Aug 22, 10:53 am, Stefan Behnel wrote: > > Rami Chowdhury wrote: > > >> I am using primarily UTF-8 based strings, like Hindi or Bengali. Can I > > >> use Python to help me in this regard? > > > > > > I can say from experience that Python on Win

Re: convert date time

2009-08-22 Thread Kushal Kumaran
On Fri, Aug 21, 2009 at 11:44 PM, Ronn Ross wrote: > I'm new to python and I'm getting a date time from a field in the database > that looks like this: > 8/2/2009 8:36:16 AM (UTC) > > I want to split it into two fields one with the date formatted like this: > -MM-DD  2009-08-02 > > and the time

Re: Using 'apply' as a decorator, to define constants

2009-08-22 Thread Jonathan Fine
Jonathan Gardner wrote: On Aug 21, 9:09 am, alex23 wrote: On Aug 21, 11:36 pm, Jonathan Fine wrote: class ColourThing(object): @apply def rgb(): def fset(self, rgb): self.r, self.g, self.b = rgb def fget(self): return (self.r, self.g, self.b)

Re: Questions on XML

2009-08-22 Thread Rami Chowdhury
encoding declaration to the top of your source file if you use encoded literal strings in your code Any tips for how to set the encoding in IDLE? printing the Unicode strings works -- trying to repr() the variable chokes with a UnicodeDecodeError, and trying to enter the literals inside IDLE

debugger

2009-08-22 Thread flagmino
To get familiar with the debugger, I have loaded this program: import math def s1(x, y): a = (x + y) print("Answer from s1"), a return def s2(x, y): b = (x - y) print("This comes from s2"), b #print z print("call from s2: "), s1(x, y) return I am trying to debug: I press

How to 'de-slashify' a string?

2009-08-22 Thread AK
Hi, if I have a string '\\303\\266', how can I convert it to '\303\266' in a general way? The problem I'm running into is that I'm connecting with pygresql to a postgres database and when I get fields that are of 'char' type, I get them in unicode, but when I get fields of 'byte' type, I get t

Re: debugger

2009-08-22 Thread Xavier Ho
On Sat, Aug 22, 2009 at 6:17 PM, flagmino wrote: > To get familiar with the debugger, I have loaded this program: > > import math > > def s1(x, y): > a = (x + y) > print("Answer from s1"), a > return > > def s2(x, y): > b = (x - y) > print("This comes from s2"), b > #print z > print

Re: Using 'apply' as a decorator, to define constants

2009-08-22 Thread Leonhard Vogt
Why I've personally stopped using it: I've always had the impression that decorators were intended to provide a convenient and obvious way of augmenting functions. Having one that automatically executes the function at definition just runs counter to the behaviour I expect from a decorator. Espe

Re: Using 'apply' as a decorator, to define constants

2009-08-22 Thread Steven D'Aprano
On Sat, 22 Aug 2009 08:09:52 +0100, Jonathan Fine wrote: > Jonathan Gardner wrote: >> On Aug 21, 9:09 am, alex23 wrote: >>> On Aug 21, 11:36 pm, Jonathan Fine wrote: >>> >>> class ColourThing(object): >>> @apply >>> def rgb(): >>> def fset(self, rgb): >>> self.r, self

Re: Annoying octal notation

2009-08-22 Thread David
Il Fri, 21 Aug 2009 16:52:29 -0700 (PDT), James Harris ha scritto: > > 0xff & 0x0e | 0b1101 > 16rff & 16r0e | 2r1101 > > Hmm. Maybe a symbol would be better than a letter. What about 2_1011, 8_7621, 16_c26h or 2;1011, 8;7621, 16;c26h ? David -- http://mail.python.org/mailman/listinfo/pyt

Re: convert date time

2009-08-22 Thread John Machin
On Aug 22, 5:11 pm, Kushal Kumaran wrote: > On Fri, Aug 21, 2009 at 11:44 PM, Ronn Ross wrote: > > I'm new to python and I'm getting a date time from a field in the database > > that looks like this: > > 8/2/2009 8:36:16 AM (UTC) > datetime.datetime.strptime() will give you a datetime object, whi

Re: Annoying octal notation

2009-08-22 Thread David
Il Fri, 21 Aug 2009 10:36:35 -0700 (PDT), Mensanator ha scritto: > Aha! Then I WAS right after all. Switch to 3.1 and you'll > soon be cured of that bad habit: > 012 + 012 > SyntaxError: invalid token (, line 1) I have tre (four) problems: 1) I am forced to use 2.5 since the production ser

Re: How to 'de-slashify' a string?

2009-08-22 Thread Steven D'Aprano
On Sat, 22 Aug 2009 04:20:23 -0400, AK wrote: > Hi, if I have a string '\\303\\266', how can I convert it to '\303\266' > in a general way? It's not clear what you mean. Do you mean you have a string '\\303\\266', that is: backslash backslash three zero three backslash backslash two six six If

Re: Annoying octal notation

2009-08-22 Thread Steven D'Aprano
On Sat, 22 Aug 2009 11:15:16 +0200, David wrote: > 3) I don't understand why useless but *harmless* things like > algebrically insignificant leading zeros should be *forbidden* and > promoted to errors. The PEP covering this change says: "There are still some strong feelings that '0123' should b

Re: Using 'apply' as a decorator, to define constants

2009-08-22 Thread Jonathan Fine
Steven D'Aprano wrote: There's a standard idiom for that, using the property() built-in, for Python 2.6 or better. Here's an example including a getter, setter, deleter and doc string, with no namespace pollution, imports, or helper functions or deprecated built-ins: class ColourThing(obje

Re: Dictionary from a list

2009-08-22 Thread EK
On Aug 20, 2:10 pm, Peter Otten <__pete...@web.de> wrote: > Jan Kaliszewski wrote: > > 20-08-2009 o 02:05:57 Jan Kaliszewski wrote: > > >> Or probably better: > > >>      from itertools import islice, izip > >>      dict(izip(islice(li, 0, None, 2), islice(li, 1, None, 2))) > > > Or similarly, per

Re: How to 'de-slashify' a string?

2009-08-22 Thread AK
Steven D'Aprano wrote: On Sat, 22 Aug 2009 04:20:23 -0400, AK wrote: Hi, if I have a string '\\303\\266', how can I convert it to '\303\266' in a general way? It's not clear what you mean. Do you mean you have a string '\\303\\266', that is: backslash backslash three zero three backslash ba

Re: How to 'de-slashify' a string?

2009-08-22 Thread Vlastimil Brom
2009/8/22 AK : > Steven D'Aprano wrote: >> >> On Sat, 22 Aug 2009 04:20:23 -0400, AK wrote: >> >>> Hi, if I have a string '\\303\\266', how can I convert it to '\303\266' >>> in a general way? >> >> It's not clear what you mean. >> >> Do you mean you have a string '\\303\\266', that is: >> >> backs

Re: Questions on XML

2009-08-22 Thread Stefan Behnel
Kee Nethery wrote: > As a newbie, the thing that caused me trouble was importing a string > into the XML parser. That would be root_element = et.fromstring(some_string) The parse() function is meant to parse from a file. > from xml.etree import ElementTree as et > theXmlDataTree = et.p

Re: Using 'apply' as a decorator, to define constants

2009-08-22 Thread Steven D'Aprano
On Sat, 22 Aug 2009 10:51:27 +0100, Jonathan Fine wrote: > Steven D'Aprano wrote: > >> There's a standard idiom for that, using the property() built-in, for >> Python 2.6 or better. >> >> Here's an example including a getter, setter, deleter and doc string, >> with no namespace pollution, import

Re: How to 'de-slashify' a string?

2009-08-22 Thread AK
Vlastimil Brom wrote: 2009/8/22 AK : Steven D'Aprano wrote: On Sat, 22 Aug 2009 04:20:23 -0400, AK wrote: Hi, if I have a string '\\303\\266', how can I convert it to '\303\266' in a general way? It's not clear what you mean. Do you mean you have a string '\\303\\266', that is: backslash b

Re: debugger

2009-08-22 Thread Albert Hopkins
On Sat, 2009-08-22 at 01:17 -0700, flagmino wrote: [...] > I am trying to debug: > I press shift-F9 and F7. I end up in the interpreter where I enter s2 > (1, 2). > > >From that point if I press F7, the program restart all over. > If I press Enter, the program gets out of debug mode. Umm.. which

Re: How to 'de-slashify' a string?

2009-08-22 Thread Vlastimil Brom
2009/8/22 AK : > Vlastimil Brom wrote: >> >> 2009/8/22 AK : >>> >>> Steven D'Aprano wrote: On Sat, 22 Aug 2009 04:20:23 -0400, AK wrote: > Hi, if I have a string '\\303\\266', how can I convert it to '\303\266' > in a general way? It's not clear what you mean.

Re: How to 'de-slashify' a string?

2009-08-22 Thread Steven D'Aprano
On Sat, 22 Aug 2009 06:09:20 -0400, AK wrote: >> Is pygresql quoting the backslash, or do you just think it is quoting >> the backslashes? How do you know? E.g. if you have '\\303', what is the >> length of that? 4 or 5? > > Length is 4, and I need it to be length of 1. E.g.: > > >>> s = '\303'

Re: Using 'apply' as a decorator, to define constants

2009-08-22 Thread Jonathan Fine
Steven D'Aprano wrote: On Sat, 22 Aug 2009 10:51:27 +0100, Jonathan Fine wrote: Steven D'Aprano wrote: There's a standard idiom for that, using the property() built-in, for Python 2.6 or better. Here's an example including a getter, setter, deleter and doc string, with no namespace pollution

warnings.warn vs logging.warning

2009-08-22 Thread Gunter Henriksen
When I want to issue a warning, I am uncertain about the distinction between warnings.warn() and logging.warning(). My naive thought is to presume "warning" means the same thing in both cases, and so if I call logging.warning(), it should take care of making sure something equivalent to my calling

Re: Annoying octal notation

2009-08-22 Thread David
Il Thu, 20 Aug 2009 16:59:14 -0700 (PDT), James Harris ha scritto: > > It maybe made sense once but this relic of the past should have been > consigned to the waste bin of history long ago. I perfectly agree with you! David. -- http://mail.python.org/mailman/listinfo/python-list

Re: Need cleanup advice for multiline string

2009-08-22 Thread Steven D'Aprano
On Wed, 19 Aug 2009 10:51:08 -0700, Simon Forman wrote: > (FWIW, I've always admired Humpty Dumpty's attitude to words. "When I use a word," Humpty Dumpty said in rather a scornful tone, "it means just what I choose it to mean -- neither more nor less." When you say "admired", do you mean what

line completion

2009-08-22 Thread Steven Woody
Hi, I wrote a program that takes some user input. Many inputs are quit often used by user, so when a user launch the program, and type in "The Sha", he wants to get "wshank Redemption" displayed automatically in reversed color (black text on white background) along his cursor. When he decided to

Blank Line at Program Exit

2009-08-22 Thread Steven Woody
Hi, Any python program, even that does absolutely nothing in the code, will cause a blank line printed out when the program exit. What's the reason? Thanks. -- Life is the only flaw in an otherwise perfect nonexistence -- Schopenhauer narke public key at http://subkeys.pgp.net:11371 (narke

Re: generate keyboard/mouse event under windows

2009-08-22 Thread yaka
Read this and see if it helps: http://kvance.livejournal.com/985732.html -- http://mail.python.org/mailman/listinfo/python-list

Re: list 'results' from maps.google then crawl

2009-08-22 Thread Stefan Behnel
Justin wrote: > list 'results' from maps.google then crawl through the (engine of some > sort) space to the 'results' website and look at it html to find the > contact Good idea. How do you know how to recognise the contact? He/she might come disguised. Stefan -- http://mail.python.org/mailman/l

generate keyboard/mouse event under windows

2009-08-22 Thread Ray
Hi, Anyone can give some help on how to generate keyboard mouse event under windows? (python 2.5) I tried pyhook, I only know how to monitor the keyboard/mouse events. but don't know how to generate/send the the event. thanks for any help. -Ray -- http://mail.python.org/mailman/listinfo/python

list 'results' from maps.google then crawl

2009-08-22 Thread Justin
list 'results' from maps.google then crawl through the (engine of some sort) space to the 'results' website and look at it html to find the contact -- http://mail.python.org/mailman/listinfo/python-list

Re: grokproject and zope.security==3.4.1 error

2009-08-22 Thread Christian Heimes
Manuel A. Iglesias Abbatemarco schrieb: I will apprreciate if someone could help me with the following error. I a trying to create a grokproject application in my debian 5.0 box, the following is the output after executing # grokproject Sample command. Getting distribution for 'zope.security==3

Re: Annoying octal notation

2009-08-22 Thread MRAB
Dennis Lee Bieber wrote: On Fri, 21 Aug 2009 16:52:29 -0700 (PDT), James Harris declaimed the following in gmane.comp.python.general: So you are saying that Smalltalk has r where r is presumably for radix? That's maybe best of all. It preserves the syntactic requirement of starting a number wi

Re: Annoying octal notation

2009-08-22 Thread MRAB
David wrote: Il Fri, 21 Aug 2009 16:52:29 -0700 (PDT), James Harris ha scritto: 0xff & 0x0e | 0b1101 16rff & 16r0e | 2r1101 Hmm. Maybe a symbol would be better than a letter. What about 2_1011, 8_7621, 16_c26h or 2;1011, 8;7621, 16;c26h ? '_': what if in the future we want to allow th

Re: PIL and Python

2009-08-22 Thread catafest
If I make it work, i will send the solution. Thank you ! -- http://mail.python.org/mailman/listinfo/python-list

Re: debugger

2009-08-22 Thread Stef Mientki
Albert Hopkins wrote: On Sat, 2009-08-22 at 01:17 -0700, flagmino wrote: [...] I am trying to debug: I press shift-F9 and F7. I end up in the interpreter where I enter s2 (1, 2). >From that point if I press F7, the program restart all over. If I press Enter, the program gets out of debug mod

Re: How to 'de-slashify' a string?

2009-08-22 Thread Piet van Oostrum
> Vlastimil Brom (VB) wrote: > decoded = '\\303\\266'.decode("string_escape") > decoded >VB> '\xc3\xb6' > print decoded >VB> ö > print '\303\266' >VB> ö > >VB> It might be an IDLE issue, but it still isn't one unicode glyph. >VB> I guess, you have to ensure, that the

Re: debugger

2009-08-22 Thread Tim Chase
Stef Mientki wrote: Albert Hopkins wrote: On Sat, 2009-08-22 at 01:17 -0700, flagmino wrote: [...] I am trying to debug: I press shift-F9 and F7. I end up in the interpreter where I enter s2 (1, 2). >From that point if I press F7, the program restart all over. If I press Enter, the program

Re: Annoying octal notation

2009-08-22 Thread Grant Edwards
On 2009-08-22, Dennis Lee Bieber wrote: > On Fri, 21 Aug 2009 10:45:51 -0700, John Nagle > declaimed the following in gmane.comp.python.general: > >> >> And it's over. We can finally dispense with octal by default. >> > I've not looked at modern Intel processor format, but if there a

your favorite debugging tool?

2009-08-22 Thread Esmail
Hi all, What is your favorite tool to help you debug your code? I've been getting along with 'print' statements but that is getting old and somewhat cumbersome. I'm primarily interested in utilities for Linux (but if you have recommendations for Windows, I'll take them too :) I use emacs as my

Re: debugger

2009-08-22 Thread Scott David Daniels
flagmino wrote: To get familiar with the debugger, I have loaded this program: import math def s1(x, y): a = (x + y) print("Answer from s1"), a return def s2(x, y): b = (x - y) print("This comes from s2"), b #print z print("call from s2: "), s1(x, y) return I am trying

Re: your favorite debugging tool?

2009-08-22 Thread Aahz
In article , Esmail wrote: > >What is your favorite tool to help you debug your code? I've been >getting along with 'print' statements but that is getting old and >somewhat cumbersome. Despite the fact that I've been using Python for more than a decade, print is still my mainstay (or possibly lo

Re: Blank Line at Program Exit

2009-08-22 Thread Dave Angel
Steven Woody wrote: Hi, Any python program, even that does absolutely nothing in the code, will cause a blank line printed out when the program exit. What's the reason? Thanks. I think the "blank line" is coming from your shell. In Windows, I believe the shell emits a newline after runni

Re: TypeError while checking for permissions with os.access() on windows xp

2009-08-22 Thread ryniek90
First, some nitpicking: Include the whole traceback when posting about errors please. Don't write "if some_boolean_expression != True:" instead prefer "if not some_boolean_expression:". Also, in your code "except (Except), ex: return ex" the parentheses are redundant, there's no "Except" Excep

Re: Decompressing gzip over FTP

2009-08-22 Thread Albert Hopkins
On Fri, 2009-08-21 at 18:15 -0700, SeanMon wrote: > Is there a way to decompress a large (2GB) gzipped file being > retrieved over FTP on the fly? > > I'm using ftplib.FTP to open a connection to a remote server, and I > have had no success connecting retrbinary to gzip without using an > intermed

Re: debugger

2009-08-22 Thread Dave Angel
Stef Mientki wrote: Albert Hopkins wrote: On Sat, 2009-08-22 at 01:17 -0700, flagmino wrote: [...] I am trying to debug: I press shift-F9 and F7. I end up in the interpreter where I enter s2 (1, 2). >From that point if I press F7, the program restart all over. If I press Enter, the program g

Re: Blank Line at Program Exit

2009-08-22 Thread Nitebirdz
On Thu, Aug 20, 2009 at 01:31:14PM +0800, Steven Woody wrote: > Hi, > Any python program, even that does absolutely nothing in the code, will > cause a blank line printed out when the program exit. What's the reason? > Thanks. > Chances are it is related to whichever operating system and/or she

Re: debugger

2009-08-22 Thread MRAB
Dave Angel wrote: Stef Mientki wrote: Albert Hopkins wrote: On Sat, 2009-08-22 at 01:17 -0700, flagmino wrote: [...] I am trying to debug: I press shift-F9 and F7. I end up in the interpreter where I enter s2 (1, 2). >From that point if I press F7, the program restart all over. If I press E

Re: TypeError while checking for permissions with os.access() on windows xp

2009-08-22 Thread Dave Angel
ryniek90 wrote: First, some nitpicking: Include the whole traceback when posting about errors please. Don't write "if some_boolean_expression != True:" instead prefer "if not some_boolean_expression:". Also, in your code "except (Except), ex: return ex" the parentheses are redundant, there's

string literal vs string variable

2009-08-22 Thread Kee Nethery
On Aug 22, 2009, at 3:32 AM, Stefan Behnel wrote: You can use both, but I suspect parsing from StringIO to be slower than parsing from the string directly. That's the case for lxml, at least. Note that fromstring() behaves the same as XML(), but it reads better when parsing from a strin

Urllib2 not working

2009-08-22 Thread Carlos Fabian Ramirez
Hello, When I try to open a URL using urllib2.urlopen it returns Name or service not known. It is not a problem with my Internet I believe, since I have Internet access on my computer, and I have verified it is not a syntax, or spelling, error on my part. I have also tried accessing the site (googl

sed/awk/perl: How to replace all spaces each with an underscore that occur before a specific string ?

2009-08-22 Thread bolega
sed/awk/perl: How to replace all spaces each with an underscore that occur before a specific string ? I really prefer a sed one liner. Example Input : This is my book. It is too thick to read. The author gets little royalty but the publisher makes a lot. Output: This_is_my_book._It_is_too__thi

Re: sed/awk/perl: How to replace all spaces each with an underscore that occur before a specific string ?

2009-08-22 Thread w_a_x_man
On Aug 22, 1:11 pm, bolega wrote: > sed/awk/perl: > > How to replace all spaces each with an underscore that occur before a > specific string ? > > I really prefer a sed one liner. > > Example > Input :  This is my book. It is too  thick to read. The author gets > little royalty but the publisher

Python - insert image / pdf / blob files to MySQL, MSSQL

2009-08-22 Thread MacRules
Where to find code examples? Or someone can post sample codes here. Thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: Annoying octal notation

2009-08-22 Thread Derek Martin
On Sat, Aug 22, 2009 at 10:03:35AM +1000, Ben Finney wrote: > > and the former is virtually indistinguishable from 00012, O0012, or > > many other combinations that someone might accidentally type (or > > intentionally type, having to do this in dozens of other programming > > languages). > > Only

Re: TypeError while checking for permissions with os.access() on windows xp

2009-08-22 Thread ryniek90
First, some nitpicking: Include the whole traceback when posting about errors please. Don't write "if some_boolean_expression != True:" instead prefer "if not some_boolean_expression:". Also, in your code "except (Except), ex: return ex" the parentheses are redundant, there's no "Except" Excep

Re: Urllib2 not working

2009-08-22 Thread Simon Forman
On Sat, Aug 22, 2009 at 2:12 PM, Carlos Fabian Ramirez wrote: > Hello, > When I try to open a URL using urllib2.urlopen it returns Name or service > not known. It is not a problem with my Internet I believe, since I have > Internet access on my computer, and I have verified it is not a syntax, or >

Re: TypeError while checking for permissions with os.access() on windows xp

2009-08-22 Thread Stephen Hansen
> > > WTF?? > Why on IDLE it works, but when i run this script in cmd.exe, the > os.getenv('HOME') goes NoneType? > I'm to newbie yet to understand this :/ > HOME is simply not a standard environment variable that Windows provides. Any program can set/add environment variables as it deems fit; in

Re: difference between raw_input() and input()

2009-08-22 Thread Juraj G.
if you prefix number with zero, it will turn into octal number... I too wasn't aware of it... at least in python :/ http://en.wikipedia.org/wiki/Octal It seems like bad practice to put zeroes before any decimal number in any language :) Juraj -- http://mail.python.org/mailman/listinfo/python-list

Re: sed/awk/perl: How to replace all spaces each with an underscore that occur before a specific string ?

2009-08-22 Thread Tim Chase
bolega wrote: sed/awk/perl: Better to post in the "sed" or "perl" mailing lists rather than a Python list. I saw an awk solution flew by. How to replace all spaces each with an underscore that occur before a specific string ? I really prefer a sed one liner. Here's a one-liner sed solutio

Re: Using 'apply' as a decorator, to define constants

2009-08-22 Thread Jan Kaliszewski
21-08-2009 o 18:09:02 alex23 wrote: Unfortunately, apply() has been removed as a built-in in 3.x. You can always implement it yourself :) def apply(function, args=(), keywords={}): return function(*args, **keywords) -- Jan Kaliszewski (zuo) -- http://mail.python.org/mailman/lis

Re: Questions on XML

2009-08-22 Thread SUBHABRATA BANERJEE
Should I help you? If you answered my questions I am differing from your view I do not get any problem in processing Hindi or Bangla or any Indian language in Python it is perfectly fine. Best Regards, Subhabrata. On Sat, Aug 22, 2009 at 9:48 AM, Rami Chowdhury wrote: > > I am using primarily UTF

Re: Annoying octal notation

2009-08-22 Thread Jan Kaliszewski
22-08-2009 o 21:04:17 Derek Martin wrote: On Sat, Aug 22, 2009 at 10:03:35AM +1000, Ben Finney wrote: These human programmers, whether newbies or long-experienced, also deal with decimal numbers every day, many of which are presented as a sequence of digits with leading zeros — and we contin

Re: string literal vs string variable

2009-08-22 Thread Piet van Oostrum
> Kee Nethery (KN) wrote: >KN> On Aug 22, 2009, at 3:32 AM, Stefan Behnel wrote: >>> >>> You can use both, but I suspect parsing from StringIO to be slower than >>> parsing from the string directly. That's the case for lxml, at least. >>> >>> Note that fromstring() behaves the same as XML

Re: sed/awk/perl: How to replace all spaces each with an underscore that occur before a specific string ?

2009-08-22 Thread Jan Kaliszewski
22-08-2009 o 20:11:32 bolega wrote: sed/awk/perl: How to replace all spaces each with an underscore that occur before a specific string ? $ rm -rf /home/bolega ; python -c 'for i in xrange(1000): print "I will never crosspost senselessly."' ;~] -- Jan Kaliszewski (zuo) -- http://mail.p

Re: Questions on XML

2009-08-22 Thread joy99
On Aug 22, 12:16 pm, Rami Chowdhury wrote: > > encoding declaration to the top of your source file if you use encoded > > literal strings in your code > > Any tips for how to set the encoding in IDLE? printing the Unicode   > strings works -- trying to repr() the variable chokes with a   > Unicode

Re: string literal vs string variable

2009-08-22 Thread Jan Kaliszewski
22-08-2009 o 19:46:51 Kee Nethery wrote: I'm not sure I know the difference between a string variable and a literal string. Is the difference as simple as: somestring = u'hello world' fromstring(somestring) <-- string variable vs XML(u'hello world') <-- literal string Yes, simply: s

ANN: mock 0.6.0, Python mocking and testing library

2009-08-22 Thread Fuzzyman
mock is a Python mock object library for testing, with additional support for runtime monkey patching. Most mocking libraries follow the ‘record -> replay’ pattern of mocking. I prefer the ‘action -> assertion’ pattern, which is more readable and intuitive; particularly when working with the Pytho

Re: logging SMTPhandler Error

2009-08-22 Thread Bev in TX
On Aug 21, 8:34 am, Bev in TX wrote: > Hi, > > I've done some Python programming, but I still consider myself a > Python newbie.  I have a Mac Pro OS X 10.5.8 system and I installed > Python 2.6.2 (the latest package available for the Mac) yesterday. > > I was working through Matt Wilson's article

Re: TypeError while checking for permissions with os.access() on windows xp

2009-08-22 Thread ryniek90
WTF?? Why on IDLE it works, but when i run this script in cmd.exe, the os.getenv('HOME') goes NoneType? I'm to newbie yet to understand this :/ HOME is simply not a standard environment variable that Windows provides. Any program can set/add environment variables as it deems

Numeric literals in other than base 10 - was Annoying octal notation

2009-08-22 Thread James Harris
On 22 Aug, 10:27, David <71da...@libero.it> wrote: ... (snipped a discussion on languages and other systems interpreting numbers with a leading zero as octal) > > Either hexadecimal should have been 0h or octal should > > have been 0t :=) > > > I have seen the use of Q/q instead in order to make

Items inheriting attributes from its container?

2009-08-22 Thread Kreso
I would like to create a list-like container class so that, additionally to usual list methods, I could attach attributes to the container instances. However, I would like it so that the items contained in the particular instance of container somehow 'inherit' those attributes i.e. cont = Containe

Re: line completion

2009-08-22 Thread Chris Rebert
On Thu, Aug 20, 2009 at 9:06 AM, Steven Woody wrote: > Hi, > I wrote a program that takes some user input.  Many inputs are quit often > used by user, so when a user launch the program, and type in "The Sha",  he > wants to get "wshank Redemption" displayed automatically in reversed color > (black

Re: sed/awk/perl: How to replace all spaces each with an underscore that occur before a specific string ?

2009-08-22 Thread Ed Morton
On Aug 22, 1:11 pm, bolega wrote: > sed/awk/perl: > > How to replace all spaces each with an underscore that occur before a > specific string ? > > I really prefer a sed one liner. Why? > Example > Input :  This is my book. It is too  thick to read. The author gets > little royalty but the publi

Re: Items inheriting attributes from its container?

2009-08-22 Thread Christian Heimes
Kreso schrieb: I would like to create a list-like container class so that, additionally to usual list methods, I could attach attributes to the container instances. However, I would like it so that the items contained in the particular instance of container somehow 'inherit' those attributes i.e.

Re: Numeric literals in other than base 10 - was Annoying octal notation

2009-08-22 Thread Mel
James Harris wrote: > I have no idea why Ada which uses the # also apparently uses it to end > a number > > 2#1011#, 8#7621#, 16#c26b# Interesting. They do it because of this example from : 2#1#E8-- an in

Re: Annoying octal notation

2009-08-22 Thread Carl Banks
On Aug 22, 12:04 pm, Derek Martin wrote: > On Sat, Aug 22, 2009 at 10:03:35AM +1000, Ben Finney wrote: > > These human programmers, whether newbies or long-experienced, also deal > > with decimal numbers every day, many of which are presented as a > > sequence of digits with leading zeros — and we

Re: Items inheriting attributes from its container?

2009-08-22 Thread Stephen Fairchild
Kreso wrote: > I would like to create a list-like container class so that, additionally > to usual list methods, I could attach attributes to the container > instances. However, I would like it so that the items contained in the > particular instance of container somehow 'inherit' those attributes

Re: Annoying octal notation

2009-08-22 Thread Carl Banks
On Aug 21, 12:48 pm, Derek Martin wrote: > John Nagle wrote: > > Yes, and making lead zeros an error as suggested in PEP 3127 is a > > good idea.  It will be interesting to see what bugs that flushes > > out. > James Harris wrote: > > It maybe made sense once but this relic of the past should have

Re: logging SMTPhandler Error

2009-08-22 Thread Ned Deily
In article , Bev in TX wrote: > On Aug 21, 8:34 am, Bev in TX wrote: > > Hi, > > > > I've done some Python programming, but I still consider myself a > > Python newbie.  I have a Mac Pro OS X 10.5.8 system and I installed > > Python 2.6.2 (the latest package available for the Mac) yesterday. >

Re: sed/awk/perl: How to replace all spaces each with an underscore that occur before a specific string ?

2009-08-22 Thread John W. Krahn
bolega wrote: sed/awk/perl: How to replace all spaces each with an underscore that occur before a specific string ? I really prefer a sed one liner. Example Input : This is my book. It is too thick to read. The author gets little royalty but the publisher makes a lot. Output: This_is_my_book

Re: sed/awk/perl: How to replace all spaces each with an underscore that occur before a specific string ?

2009-08-22 Thread MRAB
John W. Krahn wrote: bolega wrote: sed/awk/perl: How to replace all spaces each with an underscore that occur before a specific string ? I really prefer a sed one liner. Example Input : This is my book. It is too thick to read. The author gets little royalty but the publisher makes a lot. O

Re: logging SMTPhandler Error

2009-08-22 Thread Bev in TX
On Aug 22, 7:07 pm, Ned Deily wrote: > > The problem here is that gmail, like most modern mail services, requires > the use of an encrypted (SSL or TLS) connection for mail relaying so > that the required user name and password are not sent in the clear.  The > logging SMTP handler uses the smtpli

Re: Items inheriting attributes from its container?

2009-08-22 Thread Jan Kaliszewski
23-08-2009 Kreso wrote: I would like to create a list-like container class so that, additionally to usual list methods, I could attach attributes to the container instances. However, I would like it so that the items contained in the particular instance of container somehow 'inherit' those a

Re: Items inheriting attributes from its container?

2009-08-22 Thread Jan Kaliszewski
PS. Erratum: class Team(list): """A container for Player() instances.""" def __init__(self, teamdata, playerdata=None): *** Here should be added: list.__init__(self) *** for key in teamdata: setattr(self, key, teamdata[key]) for data in

Re: your favorite debugging tool?

2009-08-22 Thread Ben Finney
Esmail writes: > What is your favorite tool to help you debug your code? A “print” statement (or equivalent, like logging output). > I've been getting along with 'print' statements but that is getting > old and somewhat cumbersome. Whenever a simple output statement is too cumbersome for debug

Re: logging SMTPhandler Error

2009-08-22 Thread Ned Deily
In article <87236fb1-c09f-46e8-8492-514ba000c...@24g2000yqm.googlegroups.com>, Bev in TX wrote: > On Aug 22, 7:07 pm, Ned Deily wrote: > > [...] Or on OS X it's > > not *too* difficult to set up a local host mailer using the > > Apple-supplied prefix that would accept mail locally and forward i

Re: Annoying octal notation

2009-08-22 Thread Derek Martin
On Sat, Aug 22, 2009 at 02:55:51AM +, Steven D'Aprano wrote: > > I can see how 012 can > > be confusing to new programmers, but at least it's legible, and the > > great thing about humans is that they can be taught (usually). > > And the great thing is that now you get to teach yourself to sto

Re: Annoying octal notation

2009-08-22 Thread Derek Martin
On Fri, Aug 21, 2009 at 04:23:57PM -0700, James Harris wrote: > You misunderstand. I was saying that taking a leading zero as > indicating octal is archaic. Octal itself is fine where appropriate. I don't see that the leading zero is any more archaic than the use of octal itself... Both originate

Re: Numeric literals in other than base 10 - was Annoying octal notation

2009-08-22 Thread Richard Harter
On Sat, 22 Aug 2009 14:54:41 -0700 (PDT), James Harris wrote: >On 22 Aug, 10:27, David <71da...@libero.it> wrote: > >... (snipped a discussion on languages and other systems interpreting >numbers with a leading zero as octal) > >> > Either hexadecimal should have been 0h or octal should >> > have

Re: Annoying octal notation

2009-08-22 Thread Steven D'Aprano
On Sat, 22 Aug 2009 14:04:17 -0500, Derek Martin wrote: >> These human programmers, whether newbies or long-experienced, also deal >> with decimal numbers every day, many of which are presented as a >> sequence of digits with leading zeros — and we continue to think of >> them as decimal numbers r

Idle does not recognize PYTHONPATH

2009-08-22 Thread goldtech
Hi, Idle does not recognize PYTHONPATH set in .bashrc. Starting Python shell in the terminal sys.path shows the PYTHONPATH, but again not shown in IDLE. This is a common problem but I could not find a fix. Using Ubuntu 9.04. Python 2.6. Thanks -- http://mail.python.org/mailman/listinfo/python-li

Re: How to 'de-slashify' a string?

2009-08-22 Thread AK
Vlastimil Brom wrote: 2009/8/22 AK : Vlastimil Brom wrote: 2009/8/22 AK : Steven D'Aprano wrote: On Sat, 22 Aug 2009 04:20:23 -0400, AK wrote: Hi, if I have a string '\\303\\266', how can I convert it to '\303\266' in a general way? It's not clear what you mean. Do you mean you have a str

Re: How to create functors?

2009-08-22 Thread Paul Rubin
Steven D'Aprano writes: > According to Wikipedia, functor can be used as a synonym for "function > object": ... http://en.wikipedia.org/wiki/Function_object Hmm, I hadn't seen that usage before. I guess there's no law against it, but it seems a bit bogus to me. > I find the Haskell page entire

Re: logging SMTPhandler Error

2009-08-22 Thread Aahz
In article , Ned Deily wrote: > >Or on OS X it's not *too* difficult to set up a local host mailer using >the Apple-supplied prefix that would accept mail locally and forward it >to a more sophisticated remote mailer. It's also not too difficult to do the moral equivalent with dnspython and find

Re: Annoying octal notation

2009-08-22 Thread Steven D'Aprano
On Sat, 22 Aug 2009 22:19:01 -0500, Derek Martin wrote: > On Sat, Aug 22, 2009 at 02:55:51AM +, Steven D'Aprano wrote: >> > I can see how 012 can >> > be confusing to new programmers, but at least it's legible, and the >> > great thing about humans is that they can be taught (usually). >> >>