Re: python for loop

2009-04-01 Thread Arnaud Delobelle
Lada Kugis writes: > I'm coming from fortran and c background so I'm certainly biased by > them. But if you could explain one thing to me: > > in fortran for example: > for i=1,n > goes from 1,2,3,4,...,n > > in python for example: > for i in range(1,n) > goes from 1,2,3,4,...,n-1 > (that is, it

Re: double/float precision question

2009-04-01 Thread Steven D'Aprano
On Wed, 01 Apr 2009 19:13:33 +0200, TP wrote: > Hi everybody, > > Try the following python statements: > "%.40f" % 0.222 > '0.098864108374982606619596' float( 0.222) > 0.1 Remove the leading quote

Re: Detecting Binary content in files

2009-04-01 Thread John Machin
On Apr 1, 4:59 pm, Dennis Lee Bieber wrote: > On Tue, 31 Mar 2009 14:26:08 -0700 (PDT), ritu > declaimed the following in > gmane.comp.python.general: > > > > > if ( ( -B $filename || > >            $filename =~ /\.pdf$/ ) && > >          -s $filename > 0 ) { > >         return(1); > >     } > >

TIOBE programming language community index

2009-04-01 Thread Steven D'Aprano
The TIOBE programming community index has some interesting data this month. http://www.tiobe.com/content/paperinfo/tpci/index.html * The top three languages, C, C++ and Java between them have a combined rating approaching 50%; * Python has increased popularity over the last year, from positio

Re: A design problem I met again and again.

2009-04-01 Thread Carl Banks
On Apr 1, 12:44 am, 一首诗 wrote: > I got the same problem when writing C#/C++ when I have to provide a > lot of method to my code's user. So I create a big class as the entry > point of my code. Although these big classes doesn't contains much > logic, they do grow bigger and bigger. This seems

Re: Beazley on Generators

2009-04-01 Thread Craig Allen
this is great, thanks... we have used generators to create something akin to a cooperative tasking environment... not to implement multitasking, but to be able to control low level data processing scripts. These scripts, written as generators, yield control to a control loop which then can pause,

Re: Detecting Binary content in files

2009-04-01 Thread John Machin
On Apr 2, 8:39 am, John Machin wrote: > On Apr 1, 4:59 pm, Dennis Lee Bieber wrote: > > > > > On Tue, 31 Mar 2009 14:26:08 -0700 (PDT), ritu > > declaimed the following in > > gmane.comp.python.general: > > > > if ( ( -B $filename || > > >            $filename =~ /\.pdf$/ ) && > > >          -s

Re: Converting a PIL image object to a buffer

2009-04-01 Thread Simon Hibbs
On 1 Apr, 21:43, Gary Herron wrote: > Simon Hibbs wrote: > > I'm trying to dump a snapshot of my application window to the > > clipboard. I can use ImageGrab in PIL to get the screen data into a > > PIL image object, which i have converted to a bitmap using ImageWin, > > but when I try to pass thi

Re: Which is more Pythonic? (was: Detecting Binary content in files)

2009-04-01 Thread John Machin
On Apr 2, 2:10 am, John Posner wrote: > Dennis Lee Bieber presented a code snippet with two consecutive statements > that made me think, "I'd code this differently". So just for fun ... is > Dennis's original statement or my "_alt" statement more idiomatically > Pythonic? Are there even more Pytho

Re: Beazley on Generators

2009-04-01 Thread Carl Banks
On Mar 31, 10:03 pm, Terry Reedy wrote: > At PyCon2008, David Beazley presented an excellent talk on generators. > Generator Tricks for Systems > Programmershttp://www.dabeaz.com/generators/index.html > > At PyCon2009, he followed up with another talk on more advanced > generator usage, which Gui

Re: List of paths

2009-04-01 Thread Scott David Daniels
Nico Grubert wrote: Dear Python developers... I have the following (sorted) list I want to remove all paths x from the list if there is a path y in the list which is part of x so y.startswith(x) is true. The list I want to have is: ['/notebook', '/desktop', '/server/hp/proliant'] Any ide

Re: python for loop

2009-04-01 Thread Carl Banks
On Apr 1, 2:32 pm, Arnaud Delobelle wrote: > Lada Kugis writes: > > I'm coming from fortran and c background so I'm certainly biased by > > them. But if you could explain one thing to me: > > > in fortran for example: > > for i=1,n > > goes from 1,2,3,4,...,n > > > in python for example: > > for

Re: Beazley on Generators

2009-04-01 Thread Lawrence D'Oliveiro
In message <13298fc5-5024-4343- bf5a-7e271a08d...@o11g2000yql.googlegroups.com>, Michele Simionato wrote: > However, there are situations when you need thousands of lightweight > threads of execution ;;; The Linux kernel has been tested running hundreds of thousands of threads. -- http://mail.py

Re: python for loop

2009-04-01 Thread Ricardo Aráoz
Lada Kugis wrote: > On 01 Apr 2009 01:26:41 GMT, Steven D'Aprano > wrote: > > >> Why Python (and other languages) count from zero instead of one, and >> why half-open intervals are better than closed intervals: >> >> http://www.johndcook.com/blog/2008/06/26/why-computer-scientists-count-from-z

Re: how to handle/generate pcap file

2009-04-01 Thread Rhodri James
On Wed, 01 Apr 2009 14:53:34 +0100, Evan wrote: Hello - I'm trying to decode the pcap file which is packet capture by tcpdump or wireshark. Is there a python module that I can use it for this problem? Can python-libpcap or pycap or dpkt do that? A quick browse of the pypcap website sugge

Re: python for loop

2009-04-01 Thread Rhodri James
On Wed, 01 Apr 2009 15:12:27 +0100, Lada Kugis wrote: On 01 Apr 2009 08:06:28 GMT, Steven D'Aprano wrote: There are advantages and disadvantages to both systems, but on balance, I think that zero-based is a better system for programming, and one-based for natural language. Nicely put

Re: Thoughts on language-level configuration support?

2009-04-01 Thread Rhodri James
On Wed, 01 Apr 2009 05:15:19 +0100, jfager wrote: On Mar 31, 10:44 pm, "Rhodri James" wrote: [...] What restrictions can be put on the value you get back? What can the help system say about this, or do we have to go back to doing all that by hand? Now translate all those questions into the

Re: Matrix operations on character matrix element?

2009-04-01 Thread Terry Reedy
olusina eric wrote: I hope somebody will be able to help me here. I am trying to solve some physical problems that will require the generation of some function in terms of some parameters. These functions are derived from matrix operation on “characters”. Are there ways numpy/scipy perform mat

Re: Beazley on Generators

2009-04-01 Thread Steven D'Aprano
On Thu, 02 Apr 2009 11:37:46 +1300, Lawrence D'Oliveiro wrote: > In message <13298fc5-5024-4343- > bf5a-7e271a08d...@o11g2000yql.googlegroups.com>, Michele Simionato > wrote: > >> However, there are situations when you need thousands of lightweight >> threads of execution ;;; > > The Linux kerne

Re: Demographic Information about Python

2009-04-01 Thread Terry Reedy
Betiana Krancenblum wrote: Hi, I'm looking for statistical information about where Python is beeing used as a programming language and where it is teached as a language for beginner programmers. Where do you think I can find that information? There is some info at python.org. Ask on the e

Re: Matrix operations on character matrix element?

2009-04-01 Thread Robert Kern
On 2009-04-01 19:12, Terry Reedy wrote: olusina eric wrote: I hope somebody will be able to help me here. I am trying to solve some physical problems that will require the generation of some function in terms of some parameters. These functions are derived from matrix operation on “characters”.

Help for Toplevel

2009-04-01 Thread Muddy Coder
Hi Folks, I have a problem of handling Toplevel window. Basically, I wrote a listbox viewer with scrollbars, and saved in file listbo.py. Then in my main GUI window, with menu, I need to launch the listbox viewer, in a new window. Obviously, a Toplevel window is needed. But, I failed at passing pa

Re: Thoughts on language-level configuration support?

2009-04-01 Thread CTO
> I just mean that there should be a > clear and easy way to do it, that it should be considered a basic > service, and that if the best way to satisfy all the goals is to > integrate it directly into the language, that shouldn't be shied away > from. Honestly, the programming language and the con

pygame and socket.recv

2009-04-01 Thread Aaron Brady
Hi, I tried writing a small game on a pygame layer. The graphics are fine, and at the moment, it is not graphics intensive. It is multi- player, and for the communication, I am sending a pickle string across a LAN, once per frame. I'm observing some latency. It seems that socket.recv isn't per

Re: pygame and socket.recv

2009-04-01 Thread Tim Wintle
On Wed, 2009-04-01 at 17:58 -0700, Aaron Brady wrote: > I tried writing a small game on a pygame layer. The graphics are > fine, and at the moment, it is not graphics intensive. It is multi- > player, and for the communication, I am sending a pickle string across > a LAN, once per frame. > > I'm

Re: pygame and socket.recv

2009-04-01 Thread Aaron Brady
On Apr 1, 8:28 pm, Tim Wintle wrote: > On Wed, 2009-04-01 at 17:58 -0700, Aaron Brady wrote: > > I tried writing a small game on a pygame layer.  The graphics are > > fine, and at the moment, it is not graphics intensive.  It is multi- > > player, and for the communication, I am sending a pickle s

Re: how to handle/generate pcap file

2009-04-01 Thread Evan
On Apr 2, 6:59 am, "Rhodri James" wrote: > On Wed, 01 Apr 2009 14:53:34 +0100, Evan wrote: > > > Hello - > > > I'm trying to decode thepcapfilewhich is packet capture by tcpdump > > or wireshark.   Is there a python module that I can use it for this > > problem? > > > Can python-libpcap or pycap

Re: Beazley on Generators

2009-04-01 Thread Paul Rubin
Lawrence D'Oliveiro writes: > > However, there are situations when you need thousands of lightweight > > threads of execution ;;; > > The Linux kernel has been tested running hundreds of thousands of threads. Those are still heavyweight threads requiring context switches to switch from one to an

Re: Thoughts on language-level configuration support?

2009-04-01 Thread Steven D'Aprano
On Mon, 30 Mar 2009 06:40:00 -0700, jfager wrote: > The basic idea is that a language could offer syntactic support for > declaring configurable points in the program. The language system would > then offer an api to allow the end user to discover a programs > configuration service, as well as a

Re: Python Goes Mercurial

2009-04-01 Thread Lawrence D'Oliveiro
In message , Tim Daneliuk wrote: > ,,, when I suggested that better open source tools existed, they kindly > explained their complete lack of interest in moving several millions > of lines of code to anything new. What was their explanation? -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Goes Mercurial

2009-04-01 Thread Lawrence D'Oliveiro
In message <7a1dd0d8-1978-470b- a80d-57478d7f7...@q16g2000yqg.googlegroups.com>, Paul Boddie wrote: > And I've heard stories of "bait and > switch" with Git: "you can do XYZ with Git but not with ..." followed > by the discovery that you can't realistically do XYZ with Git, either. Cite? -- http

Display directory pyqt4 and Python

2009-04-01 Thread Dunwitch
I've looked around for the answer and have decided to ask an expert for the solution. Whats suppose to happen is a user pushes a button and displays the directory content in the text edit window on the gui. Everything works, apart from the fact that it only shows the last file in the directory, not

Re: Python Goes Mercurial

2009-04-01 Thread Tim Daneliuk
Lawrence D'Oliveiro wrote: > In message , Tim Daneliuk wrote: > >> ,,, when I suggested that better open source tools existed, they kindly >> explained their complete lack of interest in moving several millions >> of lines of code to anything new. > > What was their explanation? > Their entire

Re: Thoughts on language-level configuration support?

2009-04-01 Thread jfager
On Apr 1, 8:56 pm, CTO wrote: > > I just mean that there should be a > > clear and easy way to do it, that it should be considered a basic > > service, and that if the best way to satisfy all the goals is to > > integrate it directly into the language, that shouldn't be shied away > > from. > > Ho

Re: Which is more Pythonic?

2009-04-01 Thread Terry Reedy
John Machin wrote: On Apr 2, 2:10 am, John Posner wrote: Dennis Lee Bieber presented a code snippet with two consecutive statements that made me think, "I'd code this differently". So just for fun ... is Dennis's original statement or my "_alt" statement more idiomatically Pythonic? Are there e

Re: pygame and socket.recv

2009-04-01 Thread Terry Reedy
Aaron Brady wrote: My game loop looks like this: poll events, get 1 at most send to server wait for server reply render entire frame I am very sure that commercial 'real-time' (versus turn-based) multiplayer games do not operate that way, at least not the ones I have played. I suspect tha

Re: python for loop

2009-04-01 Thread John O'Hagan
On Wed, 1 Apr 2009, Steven D'Aprano wrote: > On Wed, 01 Apr 2009 04:39:26 +0100, Rhodri James wrote: > > Dragging this back to the original topic, you clearly find starting list > > indices from zero unintuitive. To me, with a mathematical background, > > it's not just intuitive, it's correct. Al

Sending SMS using python script

2009-04-01 Thread guptha
hi group, my application needs to send SMS occasionally to all the clients .Is there any library in python that supports in sending SMS. I like to conform few information i gathered in this regard. I can send SMS by two ways 1. Sending SMS using Email clients 2. Using sms gateway to send message

Re: Creating huge data in very less time.

2009-04-01 Thread Tim Roberts
Grant Edwards wrote: >On 2009-03-31, Dave Angel wrote: > >> They were added in NTFS, in the Windows 2000 timeframe, to my >> recollection. > >NTFS was added in NT 3.1 (which predates Win2K by 7-8 years). Although that's true, you didn't read his sentence. Sparse file support was not added to N

Re: python for loop

2009-04-01 Thread Lie
On Apr 1, 7:06 pm, Steven D'Aprano wrote: > There is a major clash between the names of ordinals in human languages > and zero-based counting. In human languages, the Nth-ordinal item comes > in position N. You can keep that useful convention with zero-based > counting by inventing the ugly word

Re: pygame and socket.recv

2009-04-01 Thread Aaron Brady
On Apr 1, 10:38 pm, Terry Reedy wrote: > Aaron Brady wrote: > > > My game loop looks like this: > > > poll events, get 1 at most > > send to server > > wait for server reply > > render entire frame > > I am very sure that commercial 'real-time' (versus turn-based) > multiplayer games do not operat

Re: python for loop

2009-04-01 Thread Aaron Brady
On Apr 1, 11:58 pm, Lie wrote: > On Apr 1, 7:06 pm, Steven D'Aprano > > wrote: > > There is a major clash between the names of ordinals in human languages > > and zero-based counting. In human languages, the Nth-ordinal item comes > > in position N. You can keep that useful convention with zero-b

Re: A design problem I met again and again.

2009-04-01 Thread Lawrence D'Oliveiro
In message <158986a9-b2d2-413e-9ca0- c584299f1...@f1g2000prb.googlegroups.com>, 一首诗 wrote: > On Apr 1, 4:55 pm, Lawrence D'Oliveiro central.gen.new_zealand> wrote: > >> In message <48506803-a6b9-432b-acef- >> >> b75f76e90...@v23g2000pro.googlegroups.com>, 一首诗 wrote: >> > Until one day I find serv

Re: Display directory pyqt4 and Python

2009-04-01 Thread Wolfgang Rohdewald
On Donnerstag, 2. April 2009, Dunwitch wrote: > for x in (fileList): > self.ui.displayVideo.setText(x) # This only shows the last self.ui.displayVideo.setText('\n'.join(fileList)) but I would go for a solution with QDirModel / QListView http://doc.trolltech.com/4.5/itemview

Re: python for loop

2009-04-01 Thread Lie
On Apr 2, 4:05 pm, Aaron Brady wrote: > On Apr 1, 11:58 pm, Lie wrote: > > > On Apr 1, 7:06 pm, Steven D'Aprano > > > wrote: > > > There is a major clash between the names of ordinals in human languages > > > and zero-based counting. In human languages, the Nth-ordinal item comes > > > in positi

Re: A design problem I met again and again.

2009-04-01 Thread Steven D'Aprano
On Thu, 02 Apr 2009 18:47:29 +1300, Lawrence D'Oliveiro wrote: >>> The question is not how many lines or how many methods, but whether it >>> makes sense to remain as one piece or not. In one previous project, I >>> had one source file with nearly 15,000 lines in it. Did it make sense >>> to split

Re: python for loop

2009-04-01 Thread Steven D'Aprano
On Thu, 02 Apr 2009 04:23:32 +, John O'Hagan wrote: > Beyond being part of a conventionally-ordered set of keys, what can an > ordinality of zero actually mean? (That's a sincere question.) In set theory, you start by defining the integers like this: 0 is the cardinality (size) of the empty

Re: python for loop

2009-04-01 Thread Steven D'Aprano
On Wed, 01 Apr 2009 21:58:47 -0700, Lie wrote: > On Apr 1, 7:06 pm, Steven D'Aprano > wrote: > >> There is a major clash between the names of ordinals in human languages >> and zero-based counting. In human languages, the Nth-ordinal item comes >> in position N. You can keep that useful conventi

Re: Regex trouble

2009-04-01 Thread akshat agarwal
Thanks Andrew. I was also of the same view that perl handled this via some special cases. On Wed, Apr 1, 2009 at 8:32 PM, andrew cooke wrote: > > more exactly, my guess is perl has a special case for this that avoids > doing a search over all possible matchers via the pushdown stack. > > andrew

Re: python for loop

2009-04-01 Thread Carl Banks
On Apr 1, 9:23 pm, John O'Hagan wrote: > Despite being thoroughly acclimatised to zero-based indexing and having no > wish to change it, I'm starting to see the OP's point. > > Many of the arguments presented in this thread in favour of zero-based > indexing have rather been arguments for half-ope

Re: python for loop

2009-04-01 Thread Aaron Brady
On Apr 2, 1:29 am, Steven D'Aprano wrote: > On Wed, 01 Apr 2009 21:58:47 -0700, Lie wrote: > > On Apr 1, 7:06 pm, Steven D'Aprano > > wrote: > > >> There is a major clash between the names of ordinals in human languages > >> and zero-based counting. In human languages, the Nth-ordinal item comes

<    1   2