Re: The opener parameter of Python 3 open() built-in

2012-09-03 Thread Ben Finney
Steven D'Aprano writes: > On Mon, 03 Sep 2012 23:19:51 -0400, Dennis Lee Bieber wrote: > > f = os.fdopen(os.open("newfile", flags | os.O_EXCL), "w") > > > > which does NOT look any cleaner to me... > > Well, I don't know about that. Once you start messing about with low- > level O_* flags,

Re: The opener parameter of Python 3 open() built-in

2012-09-03 Thread Steven D'Aprano
On Mon, 03 Sep 2012 23:19:51 -0400, Dennis Lee Bieber wrote: > On 04 Sep 2012 01:13:09 GMT, Steven D'Aprano > declaimed the following in > gmane.comp.python.general: > > > >> Why does the open builtin need this added complexity? Why not just call >> os.open directly? Or for more complex opener

Re: The opener parameter of Python 3 open() built-in

2012-09-03 Thread Ben Finney
Ben Finney writes: > So, having written the opener: > > > On Mon, 03 Sep 2012 15:29:05 +0200, Christian Heimes wrote: > > > import os > > > > > > def opener(file, flags): > > > return os.open(file, flags | os.O_EXCL) > > why not call that directly? > > f = opener(file, flags) Ah, becaus

Re: Comparing strings from the back?

2012-09-03 Thread Dan Sommers
On 2012-09-04 at 02:17:30 +, Steven D'Aprano wrote: > Besides, then somebody will say "Yes, but what about the cases where > the prefix and the suffix are both equal, but the middle will be > different?" and propose a third string-equality operator and > then there will be bloodshed. L

Re: The opener parameter of Python 3 open() built-in

2012-09-03 Thread Ben Finney
Dennis Lee Bieber writes: > On 04 Sep 2012 01:13:09 GMT, Steven D'Aprano > declaimed the following in > gmane.comp.python.general: > > What is the rationale for complicating [the builtin] open instead of > > telling people to just call their opener directly? > > To avoid the new syntax wou

Re: Comparing strings from the back?

2012-09-03 Thread Terry Reedy
On 9/3/2012 9:54 PM, Roy Smith wrote: There's been a bunch of threads lately about string implementations, and that got me thinking (which is often a dangerous thing). Let's assume you're testing two strings for equality. You've already done the obvious quick tests (i.e they're the same length)

Re: simple client data base

2012-09-03 Thread Thomas 'PointedEars' Lahn
Mark R Rivet wrote: > Hello all, I am learning to program in python. I have a need to make a > program that can store, retrieve, add, and delete client data such as > name, address, social, telephone number and similar information. This > would be a small client database for my wife who has a home

Re: is there history command in python?

2012-09-03 Thread Dwight Hutto
Google can help tremendously, if you use it correctly: Used search term 'python console remember history', and got https://www.google.com/search?client=ubuntu&channel=fs&q=python+console+remember+history&ie=utf-8&oe=utf-8, and the first one listed is below: http://stackoverflow.com/questions/9478

Re: is there history command in python?

2012-09-03 Thread Aldrich DeMata
Look at the readline module or use ipython. Aldrich On Mon, Sep 3, 2012 at 9:47 PM, contro opinion wrote: > in bash ,history command can let me know every command which i execute in > history, > is there a same command in python console?if there is no,how can i know > the historical inputs? > it

Re: Comparing strings from the back?

2012-09-03 Thread Steven D'Aprano
On Mon, 03 Sep 2012 21:54:01 -0400, Roy Smith wrote: > Let's assume you're testing two strings for equality. You've already > done the obvious quick tests (i.e they're the same length), and you're > down to the O(n) part of comparing every character. > > I'm wondering if it might be faster to st

Re: Comparing strings from the back?

2012-09-03 Thread Chris Angelico
On Tue, Sep 4, 2012 at 11:54 AM, Roy Smith wrote: > I'm wondering if it might be faster to start at the ends of the strings > instead of at the beginning? > I'm also not sure how this work with all the possible UCS/UTF encodings. > With some of them, you may get the encoding semantics wrong if yo

Re: Comparing strings from the back?

2012-09-03 Thread Dwight Hutto
On Mon, Sep 3, 2012 at 9:54 PM, Roy Smith wrote: > There's been a bunch of threads lately about string implementations, and > that got me t > > On > hinking (which is often a dangerous thing). > > Let's assume you're testing two strings for equality. You've already > done the obvious quick tests

Re: set and dict iteration

2012-09-03 Thread Steven D'Aprano
On Mon, 03 Sep 2012 21:50:57 -0400, Dave Angel wrote: > On 09/03/2012 09:26 PM, Steven D'Aprano wrote: >> An unsigned C int can count up to 4,294,967,295. I propose that you say >> that is enough iterators for anyone, and use a single, simple, version >> counter in the dict and the iterator. If s

Re: set and dict iteration

2012-09-03 Thread Dave Angel
On 09/03/2012 09:26 PM, Steven D'Aprano wrote: > On Mon, 03 Sep 2012 13:04:23 -0700, Aaron Brady wrote: > >> >> >> I think the technique would require two python longs and a bool in the >> set, and a python long in the iterator. >> >> One long counts the number of existing (open) iterators. Anoth

Comparing strings from the back?

2012-09-03 Thread Roy Smith
There's been a bunch of threads lately about string implementations, and that got me thinking (which is often a dangerous thing). Let's assume you're testing two strings for equality. You've already done the obvious quick tests (i.e they're the same length), and you're down to the O(n) part of

is there history command in python?

2012-09-03 Thread contro opinion
in bash ,history command can let me know every command which i execute in history, is there a same command in python console?if there is no,how can i know the historical inputs? it is not convenient to use direction key( up, or down arrow key) to see my historical inputs. i want an another convenie

Re: set and dict iteration

2012-09-03 Thread Steven D'Aprano
On Mon, 03 Sep 2012 13:04:23 -0700, Aaron Brady wrote: > On Monday, September 3, 2012 2:30:24 PM UTC-5, Ian wrote: >> On Sun, Sep 2, 2012 at 11:43 AM, Aaron Brady >> wrote: >> >> > We could use a Python long object for the version index to prevent >> > overflow. Combined with P. Rubin's idea to

Re: The opener parameter of Python 3 open() built-in

2012-09-03 Thread Steven D'Aprano
On Mon, 03 Sep 2012 15:29:05 +0200, Christian Heimes wrote: > Am 03.09.2012 14:32, schrieb Marco: >> Does anyone have an example of utilisation? > > The opener argument is a new 3.3 feature. For example you can use the > feature to implement exclusive creation of a file to avoid symlink > attacks

Re: Flexible string representation, unicode, typography, ...

2012-09-03 Thread Steven D'Aprano
On Mon, 03 Sep 2012 18:26:02 +0300, Serhiy Storchaka wrote: > On 03.09.12 04:42, Steven D'Aprano wrote: >> If you are *seriously* interested in debugging why string code is >> slower for you, you can start by running the full suite of Python >> string benchmarks: see the stringbench benchmark in t

Re: set and dict iteration

2012-09-03 Thread Aaron Brady
On Monday, September 3, 2012 3:28:28 PM UTC-5, Dave Angel wrote: > On 09/03/2012 04:04 PM, Aaron Brady wrote: > > > On Monday, September 3, 2012 2:30:24 PM UTC-5, Ian wrote: > > >> On Sun, Sep 2, 2012 at 11:43 AM, Aaron Brady wrote: > > >> > > >>> We could use a Python long object for the vers

Re: Async client for PostgreSQL?

2012-09-03 Thread calderone . jeanpaul
On Saturday, September 1, 2012 3:28:52 PM UTC-4, Laszlo Nagy wrote: > > Hi > > > > > > does running on tornado imply that you would not consider twisted > > > http://twistedmatrix.com ? > > > > > > If not, twisted has exactly this capability hiding long running > > > queries on whatever db'

Re: set and dict iteration

2012-09-03 Thread Serhiy Storchaka
On 27.08.12 22:17, Ian Kelly wrote: May I suggest an alternate approach? Internally tag each set or dict with a "version", which is just a C int. Every time the hash table is modified, increment the version. When an iterator is created, store the current version on the iterator. When the iter

Re: Looking for an IPC solution

2012-09-03 Thread vasudevram
On Saturday, September 1, 2012 6:25:36 PM UTC+5:30, Wolfgang Keller wrote: > > There are just so many IPC modules out there. I'm looking for a > > > solution for developing a new a multi-tier application. The core > > > application will be running on a single computer, so the IPC should > > > be

Re: simple client data base

2012-09-03 Thread Dwight Hutto
If you're just starting to learn python/computer science, why not try setting up section fields in a file that you can parse, with your own database. Then you can parse through, append, delete, etc and this will show you the 'higher' level of db's. Plus, I don't think anyone has mentioned RDBM: h

Re: set and dict iteration

2012-09-03 Thread Dave Angel
On 09/03/2012 04:04 PM, Aaron Brady wrote: > On Monday, September 3, 2012 2:30:24 PM UTC-5, Ian wrote: >> On Sun, Sep 2, 2012 at 11:43 AM, Aaron Brady wrote: >> >>> We could use a Python long object for the version index to prevent >>> overflow. Combined with P. Rubin's idea to count the number

Re: set and dict iteration

2012-09-03 Thread Aaron Brady
On Monday, September 3, 2012 2:30:24 PM UTC-5, Ian wrote: > On Sun, Sep 2, 2012 at 11:43 AM, Aaron Brady wrote: > > > We could use a Python long object for the version index to prevent > > overflow. Combined with P. Rubin's idea to count the number of open > > iterators, most use cases still w

Re: tornado.web ioloop add_timeout eats CPU

2012-09-03 Thread Bryan
Laszlo Nagy wrote: [...] > And here is my problem. If I point 5 browsers to the server, then I get > 2% CPU load (Intel i5 2.8GHz on amd64 Linux). But why? Most of the time, > the server should be sleeping. cProfile tells this: > > ncalls tottime percall cumtime percall filename:lineno(func

Re: set and dict iteration

2012-09-03 Thread Ian Kelly
On Sun, Sep 2, 2012 at 11:43 AM, Aaron Brady wrote: > We could use a Python long object for the version index to prevent overflow. > Combined with P. Rubin's idea to count the number of open iterators, most use > cases still wouldn't exceed a single word comparison; we could reset the > counte

Re: simple client data base

2012-09-03 Thread Walter Hurry
On Mon, 03 Sep 2012 18:03:27 +0200, Wolfgang Keller wrote: >> Hello all, I am learning to program in python. I have a need to make a >> program that can store, retrieve, add, and delete client data such as >> name, address, social, telephone number and similar information. This >> would be a small

Re: Flexible string representation, unicode, typography, ...

2012-09-03 Thread Ian Kelly
On Sun, Sep 2, 2012 at 6:00 AM, Serhiy Storchaka wrote: > On 02.09.12 12:52, Peter Otten wrote: >> >> Ian Kelly wrote: >> >>> Rewriting the example to use locale.strcoll instead: >> >> >> sorted(li, key=functools.cmp_to_key(locale.strcoll)) >> >> >> There is also locale.strxfrm() which you can

Re: The opener parameter of Python 3 open() built-in

2012-09-03 Thread Serhiy Storchaka
On 03.09.12 16:29, Christian Heimes wrote: Am 03.09.2012 14:32, schrieb Marco: Does anyone have an example of utilisation? The opener argument is a new 3.3 feature. For example you can use the feature to implement exclusive creation of a file to avoid symlink attacks. Or you can use new dir_

Re: simple client data base

2012-09-03 Thread Wolfgang Keller
> Hello all, I am learning to program in python. I have a need to make a > program that can store, retrieve, add, and delete client data such as > name, address, social, telephone number and similar information. This > would be a small client database for my wife who has a home accounting > busines

Re: Flexible string representation, unicode, typography, ...

2012-09-03 Thread Serhiy Storchaka
On 03.09.12 09:15, Peter Otten wrote: wxjmfa...@gmail.com wrote: Le dimanche 2 septembre 2012 14:01:18 UTC+2, Serhiy Storchaka a écrit : Hmm, and with locale.strxfrm Python 3.3 20% slower than 3.2. With a memory gain = 0 since my text contains non-latin-1 characters! I can't confirm this.

Re: Flexible string representation, unicode, typography, ...

2012-09-03 Thread Serhiy Storchaka
On 03.09.12 04:54, Steven D'Aprano wrote: This means that Python 3.3 will no longer have surrogate pairs. Am I right? As Terry said, basically, yes. Python 3.3 does not need in surrogate pairs, but does not prevent their creation. You can create a surrogate code (U+D800..U+DFFF) intentionall

Re: simple client data base

2012-09-03 Thread Oscar Benjamin
On 3 September 2012 15:12, Mark R Rivet wrote: > Hello all, I am learning to program in python. I have a need to make a > program that can store, retrieve, add, and delete client data such as > name, address, social, telephone number and similar information. This > would be a small client databas

Re: Flexible string representation, unicode, typography, ...

2012-09-03 Thread Serhiy Storchaka
On 03.09.12 04:42, Steven D'Aprano wrote: If you are *seriously* interested in debugging why string code is slower for you, you can start by running the full suite of Python string benchmarks: see the stringbench benchmark in the Tools directory of source installations, or see here: http://hg.py

Re: Flexible string representation, unicode, typography, ...

2012-09-03 Thread Roy Smith
In article <50440de2$0$29967$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > > Indexing is O(0) for any string. > > I think you mean O(1) for constant-time lookups. Why settle for constant-time, when you can have zero-time instead :-) -- http://mail.python.org/mailman/listinfo/p

Re: Time Bound Input in python

2012-09-03 Thread Emile van Sebille
On 9/3/2012 3:01 AM Vikas Kumar Choudhary said... Hi I though of taking time bound input from user in python using "input" command. it waits fro infinite time , but I want to limit the time after that user input should expire with none. Please help. Googling yields http://stackoverflow.com/q

Re: simple client data base

2012-09-03 Thread Peter Otten
Chris Angelico wrote: > You may also be needlessly reinventing the wheel. Aren't there already > several million basic contact databases around? Why roll your own? To learn a thing or two, and to stick it to the defeatists ;) -- http://mail.python.org/mailman/listinfo/python-list

Re: simple client data base

2012-09-03 Thread Mark Lawrence
On 03/09/2012 15:12, Mark R Rivet wrote: Hello all, I am learning to program in python. I have a need to make a program that can store, retrieve, add, and delete client data such as name, address, social, telephone number and similar information. This would be a small client database for my wife

Re: simple client data base

2012-09-03 Thread Martin P. Hellwig
On Monday, 3 September 2012 15:12:21 UTC+1, Manatee wrote: > Hello all, I am learning to program in python. I have a need to make a > > program that can store, retrieve, add, and delete client data such as > > name, address, social, telephone number and similar information. This > > would be a

Re: simple client data base

2012-09-03 Thread Anoop Thomas Mathew
Hi, You can make use of sqlite database also. And for the structure, you can create a single table and different columns for the fields like name, number etc. You can get more details over here. http://docs.python.org/library/sqlite3.html Thanks, Anoop Thomas Mathew atm ___ Life is short, Live i

Re: simple client data base

2012-09-03 Thread Chris Angelico
On Tue, Sep 4, 2012 at 12:12 AM, Mark R Rivet wrote: > I have been reading about lists, tuples, and dictionary data > structures in python and I am confused as to which would be more > appropriate for a simple database. I think you're looking at this backwards. A database is for storing informati

simple client data base

2012-09-03 Thread loïc Lauréote
Hi, You can try gadfly ! This system is based on SQL. Loïc > From: markrri...@aol.com > Subject: simple client data base > Date: Mon, 3 Sep 2012 10:12:11 -0400 > To: python-list@python.org > > Hello all, I am learning to program in python. I have a need to make a > program that can store,

simple client data base

2012-09-03 Thread Mark R Rivet
Hello all, I am learning to program in python. I have a need to make a program that can store, retrieve, add, and delete client data such as name, address, social, telephone number and similar information. This would be a small client database for my wife who has a home accounting business. I have

Re: The opener parameter of Python 3 open() built-in

2012-09-03 Thread Marco
On 09/03/2012 03:05 PM, Dave Angel wrote: Does anyone have an example of utilisation? As of Python 3.2.3, there is no "opener" parameter in the open() function. http://docs.python.org/py3k/library/functions.html I don't know of any such parameter in earlier or later versions, but I coul

Re: The opener parameter of Python 3 open() built-in

2012-09-03 Thread Christian Heimes
Am 03.09.2012 14:32, schrieb Marco: > Does anyone have an example of utilisation? The opener argument is a new 3.3 feature. For example you can use the feature to implement exclusive creation of a file to avoid symlink attacks. import os def opener(file, flags): return os.open(file, flags |

Re: The opener parameter of Python 3 open() built-in

2012-09-03 Thread Dave Angel
On 09/03/2012 08:32 AM, Marco wrote: > Does anyone have an example of utilisation? As of Python 3.2.3, there is no "opener" parameter in the open() function. http://docs.python.org/py3k/library/functions.html I don't know of any such parameter in earlier or later versions, but I could be wron

Time Bound Input in python

2012-09-03 Thread Vikas Kumar Choudhary
Hi I though of taking time bound input from user in python using "input" command. it waits fro infinite time , but I want to limit the time after that user input should expire with none. Please help.   Thanks & Regard's Vikas Kumar Choudhary Mobile:91-7838594971/9886793145 http://in.linkedin.

The opener parameter of Python 3 open() built-in

2012-09-03 Thread Marco
Does anyone have an example of utilisation? -- http://mail.python.org/mailman/listinfo/python-list

Re: get the matched regular expression position in string.

2012-09-03 Thread Vlastimil Brom
2012/9/3 contro opinion : > Here is a string : > str1="ha,hihi,a,ok" > I want to get the position of "," in the str1,Which can count 3,8,14. > how can I get it in python ? > -- > http://mail.python.org/mailman/listinfo/python-list > Hi, you can use re.finditer to match all "," and the start()

Re: Looking for an IPC solution

2012-09-03 Thread Jean-Michel Pichavant
Laszlo Nagy wrote: There are just so many IPC modules out there. I'm looking for a solution for developing a new a multi-tier application. The core application will be running on a single computer, so the IPC should be using shared memory (or mmap) and have very short response times. But there

Re: Flexible string representation, unicode, typography, ...

2012-09-03 Thread Terry Reedy
On 9/3/2012 2:15 AM, Peter Otten wrote: At least users of wide builds will see a decrease in memory use: Everyone saves because everyone uses large parts of the stdlib. When 3.3 start up in a Windows console, there are 56 modules in sys.modules. With Idle, there are over 130. All the identifi

Re: get the matched regular expression position in string.

2012-09-03 Thread Chris Rebert
On Mon, Sep 3, 2012 at 1:18 AM, contro opinion wrote: > Subject: get the matched regular expression position in string. As is often the case in Python, string methods suffice. Particularly for something so simple, regexes aren't necessary. > Here is a string : > > str1="ha,hihi,a,ok" > > I w

Re: get the matched regular expression position in string.

2012-09-03 Thread Mark Lawrence
On 03/09/2012 09:18, contro opinion wrote: Here is a string : str1="ha,hihi,a,ok" I want to get the position of "," in the str1,Which can count 3,8,14. how can I get it in python ? Write some code using an appropriate string method. If it doesn't work put the minimum piece of code her

get the matched regular expression position in string.

2012-09-03 Thread contro opinion
Here is a string : str1="ha,hihi,a,ok" I want to get the position of "," in the str1,Which can count 3,8,14. how can I get it in python ? -- http://mail.python.org/mailman/listinfo/python-list

Re: Twisted 12.2.0 released

2012-09-03 Thread Godson Gera
On Sat, Sep 1, 2012 at 7:17 PM, Ashwini Oruganti wrote: > On behalf of Twisted Matrix Laboratories, I am honored to announce the > release of Twisted 12.2. > > Congrats, Ashwini. adoptStreamConnection is much needed feature, happy to see that added to this release. -- Thanks & Regards, Godson G