Re: Pythonic cross-platform GUI desingers à la Interface Builder (Re: what gui designer is everyone using)

2012-06-10 Thread Chris Angelico
On Mon, Jun 11, 2012 at 5:37 AM, Dietmar Schwertberger maill...@schwertberger.de wrote: Chris Angelico wrote (in two posts): There was a time when that was a highly advertisable feature - build XYZ applications without writing a single line of code!. I've seen it in database front-end

Re: Pythonic cross-platform GUI desingers à la Interface Builder (Re: what gui designer is everyone using)

2012-06-10 Thread rusi
On Jun 10, 4:52 pm, Dietmar Schwertberger n...@schwertberger.de wrote: Am 10.06.2012 08:16, schrieb rusi: This is worth a read in this context:http://osteele.com/archives/2004/11/ides I've read the article. It presents some nice ideas, but probably the author has not used Python before.

Re: Pythonic cross-platform GUI desingers à la Interface Builder (Re: what gui designer is everyone using)

2012-06-09 Thread Dietmar Schwertberger
Am 08.06.2012 17:11, schrieb CM: I'm curious about your point but I don't really understand it. Could you try again without using any scare-quoted words? Maybe given an example of creating a small text editor application with a GUI builder/ IDE in this Pythonic way you are hoping for. Before

Re: Pythonic cross-platform GUI desingers à la Interface Builder (Re: what gui designer is everyone using)

2012-06-09 Thread CM
I think that something in the style of Visual BASIC (version 6) is required for either wxPython or PyQt/PySide (or both). In the Visual BASIC editor you can e.g. add a GUI element and directly go to the code editor to fill methods (e.g. an OnClick method). You can do this for wxPython with

Re: Pythonic cross-platform GUI desingers à la Interface Builder (Re: what gui designer is everyone using)

2012-06-09 Thread Chris Angelico
On Sat, Jun 9, 2012 at 11:25 PM, Dietmar Schwertberger n...@schwertberger.de wrote: ... for many purposes only simple GUIs are required and it should be possible to create these without studying manuals (on toolkit and GUI editor). A typical simple GUI would e.g. be for a measurement / data

Re: Pythonic cross-platform GUI desingers à la Interface Builder (Re: what gui designer is everyone using)

2012-06-09 Thread Dietmar Schwertberger
not like and did describe as un-pythonic.) Also, another requirement for this purpose would be that the tool is under active development. This would e.g. rule out Boa. I would not care whether the tool is freeware or commercial. Being freeware would make handling easier, though (e.g. deployment to all

Re: Pythonic cross-platform GUI desingers à la Interface Builder (Re: what gui designer is everyone using)

2012-06-09 Thread Chris Angelico
On Sun, Jun 10, 2012 at 3:07 AM, Dietmar Schwertberger n...@schwertberger.de wrote: None of these were such that I could propagate it as GUI development tool for non-programmers / casual users. Sure, some are good for designing the GUI, but at the point where the user code is to be added, most

Pythonic cross-platform GUI desingers à la Interface Builder (Re: what gui designer is everyone using)

2012-06-08 Thread Wolfgang Keller
of design GUI-generate code-add own code to generated code-run application with GUI has always seemed very un-pythonic to me. A dynamic, interpreted language should allow to work in a more lively, direct way to build a GUI. TIA, Sincerely, Wolfgang -- http://mail.python.org/mailman/listinfo/python

Re: Pythonic cross-platform GUI desingers à la Interface Builder (Re: what gui designer is everyone using)

2012-06-08 Thread CM
to the code and make it available live in an IDE? This whole cycle of design GUI-generate code-add own code to generated code-run application with GUI has always seemed very un-pythonic to me. A dynamic, interpreted language should allow to work in a more lively, direct way to build a GUI. TIA

how i loved lisp cons and UML and Agile and Design Patterns and Pythonic and KISS and YMMV and stopped worrying

2012-04-07 Thread Xah Lee
OMG, how i loved lisp cons and macros and UML and Agile eXtreme Programing and Design Patterns and Anti-Patterns and Pythonic and KISS and YMMV and stopped worrying. 〈World Multiconference on Systemics, Cybernetics and Informatics???〉 http://xahlee.org/comp/WMSCI.html highly advanced plain text

Re: Pythonic way with more than one max possible

2011-07-20 Thread Chris Rebert
On Tue, Jul 19, 2011 at 10:10 PM, CM cmpyt...@gmail.com wrote: On Jul 19, 11:17 pm, CM cmpyt...@gmail.com wrote: I have three items in a dict, like this: the_dict = {'a':1, 'b':2, 'c':3} but the vals could be anything.  I want to configure something else based on the winner of such a dict,

Re: Pythonic way with more than one max possible

2011-07-20 Thread Thomas Jollans
On 20/07/11 06:19, Steven D'Aprano wrote: On Wed, 20 Jul 2011 01:17 pm CM wrote: I have three items in a dict, like this: the_dict = {'a':1, 'b':2, 'c':3} but the vals could be anything. I want to configure something else based on the winner of such a dict, with these rules: 1. In this

Re: Pythonic way with more than one max possible

2011-07-20 Thread CM
Thanks, everyone. Very helpful! Che -- http://mail.python.org/mailman/listinfo/python-list

Pythonic way with more than one max possible

2011-07-19 Thread CM
I have three items in a dict, like this: the_dict = {'a':1, 'b':2, 'c':3} but the vals could be anything. I want to configure something else based on the winner of such a dict, with these rules: 1. In this dict, if there is a UNIQUE max value, that's the winner. 2. If there are any TIES for

Re: Pythonic way with more than one max possible

2011-07-19 Thread Steven D'Aprano
On Wed, 20 Jul 2011 01:17 pm CM wrote: I have three items in a dict, like this: the_dict = {'a':1, 'b':2, 'c':3} but the vals could be anything. I want to configure something else based on the winner of such a dict, with these rules: 1. In this dict, if there is a UNIQUE max value,

Re: Pythonic way with more than one max possible

2011-07-19 Thread Chris Rebert
On Tue, Jul 19, 2011 at 8:17 PM, CM cmpyt...@gmail.com wrote: I have three items in a dict, like this: the_dict = {'a':1, 'b':2, 'c':3} but the vals could be anything.  I want to configure something else based on the winner of such a dict, with these rules: 1. In this dict, if there is a

Re: Pythonic way with more than one max possible

2011-07-19 Thread CM
On Jul 19, 11:17 pm, CM cmpyt...@gmail.com wrote: I have three items in a dict, like this: the_dict = {'a':1, 'b':2, 'c':3} but the vals could be anything.  I want to configure something else based on the winner of such a dict, with these rules: 1. In this dict, if there is a UNIQUE max

Re: Pythonic way with more than one max possible

2011-07-19 Thread woooee
1. In this dict, if there is a UNIQUE max value, then its *key* is the winner. 2. If there are any TIES for max value, then the *key* 'b' is the winner by default. This will store the max value(s) in a list. In case of a tie, you can take the first value in the list, but it may be different

Re: The pythonic way equal to whoami

2011-06-09 Thread TheSaint
Christopher Head wrote: It is. Until Linux capabilities, EUID==0 used to be special-cased in the kernel Thank you all, I got a good learning *and* something to rememeber. -- goto /dev/null -- http://mail.python.org/mailman/listinfo/python-list

Re: The pythonic way equal to whoami

2011-06-08 Thread TheSaint
Kushal Kumaran wrote: os.geteuid This return 0 for *root* . I don't know if it's a standard for all distro. Mine is Archlinux. I'd just like to avoid error caused by wrong access by user -- goto /dev/null -- http://mail.python.org/mailman/listinfo/python-list

Re: The pythonic way equal to whoami

2011-06-08 Thread Christopher Head
On Wed, 08 Jun 2011 21:58:17 +0800 TheSaint nob...@nowhere.net.no wrote: Kushal Kumaran wrote: os.geteuid This return 0 for *root* . I don't know if it's a standard for all distro. Mine is Archlinux. I'd just like to avoid error caused by wrong access by user It is. Until Linux

Re: The pythonic way equal to whoami

2011-06-08 Thread Nobody
On Wed, 08 Jun 2011 21:58:17 +0800, TheSaint wrote: os.geteuid This return 0 for *root* . I don't know if it's a standard for all distro. UID 0 is the superuser. The name root is conventional, but it's the EUID (effective UID) which is used in permission checks; the kernel doesn't care about

Re: The pythonic way equal to whoami

2011-06-08 Thread Cameron Simpson
On 07Jun2011 20:22, Nitin Pawar nitinpawar...@gmail.com wrote: | import getpass | user = getpass.getuser() | | On Tue, Jun 7, 2011 at 7:54 PM, TheSaint nob...@nowhere.net.no wrote: | I was trying to find out whose the program launcher, but os.environ['USER'] | returns the user whom owns the

The pythonic way equal to whoami

2011-06-07 Thread TheSaint
Hello, I was trying to find out whose the program launcher, but os.environ['USER'] returns the user whom owns the desktop environment, regardless the program is called by root. I'd like to know it, so the program will run with the right privileges. Is there any standard function on python, that

Re: The pythonic way equal to whoami

2011-06-07 Thread Nitin Pawar
import getpass user = getpass.getuser() On Tue, Jun 7, 2011 at 7:54 PM, TheSaint nob...@nowhere.net.no wrote: Hello, I was trying to find out whose the program launcher, but os.environ['USER'] returns the user whom owns the desktop environment, regardless the program is called by root. I'd

Re: The pythonic way equal to whoami

2011-06-07 Thread Kushal Kumaran
On Tue, Jun 7, 2011 at 7:54 PM, TheSaint nob...@nowhere.net.no wrote: Hello, I was trying to find out whose the program launcher, but os.environ['USER'] returns the user whom owns the desktop environment, regardless the program is called by root. I'd like to know it, so the program will run

Re: Pythonic infinite for loop?

2011-04-15 Thread Paul Rubin
Chris Angelico ros...@gmail.com writes: That loop will exit at the first gap in the sequence. If that's what you want, you could try (untested): from itertools import takewhile seq = takewhile(lambda n: ('Keyword%d'%n) in dct, count(1)) lst = map(dct.get, seq) This does 2 lookups per

Re: Pythonic infinite for loop?

2011-04-15 Thread Chris Angelico
On Fri, Apr 15, 2011 at 5:24 PM, Paul Rubin no.email@nospam.invalid wrote: This does 2 lookups per key, which you could avoid by making the code uglier (untested):   sentinel = object()   seq = (dct.get('Keyword%d'%i,sentinel) for i in count(1))   lst = list(takewhile(lambda x: x !=

Re: Pythonic infinite for loop?

2011-04-15 Thread Paul Rubin
Chris Angelico ros...@gmail.com writes:   sentinel = object()   seq = (dct.get('Keyword%d'%i,sentinel) for i in count(1))   lst = list(takewhile(lambda x: x != sentinel, seq)) If I understand this code correctly, that's creating generators, right? It won't evaluate past the sentinel at all?

Re: Pythonic infinite for loop?

2011-04-15 Thread Peter Otten
Paul Rubin wrote: Chris Angelico ros...@gmail.com writes: sentinel = object() seq = (dct.get('Keyword%d'%i,sentinel) for i in count(1)) lst = list(takewhile(lambda x: x != sentinel, seq)) If I understand this code correctly, that's creating generators, right? It won't evaluate past the

Re: Pythonic infinite for loop?

2011-04-15 Thread Peter Otten
processing. I have a function parse_kwdlist() which takes a string (the dictionary's value) and returns the content I want out of it, so I'm wondering what the most efficient and Pythonic way to do this is. My first draft looks something like this. The input dictionary is called dct, the output

Re: Pythonic infinite for loop?

2011-04-15 Thread Chris Angelico
On Fri, Apr 15, 2011 at 6:25 PM, Peter Otten __pete...@web.de wrote: The initial data structure seems less than ideal. You might be able to replace it with a dictionary like {Keyword: [value_for_keyword_1, value_for_keyword_2, ...]} if you try hard enough. The initial data structure comes

Re: Pythonic infinite for loop?

2011-04-15 Thread Peter Otten
Chris Angelico wrote: On Fri, Apr 15, 2011 at 6:25 PM, Peter Otten __pete...@web.de wrote: The initial data structure seems less than ideal. You might be able to replace it with a dictionary like {Keyword: [value_for_keyword_1, value_for_keyword_2, ...]} if you try hard enough. The

Re: Pythonic infinite for loop?

2011-04-15 Thread Steven D'Aprano
On Fri, 15 Apr 2011 18:32:23 +1000, Chris Angelico wrote: On Fri, Apr 15, 2011 at 6:25 PM, Peter Otten __pete...@web.de wrote: The initial data structure seems less than ideal. You might be able to replace it with a dictionary like {Keyword: [value_for_keyword_1, value_for_keyword_2, ...]}

Re: Pythonic infinite for loop?

2011-04-15 Thread Steven D'Aprano
On Fri, 15 Apr 2011 13:58:22 +1000, Chris Angelico wrote: The dictionary is potentially a lot larger than this particular set of values (it's a mapping of header:value for a row of a user-provided CSV file). Does this make a difference to the best option? (Currently I'm looking at likely

Re: Pythonic infinite for loop?

2011-04-15 Thread Roy Smith
In article 4da83f8f$0$29986$c3e8da3$54964...@news.astraweb.com, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: for key in dct: if key.startswith(Keyword): maxkey = max(maxkey, int(key[7:])) I would make that a little easier to read, and less prone to Did I count

Re: Pythonic infinite for loop?

2011-04-15 Thread Ethan Furman
Chris Angelico wrote: lst=[] for i in xrange(1,1000): # arbitrary top, don't like this try: lst.append(parse_kwdlist(dct[Keyword%d%i])) except KeyError: break Possibly overkill: import dbf table = dbf.from_csv(csvfile) # fields get names f0, f1, f2, ...

Re: Pythonic infinite for loop?

2011-04-15 Thread Chris Angelico
On Fri, Apr 15, 2011 at 10:52 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Fri, 15 Apr 2011 13:58:22 +1000, Chris Angelico wrote: The dictionary is potentially a lot larger than this particular set of values (it's a mapping of header:value for a row of a user-provided CSV

Re: Pythonic infinite for loop?

2011-04-15 Thread Paul Rubin
Chris Angelico ros...@gmail.com writes: This whole code is inside a loop that we took, in smoke testing, to a couple hundred million rows (I think), with the intention of having no limit at all. So this might only look at 60-100 headers, but it will be doing so in a tight loop. If you're

Pythonic infinite for loop?

2011-04-14 Thread Chris Angelico
parse_kwdlist() which takes a string (the dictionary's value) and returns the content I want out of it, so I'm wondering what the most efficient and Pythonic way to do this is. My first draft looks something like this. The input dictionary is called dct, the output list is lst. lst=[] for i in xrange

Re: Pythonic infinite for loop?

2011-04-14 Thread Ryan Kelly
into a single list with some processing. I have a function parse_kwdlist() which takes a string (the dictionary's value) and returns the content I want out of it, so I'm wondering what the most efficient and Pythonic way to do this is. My first draft looks something like this. The input

Re: Pythonic infinite for loop?

2011-04-14 Thread Nobody
On Fri, 15 Apr 2011 12:10:52 +1000, Chris Angelico wrote: One, is there a way to make an xrange object and leave the top off? itertools.count() And two, can the entire thing be turned into a list comprehension or something? Generally any construct with a for loop that appends to a list is

Re: Pythonic infinite for loop?

2011-04-14 Thread Steven D'Aprano
On Fri, 15 Apr 2011 12:10:52 +1000, Chris Angelico wrote: Apologies for interrupting the vital off-topic discussion, but I have a real Python question to ask. Sorry, you'll in the wrong forum for that. *wink* [...] My first draft looks something like this. The input dictionary is called

Re: Pythonic infinite for loop?

2011-04-14 Thread John Connor
() which takes a string (the dictionary's value) and returns the content I want out of it, so I'm wondering what the most efficient and Pythonic way to do this is. My first draft looks something like this. The input dictionary is called dct, the output list is lst. lst=[] for i in xrange

Re: Pythonic infinite for loop?

2011-04-14 Thread Ryan Kelly
On Fri, 2011-04-15 at 12:34 +1000, Ryan Kelly wrote: On Fri, 2011-04-15 at 12:10 +1000, Chris Angelico wrote: My first draft looks something like this. The input dictionary is called dct, the output list is lst. lst=[] for i in xrange(1,1000): # arbitrary top, don't like this

Re: Pythonic infinite for loop?

2011-04-14 Thread Chris Angelico
Thanks for the responses, all! In its strictest sense, itertools.count() seems to be what I'm after, but may not be what I need. On Fri, Apr 15, 2011 at 12:33 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: No. But you can use an itertools.count([start=0]) object, and then catch

Attest 0.4 released: Modern, Pythonic unit testing

2011-01-09 Thread dag.odenh...@gmail.com
Hello fellow Pythonista, I just released version 0.4 of Attest, a modern framework for unit testing. Website and documentation: http://packages.python.org/Attest/ Source code: https://github.com/dag/attest Issues: https://github.com/dag/attest/issues PyPI: http://pypi.python.org/pypi/Attest/0.4

Re: Pythonic/idiomatic?

2010-11-09 Thread Peter Otten
Seebs wrote: I have an existing hunk of Makefile code: CPPFLAGS = $(filter -D* -I* -i* -U*,$(TARGET_CFLAGS)) For those not familiar with GNU makeisms, this means assemble a string which consists of all the words in $(TARGET_CFLAGS) which start with one of -D, -I, -i, or -U. So if you give

Re: Pythonic/idiomatic?

2010-11-09 Thread Mark Wooding
Seebs usenet-nos...@seebs.net writes: ' '.join([x for x in target_cflags.split() if re.match('^-[DIiU]', x)]) This appears to do the same thing, but is it an idiomatic use of list comprehensions, or should I be breaking it out into more bits? It looks OK to me. You say (elsewhere in

Re: Pythonic/idiomatic?

2010-11-09 Thread Jean-Michel Pichavant
use of list comprehensions, or should I be breaking it out into more bits? You will note that of course, I have carefully made it a one-liner so I don't have to worry about indentation*. -s [*] Kidding, I just thought this seemed like a pretty clear expression. One pythonic way to do

Re: Pythonic/idiomatic?

2010-11-09 Thread Seebs
On 2010-11-09, Jean-Michel Pichavant jeanmic...@sequans.com wrote: One pythonic way to do it, is to use an option parser. That seems like massive overkill -- I don't care about any of the other options. It seems like it'd result in doing more work to get and then extract the options, and most

Re: Pythonic/idiomatic?

2010-11-09 Thread Martin Gregorie
On Wed, 10 Nov 2010 00:11:23 +, Seebs wrote: On 2010-11-09, Jean-Michel Pichavant jeanmic...@sequans.com wrote: One pythonic way to do it, is to use an option parser. That seems like massive overkill -- I don't care about any of the other options. It seems like it'd result in doing

Re: Pythonic/idiomatic?

2010-11-09 Thread Robert Kern
-of-prefixes feature of ???str.startswith??? either. Bummer. Eww. At which point, the Pythonic thing to do is to convince your organisation to use a version of Python that's at least officially supported by the PSF :-) Unfortunately, we're selling something to people who will explode if we tell

Pythonic/idiomatic?

2010-11-08 Thread Seebs
I have an existing hunk of Makefile code: CPPFLAGS = $(filter -D* -I* -i* -U*,$(TARGET_CFLAGS)) For those not familiar with GNU makeisms, this means assemble a string which consists of all the words in $(TARGET_CFLAGS) which start with one of -D, -I, -i, or -U. So if you give it

Re: Pythonic/idiomatic?

2010-11-08 Thread geremy condra
On Mon, Nov 8, 2010 at 6:32 PM, Seebs usenet-nos...@seebs.net wrote: I have an existing hunk of Makefile code:        CPPFLAGS = $(filter -D* -I* -i* -U*,$(TARGET_CFLAGS)) For those not familiar with GNU makeisms, this means assemble a string which consists of all the words in $(TARGET_CFLAGS)

Re: Pythonic/idiomatic?

2010-11-08 Thread Ben Finney
Seebs usenet-nos...@seebs.net writes: I have a similar situation in a Python context, and I am wondering whether this is an idiomatic spelling: ' '.join([x for x in target_cflags.split() if re.match('^-[DIiU]', x)]) This appears to do the same thing, but is it an idiomatic use of list

Re: Pythonic/idiomatic?

2010-11-08 Thread Seebs
On 2010-11-09, Ben Finney ben+pyt...@benfinney.id.au wrote: For this purpose, there is a generator expression syntax URL:http://docs.python.org/reference/expressions.html#generator-expressions, almost identical to a list comprehension except without the enclosing brackets. ' '.join(x for

Re: Pythonic/idiomatic?

2010-11-08 Thread Ben Finney
as 2.4. Then you don't yet have the ‘any’ and ‘all’ built-in functions, or the tuple-of-prefixes feature of ‘str.startswith’ either. Bummer. At which point, the Pythonic thing to do is to convince your organisation to use a version of Python that's at least officially supported by the PSF

Re: Pythonic/idiomatic?

2010-11-08 Thread Tim Chase
On 11/08/10 18:34, Seebs wrote: On 2010-11-09, Ben Finneyben+pyt...@benfinney.id.au wrote: ' '.join(x for x in target_cflags.split() if re.match('^-[DIiU]', x)) Ahh, handy. ... The latter works only in Python with set literals (Python 2.7 or later). I think we're stuck with

Re: Pythonic/idiomatic?

2010-11-08 Thread Seebs
of ???str.startswith??? either. Bummer. Eww. At which point, the Pythonic thing to do is to convince your organisation to use a version of Python that's at least officially supported by the PSF :-) Unfortunately, we're selling something to people who will explode if we tell them to upgrade their RHEL4 systems

Re: Pythonic/idiomatic?

2010-11-08 Thread Arnaud Delobelle
Seebs usenet-nos...@seebs.net writes: I have an existing hunk of Makefile code: CPPFLAGS = $(filter -D* -I* -i* -U*,$(TARGET_CFLAGS)) For those not familiar with GNU makeisms, this means assemble a string which consists of all the words in $(TARGET_CFLAGS) which start with one of -D,

Re: Pythonic way of saying 'at least one of a, b, or c is in some_list'

2010-10-31 Thread Lawrence D'Oliveiro
In message 4cca5aaf$0$1600$742ec...@news.sonic.net, John Nagle wrote: This is cheaper than intersection ... All together now: “PREMATURE OPTIMIZATION IS THE ROOT OF ALL EVIL!” -- http://mail.python.org/mailman/listinfo/python-list

Re: Pythonic way of saying 'at least one of a, b, or c is in some_list'

2010-10-31 Thread Lawrence D'Oliveiro
In message 687bcb76-0093-4d68-ba56-0390a3e1e...@30g2000yql.googlegroups.com, cbr...@cbrownsystems.com wrote: I should note that efficiency is not an issue to me here; this is for when you have, say, a list user_options of at most around 15 options or so, and you want to perform some action if

Re: Pythonic way of saying 'at least one of a, b, or c is in some_list'

2010-10-31 Thread cbr...@cbrownsystems.com
On Oct 31, 4:27 pm, Lawrence D'Oliveiro l...@geek- central.gen.new_zealand wrote: In message 687bcb76-0093-4d68-ba56-0390a3e1e...@30g2000yql.googlegroups.com, cbr...@cbrownsystems.com wrote: I should note that efficiency is not an issue to me here; this is for when you have, say, a list

Re: Pythonic way of saying 'at least one of a, b, or c is in some_list'

2010-10-29 Thread Xavier Ho
On 29 October 2010 15:50, Paul Rubin no.em...@nospam.invalid wrote: John Nagle na...@animats.com writes: d1 = set('monday','tuesday') days_off = set('saturday','sunday') if not d1.isdisjoint(days_off) :... This is cheaper than intersection, since it doesn't have to allocate

Re: Pythonic way of saying 'at least one of a, b, or c is in some_list'

2010-10-29 Thread cbr...@cbrownsystems.com
', 'tuesday'] if d in days_off]):     doSomething Is there a better pythonic idiom for this situation? The latter can be written more concisely:     if any(d in days_off for d in ['monday', 'tuesday']):         # do something For the list comprehension approach, I like this much better

Re: Pythonic way of saying 'at least one of a, b, or c is in some_list'

2010-10-29 Thread Carl Banks
On Oct 28, 10:50 pm, Paul Rubin no.em...@nospam.invalid wrote: John Nagle na...@animats.com writes:    d1 = set('monday','tuesday')    days_off = set('saturday','sunday')    if not d1.isdisjoint(days_off) :...    This is cheaper than intersection, since it doesn't have to allocate and

Re: Pythonic way of saying 'at least one of a, b, or c is in some_list'

2010-10-29 Thread HEK
Is there a better pythonic idiom for this situation? Cheers - Chas The most pythonic way is the following: class anyof(set): def __contains__(self,item): if isinstance(item,anyof): for it in item: if self.__contains__

Re: Pythonic way of saying 'at least one of a, b, or c is in some_list'

2010-10-29 Thread Xavier Ho
: if 'monday in days_off or tuesday in days_off: doSomething I currently am tending to write: if any([d for d in ['monday', 'tuesday'] if d in days_off]): doSomething Is there a better pythonic idiom for this situation? Cheers - Chas The most pythonic way is the following: class

Re: Pythonic way of saying 'at least one of a, b, or c is in some_list'

2010-10-29 Thread Steven D'Aprano
On Thu, 28 Oct 2010 09:16:42 -0700, cbr...@cbrownsystems.com wrote: It's clear but tedious to write: if 'monday in days_off or tuesday in days_off: doSomething I currently am tending to write: if any([d for d in ['monday', 'tuesday'] if d in days_off]): doSomething Use a

Re: Pythonic way of saying 'at least one of a, b, or c is in some_list'

2010-10-29 Thread Adam Przybyla
pythonic idiom for this situation? ... hmmm, try this: if set(['monday', 'tuesday'])set(days_off): dosomething Regards Adam Przybyla -- http://mail.python.org/mailman/listinfo/python-list

Re: Pythonic way of saying 'at least one of a, b, or c is in some_list'

2010-10-29 Thread cbr...@cbrownsystems.com
On Oct 29, 2:43 am, Steven D'Aprano st...@remove-this- cybersource.com.au wrote: On Thu, 28 Oct 2010 09:16:42 -0700, cbr...@cbrownsystems.com wrote: It's clear but tedious to write: if 'monday in days_off or tuesday in days_off:     doSomething I currently am tending to write: if

Pythonic way of saying 'at least one of a, b, or c is in some_list'

2010-10-28 Thread cbr...@cbrownsystems.com
It's clear but tedious to write: if 'monday in days_off or tuesday in days_off: doSomething I currently am tending to write: if any([d for d in ['monday', 'tuesday'] if d in days_off]): doSomething Is there a better pythonic idiom for this situation? Cheers - Chas -- http

Re: Pythonic way of saying 'at least one of a, b, or c is in some_list'

2010-10-28 Thread John Posner
On 10/28/2010 12:16 PM, cbr...@cbrownsystems.com wrote: It's clear but tedious to write: if 'monday in days_off or tuesday in days_off: doSomething I currently am tending to write: if any([d for d in ['monday', 'tuesday'] if d in days_off]): doSomething Is there a better pythonic

Re: Pythonic way of saying 'at least one of a, b, or c is in some_list'

2010-10-28 Thread cbr...@cbrownsystems.com
', 'tuesday'] if d in days_off]):      doSomething Is there a better pythonic idiom for this situation? Clunky, but it might prompt you to think of a better idea: convert the lists to sets, and take their intersection. -John I thought of that as well, e.g.: if set([monday,tuesday']).intersection

Re: Pythonic way of saying 'at least one of a, b, or c is in some_list'

2010-10-28 Thread Chris Kaynor
]): doSomething A slightly cleaner form would be: if any(day in days_off for day in ['Monday', 'Tuesday']): block To make that a bit easier to read: if any((day in days_off) for day in ['Monday', 'Tuesday']): block Is there a better pythonic idiom for this situation? Cheers - Chas

Re: Pythonic way of saying 'at least one of a, b, or c is in some_list'

2010-10-28 Thread Chris Rebert
:      doSomething I currently am tending to write: if any([d for d in ['monday', 'tuesday'] if d in days_off]):      doSomething Is there a better pythonic idiom for this situation? Clunky, but it might prompt you to think of a better idea: convert the lists to sets, and take

Re: Pythonic way of saying 'at least one of a, b, or c is in some_list'

2010-10-28 Thread nn
:      doSomething I currently am tending to write: if any([d for d in ['monday', 'tuesday'] if d in days_off]):      doSomething Is there a better pythonic idiom for this situation? Clunky, but it might prompt you to think of a better idea: convert the lists to sets, and take

Re: Pythonic way of saying 'at least one of a, b, or c is in some_list'

2010-10-28 Thread cbr...@cbrownsystems.com
but tedious to write: if 'monday in days_off or tuesday in days_off:      doSomething I currently am tending to write: if any([d for d in ['monday', 'tuesday'] if d in days_off]):      doSomething Is there a better pythonic idiom for this situation? Clunky, but it might prompt you

Re: Pythonic way of saying 'at least one of a, b, or c is in some_list'

2010-10-28 Thread Arnaud Delobelle
pythonic idiom for this situation? The latter can be written more concisely: if any(d in days_off for d in ['monday', 'tuesday']): # do something -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list

Re: Pythonic way of saying 'at least one of a, b, or c is in some_list'

2010-10-28 Thread John Nagle
]): doSomething Is there a better pythonic idiom for this situation? Clunky, but it might prompt you to think of a better idea: convert the lists to sets, and take their intersection. -John d1 = set('monday','tuesday') days_off = set('saturday','sunday') if not d1.isdisjoint(days_off

Re: Pythonic way of saying 'at least one of a, b, or c is in some_list'

2010-10-28 Thread Paul Rubin
John Nagle na...@animats.com writes: d1 = set('monday','tuesday') days_off = set('saturday','sunday') if not d1.isdisjoint(days_off) :... This is cheaper than intersection, since it doesn't have to allocate and construct a set. It just tests whether any element in the smaller of

[issue10006] non-Pythonic fate of __abstractmethods__

2010-10-24 Thread Éric Araujo
Changes by Éric Araujo mer...@netwok.org: -- versions: +Python 3.2 -Python 2.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10006 ___ ___

Re: Deditor -- pythonic text-editor

2010-10-18 Thread Jean-Michel Pichavant
Kruptein wrote: on steven, peter and eliasf: Well okay I'm new to the world of developing programs, if I encounter problems I directly post a bug on the relevant page, that's maybe why I was a bit frustrated :) but what you three say is indeed true.. Hi, It does not work with python 2.5

[ANN] bento 0.0.4, a pythonic packaging solution for python softwares

2010-10-10 Thread David Cournapeau
Hi, I am pleased to announce the release 0.0.4 for Bento, a pythonic packaging solution for python softwares. Bento is an alternative to distutils/setuptools/distutils2 geared toward simplicity and hackability: http://cournape.github.com/Bento/ Download: http://github.com/cournape/Bento

[issue10006] non-Pythonic fate of __abstractmethods__

2010-10-02 Thread Benjamin Peterson
or becomes absent from output of dir() -- but none of those has happened.  Now we ended up with a consistent non-Pythonic fate of __abstractmethods__ listed in output of dir() but not accessible.  is that a feature? type has no __abstractmethods__, so it should raise an AttributeError. Note

[issue10006] non-Pythonic fate of __abstractmethods__

2010-10-01 Thread Yaroslav Halchenko
: Yaroslav.Halchenko priority: normal severity: normal status: open title: non-Pythonic fate of __abstractmethods__ versions: Python 2.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10006

[issue10006] non-Pythonic fate of __abstractmethods__

2010-10-01 Thread Andreas Stührk
Changes by Andreas Stührk andy-pyt...@hammerhartes.de: -- nosy: +Trundle ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10006 ___ ___

[issue10006] non-Pythonic fate of __abstractmethods__

2010-10-01 Thread R. David Murray
Changes by R. David Murray rdmur...@bitdance.com: -- nosy: +benjamin.peterson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10006 ___ ___

[issue10006] non-Pythonic fate of __abstractmethods__

2010-10-01 Thread Benjamin Peterson
Benjamin Peterson benja...@python.org added the comment: I see the problem; will consider/fix later today hopefully. -- assignee: - benjamin.peterson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10006

[issue10006] non-Pythonic fate of __abstractmethods__

2010-10-01 Thread Daniel Urban
Changes by Daniel Urban urban.dani...@gmail.com: -- nosy: +durban ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10006 ___ ___ Python-bugs-list

[issue10006] non-Pythonic fate of __abstractmethods__

2010-10-01 Thread Benjamin Peterson
Benjamin Peterson benja...@python.org added the comment: As of r85154, type.__abstractmethods__ now raises an AttributeError, too. -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org

[issue10006] non-Pythonic fate of __abstractmethods__

2010-10-01 Thread Yaroslav Halchenko
-Pythonic fate of __abstractmethods__ listed in output of dir() but not accessible. is that a feature? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10006

Re: Deditor -- pythonic text-editor

2010-08-16 Thread Kruptein
I still keep getting more downloads then usual which is awesome, but I still don't get any kind of response! please mail me or reply to this post with what you think, You can tell me that the program sucks but if you want to, do it in such a way that you also describe what exactly is the problem

Re: Deditor -- pythonic text-editor

2010-08-16 Thread Steven D'Aprano
On Mon, 16 Aug 2010 01:52:52 -0700, Kruptein wrote: I still keep getting more downloads then usual which is awesome, but I still don't get any kind of response! Welcome to the real world. For every user who sends you an email, you'll probably have 1000 who don't. Or 10,000. please mail me

Re: Deditor -- pythonic text-editor

2010-08-16 Thread Peter Otten
Steven D'Aprano wrote: On Mon, 16 Aug 2010 01:52:52 -0700, Kruptein wrote: I still keep getting more downloads then usual which is awesome, but I still don't get any kind of response! Welcome to the real world. For every user who sends you an email, you'll probably have 1000 who don't.

Re: Deditor -- pythonic text-editor

2010-08-16 Thread eliasf
On Mon, 16 Aug 2010 14:26:09 +0300, Peter Otten __pete...@web.de wrote: Steven D'Aprano wrote: If nobody asks for any changes, then just keep doing what you're doing. Or you can introduce a bug; if your users don't start complaining you don't have any... Even that doesn't work. They may blog

Re: Deditor -- pythonic text-editor

2010-08-16 Thread Kruptein
on steven, peter and eliasf: Well okay I'm new to the world of developing programs, if I encounter problems I directly post a bug on the relevant page, that's maybe why I was a bit frustrated :) but what you three say is indeed true.. -- http://mail.python.org/mailman/listinfo/python-list

Re: Deditor -- pythonic text-editor

2010-08-15 Thread Kruptein
I've noticed that there were a lot of downloads since I posted this topic, but I don't get any response from anyone so I actually still don't know whether it is good, bad, ugly, pretty, easy to use,... So please help me! :) -- http://mail.python.org/mailman/listinfo/python-list

Deditor -- pythonic text-editor

2010-08-13 Thread Kruptein
Hey, I've finished my second version of deditor, a python text-editor for python under linux. It offers some python-only features like an interpreter, a code- analyzer, syntax-highlighting,... Are there some people in here who would like to test the app? (and maybe even help spread it) more

<    1   2   3   4   5   6   7   8   9   10   >