Re: recursive function: use a global or pass a parameter?

2015-01-16 Thread Yawar Amin
On Friday, January 16, 2015 at 9:24:15 PM UTC-5, Yawar Amin wrote: > [...] > vals.extend(curr_obj.values()) Ah, I should mention that the above will do a breadth-first search. If we want to do a depth-first search we simply replace the above line with: vals.extendleft(curr_obj.values(

pyqtdeploy on windows

2015-01-16 Thread Hektor black
hi i have a code with pyqt4 and i want run in android with this tutorial http://pyqt.sourceforge.net/Docs/pyqtdeploy/command_line.html my project include of : m.py m.pyw m.ui when run pyqtdeploy myproject.pdy in cmd get error installing py 3.4.2 pyqt5 for pyqtdeploy any one know good tutorial for

Re: recursive function: use a global or pass a parameter?

2015-01-16 Thread Yawar Amin
On Friday, January 16, 2015 at 1:34:51 PM UTC-5, Peter Otten wrote: > [...] > I recommend that you use a generator: > > >>> def walk(obj): > ... if not hasattr(obj, "keys"): > ... return > ... if "things" in obj: > ... yield obj["things"] > ... for v in obj.values(): >

Re: recursive function: use a global or pass a parameter?

2015-01-16 Thread Chris Angelico
On Sat, Jan 17, 2015 at 9:20 AM, Gregory Ewing wrote: > The only thing I would change is to wrap it all up > in a top-level function that takes care of creating > the result set and returning it. > > def walk(obj): > res = set() > _walk(obj, res) > return res > > def _walk(obj, res): > ...

Re: recursive function: use a global or pass a parameter?

2015-01-16 Thread Gregory Ewing
Tim wrote: I have this type of situation and wonder if I should use a global variable outside the recursive function instead of passing the updated parameter through. No! Globals are evil, at least for that sort of thing. The way you're doing it is fine. The only thing I would change is to wra

Re: lambdak: multi-line lambda implementation in native Python

2015-01-16 Thread Gregory Ewing
Chris Angelico wrote: Is this to get around style guides that reject this kind of model: x = Foo( opt1=True, opt2=True, color=Yellow, ) It's to get around the fact that you *can't* do that in Java, because it doesn't have keyword arguments. This is a source of a lot of the complex

Re: Factories and Builders [was Re: lambdak...]

2015-01-16 Thread Gregory Ewing
Steven D'Aprano wrote: I've never really understand why "abstract factory", "factory method" and "builder" are considered different design patterns. They're variants on the same idea. I think it's because they address different problems. Factories are for hiding the details of how an object is

Re: lambdak: multi-line lambda implementation in native Python

2015-01-16 Thread Gregory Ewing
Marko Rauhamaa wrote: Gregory Ewing : If those are 24-bit RGB pixels, you could encode 3 characters in each pixel. Not since Python3. Characters are Unicode now so you'll need to dedicate a pixel for each character. Depends on which characters you want. With the Flexible Chromatic Represent

[ANN] Pylint 1.4.1 / Astroid 1.3.3 released

2015-01-16 Thread Claudiu Popa
Hello, It's my pleasure to announce the release of both Pylint 1.4.1 and Astroid 1.3.3 respectively. The following bug fixes and features made their way into Astroid 1.3.3: * Restore file_stream to a property, but deprecate it in favour of the newly added method Module.stream. *

Re: recursive function: use a global or pass a parameter?

2015-01-16 Thread Tim
On Friday, January 16, 2015 at 1:34:51 PM UTC-5, Peter Otten wrote: >> Tim wrote: >> > Globals are generally bad as they make code non-reentrant; when two calls of > the function run simultaneously the data will be messed up. > > I recommend that you use a generator: > > >>> def walk(obj): > ..

Re: recursive function: use a global or pass a parameter?

2015-01-16 Thread Peter Otten
Tim wrote: > I have this type of situation and wonder if I should use a global variable > outside the recursive function instead of passing the updated parameter > through. > > I want to get a union of all the values that any 'things' key may have, > even in a nested dictionary (and I do not know

Re: recursive function: use a global or pass a parameter?

2015-01-16 Thread Rustom Mody
On Friday, January 16, 2015 at 11:26:46 PM UTC+5:30, Chris Angelico wrote: > On Sat, Jan 17, 2015 at 4:49 AM, Tim wrote: > > I want to get a union of all the values that any 'things' key may have, > > even in a nested dictionary (and I do not know beforehand how deep the > > nesting might go): >

Android Native Build Help: python build_ext

2015-01-16 Thread Cyd Haselton
I'm building python on my Android tablet and, while the executable and library builds successfully, I run into a problem when the newly built python runs build_ext; it builds the _struct module and then immediately afterwards my build environment throws an 'undefined reference to dlopen' error. To

Re: How to "wow" someone new to Python

2015-01-16 Thread Emile van Sebille
On 1/16/2015 9:44 AM, Chris Angelico wrote: > exact line of code that would show off Python's awesomeness. a,b = b,a Emile -- https://mail.python.org/mailman/listinfo/python-list

Re: How to "wow" someone new to Python

2015-01-16 Thread Tim Chase
On 2015-01-17 02:03, Chris Angelico wrote: > Ideally, this should be something that can be demo'd quickly and > easily, and it should be impressive without going into great details > of "and see, this is how it works on the inside". So, how would you > brag about this language? First, I agree with

Re: recursive function: use a global or pass a parameter?

2015-01-16 Thread Chris Angelico
On Sat, Jan 17, 2015 at 4:49 AM, Tim wrote: > I want to get a union of all the values that any 'things' key may have, even > in a nested dictionary (and I do not know beforehand how deep the nesting > might go): > > d = {'things':1, 'two':{'things':2}} > > def walk(obj, res): > if not hasatt

recursive function: use a global or pass a parameter?

2015-01-16 Thread Tim
I have this type of situation and wonder if I should use a global variable outside the recursive function instead of passing the updated parameter through. I want to get a union of all the values that any 'things' key may have, even in a nested dictionary (and I do not know beforehand how deep

Re: How to "wow" someone new to Python

2015-01-16 Thread Chris Angelico
On Sat, Jan 17, 2015 at 4:31 AM, Rustom Mody wrote: > Nice point! > First class concrete data structures is a blessing especially for > a C programmer. Definitely! Worth noting. There've been some nice concepts mentioned; concrete suggestions would be good too. Some specific feature or exact lin

Re: How to "wow" someone new to Python

2015-01-16 Thread Rustom Mody
On Friday, January 16, 2015 at 10:51:52 PM UTC+5:30, Mirage Web Studio wrote: > On 01/16/2015 08:33 PM, Chris Angelico wrote: > > Scenario: You're introducing someone to Python for the first time. > > S/he may have some previous programming experience, or may be new to > > the whole idea of giving

Re: How to "wow" someone new to Python

2015-01-16 Thread Albert-Jan Roskam
On Fri, Jan 16, 2015 4:24 PM CET Andrew Berg wrote: >On 2015.01.16 09:03, Chris Angelico wrote: >> Scenario: You're introducing someone to Python for the first time. >> S/he may have some previous programming experience, or may be new to >> the whole idea of giving a

Re: How to "wow" someone new to Python

2015-01-16 Thread Mirage Web Studio
On 01/16/2015 08:33 PM, Chris Angelico wrote: > Scenario: You're introducing someone to Python for the first time. > S/he may have some previous programming experience, or may be new to > the whole idea of giving a computer instructions. You have a couple of > minutes to show off how awesome Pytho

Re: How to "wow" someone new to Python

2015-01-16 Thread Rustom Mody
On Friday, January 16, 2015 at 8:34:20 PM UTC+5:30, Chris Angelico wrote: > Scenario: You're introducing someone to Python for the first time. > S/he may have some previous programming experience, or may be new to > the whole idea of giving a computer instructions. You have a couple of > minutes to

Re: How to "wow" someone new to Python

2015-01-16 Thread Marco Buttu
On 16/01/2015 16:03, Chris Angelico wrote: Scenario: You're introducing someone to Python for the first time. S/he may have some previous programming experience, or may be new to the whole idea of giving a computer instructions. You have a couple of minutes to show off how awesome Python is. What

Re: lambdak: multi-line lambda implementation in native Python

2015-01-16 Thread Michael Torrie
On 01/15/2015 10:29 PM, Ian Kelly wrote: > On Thu, Jan 15, 2015 at 9:00 PM, Chris Angelico wrote: >> My first response was going to be "Well, you can always add another >> layer of indirection to try to solve your problem", but then I went >> and looked up builders on Wikipedia. Now I'm confused.

Re: How to "wow" someone new to Python

2015-01-16 Thread Marko Rauhamaa
Chris Angelico : > Scenario: You're introducing someone to Python for the first time. > S/he may have some previous programming experience, or may be new to > the whole idea of giving a computer instructions. You have a couple of > minutes to show off how awesome Python is. What do you do? My exp

Re: How to "wow" someone new to Python

2015-01-16 Thread Andrew Berg
On 2015.01.16 09:03, Chris Angelico wrote: > Scenario: You're introducing someone to Python for the first time. > S/he may have some previous programming experience, or may be new to > the whole idea of giving a computer instructions. You have a couple of > minutes to show off how awesome Python is

Re: How to "wow" someone new to Python

2015-01-16 Thread Skip Montanaro
If you want to show off the REPL, I'd got for iPython and show them some simple matplotlib examples (plotting sin waves, maybe dig up a CSV file on the net with some data your friend is familiar with, etc) Skip On Fri, Jan 16, 2015 at 9:03 AM, Chris Angelico wrote: > Scenario: You're introduci

How to "wow" someone new to Python

2015-01-16 Thread Chris Angelico
Scenario: You're introducing someone to Python for the first time. S/he may have some previous programming experience, or may be new to the whole idea of giving a computer instructions. You have a couple of minutes to show off how awesome Python is. What do you do? I was thinking along the lines o

Re: lambdak: multi-line lambda implementation in native Python

2015-01-16 Thread Marko Rauhamaa
Gregory Ewing : > Dennis Lee Bieber wrote: >> On Fri, 16 Jan 2015 01:50:00 +1100, Chris Angelico >> declaimed the following: >> >>>Problem: You have a smartphone with a 4x4 pixel screen. >> >> BIG problem, considering that a late 70s DECWriter needed 5x7 >> pixels for glyphs in an 8x10 pixel

Re: Comparisons and sorting of a numeric class....

2015-01-16 Thread Rustom Mody
On Friday, January 16, 2015 at 7:20:13 AM UTC+5:30, Andrew Robinson wrote: Disclaimers 1. Ive not really read the above 542 lines and earlier 2. I am not a fan of OOP Still some thoughts... Electrical engineering (EE) and computer science (CS) may seem related but are quite different disciplin

Re: lambdak: multi-line lambda implementation in native Python

2015-01-16 Thread Gregory Ewing
Dennis Lee Bieber wrote: On Fri, 16 Jan 2015 01:50:00 +1100, Chris Angelico declaimed the following: > Problem: You have a smartphone with a 4x4 pixel screen. BIG problem, considering that a late 70s DECWriter needed 5x7 pixels for glyphs in an 8x10 pixel character cell {as I recall.

Re: Comparisons and sorting of a numeric class....

2015-01-16 Thread Gregory Ewing
Andrew Robinson wrote: I never said subclassing bool is the 'only' solution; I have indicated it's a far better solution than many. An assertion with which we very much disagree. I have spent well over twenty years on and off dealing with boolean values that are very often mixed indistingu

EuroPython 2015: Your chance to sign up as a launch sponsor

2015-01-16 Thread M.-A. Lemburg
Companies who would like to sign up as a EuroPython 2015 launch sponsor are encouraged to contact the sponsor work group at: sponsor...@europython.eu Launch sponsors will get the additional benefit of being listed on the website when we launch - for free. You just need to

Re: List of "python -m" tools

2015-01-16 Thread Miki Tebeka
Thanks for all the answers! -- https://mail.python.org/mailman/listinfo/python-list

Re: Comparisons and sorting of a numeric class....

2015-01-16 Thread Gregory Ewing
Ian Kelly wrote: Wait, are you actually asking why bool is a doubleton? If nobody has answered that, I think probably nobody understood you were asking it, because it shouldn't need to be explained. What does perhaps need explaining is why Python goes out of its way to *enforce* the doubleton-n