Re: The trouble with "dynamic attributes".

2010-09-18 Thread Lie Ryan
On 09/18/10 03:53, Ethan Furman wrote: > Lie Ryan wrote: > [snip] >> And even dict-syntax is not perfect for accessing XML file, e.g.: >> >> >> foo >> bar >> >> >> should a['b'] be 'foo' or 'bar'? > > Attribute style access would also fail in this instance -- how is this > worked-around?

Re: socket.error: [Errno 98] Address already in use

2010-09-18 Thread Lawrence D'Oliveiro
In message , Nobody wrote: > On Sun, 19 Sep 2010 12:27:08 +1200, Lawrence D'Oliveiro wrote: > >>> That's why Stevens recommends that all TCP servers use the >>> SO_REUSEADDR socket option. >> >> I don’t think I’ve ever used that. It seems to defeat a safety mechanism >> which was put in for a re

Re: socket.error: [Errno 98] Address already in use

2010-09-18 Thread Nobody
On Sun, 19 Sep 2010 12:27:08 +1200, Lawrence D'Oliveiro wrote: >> That's why Stevens recommends that all TCP servers use the >> SO_REUSEADDR socket option. > > I don’t think I’ve ever used that. It seems to defeat a safety mechanism > which was put in for a reason. It was put in for the benefit

Re: Why IterableUserDict?

2010-09-18 Thread Steven D'Aprano
On Sat, 18 Sep 2010 09:42:14 +0200, Peter Otten wrote: [...] >> Now that boggles my brain. Why was support for iteration added as a >> subclass, instead of simply adding the __iter__ method to UserDict? >> UserDict is supposed to be a drop-in replacement for dict (although the >> use-cases for it

Re: Too much code - slicing

2010-09-18 Thread Steven D'Aprano
On Sun, 19 Sep 2010 00:35:14 +, Seebs wrote: > On 2010-09-19, AK wrote: >> Funny that you should say that, because I thought quite a few times >> that it would be really awesome if some texts in English had syntax >> highlighting. Obviously, not Brothers Karamazov, but something like a >> tut

Re: [DB-SIG] dbf files and compact indices

2010-09-18 Thread Ethan Furman
Carl Karsten wrote: On Sat, Sep 18, 2010 at 11:23 PM, Ethan Furman wrote: Thanks for the suggestion, but I don't want to be tied to Foxpro, which means I need to be able to parse these files directly. I have the dbf files, now I need the idx and cdx files. What do you mean "tied" ? I mea

Re: [DB-SIG] dbf files and compact indices

2010-09-18 Thread Ethan Furman
Dennis Lee Bieber wrote: On Sat, 18 Sep 2010 10:44:06 -0700, Ethan Furman declaimed the following in gmane.comp.python.general: I have a pure-python module to read db3 and vfp 6 dbf files, and I find that I need to read (and write) the idx and cdx index files that foxpro generates. We are i

Re: [DB-SIG] dbf files and compact indices

2010-09-18 Thread Carl Karsten
On Sat, Sep 18, 2010 at 11:23 PM, Ethan Furman wrote: > Vernon Cole wrote: >> >> Ethan: >> I cannot see where you mentioned your operating system, I am assuming >> Windows. >> >> Perhaps you have already investigated this ... I have no way to test it >> ... but you might try: >> ADO can access alm

Re: [DB-SIG] dbf files and compact indices

2010-09-18 Thread Ethan Furman
Vernon Cole wrote: Ethan: I cannot see where you mentioned your operating system, I am assuming Windows. Perhaps you have already investigated this ... I have no way to test it ... but you might try: ADO can access almost any data source, and a quick look seems to show that .dbf is supported

Re: Too much code - slicing

2010-09-18 Thread Steven D'Aprano
On Sat, 18 Sep 2010 21:58:58 -0400, AK wrote: >> I don't understand this. So far as I know, the phrase "speed reading" >> refers to various methods of reading much faster than most people read, >> and is real but not exceptionally interesting. > > Afaik the idea is that you can read a novel at t

Re: Too much code - slicing

2010-09-18 Thread Steven D'Aprano
On Sat, 18 Sep 2010 19:09:33 -0700, Carl Banks wrote: > Apart from occasions like this and throwaway one-liners I use regular > if-then statements. If Python had added the C-like a ? b : c, then I'd > use it a lot more, since that version is not inherently unbalanced. Define "unbalanced". Putti

Re: Plz comment on this code

2010-09-18 Thread Steven D'Aprano
On Sun, 19 Sep 2010 12:23:15 +1000, fridge wrote: > # bigdigits2.py [snip code] It looks like Python. Did you have a specific question? P.S. Please don't send HTML to non-binary news groups, it's very annoying. And if you're sending it by email, your mail client appears to be broken, because i

Re: Plz comment on this code

2010-09-18 Thread Jason Swails
On Sat, Sep 18, 2010 at 10:23 PM, fridge wrote: > # bigdigits2.py > ^ Here is the comment > > import sys > > zero=["***", >"* *", >"***"] > one=["***", > " * ", > "***"] > digits=[zero,one,zero,one,zero,one,zero,one,zero,one] > > inputted_digit=sys.argv[1] > column_max=len(i

Re: Too much code - slicing

2010-09-18 Thread AK
On 09/18/2010 10:12 PM, Seebs wrote: On 2010-09-19, AK wrote: On 09/18/2010 08:35 PM, Seebs wrote: News flash: Not all people think the same way. Film at 11. :) I've tried to use syntax coloring editors, and I've always found that they end up making me slower and less accurate at reading

Re: Learning inheritance

2010-09-18 Thread alex23
Niklasro wrote: > I got 2 files main.py and i18n both with > webapp request handlers which I would like access the variable. I'd probably use a module for this. Create a third file, called something like shared.py, containing the line that bruno gave above: url = os.environ.get("HTTP_HOST", os.e

Re: Too much code - slicing

2010-09-18 Thread Seebs
On 2010-09-19, AK wrote: > On 09/18/2010 08:35 PM, Seebs wrote: >> That wouldn't be *syntax* highlighting, that'd be *semantic* highlighting. > In case of programming, the effect is similar. I have not found that to be the case. It's been exactly the same as syntax highlighting in English would

Plz comment on this code

2010-09-18 Thread fridge
# bigdigits2.py import sys zero=["***", "* *", "***"] one=["***", " * ", "***"] digits=[zero,one,zero,one,zero,one,zero,one,zero,one] inputted_digit=sys.argv[1] column_max=len(inputted_digit) row_max=3 r=0 while r<3: line="" c=0 while c-- http://mail.python.org/mailman/listinfo/

Re: Too much code - slicing

2010-09-18 Thread Carl Banks
On Sep 17, 1:01 pm, Andreas Waldenburger wrote: > On Thu, 16 Sep 2010 16:20:33 -0400 AK wrote: > > > I also like this construct that works, I think, since 2.6: > > > code = dir[int(num):] if side == 'l' else dir[:-1*int(num)] > > I wonder when this construct will finally start to look good. I do

ctypes and buffers

2010-09-18 Thread Carl Banks
I am creating a ctypes buffer from an existing non-ctypes object that supports buffer protocol using the following code: from ctypes import * PyObject_AsReadBuffer = pythonapi.PyObject_AsReadBuffer PyObject_AsReadBuffer.argtypes = [py_object,POINTER(c_void_p),POINTER(c_size_t)] PyObject_AsReadBu

Re: Too much code - slicing

2010-09-18 Thread AK
On 09/18/2010 09:08 PM, Dennis Lee Bieber wrote: On Sat, 18 Sep 2010 20:00:32 -0400, AK declaimed the following in gmane.comp.python.general: Funny that you should say that, because I thought quite a few times that it would be really awesome if some texts in English had syntax highlighting. O

Re: Too much code - slicing

2010-09-18 Thread AK
On 09/18/2010 08:35 PM, Seebs wrote: On 2010-09-19, AK wrote: Funny that you should say that, because I thought quite a few times that it would be really awesome if some texts in English had syntax highlighting. Obviously, not Brothers Karamazov, but something like a tutorial, or a manual, or a

Re: Learning inheritance

2010-09-18 Thread Carl Banks
On Sep 18, 4:15 pm, Jorgen Grahn wrote: > On Sat, 2010-09-18, Niklasro wrote: > > Hi > > How can I make the visibility of a variable across many methods or > > files? To avoid repeating the same line eg     url = > > os.environ['HTTP_HOST'] if os.environ.get('HTTP_HOST') else > > os.environ['SERVE

Re: Too much code - slicing

2010-09-18 Thread Seebs
On 2010-09-19, AK wrote: > Funny that you should say that, because I thought quite a few times that > it would be really awesome if some texts in English had syntax > highlighting. Obviously, not Brothers Karamazov, but something like a > tutorial, or a manual, or an online article. If key words w

Re: socket.error: [Errno 98] Address already in use

2010-09-18 Thread Lawrence D'Oliveiro
In message , Jorgen Grahn wrote: > That's why Stevens recommends that all TCP servers use the > SO_REUSEADDR socket option. I don’t think I’ve ever used that. It seems to defeat a safety mechanism which was put in for a reason. -- http://mail.python.org/mailman/listinfo/python-list

Re: Too much code - slicing

2010-09-18 Thread AK
On 09/18/2010 07:38 PM, Seebs wrote: On 2010-09-18, AK wrote: On 09/18/2010 06:56 PM, Seebs wrote: Basically, I can handle do x if y pretty well, but do x if y else z always breaks my parser. So in English, I might say "I'll go to the store if I have time", but I'd rarely us

Re: Too much code - slicing

2010-09-18 Thread Seebs
On 2010-09-18, AK wrote: > On 09/18/2010 06:56 PM, Seebs wrote: >> Basically, I can handle >> do x if y >> pretty well, but >> do x if y else z >> always breaks my parser. >> So in English, I might say "I'll go to the store if I have time", but >> I'd rarely use "I'll go to the store if

Re: The trouble with "dynamic attributes".

2010-09-18 Thread Jorgen Grahn
On Fri, 2010-09-17, James Mills wrote: > On Fri, Sep 17, 2010 at 11:33 AM, moerchendiser2k3 > wrote: >> I am really sorry, but what are you talking about ? Hmmm, ...I have >> problems to compile Python on SL, I did not ask anything about >> "dynamic attribute". I don't get it... > > You are subscr

Re: Too much code - slicing

2010-09-18 Thread AK
On 09/18/2010 06:56 PM, Seebs wrote: On 2010-09-18, Steven D'Aprano wrote: On Fri, 17 Sep 2010 16:01:54 -0400, Andreas Waldenburger wrote: On Thu, 16 Sep 2010 16:20:33 -0400 AK wrote: I also like this construct that works, I think, since 2.6: code = dir[int(num):] if side == 'l' else dir[

Re: socket.error: [Errno 98] Address already in use

2010-09-18 Thread Jorgen Grahn
On Sat, 2010-09-18, Lawrence D'Oliveiro wrote: > In message > <2f830099-4264-47bc-98ee-31950412a...@q21g2000prm.googlegroups.com>, cerr > wrote: > >> I get a socket error "[Errno 98] Address already in use" when i try to >> open a socket that got closed before with close(). How come close() >> do

Re: Learning inheritance

2010-09-18 Thread Niklasro
On Sep 18, 4:13 pm, "bruno.desthuilli...@gmail.com" wrote: > On 18 sep, 17:25, Niklasro wrote: > > > Hi > > How can I make the visibility of a variable across many methods or > > files? To avoid repeating the same line eg     url = > > os.environ['HTTP_HOST'] if os.environ.get('HTTP_HOST') else >

Re: Learning inheritance

2010-09-18 Thread Jorgen Grahn
On Sat, 2010-09-18, Niklasro wrote: > Hi > How can I make the visibility of a variable across many methods or > files? To avoid repeating the same line eg url = > os.environ['HTTP_HOST'] if os.environ.get('HTTP_HOST') else > os.environ['SERVER_NAME'] I repeat for many methods. So declaring it >

Re: Why IterableUserDict?

2010-09-18 Thread Terry Reedy
On 9/17/2010 11:12 PM, Steven D'Aprano wrote: I was writing some tests for a mapping class I have made, and I decided to run those same tests over dict and UserDict. The built-in dict passed all the tests, but UserDict failed one: You forgot to specify Python version ;-). class SimpleMappingT

Re: Too much code - slicing

2010-09-18 Thread Seebs
On 2010-09-18, Steven D'Aprano wrote: > On Fri, 17 Sep 2010 16:01:54 -0400, Andreas Waldenburger wrote: >> On Thu, 16 Sep 2010 16:20:33 -0400 AK wrote: >>> I also like this construct that works, I think, since 2.6: >>> code = dir[int(num):] if side == 'l' else dir[:-1*int(num)] >> I wonder when

Re: Standard library function to remove folder with files and subfolders?

2010-09-18 Thread Philip Semanchuk
On Sep 18, 2010, at 5:24 PM, pyt...@bdurham.com wrote: > Is there a standard library function to remove a folder that may > contain files and subfolders? Or must I write a function that > walks my folder's children and deletes all files/subfolders > first, and then call os.removedirs()? In Pytho

Standard library function to remove folder with files and subfolders?

2010-09-18 Thread python
Is there a standard library function to remove a folder that may contain files and subfolders? Or must I write a function that walks my folder's children and deletes all files/subfolders first, and then call os.removedirs()? Thank you, Malcolm -- http://mail.python.org/mailman/listinfo/python-lis

Re: data structure suggestion (native python datatypes or sqlite; compound select)

2010-09-18 Thread Vlastimil Brom
2010/9/18 Dennis Lee Bieber : > On Sat, 18 Sep 2010 10:48:44 +0200, Vlastimil Brom > declaimed the following in > gmane.comp.python.general: > >> >> http://mail.python.org/pipermail/python-list/2008-May/540773.html >> >        Ah, based on that listing you are not worried about embedded tags; > yo

Re: [OS X 10.5] hitting TAB inserts ./ in interactive mode ?

2010-09-18 Thread Ned Deily
In article , Lawrence D'Oliveiro wrote: > In message , Ned Deily > wrote: > > try: > > import readline > > except ImportError: > > print("Module readline not available.") > > else: > > import rlcompleter > > readline.parse_and_bind("tab: complete") >

Re: [DB-SIG] dbf files and compact indices

2010-09-18 Thread Ethan Furman
Carl Karsten wrote: On Sat, Sep 18, 2010 at 11:16 AM, Ethan Furman wrote: Carl Karsten wrote: On Sat, Sep 18, 2010 at 1:11 AM, Ethan Furman wrote: Does anybody have any pointers, tips, web-pages, already written routines, etc, on parsing *.cdx files? I have found the pages on MS's sight

Re: [DB-SIG] dbf files and compact indices

2010-09-18 Thread Carl Karsten
On Sat, Sep 18, 2010 at 11:16 AM, Ethan Furman wrote: > Carl Karsten wrote: >> >> On Sat, Sep 18, 2010 at 1:11 AM, Ethan Furman wrote: >> >>> Does anybody have any pointers, tips, web-pages, already written >>> routines, >>> etc, on parsing *.cdx files?  I have found the pages on MS's sight for >

Making logging.getLogger() simpler

2010-09-18 Thread Lie Ryan
I was expecting this to work: import logging logger = logging.getLogger(__name__) logger.warn('this is a warning') instead it produced the error: No handlers could be found for logger "__main__" However, if instead I do: import logging logging.warn('creating logger') logger = lo

Re: [DB-SIG] dbf files and compact indices

2010-09-18 Thread Ethan Furman
Carl Karsten wrote: On Sat, Sep 18, 2010 at 1:11 AM, Ethan Furman wrote: Does anybody have any pointers, tips, web-pages, already written routines, etc, on parsing *.cdx files? I have found the pages on MS's sight for Foxpro, but they neglect to describe the compaction algorithm used, and my

Re: Learning inheritance

2010-09-18 Thread bruno.desthuilli...@gmail.com
On 18 sep, 17:25, Niklasro wrote: > Hi > How can I make the visibility of a variable across many methods or > files? To avoid repeating the same line eg     url = > os.environ['HTTP_HOST'] if os.environ.get('HTTP_HOST') else > os.environ['SERVER_NAME'] First learn to use Python correctly: url =

Learning inheritance

2010-09-18 Thread Niklasro
Hi How can I make the visibility of a variable across many methods or files? To avoid repeating the same line eg url = os.environ['HTTP_HOST'] if os.environ.get('HTTP_HOST') else os.environ['SERVER_NAME'] I repeat for many methods. So declaring it to a super class and inheriting it is my plan.

Re: socket.error: [Errno 98] Address already in use

2010-09-18 Thread Lawrence D'Oliveiro
In message , Grant Edwards wrote: > Even when the connection was properly terminated (from an > application's POV), there's a TIME_WAIT period before the TCP stack > considered the connection completely gone and will allow re-use of the > port. I’m not so sure about that. I’ve done a bunch of dev

Re: socket.error: [Errno 98] Address already in use

2010-09-18 Thread Grant Edwards
On 2010-09-18, Lawrence D'Oliveiro wrote: > In message ><2f830099-4264-47bc-98ee-31950412a...@q21g2000prm.googlegroups.com>, cerr > wrote: > >> I get a socket error "[Errno 98] Address already in use" when i try to >> open a socket that got closed before with close(). How come close() >> doesn't

Re: Porting PEP 3148 to 2.x series

2010-09-18 Thread k3xji
> I'll probably port 3148 to Python 2.x after its running happily in   > Python 3.2. Very good news. One idea: Once library becomes reliable enough- of course there are various use cases - but IMHO it perfectly fits the problem domain of implementing an async DB library on top of it. I suppose th

Re: self-closing window with wxPython

2010-09-18 Thread Gregory Ewing
Jabba Laci wrote: I'd like to create a simple alarm application that shows an alarm window. The application should shut down automatically after 5 seconds. Are you sure that's a good idea? What happens if the user gets distracted for 6 seconds and misses the alarm? -- Greg -- http://mail.pyth

Re: data structure suggestion (native python datatypes or sqlite; compound select)

2010-09-18 Thread Vlastimil Brom
2010/9/18 Dennis Lee Bieber : > On Fri, 17 Sep 2010 10:44:43 +0200, Vlastimil Brom > declaimed the following in > gmane.comp.python.general: > > >> Ok, thanks for confirming my suspicion :-), >> Now I have to decide whether I shall use my custom data structure, >> where I am on my own, or whether

Re: [OS X 10.5] hitting TAB inserts ./ in interactive mode ?

2010-09-18 Thread Lawrence D'Oliveiro
In message , Ned Deily wrote: > try: > import readline > except ImportError: > print("Module readline not available.") > else: > import rlcompleter > readline.parse_and_bind("tab: complete") > > Note the print() form which works with either Python 2 or

Re: Why IterableUserDict?

2010-09-18 Thread Peter Otten
Steven D'Aprano wrote: > I was writing some tests for a mapping class I have made, and I decided > to run those same tests over dict and UserDict. The built-in dict passed > all the tests, but UserDict failed one: > > class SimpleMappingTest(unittest.TestCase): > type2test = UserDict.UserDict