Re: Design thought for callbacks

2015-02-21 Thread Marko Rauhamaa
Steven D'Aprano : > Marko Rauhamaa wrote: >> Grant Edwards : >>> the polite thing to do is to delete references to it when you're done >>> with it. >> >> I disagree with that recommendation. You should do the natural thing and >> not care who holds references to who. > > I don't understand this.

Re: Design thought for callbacks

2015-02-21 Thread Ian Kelly
On Sat, Feb 21, 2015 at 1:57 PM, Grant Edwards wrote: > On 2015-02-21, Cem Karan wrote: >> >> On Feb 21, 2015, at 12:42 AM, Chris Angelico wrote: >> >>> On Sat, Feb 21, 2015 at 1:44 PM, Cem Karan wrote: In order to inform users that certain bits of state have changed, I require them

Re: Design thought for callbacks

2015-02-21 Thread Frank Millman
"Steven D'Aprano" wrote in message news:54e8af1b$0$12976$c3e8da3$54964...@news.astraweb.com... > Frank Millman wrote: > >> I tried something similar a while ago, and I did find a gotcha. >> >> The problem lies in this phrase - "if they are no longer alive, they are >> automatically removed from

Re: Design thought for callbacks

2015-02-21 Thread Chris Angelico
On Sun, Feb 22, 2015 at 3:38 PM, Steven D'Aprano wrote: > But you are using it. You might not be using it by name, but you are using > it via the callback function. What did you expect, that Python should read > your mind and somehow intuit that you still care about this socket > listener, but not

Re: How to design a search engine in Python?

2015-02-21 Thread subhabangalore
On Sunday, February 22, 2015 at 11:08:47 AM UTC+5:30, Denis McMahon wrote: > On Sat, 21 Feb 2015 21:02:34 -0800, subhabangalore wrote: > > > Thank you for your suggestion. But I was looking for a small tutorial of > > algorithm of the whole engine. I would try to check it build individual > > modu

Re: How to design a search engine in Python?

2015-02-21 Thread Denis McMahon
On Sat, 21 Feb 2015 21:02:34 -0800, subhabangalore wrote: > Thank you for your suggestion. But I was looking for a small tutorial of > algorithm of the whole engine. I would try to check it build individual > modules and integrate them. I was getting some in google and youtube, > but I tried to co

Re: How to design a search engine in Python?

2015-02-21 Thread subhabangalore
On Sunday, February 22, 2015 at 10:12:39 AM UTC+5:30, Steven D'Aprano wrote: > wrote: > > > Dear Group, > > > > I am trying to build a search engine in Python. > > How to design a search engine in Python? > > First, design a search engine. > > Then, write Python code to implement that search e

Re: How to design a search engine in Python?

2015-02-21 Thread Steven D'Aprano
subhabangal...@gmail.com wrote: > Dear Group, > > I am trying to build a search engine in Python. How to design a search engine in Python? First, design a search engine. Then, write Python code to implement that search engine. > To do this, I have read tutorials and working methodologies fro

Re: Design thought for callbacks

2015-02-21 Thread Steven D'Aprano
Chris Angelico wrote: > On Sun, Feb 22, 2015 at 1:04 PM, Steven D'Aprano > wrote: >> Marko Rauhamaa wrote: >> >>> Grant Edwards : >>> the polite thing to do is to delete references to it when you're done with it. >>> >>> I disagree with that recommendation. You should do the natural thi

Re: Algorithm for Creating Supersets of Smaller Sets Based on Common Elements

2015-02-21 Thread Steven D'Aprano
TommyVee wrote: > Start off with sets of elements as follows: > > 1. A,B,E,F > 2. G,H,L,P,Q > 3. C,D,E,F > 4. E,X,Z > 5. L,M,R > 6. O,M,Y > > Note that sets 1, 3 and 4 all have the element 'E' in common, therefore > they are "related" and form the following superset: > > A,B,C,D,E,F,X,Z Sounds

Re: Design thought for callbacks

2015-02-21 Thread Chris Angelico
On Sun, Feb 22, 2015 at 1:04 PM, Steven D'Aprano wrote: > Marko Rauhamaa wrote: > >> Grant Edwards : >> >>> the polite thing to do is to delete references to it when you're done >>> with it. >> >> I disagree with that recommendation. You should do the natural thing and >> not care who holds refere

Re: Design thought for callbacks

2015-02-21 Thread Steven D'Aprano
Marko Rauhamaa wrote: > Grant Edwards : > >> the polite thing to do is to delete references to it when you're done >> with it. > > I disagree with that recommendation. You should do the natural thing and > not care who holds references to who. I don't understand this. What is "the natural thing

Re: Algorithm for Creating Supersets of Smaller Sets Based on Common Elements

2015-02-21 Thread TommyVee
"TommyVee" wrote in message news:Bg5Gw.1344030$no4.494...@fx19.iad... Start off with sets of elements as follows: 1. A,B,E,F 2. G,H,L,P,Q 3. C,D,E,F 4. E,X,Z 5. L,M,R 6. O,M,Y Note that sets 1, 3 and 4 all have the element 'E' in common, therefore they are "related" and form the following supe

Re: pypandoc and restructured text

2015-02-21 Thread alb
Hi Chris, Chris Angelico wrote: [] >> Thanks a lot for the hint. Maybe I should seriously think about >> upgrading the whole distro. It's just that Gnome3 really sucks to my >> taste and I'm not in the mood to look for another Desktop >> Environment...(maybe I should go back to CDE). >> > > This

Re: Algorithm for Creating Supersets of Smaller Sets Based on Common Elements

2015-02-21 Thread Mark Lawrence
On 21/02/2015 19:46, TommyVee wrote: Start off with sets of elements as follows: 1. A,B,E,F 2. G,H,L,P,Q 3. C,D,E,F 4. E,X,Z 5. L,M,R 6. O,M,Y Note that sets 1, 3 and 4 all have the element 'E' in common, therefore they are "related" and form the following superset: A,B,C,D,E,F,X,Z Likewise,

Re: Design thought for callbacks

2015-02-21 Thread Marko Rauhamaa
Grant Edwards : > the polite thing to do is to delete references to it when you're done > with it. I disagree with that recommendation. You should do the natural thing and not care who holds references to who. Marko -- https://mail.python.org/mailman/listinfo/python-list

Re: Design thought for callbacks

2015-02-21 Thread Grant Edwards
On 2015-02-21, Cem Karan wrote: > > On Feb 21, 2015, at 12:42 AM, Chris Angelico wrote: > >> On Sat, Feb 21, 2015 at 1:44 PM, Cem Karan wrote: >>> In order to inform users that certain bits of state have changed, I require >>> them to register a callback with my code. The problem is that when

How to design a search engine in Python?

2015-02-21 Thread subhabangalore
Dear Group, I am trying to build a search engine in Python. To do this, I have read tutorials and working methodologies from web and books like Stanford IR book [ http://www-nlp.stanford.edu/IR-book/]. I know how to design a crawler, I know PostgresSql, I am fluent with PageRank, TF-IDF, Zipf

Re: subprocess command fails

2015-02-21 Thread Larry Hudson
On 02/20/2015 08:47 PM, Brad s wrote: [...] print("command = %r" % (cmdargv,)) sfmove = subprocess.call(cmdargv) also, is the % to Python what precision is to C++? No. It is like the % in C's printf(). -=- Larry -=- -- https://mail.python.org/mailman/listinfo/python-list

Re: Algorithm for Creating Supersets of Smaller Sets Based on Common Elements

2015-02-21 Thread Dave Angel
On 02/21/2015 02:46 PM, TommyVee wrote: Start off with sets of elements as follows: 1. A,B,E,F 2. G,H,L,P,Q 3. C,D,E,F 4. E,X,Z 5. L,M,R 6. O,M,Y Note that sets 1, 3 and 4 all have the element 'E' in common, therefore they are "related" and form the following superset: A,B,C,D,E,F,X,Z Likewis

Re: Algorithm for Creating Supersets of Smaller Sets Based on Common Elements

2015-02-21 Thread Ethan Furman
On 02/21/2015 11:46 AM, TommyVee wrote: > Start off with sets of elements as follows: > > 1. A,B,E,F > 2. G,H,L,P,Q > 3. C,D,E,F > 4. E,X,Z > 5. L,M,R > 6. O,M,Y > > Note that sets 1, 3 and 4 all have the element 'E' in common, therefore they > are "related" and form the following superset: > >

Re: Algorithm for Creating Supersets of Smaller Sets Based on Common Elements

2015-02-21 Thread Joel Goldstick
On Sat, Feb 21, 2015 at 2:46 PM, TommyVee wrote: > Start off with sets of elements as follows: > > 1. A,B,E,F > 2. G,H,L,P,Q > 3. C,D,E,F > 4. E,X,Z > 5. L,M,R > 6. O,M,Y > > Note that sets 1, 3 and 4 all have the element 'E' in common, therefore they > are "related" and form the following superse

Algorithm for Creating Supersets of Smaller Sets Based on Common Elements

2015-02-21 Thread TommyVee
Start off with sets of elements as follows: 1. A,B,E,F 2. G,H,L,P,Q 3. C,D,E,F 4. E,X,Z 5. L,M,R 6. O,M,Y Note that sets 1, 3 and 4 all have the element 'E' in common, therefore they are "related" and form the following superset: A,B,C,D,E,F,X,Z Likewise, sets 2 and 5 have the element 'L' in

Re: 'Lite' Databases (Re: sqlite3 and dates)

2015-02-21 Thread Eric S. Johansson
On 02/21/2015 01:22 AM, Ned Deily wrote: SQLite is one of the most widely-used, best-documented, best-tested, and well-respected software packages in the world. yes but is still sql. there are a couple of small scale not-sql databases that look interesting. problem with them is that the crea

Re: Accessible tools

2015-02-21 Thread Tim Chase
On 2015-02-21 10:21, Bryan Duarte wrote: > those of us who rely on screen readers to interact with our > computers have a few things we do, and tend to not do. [snip] While my experience has shown most of your items to be true, I'd contend that >• Do not, have access to debugging tools. is mist

Re: Design thought for callbacks

2015-02-21 Thread Steven D'Aprano
Cem Karan wrote: > > On Feb 21, 2015, at 8:15 AM, Chris Angelico wrote: > >> On Sun, Feb 22, 2015 at 12:13 AM, Cem Karan wrote: >>> OK, so it would violate the principle of least surprise for you. >>> Interesting. Is this a general pattern in python? That is, callbacks >>> are owned by what

Re: Accessible tools

2015-02-21 Thread Bryan Duarte
Tim, I am also on the blind linux list. I do not often post there as I predominately use a Mac and the Unix terminal but I am using Linux Kali on the side for some side tinkering and learning. I would use Linux a lot more if the screen reader was not so robotic... Would you be willing to be inc

Re: Accessible tools

2015-02-21 Thread Bryan Duarte
Eric, Although I would most likely enjoy the former option I feel the latter would be most appropriate for contacting you. Thanks for getting back to me and explaining some of this. I will contact you off list for sure so as not to fill up the lists mailboxes with this topic. I will say that

Re: Best practice: Sharing object between different objects

2015-02-21 Thread Paul Rubin
pfranke...@gmail.com writes: > ADC, DAC components. As I said, I would like to derive the > corresponding classes from one common class, let's say I2CDevice, so > that they can share the same bus connection (I don't want to do a > import smbus, ..., self.bus = smbus.SMBus(1) all the time). I don'

Re: Design thought for callbacks

2015-02-21 Thread Marko Rauhamaa
Steven D'Aprano : > Other than that, I cannot see how calling a function which has *not* > yet been garbage collected can fail, just because the only reference > still existing is a weak reference. Maybe the logic of the receiving object isn't prepared for the callback anymore after an intervenin

Re: try pattern for database connection with the close method

2015-02-21 Thread Peter Otten
Ian Kelly wrote: > On Sat, Feb 21, 2015 at 8:27 AM, Peter Otten <__pete...@web.de> wrote: >> Ian Kelly wrote: >> >>> On Sat, Feb 21, 2015 at 5:22 AM, Mark Lawrence >>> wrote: try: with lite.connect('data.db') as db: try: db.execute(sql, parms) except l

Re: Design thought for callbacks

2015-02-21 Thread Steven D'Aprano
Frank Millman wrote: > I tried something similar a while ago, and I did find a gotcha. > > The problem lies in this phrase - "if they are no longer alive, they are > automatically removed from the WeakSet, preventing me from accidentally > calling them when they are dead." > > I found that the r

Re: Design thought for callbacks

2015-02-21 Thread Marko Rauhamaa
Chris Angelico : > On Sat, Feb 21, 2015 at 1:44 PM, Cem Karan wrote: >> In order to inform users that certain bits of state have changed, I >> require them to register a callback with my code. The problem is that >> when I store these callbacks, it naturally creates a strong reference >> to the

Re: Design thought for callbacks

2015-02-21 Thread Chris Angelico
On Sun, Feb 22, 2015 at 2:45 AM, Cem Karan wrote: > OK, so if I'm reading your code correctly, you're breaking the cycle in your > object graph by making the GUI the owner of the callback, correct? No other > chunk of code has a reference to the callback, correct? Correct. The GUI engine ultim

Re: try pattern for database connection with the close method

2015-02-21 Thread Ian Kelly
On Sat, Feb 21, 2015 at 8:27 AM, Peter Otten <__pete...@web.de> wrote: > Ian Kelly wrote: > >> On Sat, Feb 21, 2015 at 5:22 AM, Mark Lawrence >> wrote: >>> try: >>> with lite.connect('data.db') as db: >>> try: >>> db.execute(sql, parms) >>> except lite.IntegrityError: >>>

Re: Design thought for callbacks

2015-02-21 Thread Cem Karan
On Feb 21, 2015, at 9:36 AM, Chris Angelico wrote: > On Sun, Feb 22, 2015 at 1:07 AM, Cem Karan wrote: >> I agree about closures; its the only way they could work. When I was >> originally thinking about the library, I was trying to include all types of >> callbacks, including closures and c

Re: try pattern for database connection with the close method

2015-02-21 Thread Peter Otten
Ian Kelly wrote: > On Sat, Feb 21, 2015 at 5:22 AM, Mark Lawrence > wrote: >> On 21/02/2015 02:42, Mario Figueiredo wrote: >>> >>> Hello all, >>> >>> I'm using the following pattern for db access that requires me to >>> close the connection as soon as it is not needed: >>> >>> import sq

Re: try pattern for database connection with the close method

2015-02-21 Thread Peter Otten
Mario Figueiredo wrote: > Hello all, > > I'm using the following pattern for db access that requires me to > close the connection as soon as it is not needed: > > import sqlite3 as lite > > try: > db = lite.connect('data.db') > except lite.DatabaseError: >

Re: try pattern for database connection with the close method

2015-02-21 Thread Ian Kelly
On Sat, Feb 21, 2015 at 5:22 AM, Mark Lawrence wrote: > On 21/02/2015 02:42, Mario Figueiredo wrote: >> >> Hello all, >> >> I'm using the following pattern for db access that requires me to >> close the connection as soon as it is not needed: >> >> import sqlite3 as lite >> >> t

Re: Python path on windows

2015-02-21 Thread Chris Angelico
On Sun, Feb 22, 2015 at 1:10 AM, Dave Angel wrote: > But you could always write your own py.exe, which interprets the shebang > differently. > > Or run python.exe yourself, which as far as I know, pays no attention to > shebang lines. Or, my preferred solution: Fix the shebangs :) It's usually no

Re: Design thought for callbacks

2015-02-21 Thread Chris Angelico
On Sun, Feb 22, 2015 at 1:07 AM, Cem Karan wrote: > I agree about closures; its the only way they could work. When I was > originally thinking about the library, I was trying to include all types of > callbacks, including closures and callable objects. The callable objects may > pass themselv

Re: Best practice: Sharing object between different objects

2015-02-21 Thread Dave Angel
On 02/21/2015 07:15 AM, pfranke...@gmail.com wrote: Hello! I have a best-practice question: Imagine I have several hardware devices that I work with on the same I2C bus and I am using the python smbus module for that purpose. The individual devices are sensors, ADC, DAC components. As I said,

Re: Design thought for callbacks

2015-02-21 Thread Devin Jeanpierre
On Fri, Feb 20, 2015 at 9:42 PM, Chris Angelico wrote: > No, it's not. I would advise using strong references - if the callback > is a closure, for instance, you need to hang onto it, because there > are unlikely to be any other references to it. If I register a > callback with you, I expect it to

Re: Design thought for callbacks

2015-02-21 Thread Cem Karan
On Feb 21, 2015, at 8:37 AM, Mark Lawrence wrote: > On 21/02/2015 05:41, Frank Millman wrote: >> >> "Cem Karan" wrote in message >> news:33677ae8-b2fa-49f9-9304-c8d937842...@gmail.com... >>> Hi all, I'm working on a project that will involve the use of callbacks, >>> and I want to bounce an id

Re: Python path on windows

2015-02-21 Thread Dave Angel
On 02/21/2015 06:05 AM, Gisle Vanem wrote: Dave Angel wrote: Finally, when py.exe starts, it reads that first (shebang) line, and decides which python interpreter to actually use. py.exe? Do you mean python.exe? Reread my post, or read Mark's reply to yours. The job of py.exe or pyw.exe i

Re: Design thought for callbacks

2015-02-21 Thread Cem Karan
On Feb 21, 2015, at 8:15 AM, Chris Angelico wrote: > On Sun, Feb 22, 2015 at 12:13 AM, Cem Karan wrote: >> OK, so it would violate the principle of least surprise for you. >> Interesting. Is this a general pattern in python? That is, callbacks are >> owned by what they are registered with?

Re: pypandoc and restructured text

2015-02-21 Thread Chris Angelico
On Sun, Feb 22, 2015 at 12:39 AM, alb wrote: > Hi Wolfgang, > > Wolfgang Maier wrote: > [] >> I have pandoc 1.12.2.1 and it recognizes the figure directive just fine >> (tested with html output so I cannot say anything about LaTeX). > > This reminds me that I need to move sooner or later from squ

Re: pypandoc and restructured text

2015-02-21 Thread Fabien
On 21.02.2015 14:39, alb wrote: Do you know of anyway to install wheezy packages on squeeze? No need for a new distro. Use virtualenv, this is simple and great: http://simononsoftware.com/virtualenv-tutorial-part-2/ Cheers, Fabien -- https://mail.python.org/mailman/listinfo/python-list

Re: pypandoc and restructured text

2015-02-21 Thread alb
Hi Wolfgang, Wolfgang Maier wrote: [] > I have pandoc 1.12.2.1 and it recognizes the figure directive just fine > (tested with html output so I cannot say anything about LaTeX). This reminds me that I need to move sooner or later from squeeze to wheezy... Do you know of anyway to install whee

Re: Design thought for callbacks

2015-02-21 Thread Mark Lawrence
On 21/02/2015 05:41, Frank Millman wrote: "Cem Karan" wrote in message news:33677ae8-b2fa-49f9-9304-c8d937842...@gmail.com... Hi all, I'm working on a project that will involve the use of callbacks, and I want to bounce an idea I had off of everyone to make sure I'm not developing a bad idea.

Re: Design thought for callbacks

2015-02-21 Thread Cem Karan
On Feb 21, 2015, at 12:41 AM, Frank Millman wrote: > > "Cem Karan" wrote in message > news:33677ae8-b2fa-49f9-9304-c8d937842...@gmail.com... >> Hi all, I'm working on a project that will involve the use of callbacks, >> and I want to bounce an idea I had off of everyone to make sure I'm not

Re: Design thought for callbacks

2015-02-21 Thread Chris Angelico
On Sun, Feb 22, 2015 at 12:13 AM, Cem Karan wrote: > OK, so it would violate the principle of least surprise for you. > Interesting. Is this a general pattern in python? That is, callbacks are > owned by what they are registered with? > > In the end, I want to make a library that offers as fe

Re: Design thought for callbacks

2015-02-21 Thread Cem Karan
On Feb 21, 2015, at 12:42 AM, Chris Angelico wrote: > On Sat, Feb 21, 2015 at 1:44 PM, Cem Karan wrote: >> In order to inform users that certain bits of state have changed, I require >> them to register a callback with my code. The problem is that when I store >> these callbacks, it naturall

Re: Python path on windows

2015-02-21 Thread Mark Lawrence
On 21/02/2015 11:05, Gisle Vanem wrote: Dave Angel wrote: Finally, when py.exe starts, it reads that first (shebang) line, and decides which python interpreter to actually use. py.exe? Do you mean python.exe? py.exe or pyw.exe come with the Python launcher on Windows and work out which ve

Best practice: Sharing object between different objects

2015-02-21 Thread pfranken85
Hello! I have a best-practice question: Imagine I have several hardware devices that I work with on the same I2C bus and I am using the python smbus module for that purpose. The individual devices are sensors, ADC, DAC components. As I said, I would like to derive the corresponding classes from

Re: try pattern for database connection with the close method

2015-02-21 Thread Mark Lawrence
On 21/02/2015 02:42, Mario Figueiredo wrote: Hello all, I'm using the following pattern for db access that requires me to close the connection as soon as it is not needed: import sqlite3 as lite try: db = lite.connect('data.db') except lite.DatabaseErro

Re: Python path on windows

2015-02-21 Thread Gisle Vanem
Dave Angel wrote: Finally, when py.exe starts, it reads that first (shebang) line, and decides which python interpreter to actually use. py.exe? Do you mean python.exe? Is there a way to make python.exe ignore all Shebang lines in all scripts? I had many generated .py-files with: #!g:\Prog

Re: 'Lite' Databases (Re: sqlite3 and dates)

2015-02-21 Thread Sibylle Koczian
Am 20.02.2015 um 15:16 schrieb Dennis Lee Bieber: The middle-ground is probably something like the embedded version of Firebird (pity there has been no updated book -- "The Firebird Book" came out in 2004, v1.5 while 2.5 is current [Whoops, looks like there /is/ an update, print-on-deman

Re: 'Lite' Databases (Re: sqlite3 and dates)

2015-02-21 Thread Paul Rubin
Ned Deily writes: >> Same reason lots of people have forked Postgres. Or you might just want >> to customize it. > Well, for whatever reason one might have, one can: it's public domain > software. Yes, but unlike with most FOSS software, your version has much lower quality assurance than the "o

Re: 'Lite' Databases (Re: sqlite3 and dates)

2015-02-21 Thread Ned Deily
In article <871tljepea@jester.gateway.pace.com>, Paul Rubin wrote: > Ned Deily writes: > > (though I don't know why anyone would want to fork it). > > Same reason lots of people have forked Postgres. Or you might just want > to customize it. Well, for whatever reason one might have, on