Re: object.enable() anti-pattern

2013-05-08 Thread Terry Jan Reedy
On 5/9/2013 1:23 AM, Steven D'Aprano wrote: Besides, this is not to denigrate the idea of a read() function that takes a filename and returns its contents. But that is not an object constructor. It may construct a file object internally, but it doesn't return the file object, so it is completely

Append to python List

2013-05-08 Thread RAHUL RAJ
Checkout the following code: sample2 = [x+y for x in range(1,10) for y in range(1,10) if x!=y] output=[] output=[x for x in sample2 if x not in output] the output I get is 3 4 5 6 7 8 9 10 3 5 6 7 8 9 10 11 4 5 7 8 9 10 11 12 5 6 7 9 10 11 12 13 6 7 8 9 11 12 13 14 7 8 9 10 11 13 14 15 8 9 10

Re: Help with implementing callback functions using ctypes

2013-05-08 Thread dieter
jamadagni writes: > ... I cannot help you with "ctypes". But, if you might be able to use "cython", then calling callbacks is not too difficult (you can find an example in e.g. my "dm.xmlsec.binding"). Note, however, that properly handling the GIL ("Global Interpreter Lock") may be of great impor

Re: object.enable() anti-pattern

2013-05-08 Thread Chris Angelico
On Thu, May 9, 2013 at 3:37 PM, Steven D'Aprano wrote: > I can see use-cases for separating "make it go" from initialisation. It > all depends on what you might want to do to the object before making it > go. If the answer is "Nothing", then there is no reason not to have the > constructor make it

Re: Message passing syntax for objects | OOPv2

2013-05-08 Thread Steven D'Aprano
On Wed, 08 May 2013 19:35:58 -0700, Mark Janssen wrote: > Long story short: the lambda > calculus folks have to split from the Turing machine folks. > These models of computation should not use the same language. Their > computation models are too radically different. Their computation models

Re: object.enable() anti-pattern

2013-05-08 Thread Steven D'Aprano
On Thu, 09 May 2013 02:38:36 +, Dan Sommers wrote: > Think of spinning off a thread: initialize it synchronously, and then > let it execute asynchronously. We tend towards that pattern even when > we know that execution will be synchronous, because we also that it > could be asynchronous one

Re: object.enable() anti-pattern

2013-05-08 Thread Steven D'Aprano
On Thu, 09 May 2013 02:42:01 +, Dan Sommers wrote: > On Wed, 08 May 2013 08:52:12 +, Steven D'Aprano wrote: > >> This is an anti-pattern to avoid. The idea is that creating a resource >> ought to be the same as "turning it on", or enabling it, or similar. >> For example, we don't do this

Re: Red Black Tree implementation?

2013-05-08 Thread duncan smith
On 09/05/13 02:40, Dan Stromberg wrote: OK, I've got one copy of trees.py with md5 211f80c0fe7fb9cb42feb9645b4b3ffe. You seem to be saying I should have two though, but I don't know that I do... I've just re-sent it. Duncan -- http://mail.python.org/mailman/listinfo/python-list

Anybody familiar with pygments ?

2013-05-08 Thread dabaichi
Hello guys: pygments version: 1.6 python version :3.3.1(64bits, use msi installer install) os:windows 7 (64bits) Hereis my python source code: #!/usr/bin/env python #-*- coding=utf-8 -*- import os import sys from pygments import highlight as html_highlight from pygments.lexers import get_lexer_b

Re: Message passing syntax for objects | OOPv2

2013-05-08 Thread Mark Janssen
> "Lisp will remain the pinnacle of lambda calculus" ??? : Surreal > feeling of falling into a 25-year time-warp > > Read this http://www.cs.kent.ac.uk/people/staff/dat/miranda/wadler87.pdf > > Just for historical context: > When this was written in the 80s: > - The FP languages of the time -- KRC

Re: Message passing syntax for objects | OOPv2

2013-05-08 Thread rusi
On May 9, 7:35 am, Mark Janssen wrote: > On Fri, Apr 12, 2013 at 11:28 PM, Mark Janssen > > wrote: > >> Mark, this proposal is out of place on a Python list, because it proposes > >> an > >> object methodology radically different from any that is implemented in > >> Python now, or is even remote

Re: object.enable() anti-pattern

2013-05-08 Thread Steven D'Aprano
On Wed, 08 May 2013 14:27:53 +, Duncan Booth wrote: > Steven D'Aprano wrote: > >> I'm looking for some help in finding a term, it's not Python-specific >> but does apply to some Python code. >> >> This is an anti-pattern to avoid. The idea is that creating a resource >> ought to be the same

Re: Making safe file names

2013-05-08 Thread Steven D'Aprano
On Wed, 08 May 2013 21:11:28 -0500, Andrew Berg wrote: > It's a thing (especially in witch house) to make names with odd glyphs > in order to be harder to find and be more "underground". Very silly. Try > doing searches for these artists with names like these: Challenge accepted. > http://www.la

Re: object.enable() anti-pattern

2013-05-08 Thread Mark Janssen
>> This is an anti-pattern to avoid. The idea is that creating a resource >> ought to be the same as "turning it on", or enabling it, or similar. For >> example, we don't do this in Python: > > I would call it "user-mediated resource allocation" as distinct from > "object-mediated" resource allocat

Re: object.enable() anti-pattern

2013-05-08 Thread Mark Janssen
> I'm looking for some help in finding a term, it's not Python-specific but > does apply to some Python code. > > This is an anti-pattern to avoid. The idea is that creating a resource > ought to be the same as "turning it on", or enabling it, or similar. For > example, we don't do this in Python:

Re: object.enable() anti-pattern

2013-05-08 Thread Dan Sommers
On Wed, 08 May 2013 08:52:12 +, Steven D'Aprano wrote: > This is an anti-pattern to avoid. The idea is that creating a resource > ought to be the same as "turning it on", or enabling it, or similar. For > example, we don't do this in Python: > > f = file("some_file.txt") > f.open() > data =

Re: object.enable() anti-pattern

2013-05-08 Thread Dan Sommers
On Wed, 08 May 2013 14:27:53 +, Duncan Booth wrote: > Steven D'Aprano wrote: >> I'm looking for some help in finding a term, it's not Python-specific >> but does apply to some Python code. >> >> This is an anti-pattern to avoid. The idea is that creating a >> resource ought to be the same a

Re: Message passing syntax for objects | OOPv2

2013-05-08 Thread Mark Janssen
On Fri, Apr 12, 2013 at 11:28 PM, Mark Janssen wrote: >> Mark, this proposal is out of place on a Python list, because it proposes an >> object methodology radically different from any that is implemented in >> Python now, or is even remotely likely to be implemented in Python in the >> future. >

Re: Making safe file names

2013-05-08 Thread Andrew Berg
On 2013.05.08 19:16, Roy Smith wrote: > Yup. At Songza, we deal with this crap every day. It usually bites us > the worst when trying to do keyword searches. When somebody types in > "Blue Oyster Cult", they really mean "Blue Oyster Cult", and our search > results need to reflect that. Likew

Re: Making safe file names

2013-05-08 Thread Roy Smith
In article <518b00a2$0$29997$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > > When somebody types in > > "Blue Oyster Cult", they really mean "Blue Oyster Cult", > > Surely they really mean Blue Öyster Cult. Yes. The oomlaut was there when I typed it. Who knows what happened

Re: Making safe file names

2013-05-08 Thread Steven D'Aprano
On Wed, 08 May 2013 20:16:25 -0400, Roy Smith wrote: > Yup. At Songza, we deal with this crap every day. It usually bites us > the worst when trying to do keyword searches. When somebody types in > "Blue Oyster Cult", they really mean "Blue Oyster Cult", Surely they really mean Blue Öyster Cu

Re: Red Black Tree implementation?

2013-05-08 Thread Dan Stromberg
OK, I've got one copy of trees.py with md5 211f80c0fe7fb9cb42feb9645b4b3ffe. You seem to be saying I should have two though, but I don't know that I do... On 5/8/13, duncan smith wrote: > On 07/05/13 02:20, Dan Stromberg wrote: >> >> On Mon, May 6, 2013 at 5:55 PM, duncan smith >

Re: Style question -- plural of class name?

2013-05-08 Thread Cameron Simpson
On 09May2013 00:02, Steven D'Aprano wrote: | On Wed, 08 May 2013 16:20:48 -0400, Roy Smith wrote: | > "A list of FooEntry's" | | "Here come's an S! Quick, jam on an apostrophe!" | | This is called the grocer's apostrophe, and is universally held in | contempt no matter what variant of English

Re: Style question -- plural of class name?

2013-05-08 Thread Colin J. Williams
On 08/05/2013 4:20 PM, Roy Smith wrote: FooEntry is a class. How would you describe a list of these in a docstring? "A list of FooEntries" 0 "A list of FooEntrys" -1 "A list of FooEntry's" +1 "A list of FooEntry instances" No FooEntry is specified as a class. The first one certainly so

Re: Making safe file names

2013-05-08 Thread Chris Angelico
On Thu, May 9, 2013 at 10:16 AM, Roy Smith wrote: > Pro-tip, guys. If you want to form a band, and expect people to be able > to find your stuff in a search engine some day, don't play cute with > your name. It's the modern equivalent of names like Catherine Withekay. ChrisA -- http://mail.pyt

Re: Making safe file names

2013-05-08 Thread Roy Smith
In article , Dennis Lee Bieber wrote: > On Tue, 07 May 2013 18:10:25 -0500, Andrew Berg > declaimed the following in > gmane.comp.python.general: > > > None of these would work because I would have no idea which file stores > > data for which artist without writing code to figure it out. If I

Re: Style question -- plural of class name?

2013-05-08 Thread Steven D'Aprano
On Wed, 08 May 2013 15:33:07 -0500, Skip Montanaro wrote: > This one: > >> "A list of FooEntry instances" > > Besides the obvious spelling issues in the others, it's not immediately > clear if the list contains just FooEntry instances, FooEntry classes > (perhaps subclasses) or a mix of the two.

Re: help on Implementing a list of dicts with no data pattern

2013-05-08 Thread MRAB
On 09/05/2013 00:47, rlelis wrote: Hi guys, I'm working on this long file, where i have to keep reading and storing different excerpts of text (data) in different variables (list). Once done that i want to store in dicts the data i got from the lists mentioned before. I want them on a list of

Re: Style question -- plural of class name?

2013-05-08 Thread Chris Angelico
On Thu, May 9, 2013 at 6:20 AM, Roy Smith wrote: > "A list of FooEntry's" Only if you put another apostrophe in: "A list of 'FooEntry's" But the delimited style is almost never of use. I'd go for this only if there were some sort of automated markup being applied - if the word FooEntry were tur

Re: help on Implementing a list of dicts with no data pattern

2013-05-08 Thread Dave Angel
On 05/08/2013 07:47 PM, rlelis wrote: Hi guys, Please read this http://wiki.python.org/moin/GoogleGroupsPython. I'm working on this long file, where i have to keep reading and storing different excerpts of text (data) in different variables (list). Once done that i want to store in dicts t

Re: cello library

2013-05-08 Thread Chris Angelico
On Thu, May 9, 2013 at 7:06 AM, Terry Jan Reedy wrote: > Legitimate request, like some I have made of others. Since I trust Mark: It's actually nothing to do with trusting Mark. I've often seen posts from addresses of people I trust, but with links that I definitely would not want to click... and

Re: Style question -- plural of class name?

2013-05-08 Thread Steven D'Aprano
On Wed, 08 May 2013 16:20:48 -0400, Roy Smith wrote: > FooEntry is a class. How would you describe a list of these in a > docstring? Which language are you writing your docstrings in? Obey the normal rules of spelling, grammar and punctuation for your language, which I assume is English. >

help on Implementing a list of dicts with no data pattern

2013-05-08 Thread rlelis
Hi guys, I'm working on this long file, where i have to keep reading and storing different excerpts of text (data) in different variables (list). Once done that i want to store in dicts the data i got from the lists mentioned before. I want them on a list of dicts for later RDBMs purpose's. The

Re: Red Black Tree implementation?

2013-05-08 Thread duncan smith
On 07/05/13 02:20, Dan Stromberg wrote: On Mon, May 6, 2013 at 5:55 PM, duncan smith mailto:buzzard@invalid.invalid>> wrote: [snip] I'd prefer Apache or MIT or BSD 3-clause, but I could probably work with this. http://joinup.ec.europa.eu/community/eupl/news/licence-proliferation-way-out

Re: Get filename using filefialog.askfilename

2013-05-08 Thread Dave Angel
On 05/08/2013 04:14 PM, cheirasa...@gmail.com wrote: El martes, 7 de mayo de 2013 23:53:32 UTC+2, Terry Jan Reedy escribió: On 5/7/2013 4:27 PM, cheirasa...@gmail.com wrote: Yeah. This is an answer. A lot of thanks. For a moment there, I thought you were being sarcastic, and ungra

Re: Style question -- plural of class name?

2013-05-08 Thread Denis McMahon
On Wed, 08 May 2013 16:20:48 -0400, Roy Smith wrote: > FooEntry is a class. How would you describe a list of these in a > docstring? > > "A list of FooEntries" > > "A list of FooEntrys" > > "A list of FooEntry's" > > "A list of FooEntry instances" > > The first one certainly sounds the best,

Re: Globally available I/O connection (K8055 I/O board)

2013-05-08 Thread Dave Angel
On 05/08/2013 04:50 PM, flex...@gmail.com wrote: I'm having a bit of an issue trying to make a globally available connection to my Velleman K8055 I/O board... I've documented my issue as best I can here: http://stackoverflow.com/questions/16449706/python-access-global-instance-of-connection

Re: cello library

2013-05-08 Thread Terry Jan Reedy
On 5/8/2013 6:01 AM, Chris Angelico wrote: On Wed, May 8, 2013 at 7:39 PM, Mark Lawrence wrote: Hi folks, I thought some of you might find this interesting [link redacted] Unredacted: http://libcello.org/ If this is a legit post, can you please elaborate on just _why_ we would find it inte

Globally available I/O connection (K8055 I/O board)

2013-05-08 Thread flexage
I'm having a bit of an issue trying to make a globally available connection to my Velleman K8055 I/O board... I've documented my issue as best I can here: http://stackoverflow.com/questions/16449706/python-access-global-instance-of-connection Could anybody shed some light on a way to combat my

Re: Style question -- plural of class name?

2013-05-08 Thread Ian Kelly
On Wed, May 8, 2013 at 2:37 PM, John Downs wrote: > On Wed, May 8, 2013 at 4:20 PM, Roy Smith wrote: >> >> FooEntry is a class. How would you describe a list of these in a >> docstring? >> >> "A list of FooEntries" >> >> "A list of FooEntrys" >> >> "A list of FooEntry's" >> >> "A list of FooEntr

Re: Style question -- plural of class name?

2013-05-08 Thread John Downs
On Wed, May 8, 2013 at 4:20 PM, Roy Smith wrote: > FooEntry is a class. How would you describe a list of these in a > docstring? > > "A list of FooEntries" > > "A list of FooEntrys" > > "A list of FooEntry's" > > "A list of FooEntry instances" > > The first one certainly sounds the best, but it

Re: Style question -- plural of class name?

2013-05-08 Thread Skip Montanaro
This one: > "A list of FooEntry instances" Besides the obvious spelling issues in the others, it's not immediately clear if the list contains just FooEntry instances, FooEntry classes (perhaps subclasses) or a mix of the two. #4 makes it clear. Skip -- http://mail.python.org/mailman/listinfo/p

Style question -- plural of class name?

2013-05-08 Thread Roy Smith
FooEntry is a class. How would you describe a list of these in a docstring? "A list of FooEntries" "A list of FooEntrys" "A list of FooEntry's" "A list of FooEntry instances" The first one certainly sounds the best, but it seems wierd to change the spelling of the class name to make it plural

Re: Get filename using filefialog.askfilename

2013-05-08 Thread cheirasacan
El martes, 7 de mayo de 2013 23:53:32 UTC+2, Terry Jan Reedy escribió: > On 5/7/2013 4:27 PM, cheirasa...@gmail.com wrote: > > > > > file = filedialog.askopenfile ( mode... ) > > > > askopenfile is a convenience function that creates an Open dialog > > object, shows it, gets the name r

ANN: MacroPy: quasiquotes, case classes, LINQ and more! Now available on PyPI

2013-05-08 Thread Haoyi Li
Hey All, MacroPy is an implementation of Macros in Python which lets you very easily modify the semantics of a python program. Apart from the implementation of macros themselves, we also have a pretty impressive list of feature demos that were implemented on top of macros: - Quasiquotes, a qui

Re: MySQL Database

2013-05-08 Thread Kevin Holleran
Thanks, I actually intend to, was just whipping something up to be an example for my question. -- Kevin Holleran Master of Science, Computer Information Systems Grand Valley State University Master of Business Administration Western Michigan University GCFA, GCFE, CCNA, ISA, MCSA, MCDST, MCP "

Re: MySQL Database

2013-05-08 Thread MRAB
On 08/05/2013 19:52, Kevin Holleran wrote: Hello, I want to connect to a MySQL database, query for some records, manipulate some data, and then update the database. When I do something like this: db_c.execute("SELECT a, b FROM Users") for row in db_c.fetchall(): (r,d) = row[0].

Re: MySQL Database

2013-05-08 Thread Kevin Holleran
On Wed, May 8, 2013 at 2:56 PM, Chris Angelico wrote: > On Thu, May 9, 2013 at 4:52 AM, Kevin Holleran wrote: > > Will using db_c to update the database mess up the loop that is cycling > > through db_c.fetchall()? > > Nope; fetchall() returns a list, which you're then iterating over. > Nothing

Re: MySQL Database

2013-05-08 Thread Chris Angelico
On Thu, May 9, 2013 at 4:52 AM, Kevin Holleran wrote: > Will using db_c to update the database mess up the loop that is cycling > through db_c.fetchall()? Nope; fetchall() returns a list, which you're then iterating over. Nothing the database does can disrupt that. ChrisA -- http://mail.python.

MySQL Database

2013-05-08 Thread Kevin Holleran
Hello, I want to connect to a MySQL database, query for some records, manipulate some data, and then update the database. When I do something like this: db_c.execute("SELECT a, b FROM Users") for row in db_c.fetchall(): (r,d) = row[0].split('|') (g,e) = domain.split('.

Re: Unicode humor

2013-05-08 Thread Christian Gollwitzer
Am 08.05.13 15:19, schrieb Roy Smith: Apropos to any of the myriad unicode threads that have been going on recently: http://xkcd.com/1209/ http://xkcd.com/1137/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Unicode humor

2013-05-08 Thread Sven
I saw this this morning and the first thing I thought of was this list... unlike you I was too lazy to post it :) On 8 May 2013 14:19, Roy Smith wrote: > Apropos to any of the myriad unicode threads that have been going on > recently: > > http://xkcd.com/1209/ > -- > http://mail.python.org/mai

Re: object.enable() anti-pattern

2013-05-08 Thread Duncan Booth
Steven D'Aprano wrote: > I'm looking for some help in finding a term, it's not Python-specific > but does apply to some Python code. > > This is an anti-pattern to avoid. The idea is that creating a resource > ought to be the same as "turning it on", or enabling it, or similar I've come across

Re: object.enable() anti-pattern

2013-05-08 Thread Roy Smith
In article <518a123c$0$11094$c3e8...@news.astraweb.com>, Steven D'Aprano wrote: > I'm looking for some help in finding a term, it's not Python-specific but > does apply to some Python code. > > This is an anti-pattern to avoid. The idea is that creating a resource > ought to be the same as "t

Unicode humor

2013-05-08 Thread Roy Smith
Apropos to any of the myriad unicode threads that have been going on recently: http://xkcd.com/1209/ -- http://mail.python.org/mailman/listinfo/python-list

Re: object.enable() anti-pattern

2013-05-08 Thread Steven D'Aprano
On Wed, 08 May 2013 11:13:33 +0100, Robert Kern wrote: > On 2013-05-08 09:52, Steven D'Aprano wrote: >> I'm looking for some help in finding a term, it's not Python-specific >> but does apply to some Python code. >> >> This is an anti-pattern to avoid. The idea is that creating a resource >> ought

Help with implementing callback functions using ctypes

2013-05-08 Thread jamadagni
Hello. I am running Kubuntu Raring with Python 3.3.1. (I mostly don't myself use Py2.) I have the below C program spiro.c (obviously a simplified testcase) which I compile to a sharedlib using clang -fPIC -shared -o libspiro.so spiro.c, sudo cp to /usr/lib and am trying to call from a Python s

Re: Why do Perl programmers make more money than Python programmers

2013-05-08 Thread rusi
On May 8, 6:11 am, Benjamin Kaplan wrote: > On May 7, 2013 5:42 PM, "Neil Hodgson" wrote: > > jmfauth: > > >> 2) More critical, Py 3.3, just becomes non unicode compliant, > >> (eg European languages or "ascii" typographers !) > >> ... > > >    This is not demonstrating non-compliance. It is com

Re: object.enable() anti-pattern

2013-05-08 Thread Robert Kern
On 2013-05-08 09:52, Steven D'Aprano wrote: I'm looking for some help in finding a term, it's not Python-specific but does apply to some Python code. This is an anti-pattern to avoid. The idea is that creating a resource ought to be the same as "turning it on", or enabling it, or similar. I do

Re: cello library

2013-05-08 Thread Chris Angelico
On Wed, May 8, 2013 at 7:39 PM, Mark Lawrence wrote: > Hi folks, > > I thought some of you might find this interesting [link redacted] If this is a legit post, can you please elaborate on just _why_ we would find it interesting? I'm leery of clicking random links like that without at least some i

Re: object.enable() anti-pattern

2013-05-08 Thread Christian Heimes
Am 08.05.2013 10:52, schrieb Steven D'Aprano: > Basically, any time you have two steps required for using an object, e.g. > like this: > > obj = someobject(arg1, arg2) > obj.enable() > > you should move the make-it-work functionality out of the enable method > and into __init__ so that creating

cello library

2013-05-08 Thread Mark Lawrence
Hi folks, I thought some of you might find this interesting http://libcello.org/ -- If you're using GoogleCrap™ please read this http://wiki.python.org/moin/GoogleGroupsPython. Mark Lawrence -- http://mail.python.org/mailman/listinfo/python-list

object.enable() anti-pattern

2013-05-08 Thread Steven D'Aprano
I'm looking for some help in finding a term, it's not Python-specific but does apply to some Python code. This is an anti-pattern to avoid. The idea is that creating a resource ought to be the same as "turning it on", or enabling it, or similar. For example, we don't do this in Python: f = fi

Re: multiple versions of python

2013-05-08 Thread Fábio Santos
On 8 May 2013 01:03, "Roy Smith" wrote: > > In article <72f93710-9812-441e-8d3d-f221d5698...@googlegroups.com>, > sokovic.anamar...@gmail.com wrote: > > > Hi, > > > > what is the generally recommended structure when we have into play this type > > of problem: > > multiple versions of python (both