Re: count strangeness

2011-05-21 Thread James Stroud
James Stroud wrote: Chris Rebert wrote: WTF? Assuming your question is "Why is 1024 there twice?", the answer is The question is "Why is 1024 there at all?" It should be 10. James I mean 11, not 10--but you get the point. James -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there a better way to solve this?

2011-05-21 Thread Chris Rebert
On Sat, May 21, 2011 at 11:28 PM, Ganapathy Subramanium wrote: > Hello, > > I'm a new bie to python programming and on the processing of learning python > programming. I have coded my first program of fibonnaci generation and would > like to know if there are better ways of achieving the same. > >

Re: count strangeness

2011-05-21 Thread James Stroud
Peter Otten wrote: James Stroud wrote: WTF? Put the code into a file, run it -- and be enlightened ;) tal 72% python2.7 eraseme.py 1 2 4 8tal 73% cat eraseme.py #! /usr/bin/env python class C: def __init__(self): self.data = [] def doit(self, count=0): for c in self.data:

Re: count strangeness

2011-05-21 Thread James Stroud
Chris Rebert wrote: WTF? Assuming your question is "Why is 1024 there twice?", the answer is The question is "Why is 1024 there at all?" It should be 10. James -- http://mail.python.org/mailman/listinfo/python-list

Re: count strangeness

2011-05-21 Thread Peter Otten
James Stroud wrote: > tal 65% python2.7 > Python 2.7.1 (r271:86832, May 21 2011, 22:52:14) > [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin > Type "help", "copyright", "credits" or "license" for more information. > py> class C(object): > ... def __init__(self): > ... self.data = [] >

Is there a better way to solve this?

2011-05-21 Thread Ganapathy Subramanium
Hello, I'm a new bie to python programming and on the processing of learning python programming. I have coded my first program of fibonnaci generation and would like to know if there are better ways of achieving the same. I still feel quite a few things to be improved. Just wanted experts thought

Re: count strangeness

2011-05-21 Thread Chris Rebert
On Sat, May 21, 2011 at 11:02 PM, James Stroud wrote: > tal 65% python2.7 > Python 2.7.1 (r271:86832, May 21 2011, 22:52:14) > [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin > Type "help", "copyright", "credits" or "license" for more information. > py> class C(object): > ...   def __init__(

count strangeness

2011-05-21 Thread James Stroud
tal 65% python2.7 Python 2.7.1 (r271:86832, May 21 2011, 22:52:14) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information. py> class C(object): ... def __init__(self): ... self.data = [] ... def doit(self, count=0): ...

Re: Why did Quora choose Python for its development?

2011-05-21 Thread Hansmeet Singh
i think we should end our butchering of perl on a light note (you may have already read this): EXTERIOR: DAGOBAH -- DAY With Yoda strapped to his back, Luke climbs up one of the many thick vines that grow in the swamp until he reaches the Dagobah statistics lab. Panting heavily, he continues his ex

Re: checking if a list is empty

2011-05-21 Thread Chris Angelico
On Sun, May 22, 2011 at 2:32 PM, rusi wrote: > Recently on the emacs list there was a big flame-fest because the > behavior (aka interface) of return/newline changed. > The argument for change: Can we have emacs behave a little more like a > 21st century application? > Against: Somebody's scriptin

Re: Why did Quora choose Python for its development?

2011-05-21 Thread Chris Angelico
On Sun, May 22, 2011 at 11:50 AM, Dan Stromberg wrote: > Perl is like 10 languages smushed together.  To write it, you need only > learn one of the 10.   To read someone else's, you don't know what subset of > those 10 they've used until you get deep into the code. +1 QOTW. Perl: The Swiss Army

Re: checking if a list is empty

2011-05-21 Thread rusi
On May 22, 8:52 am, Chris Angelico wrote: > On Sun, May 22, 2011 at 1:02 PM, rusi wrote: > > Why is the C library in linux called libc6 and not just libc? > > I assume you mean this?http://www.linux-m68k.org/faq/glibcinfo.html Ha Ha! Thanks for that link! I quote: > You should not be using libc

Multiprocessing: don't push the pedal to the metal?

2011-05-21 Thread John Ladasky
Hello again, everyone. I'm developing some custom neural network code. I'm using Python 2.6, Numpy 1.5, and Ubuntu Linux 10.10. I have an AMD 1090T six-core CPU. About six weeks ago, I asked some questions about multiprocessing in Python, and I got some very helpful responses from you all. ht

Re: checking if a list is empty

2011-05-21 Thread Chris Angelico
On Sun, May 22, 2011 at 1:02 PM, rusi wrote: > Why is the C library in linux called libc6 and not just libc? I assume you mean this? http://www.linux-m68k.org/faq/glibcinfo.html When you dynamically link against a shared object, you save on executable size, but you have to have that shared objec

Re: checking if a list is empty

2011-05-21 Thread rusi
On May 22, 1:11 am, Terry Reedy wrote: > I agree that the domain of a function should be defined from the start > (and only expanded in the future). I dont understand... I dont always write correct code -- otherwise called 'a bug' -- though I never let the damn bug lose intentionally. And when I

Re: checking if a list is empty

2011-05-21 Thread Chris Angelico
On Sun, May 22, 2011 at 11:02 AM, Steven D'Aprano wrote: > On Sat, 21 May 2011 15:46:01 +0100, John J Lee wrote: > > Er, yes? But in any realistic example (your trivial function xyzzyx below > is not very realistic) you'll almost certainly get additional hints in > the function body. True, but so

Re: TK program problem

2011-05-21 Thread bvdp
> One of the purposes and advantages of Python 3 is having only one class > system. Best to always use new-style classes in Python 2.2+ unless you > understand and need old-style classes (and need should be never for most > people). > Thanks for this. I'll keep it in mind! One thing I really don

Re: Why did Quora choose Python for its development?

2011-05-21 Thread Dan Stromberg
On Fri, May 20, 2011 at 1:47 PM, Dotan Cohen wrote: > They considered Haskell and OCaml and not a single mention of Perl? > Perl is like 10 languages smushed together. To write it, you need only learn one of the 10. To read someone else's, you don't know what subset of those 10 they've used u

Re: Abandoning Python

2011-05-21 Thread Dan Stromberg
On Sat, May 21, 2011 at 6:25 PM, Daniel Kluev wrote: > Also, most of these complaints could be solved by using correct python > dialect for particular task - RPython, Cython and so on. > Cython is an interesting dialect that I use now and then. RPython is probably just as well avoided. PyPy, w

Re: Abandoning Python

2011-05-21 Thread Dan Stromberg
On Sat, May 21, 2011 at 9:00 AM, John Bokma wrote: > > A language I want to give a serious try the coming months is Haskell. > > Haskell is indeed interesting. However, do any of Haskell's implementations exploit the opportunities for parallelism that Haskell's definition allows? -- http://mail

Re: Abandoning Python

2011-05-21 Thread Dan Stromberg
On Sat, May 21, 2011 at 8:49 AM, John J Lee wrote: > > > I still like Python after using it for over a decade, but there are > things I don't like. > > What are your favourite up-and-coming languages of the moment? > > Here's my wishlist (not really in any order): > > * A widely used standard f

Re: Abandoning Python

2011-05-21 Thread Daniel Kluev
On Sun, May 22, 2011 at 12:25 PM, Daniel Kluev wrote: > According to all language popularity indexes [1-10], C# and Forgot to include references, although everyone probably already knows them, [1] https://www.ohloh.net/languages?query=&sort=projects [2] http://www.tiobe.com/index.php/content/pap

Re: Abandoning Python

2011-05-21 Thread Daniel Kluev
On Sun, May 22, 2011 at 2:49 AM, John J Lee wrote: > Here's my wishlist (not really in any order): How come pony is not listed there? Language cannot be better than python without pony! >  * An even larger user base, contributing more and better free and >   commercial software. According to al

Re: checking if a list is empty

2011-05-21 Thread Steven D'Aprano
On Sat, 21 May 2011 15:46:01 +0100, John J Lee wrote: > In the absence of an explicit interface declaration (have any standards > emerged for that in Python 3, BTW?), the use of len() does give you some > information about the interface, which sometimes makes it easier to > change the function. E

Re: TK program problem

2011-05-21 Thread Terry Reedy
On 5/21/2011 8:03 PM, bvdp wrote: Yes, I can confirm that both the lambda and setting the class to: class selectFav(object): One of the purposes and advantages of Python 3 is having only one class system. Best to always use new-style classes in Python 2.2+ unless you understand and nee

Re: hash values and equality

2011-05-21 Thread Steven D'Aprano
On Sat, 21 May 2011 15:55:56 -0700, John Nagle wrote: > On 5/19/2011 11:33 PM, Ulrich Eckhardt wrote: > >> For that reason, it is generally useful to use immutable types like >> integers, floats, strings and tuples thereof as keys. Since you can't >> change them, you basically have the guarantee

Re: TK program problem

2011-05-21 Thread bvdp
On May 20, 4:37 pm, rantingrick wrote: > Thats sounds to me a lot like hammering square pegs though round > holes... Perhaps you should explain first in "plain english" what Ahh, but what fun would the Internet, Usenet and programming be without round holes and square pegs. I thought my English

Re: TK program problem

2011-05-21 Thread bvdp
Thanks, Peter, for the detailed explanation. I was going to write a bit of sample/minimal code to demo this, but you nicely beat me to it! > Here's a minimal script to reproduces the problem: > > $ cat tkcallclass.py > import Tkinter as tk > > root = tk.Tk() > root.withdraw() > > class Classic: >

Re: hash values and equality

2011-05-21 Thread Irmen de Jong
On 22-5-2011 0:55, John Nagle wrote: > On 5/19/2011 11:33 PM, Ulrich Eckhardt wrote: > >> For that reason, it is generally useful to use immutable types like >> integers, floats, strings and tuples thereof as keys. Since you can't change >> them, you basically have the guarantee that they hash the

Re: hash values and equality

2011-05-21 Thread John Nagle
On 5/19/2011 11:33 PM, Ulrich Eckhardt wrote: For that reason, it is generally useful to use immutable types like integers, floats, strings and tuples thereof as keys. Since you can't change them, you basically have the guarantee that they hash the same. Right. It's something of a lack tha

Re: Customize help output from optparse (or argparse)

2011-05-21 Thread Thorsten Kampe
* Thomas 'PointedEars' Lahn (Thu, 12 May 2011 22:22:20 +0200) > Thorsten Kampe wrote: > > I'm using optparse for a little Python script. > > > > 1. The output from "--help" is: > > """ > > Usage: script.py > > > > script.py does something > > > > Options: > > -h, --help show this help messa

Re: referring to package scope from module, using relative import?

2011-05-21 Thread Irmen de Jong
On 21-5-2011 22:00, Ian Kelly wrote: > Note that PEP 8 discourages relative imports and encourages absolute > imports, though. This would be the preferred way to do it: > > from A import something Right. I got rid of the silly relative import stuff. As an added bonus, this makes my original qu

Re: checking if a list is empty

2011-05-21 Thread Terry Reedy
On 5/21/2011 10:46 AM, John J Lee wrote: In the absence of an explicit interface declaration (have any standards emerged for that in Python 3, BTW?), the use of len() does give you some information about the interface, which sometimes makes it easier to change the function. I'm sure you fully u

Re: referring to package scope from module, using relative import?

2011-05-21 Thread Ian Kelly
On Sat, May 21, 2011 at 1:28 PM, Irmen de Jong wrote: > Hi, > > I have a package with several modules in it. The package also has some > objects created > in the package scope (done in the package __init__.py). > > Is it possible to access those package scope objects from the modules, with > rel

Re: Problem in using subprocess module and communicate()

2011-05-21 Thread Chris Rebert
On Sat, May 21, 2011 at 8:56 AM, vijay swaminathan wrote: > Hi  Gurus, > > I'm having some problem in using the communicate() along with the > subprocess.I would like to invoke a command prompt and pass  on a .bat file > to execute. I went through the subprocess module and understood that using >

referring to package scope from module, using relative import?

2011-05-21 Thread Irmen de Jong
Hi, I have a package with several modules in it. The package also has some objects created in the package scope (done in the package __init__.py). Is it possible to access those package scope objects from the modules, with relative imports or something? So that I don't have to import the packag

Re: Abandoning Python

2011-05-21 Thread Bill Allen
You have ideas, a text editor, and a computer - best get to coding. What's stopping you? You largely want Python, with modifications. Join the development team and help implement those changes, or fork your own flavor and do what you wish. Right? You imagine it's an easy task, so get after

experiments with dictionary attacks against password hashes, in Python

2011-05-21 Thread Irmen de Jong
Hi, I've been experimenting a little with dictionary attacks against password hashes. It turned out that Python is plenty fast for this task, if you use precomputed hash databases. I used a few rather large dictionary files (most of the words of the English language, and most of the words of t

[Book] Python 3 Web Development Beginner's Guide

2011-05-21 Thread Robert
Has anyone read this one? If so, what did you think? -- Bob -- http://mail.python.org/mailman/listinfo/python-list

Re: Abandoning Python

2011-05-21 Thread John Bokma
John J Lee writes: > > > I still like Python after using it for over a decade, but there are > things I don't like. > > What are your favourite up-and-coming languages of the moment? > > Here's my wishlist (not really in any order): > > * A widely used standard for (optional) interface declarat

Problem in using subprocess module and communicate()

2011-05-21 Thread vijay swaminathan
Hi Gurus, I'm having some problem in using the communicate() along with the subprocess.I would like to invoke a command prompt and pass on a .bat file to execute. I went through the subprocess module and understood that using communicate, we can send the send data to stdin. According to the doc

Abandoning Python

2011-05-21 Thread John J Lee
I still like Python after using it for over a decade, but there are things I don't like. What are your favourite up-and-coming languages of the moment? Here's my wishlist (not really in any order): * A widely used standard for (optional) interface declaration -- or something better. I wan

Re: checking if a list is empty

2011-05-21 Thread Emile van Sebille
On 5/21/2011 7:46 AM John J Lee said... Gregory Ewing writes: Hans Georg Schaathun wrote: 0 is a number as real and existent as any other, one would think that the empty list is also as real and existent as any other list. 0 does have some special properties, though, such as being the add

Re: List of WindowsError error codes and meanings

2011-05-21 Thread Genstein
Andrew Berg writes: Since Python 2.5, the errno attribute maps the Windows error to error codes that match the attributes of module errno. Good point, I completely misread that. At least the Windows error code is still available as the winerror attribute. As an aside - call me stupid, but I

Re: Python in CS1

2011-05-21 Thread Sarah Mount
On Sat, May 21, 2011 at 09:30, Franck Ditter wrote: > Except at MIT, who knows some good CS1 references for teaching Python ? James Shuttleworth and I did a lot of this at Coventry, the book Python for Rookies came from that. We don't use Python in CS1 at Wolverhampton, but James is still activel

Re: English Idiom in Unix: Directory Recursively

2011-05-21 Thread Grant Edwards
On 2011-05-19, Peter Moylan wrote: > In the microcontroller world, the big performance hits come from the > fact that the only available compilers are for C and sometimes C++. > (And nobody uses assembly language except for the very little jobs.) > The nature of the C language prevents compilers

Re: Python in CS1

2011-05-21 Thread Patty
- Original Message - From: "Corey Richardson" To: Sent: Saturday, May 21, 2011 7:19 AM Subject: Re: Python in CS1 -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 05/21/2011 04:30 AM, Franck Ditter wrote: Except at MIT, who knows some good CS1 references for teaching Python ? Tha

Re: checking if a list is empty

2011-05-21 Thread John J Lee
Gregory Ewing writes: > Hans Georg Schaathun wrote: >> 0 is a number as real and existent as any other, >> one would think that the empty list is also as real and existent as >> any other list. > > 0 does have some special properties, though, such as > being the additive identity and not having

Re: Python in CS1

2011-05-21 Thread Corey Richardson
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 05/21/2011 04:30 AM, Franck Ditter wrote: > Except at MIT, who knows some good CS1 references for teaching Python ? > Thanks, > >franck Check out http://www.python.org/community/sigs/current/edu-sig/, and if nothing there satisfies you jump ov

Re: Parsing a graph image

2011-05-21 Thread John J Lee
Bastian Ballmann writes: > Hi, > > the project sounds like the exact tool that i need but regarding the > user manual one has to mark the points on the graph manually. Therefore > it's more work to get the data out than doing it without a tool. Or may > I miss something here? > Greets Read the d

SOLVED Re: distutils on windows ignoring package_data

2011-05-21 Thread Wilbert Berendsen
Solved: the problem was right there in the packagelist() function, it replaced '/' with dots instead of using os.sep ... I'm very sorry for the noise, although it's surprising everything else works without dots in the packages names :-) with regard, Wilbert Berendsen -- http://www.wilbertberend

Re: Overuse of try/except/else?

2011-05-21 Thread Daniel Kluev
On Tue, May 10, 2011 at 11:40 AM, Kyle T. Jones wrote: > > It has been hard for me to determine what would constitute overuse. > Good example of abuse is catching KeyboardInterrupt or SystemExit inside some library code. PycURL does it, and its truly annoying. -- With best regards, Daniel Kluev

Re: application level monitoring for python

2011-05-21 Thread John J Lee
Walter Chang writes: > Hi > > is there any open source library for python that can allow application > level monitoring ? For example,application can send per request level/ > aggregated monitoring events and some remote server dump it and show > in the monitoring graph in real time ? What's be

Re: how to get PID from subprocess library

2011-05-21 Thread TheSaint
Kushal Kumaran wrote: > That's how it is able to give you the status. So, if you > are using getstatusoutput, you will have only one instance of your > command running. My intent is to launch only one program instance, which will goes as daemon. To avoid a second call I'd like rather to use Pyth

Re: List of WindowsError error codes and meanings

2011-05-21 Thread John J Lee
Andrew Berg writes: > This is probably somewhat off-topic, but where would I find a list of > what each error code in WindowsError means? WindowsError is so broad > that it could be difficult to decide what to do in an except clause. > Fortunately, sys.exc_info()[1][0] holds the specific error co

ANN: lfm v2.3

2011-05-21 Thread Iñigo Serna
Hi, new version of lfm. Note that it requires python v2.5+ now, and it's incompatible with v3.x. Description: == Last File Manager is a powerful file manager for the UNIX console. It has a curses interface and it's written in Python. Licensed under GNU Public License version 3. Some of t

Re: English Idiom in Unix: Directory Recursively

2011-05-21 Thread Lars Enderin
2011-05-21 11:54, Lars Enderin skrev: > 2011-05-21 11:52, Lars Enderin skrev: >> >> Please include attributions, in this case for Peter Moylan and rusi! > > Just Peter Moylan, sorry! Ignore the above. -- http://mail.python.org/mailman/listinfo/python-list

Re: English Idiom in Unix: Directory Recursively

2011-05-21 Thread Lars Enderin
2011-05-21 11:52, Lars Enderin skrev: > > Please include attributions, in this case for Peter Moylan and rusi! Just Peter Moylan, sorry! -- http://mail.python.org/mailman/listinfo/python-list

Re: English Idiom in Unix: Directory Recursively

2011-05-21 Thread Lars Enderin
2011-05-21 10:32, Jonathan de Boyne Pollard skrev: >> The supposed inefficiency of recursive implementations is based >> largely on the properties of hardware that is now obsolete. With >> modern processors there's no great efficiency hit. In some of the >> smaller microcontrollers, it's true, you

Re: hash values and equality

2011-05-21 Thread Peter Otten
Gregory Ewing wrote: > Ethan Furman wrote: >> Ulrich Eckhardt wrote: >> >>> If two equal objects have different hashes, they >>> will be stored in different places in the hash map. Looking for >>> object1 will then not turn up with object2, even though they are equal. >> >> In this case this is

Re: English Idiom in Unix: Directory Recursively

2011-05-21 Thread Jonathan de Boyne Pollard
The supposed inefficiency of recursive implementations is based largely on the properties of hardware that is now obsolete. With modern processors there's no great efficiency hit. In some of the smaller microcontrollers, it's true, you do have to worry about stack overflow; but the ARM processo

Re: Faster Recursive Fibonacci Numbers

2011-05-21 Thread Gregory Ewing
Chris Angelico wrote: It seems strange to smoothly slide from native integer to long integer and just keep on going, and yet to be unable to do the same if there's a fractional part on it. The trouble is that if you always compute exact results by default, the number of digits required can blow

distutils on windows ignoring package_data

2011-05-21 Thread Wilbert Berendsen
Hi, I have created a distutils setup.py script that installs a list of packages (all subpackages of one main package). Some packages have package_data files (icons, translations, etc). Running setup.py install on my Linux system (python 2.6) perfectly installs all package data, but on Windows

Python in CS1

2011-05-21 Thread Franck Ditter
Except at MIT, who knows some good CS1 references for teaching Python ? Thanks, franck -- http://mail.python.org/mailman/listinfo/python-list

Re: hash values and equality

2011-05-21 Thread Gregory Ewing
Ethan Furman wrote: Ulrich Eckhardt wrote: If two equal objects have different hashes, they will be stored in different places in the hash map. Looking for object1 will then not turn up with object2, even though they are equal. In this case this is the behavior I want. You can't rely on i

Re: TK program problem

2011-05-21 Thread Peter Otten
bvdp wrote: > I've just done an update to my system here to Ubuntu 11.04. Mostly no > problems ... but I have an important (to me) python/TK program that's > stopped working. Well, it works ... mostly. > > The python version is 2.7.1+ (no idea what the + means!). > > I _think_ I have traced the

Re: Overuse of try/except/else?

2011-05-21 Thread James Mills
On Sat, May 21, 2011 at 3:40 PM, Cameron Simpson wrote: > These days I think I'd use a LateFunction (a facility of my own which is > a lot like the futures module) which returns a callable when you submit > a function; the worker thread runs the submitted function and catches the > return value or