Re: Is there any advantage to using a main() in python scripts?

2013-12-11 Thread Roy Smith
In article , mar...@letterboxes.org wrote: > I would agree with the previous post but also add that I've stopped > calling the main function "main()" and usually give it a more > descriptive name, such as "bake_cookies()" or whatever. I think that > that makes it clearer what it's doing when use

Re: Is there any advantage to using a main() in python scripts?

2013-12-11 Thread Roy Smith
In article <32615c9a-b983-4399-bb55-6df6c230f...@googlegroups.com>, JL wrote: > Python scripts can run without a main(). What is the advantage to using a > main()? Is it necessary to use a main() when the script uses command line > arguments? (See script below) > > #!/usr/bin/python > > impo

Re: Programming puzzle with boolean circuits

2013-12-11 Thread Johannes Bauer
On 09.12.2013 14:25, Chris Angelico wrote: >> I found this puzzle again and was thinking about: How would I code a >> brute-force approach to this problem in Python? > > Ooooh interesting! Ha, I thought so too :-) > Well, here's a start: There's no value in combining the same value in > an AND

Re: grab dict keys/values without iterating ?!

2013-12-11 Thread Steven D'Aprano
On Wed, 11 Dec 2013 12:07:08 +0200, Tamer Higazi wrote: > Hi Dave! > > You were absolutely right. > I don't want to iterate the entire dict to get me the key/values > > Let us say this dict would have 20.000 entries, but I want only those > with "Aa" to be grabed. > Those starting with these 2 l

Re: Figuring out what dependencies are needed

2013-12-11 Thread Robert Kern
On 2013-12-11 13:27, Steven D'Aprano wrote: On Wed, 11 Dec 2013 04:44:53 -0800, sal wrote: Now I'd like to use the backtesting package from zipline (zipline.io), ".io" is not normally a file extension for Python files. Are you sure that's Python code? That's a package name, not a filename.

Re: grab dict keys/values without iterating ?!

2013-12-11 Thread rusi
Reordering to un-top-post. > On 11.12.2013 06:47, Dave Angel wrote: > > On Wed, 11 Dec 2013 02:02:20 +0200, Tamer Higazi wrote: > >> Is there a way to get dict by search terms without iterating the > > entire > >> dictionary ?! > >> I want to grab the dict's key and values started with 'Ar'... >

Re: Figuring out what dependencies are needed

2013-12-11 Thread Mark Lawrence
On 11/12/2013 12:44, s...@nearlocal.com wrote: I'm a Python beginner. I want to use it for stats work, so I downloaded Anaconda which has several of the popular libraries already packaged for Mac OS X. Now I'd like to use the backtesting package from zipline (zipline.io), but while running t

Re: Figuring out what dependencies are needed

2013-12-11 Thread Steven D'Aprano
On Wed, 11 Dec 2013 04:44:53 -0800, sal wrote: > Now I'd like to use the backtesting package from zipline (zipline.io), ".io" is not normally a file extension for Python files. Are you sure that's Python code? > but while running the test script in iPython, I receive the following > error: >

Re: please guide to make proxy type function in python

2013-12-11 Thread Mark Lawrence
On 11/12/2013 12:28, Jai wrote: please guide to make proxy type function in python Write some code after looking at the documentation http://docs.python.org/3/. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- ht

Re: grab dict keys/values without iterating ?!

2013-12-11 Thread Tamer Higazi
Hi Peter! I got the message I know that I could have used a database. I am using for a good reason the ZODB Database. I am making things in the ZODB Database persistent, I don't like to distribute among machines. Making use of sqlite, won't give me the possibility to scale as the amount

Re: Script Request

2013-12-11 Thread Steven D'Aprano
On Wed, 11 Dec 2013 04:53:41 -0700, Jeff James wrote: > Looking for a script which will check connectivity of any or all of our > company URL's first thing in the morning to make sure none or our sites > are down. Any suggestions ? Don't reinvent the wheel, use a tool already designed for thi

Re: Is there any advantage to using a main() in python scripts?

2013-12-11 Thread marduk
I would agree with the previous post but also add that I've stopped calling the main function "main()" and usually give it a more descriptive name, such as "bake_cookies()" or whatever. I think that that makes it clearer what it's doing when used as a library and the 'if __name__ == '__main__'" a

Figuring out what dependencies are needed

2013-12-11 Thread sal
I'm a Python beginner. I want to use it for stats work, so I downloaded Anaconda which has several of the popular libraries already packaged for Mac OS X. Now I'd like to use the backtesting package from zipline (zipline.io), but while running the test script in iPython, I receive the followin

Re: Experiences/guidance on teaching Python as a first programming language

2013-12-11 Thread Chris Angelico
On Wed, Dec 11, 2013 at 10:46 PM, Oscar Benjamin wrote: > This definitely wouldn't work for my students but a friend of mine > studied CS (at Warwick?) and his course worked as Dijkstra describes. > In the first year they don't touch a real programming language or > write any actual programs. They

Re: Experiences/guidance on teaching Python as a first programming language

2013-12-11 Thread Steve Simmons
On 11/12/2013 13:02, Chris Angelico wrote: On Wed, Dec 11, 2013 at 10:33 PM, Steve Simmons wrote: On 11/12/2013 11:45, Chris Angelico wrote: And then, shortly after the beginning of the story, you need to introduce the villain. Thanks, jmf, for taking that position in our role-play storytelli

please guide to make proxy type function in python

2013-12-11 Thread Jai
please guide to make proxy type function in python -- https://mail.python.org/mailman/listinfo/python-list

Re: Script Request

2013-12-11 Thread Larry Martell
On Wed, Dec 11, 2013 at 6:53 AM, Jeff James wrote: > Looking for a script which will check connectivity of any or all of our > company URL's first thing in the morning to make sure none or our sites are > down. Any suggestions ? Thank You import urllib sites = ["http://www.amazon.com/";, "

Re: grab dict keys/values without iterating ?!

2013-12-11 Thread Peter Otten
Tamer Higazi wrote: > Hi Dave! > > You were absolutely right. > I don't want to iterate the entire dict to get me the key/values > > Let us say this dict would have 20.000 entries, but I want only those > with "Aa" to be grabed. > Those starting with these 2 letters would be only 5 or 6 then it

Re: Experiences/guidance on teaching Python as a first programming language

2013-12-11 Thread Larry Martell
On Tue, Dec 10, 2013 at 9:16 PM, Denis McMahon wrote: > On Tue, 10 Dec 2013 20:35:47 -0500, Dennis Lee Bieber wrote: > >> On Tue, 10 Dec 2013 18:25:48 +1300, Gregory Ewing >> declaimed the following: > >>>That's like saying that when teaching woodwork we shouldn't let people >>>use hammers, we sh

Re: Experiences/guidance on teaching Python as a first programming language

2013-12-11 Thread Chris Angelico
On Wed, Dec 11, 2013 at 10:33 PM, Steve Simmons wrote: > > On 11/12/2013 11:45, Chris Angelico wrote: >> >> And then, shortly after the beginning of the story, you need to >> introduce the villain. Thanks, jmf, for taking that position in our >> role-play storytelling scenario! A round of applause

Script Request

2013-12-11 Thread Jeff James
Looking for a script which will check connectivity of any or all of our company URL's first thing in the morning to make sure none or our sites are down. Any suggestions ? Thank You -- https://mail.python.org/mailman/listinfo/python-list

Re: Experiences/guidance on teaching Python as a first programming language

2013-12-11 Thread Oscar Benjamin
On 11 December 2013 08:43, Chris Angelico wrote: > On Wed, Dec 11, 2013 at 7:34 PM, Devin Jeanpierre > wrote: > > When you tell a story, it's important to engage the reader from the > start. Sometimes that means starting the story in the middle of the > action, and filling in the important-but-le

Re: grab dict keys/values without iterating ?!

2013-12-11 Thread Tamer Higazi
Hi Dave! You were absolutely right. I don't want to iterate the entire dict to get me the key/values Let us say this dict would have 20.000 entries, but I want only those with "Aa" to be grabed. Those starting with these 2 letters would be only 5 or 6 then it would take a lot of time. In whi

Re: Trouble with Multi-threading

2013-12-11 Thread Steve Simmons
On 11/12/2013 11:37, Steven D'Aprano wrote: When did this forum become so intolerant of even the tiniest, most minor breaches of old-school tech etiquette? [... Giant Snip...] Well said Steven. I've only been member of this list for (maybe) a year, mainly lurking to learn about Python and I

mush 1.2 released! - Type-based dependency injection for scripts

2013-12-11 Thread Chris Withers
Hi All, I'm very happy to announce the a new release of Mush, a light weight dependency injection framework aimed at enabling the easy testing and re-use of chunks of code that make up scripts. This release rounds out a some more rough edges after even more real world use: - The 'nothing'

Re: Experiences/guidance on teaching Python as a first programming language

2013-12-11 Thread Steve Simmons
On 11/12/2013 11:45, Chris Angelico wrote: And then, shortly after the beginning of the story, you need to introduce the villain. Thanks, jmf, for taking that position in our role-play storytelling scenario! A round of applause for jmf, folks, for doing a brilliant impression of the uninformed-y

Re: Experiences/guidance on teaching Python as a first programming language

2013-12-11 Thread Steven D'Aprano
On Wed, 11 Dec 2013 19:43:52 +1100, Chris Angelico wrote: > [1] http://tvtropes.org/pmwiki/pmwiki.php/Main/InMediasRes TV Tropes? You utter, utter bastard. Must... resist... call... of... TV Tropes... -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Trouble with Multi-threading

2013-12-11 Thread Steven D'Aprano
On Tue, 10 Dec 2013 11:21:32 -0500, dan.rose wrote: > I am running PYTHON 2.7.3 and executing a PYTHON program that uses > multi-threading. I am running this on a 64-bit Windows 2008 R2 server > (Service Pack 1). Hi Dan, and despite the emails from a few others, welcome. My further comments bel

Re: Experiences/guidance on teaching Python as a first programming language

2013-12-11 Thread Chris Angelico
On Wed, Dec 11, 2013 at 7:43 PM, Chris Angelico wrote: > When you tell a story, it's important to engage the reader from the > start. On Wed, Dec 11, 2013 at 8:39 PM, wrote: > A few practical considerations, far away from theoretical > aspects. Mainly for non ascii, understand non native Englis

Re: Is there any advantage to using a main() in python scripts?

2013-12-11 Thread Chris Angelico
On Wed, Dec 11, 2013 at 9:26 PM, Ben Finney wrote: > except SystemExit, exc: For new code, you'd of course want to write that as: except SystemExit as exc: which is compatible with Python 2.6, 2.7, and 3.x, while the other syntax is 2.x only. ChrisA -- https://mail.python.org/mailman/

Re: Trouble with Multi-threading

2013-12-11 Thread Steven D'Aprano
On Tue, 10 Dec 2013 17:57:50 +, Walter Hurry wrote: > On Tue, 10 Dec 2013 11:21:32 -0500, dan.rose wrote: > >> "PLEASE NOTE: The preceding information may be confidential or >> privileged. It only should be used or disseminated for the purpose of >> conducting business with Parker. If you are

Re: Is there any advantage to using a main() in python scripts?

2013-12-11 Thread Ben Finney
JL writes: > Python scripts can run without a main(). What is the advantage to > using a main()? Modular code – that is, implementing the program functionality in small, well-defined units with narrow, strictly-defined interfaces – is good design. Practical benefits include being able to easily

Re: Differences between obj.attribute and getattr(obj, "attribute")

2013-12-11 Thread Johannes Schneider
thank you guys. On 11.12.2013 10:36, Chris Angelico wrote: 2013/12/11 Johannes Schneider : can somebody explain me the difference between accessing attributes via obj.attribute and getattr(obj, "attribute")? Is there a special reason or advantage when using getattr? You use getattr when the at

Re: Experiences/guidance on teaching Python as a first programming language

2013-12-11 Thread Mark Lawrence
On 11/12/2013 09:39, wxjmfa...@gmail.com wrote: A few practical considerations, far away from theoretical aspects. Mainly for non ascii, understand non native English speakers. Python is an "ascii oriented product". Sheer unadulterated rubbish. Platform. On Windows, the solely version which

Is there any advantage to using a main() in python scripts?

2013-12-11 Thread JL
Python scripts can run without a main(). What is the advantage to using a main()? Is it necessary to use a main() when the script uses command line arguments? (See script below) #!/usr/bin/python import sys def main(): # print command line arguments for arg in sys.argv[1:]: pri

Re: python import error

2013-12-11 Thread Mark Lawrence
On 11/12/2013 05:45, smilesonisa...@gmail.com wrote: On Wednesday, December 11, 2013 10:23:34 AM UTC+5:30, John Gordon wrote: In <93405ea9-6faf-4a09-9fd9-ed264e313...@googlegroups.com> smilesonisa...@gmail.com writes: File "aaa.py", line 5, in from ccc.ddd import sss ImportEr

Re: Experiences/guidance on teaching Python as a first programming language

2013-12-11 Thread wxjmfauth
A few practical considerations, far away from theoretical aspects. Mainly for non ascii, understand non native English speakers. Python is an "ascii oriented product". Platform. On Windows, the solely version which works harmoniously with the system is Py 2.7 in a byte string mode (ie non unicode

Re: Differences between obj.attribute and getattr(obj, "attribute")

2013-12-11 Thread Chris Angelico
On Wed, Dec 11, 2013 at 8:30 PM, Jurko Gospodnetić wrote: > Also, you can not test whether an object has an attribute when using the > object.attribute access method without raising/catching an exception and > then it can be hard to make sure no other code caused the exception. It's pretty easy

Re: Differences between obj.attribute and getattr(obj, "attribute")

2013-12-11 Thread Chris Angelico
2013/12/11 Johannes Schneider : > can somebody explain me the difference between accessing attributes via > obj.attribute and getattr(obj, "attribute")? > > Is there a special reason or advantage when using getattr? You use getattr when the attribute name comes from a string, rather than a literal

Re: Differences between obj.attribute and getattr(obj, "attribute")

2013-12-11 Thread Jurko Gospodnetić
Hi. On 11.12.2013. 9:23, Johannes Schneider wrote: can somebody explain me the difference between accessing attributes via obj.attribute and getattr(obj, "attribute")? Is there a special reason or advantage when using getattr? You can not use obj.attribute if you have the word 'attribute'

Differences between obj.attribute and getattr(obj, "attribute")

2013-12-11 Thread Johannes Schneider
Hi list, can somebody explain me the difference between accessing attributes via obj.attribute and getattr(obj, "attribute")? Is there a special reason or advantage when using getattr? bg, Johannes -- Johannes Schneider Webentwicklung johannes.schnei...@galileo-press.de Tel.: +49.228.42150.xxx

Re: Experiences/guidance on teaching Python as a first programming language

2013-12-11 Thread Chris Angelico
On Wed, Dec 11, 2013 at 7:34 PM, Devin Jeanpierre wrote: > On Tue, Dec 10, 2013 at 2:02 PM, Ethan Furman wrote: >> Doesn't sound like they do, as that's causing plenty of problems. In >> today's world that level of knowledge isn't always necessary, especially if >> your degree is not in CS. One

Re: Experiences/guidance on teaching Python as a first programming language

2013-12-11 Thread Devin Jeanpierre
On Tue, Dec 10, 2013 at 2:02 PM, Ethan Furman wrote: > Doesn't sound like they do, as that's causing plenty of problems. In > today's world that level of knowledge isn't always necessary, especially if > your degree is not in CS. One of the (many) nice things about Python is one > doesn't need t

Using Python inside Programming Without Coding Technology (PWCT) environment.

2013-12-11 Thread msfclipper
Hello Article : Using Python inside Programming Without Coding Technology (PWCT) environment. http://www.codeproject.com/Articles/693408/Using-Python-inside-Programming-Without-Coding-Tec In this article you will find information about using Python in the PWCT Visual Programming Environment P

load_module for loading packages

2013-12-11 Thread Sergey
Hi, If I use load_module for loading module, I can instantiate classes, defined in that module. Is it possible to do the same, if load not a module, but package? Python documentation for load_module contains description, that load_module can load a package. But I can not find examples, how to w

<    1   2