Re: When is divmod(a,b)[0] == floor(a/b)-1 ?

2009-09-26 Thread Martin v. Löwis
>> In [21]: a = 10.0 > >> In [22]: b = 10.0 / 3.0 > >> In [24]: divmod(a, b)[0] >> Out[24]: 2.0 > >> In [25]: math.floor(a / b) - 1.0 >> Out[25]: 2.0 > > Wow. To me this stuff is just black magic, with a bit of voodoo > added for good measure... Maybe some day I'll understand it. I think thi

Re: unexplainable python

2009-09-26 Thread John Nagle
dads wrote: Sorry forgot to mention I'm using python 2.6 This looks like a homework assignment. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: Plugins for a Python program

2009-09-26 Thread John Nagle
OldAl wrote: I am impressed with Bazaar's implementation of plugins: a Python plugin is simply copied to a ./bazaar/plugin/ directory and the plugin is recognized by Bazaar and can be run from CLI as: bzr I would like to implement something similar in my Finite Element Method program, so that

Re: Anyone with Experience Using WinTV Capture Cards?

2009-09-26 Thread W. eWatson
Tim Roberts wrote: "W. eWatson" wrote: W. eWatson wrote: A friend is looking for some help with how to use Python to access a WinTV (Go Plus) capture card, and how to display an image from it. Is there some facility that might help him, or does anyone have experience with such use that migh

Re: unexplainable python

2009-09-26 Thread Dave Angel
dads wrote: When creating a script that converts digits to words I've come across some unexplainable python. The script works fine until I use a 5 digit number and get a 'IndexError: string index out of range'. After looking into it and adding some print calls, it looks like a variable changes fo

Re: How to run python script in emacs

2009-09-26 Thread Nobody
On Sat, 26 Sep 2009 08:54:49 -0700, devilkin wrote: > I'm just starting learning python, and coding in emacs. I usually > split emacs window into two, coding in one, and run script in the > other, which is not very convenient. anyone can help me with it? is > there any tricks like emacs short cut?

Re: can i use the browser to show the result of python

2009-09-26 Thread Dave Angel
Hacken wrote: On Sep 25, 6:27 pm, Dave Angel wrote: Hacken wrote: I have write some python script i want to use browser(IE or FF) to call it, an show the returns! how to? You don't say much about your environment, nor the nature of your script. So my response will

Re: unexplainable python

2009-09-26 Thread Mel
dads wrote: > When creating a script that converts digits to words I've come across > some unexplainable python. The script works fine until I use a 5 digit > number and get a 'IndexError: string index out of range'. After > looking into it and adding some print calls, it looks like a variable > c

Re: unexplainable python

2009-09-26 Thread tec
dads 写道: ... enter number: 34567 _5digit function used 34 before sent to _2digit 34 slice when at _2digit function 34 before sent to plus_ten function 7 slice when at _2digit function This is the point. _2digit() only gets 1 digit("7") and needs accessing the second byte in: var = self.plu

Re: unexplainable python

2009-09-26 Thread Banibrata Dutta
Without reading or trying to understand the program well enough, at the very outset, looks like it's a program to convert a set of numeric digits into it's equivalent whole number representation, in textual form, and that while author of this piece of code has taken care of english numeric nuances

Re: How to run python script in emacs

2009-09-26 Thread Join hack
you can use emacs command shell for that 2009/9/26 devilkin > I'm just starting learning python, and coding in emacs. I usually > split emacs window into two, coding in one, and run script in the > other, which is not very convenient. anyone can help me with it? is > there any tricks like emacs

Re: unexplainable python

2009-09-26 Thread Chris Rebert
On Sat, Sep 26, 2009 at 7:37 PM, dads wrote: > When creating a script that converts digits to words I've come across > some unexplainable python. The script works fine until I use a 5 digit > number and get a 'IndexError: string index out of range'. Please provide the full error traceback. Help u

Re: unexplainable python

2009-09-26 Thread dads
Sorry forgot to mention I'm using python 2.6 -- http://mail.python.org/mailman/listinfo/python-list

unexplainable python

2009-09-26 Thread dads
When creating a script that converts digits to words I've come across some unexplainable python. The script works fine until I use a 5 digit number and get a 'IndexError: string index out of range'. After looking into it and adding some print calls, it looks like a variable changes for no reason. T

Re: can i use the browser to show the result of python

2009-09-26 Thread Steven D'Aprano
On Sat, 26 Sep 2009 19:05:37 -0700, Hacken wrote: > i just want write my programes in python, and i use Browser to show my > GUI, > > can i do that?and how to? > > thanks,waitting.. In Python 2.6, you can use the webbrowser module. -- Steven -- http://mail.python.org/mailman/listinfo

Re: can i use the browser to show the result of python

2009-09-26 Thread Hacken
On Sep 25, 6:27 pm, Dave Angel wrote: > Hacken wrote: > > I have write some python script > > > i want to use browser(IE or FF) to call it, an show the returns! > > > how to? > > You don't say much about your environment, nor the nature of your > script. So my response will be very generic. > > If

Plugins for a Python program

2009-09-26 Thread OldAl
I am impressed with Bazaar's implementation of plugins: a Python plugin is simply copied to a ./bazaar/plugin/ directory and the plugin is recognized by Bazaar and can be run from CLI as: bzr I would like to implement something similar in my Finite Element Method program, so that any user can wr

Re: flow control and nested loops

2009-09-26 Thread Bearophile
Raymond Hettinger: > Another approach for exiting multiple levels of loops is wrap the > inner calls in a function and return from them when needed: > >    def f(x): >        for y in y: >            for z in Z: >                if test1(x,y,z): >                    return >                frobnic

Re: What does the list_folders() method of mailbox.Maildir actually ?do (if anything)?

2009-09-26 Thread Tim Roberts
tinn...@isbd.co.uk wrote: > >My maildir hierarchy is created by mutt which is a *very* standards >compliant MUA, surely standard python libraries should work with >standard maildirs not some wierd extension thereof. The Maildir specification does not allow for subfolders. That was added in Maildi

Re: Anyone with Experience Using WinTV Capture Cards?

2009-09-26 Thread Tim Roberts
"W. eWatson" wrote: >W. eWatson wrote: >> A friend is looking for some help with how to use Python to access a >> WinTV (Go Plus) capture card, and how to display an image from it. Is >> there some facility that might help him, or does anyone have experience >> with such use that might suggest

Re: Is there a method (similar to str() method in R) that can print the data structure in python?

2009-09-26 Thread Robert Kern
On 2009-09-26 09:32 AM, Peng Yu wrote: Hi, I am looking for a method in python that is similar to the function str() in R, if you are familiar with R, If you have no idea of R, what I want is to print the class information of an object and the values of its members. Overloading '__expr__' and '

Re: Most "active" coroutine library project?

2009-09-26 Thread Grant Edwards
On 2009-09-26, Dave Angel wrote: > Actually even 64k looked pretty good, compared to the 1.5k of > RAM and 2k of PROM for one of my projects, a navigation system > for shipboard use. I've worked on projects as recently as the past year that had only a couple hundred bytes of RAM, and most of it

Re: How to control I/O buffering besides -u?

2009-09-26 Thread Matt Joiner
You can try flushing, or reopening with no buffering sys.stdout.flush() sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0) On Sun, Sep 27, 2009 at 2:20 AM, Dave Angel wrote: > kj wrote: >> >> Is there any way to specify unbuffered I/O from *within* the code >> (rather than via the command-line

Re: What does the list_folders() method of mailbox.Maildir actually ??do (if anything)?

2009-09-26 Thread tinnews
Jeff McNeil wrote: > > > My maildir hierarchy is created by mutt which is a *very* standards > > > compliant MUA, surely standard python libraries should work with > > > standard maildirs not some wierd extension thereof. > > > > > -- > > > Chris Green > > > > The doc says that "Folders of the sty

Re: Why the file mode of .pyc files has x?

2009-09-26 Thread Peng Yu
On Sat, Sep 26, 2009 at 8:10 AM, Steven D'Aprano wrote: > On Sat, 26 Sep 2009 06:57:52 -0500, Peng Yu wrote: > >> Hi, >> >> It is strange that the file mode of .pyc files are changed to executable >> (x mode) after the corresponding .py files have been run. > > Are you sure? They don't on my syste

Re: What does the list_folders() method of mailbox.Maildir actually ??do (if anything)?

2009-09-26 Thread tinnews
Jeff McNeil wrote: > > > The Maildir++ spec states that folders need to begin with a period. > > > The list_folders method enforces that: > > > > >     def list_folders(self): > > >         """Return a list of folder names.""" > > >         result = [] > > >         for entry in os.listdir(self._p

Re: [Tutor] Help required

2009-09-26 Thread Lie Ryan
waqas ahmad wrote: Now i want to search all those pages, where i have *NOT* written "#acl InternationalGroup:read" *But* i have written only "CatInternational" in the page text. You can split the two queries into two regexes: import re acl = re.compile(r'#acl InternationalGroup:read') cat =

Python-URL! - weekly Python news and links (Sep 26)

2009-09-26 Thread Gabriel Genellina
QOTW: "Forget ethical. We can do his homework for him, we can perhaps pass exams for him, maybe graduate for him, and then with our luck, he'll get a job in our office and we get to do his work for him." - Mel http://groups.google.com/group/comp.lang.python/msg/8f7c1fa393c23476

Re: importing with .m instead of .py

2009-09-26 Thread wisccal
Wanderer wrote: > Is there a way to get python to import files that don't end in .py? How about using imp.load_source? y...@x:/tmp$ cat out.m print("this is my module") # comment y=[1,2,3,4,5,6,7,8,9]; # comment y...@x:/tmp$ cat load_my_module.py import imp MyModule=imp.load_source('MyModule','ou

How to run python script in emacs

2009-09-26 Thread devilkin
I'm just starting learning python, and coding in emacs. I usually split emacs window into two, coding in one, and run script in the other, which is not very convenient. anyone can help me with it? is there any tricks like emacs short cut? also please recommand some emacs plug-ins for python progra

Re: Most "active" coroutine library project?

2009-09-26 Thread Grant Edwards
On 2009-09-26, Dennis Lee Bieber wrote: > On Fri, 25 Sep 2009 14:22:51 + (UTC), Grant Edwards > declaimed the following in > gmane.comp.python.general: > >> >> EXX accomplised much of the context switch operation. I don't >> remember how much RAM was available, but it wasn't much... > > Zilo

[ANN] python-daemon 1.5.1

2009-09-26 Thread Ben Finney
Howdy all, I'm pleased to announce the release of version 1.5.1 of ‘python-daemon’. What is python-daemon = The ‘python-daemon’ library is the reference implementation of PEP 3143 http://www.python.org/dev/peps/pep-3143/>, “Standard daemon process library”. The source distri

multiprocessing + console + windows = challenge?

2009-09-26 Thread Valery
Hi all. So, the doc is pitiless: "Note Functionality within this package requires that the __main__ method be importable by the children. This is covered in Programming guidelines however it is worth pointing out here. This means that some examples, such as the multiprocessing.Pool examples wi

Re: Twisted: 1 thread in the reactor pattern

2009-09-26 Thread exarkun
On 25 Sep, 05:25 am, jacopo.pe...@gmail.com wrote: On Sep 24, 7:54�pm, exar...@twistedmatrix.com wrote: On 07:10 am, jacopo.pe...@gmail.com wrote: >On Sep 23, 5:57�pm, exar...@twistedmatrix.com wrote: >[snip] [snip] If you have a function that takes 5 minutes to run, then you're blocking the

Re: Why the file mode of .pyc files has x?

2009-09-26 Thread Steven D'Aprano
On Sat, 26 Sep 2009 06:57:52 -0500, Peng Yu wrote: > Hi, > > It is strange that the file mode of .pyc files are changed to executable > (x mode) after the corresponding .py files have been run. Are you sure? They don't on my system. [st...@sylar test]$ ls -l total 8 -rw-rw-r-- 1 steve steve 6

Re: is this whiff/wsgi claim true?

2009-09-26 Thread exarkun
On 25 Sep, 02:26 pm, aaron.watt...@gmail.com wrote: Hi folks. I just modified the WHIFF concepts index page http://aaron.oirt.rutgers.edu/myapp/docs/W1000.concepts To include the following paragraph with a startling and arrogant claim in the final sentence :) """ Developers build WHIFF app

How to control I/O buffering besides -u?

2009-09-26 Thread kj
Is there any way to specify unbuffered I/O from *within* the code (rather than via the command-line -u flag)? TIA! kynn -- http://mail.python.org/mailman/listinfo/python-list

Re: Comparison of parsers in python?

2009-09-26 Thread andrew cooke
On Sep 21, 10:59 am, Nobody wrote: > I have a similar question. > > What I want: a tokeniser generator which can take a lex-style grammar (not > necessarily lex syntax, but a set of token specifications defined by > REs, BNF, or whatever), generate a DFA, then run the DFA on sequences of > bytes.

Re: Most "active" coroutine library project?

2009-09-26 Thread Dave Angel
Dennis Lee Bieber wrote: On Fri, 25 Sep 2009 14:22:51 + (UTC), Grant Edwards declaimed the following in gmane.comp.python.general: EXX accomplised much of the context switch operation. I don't remember how much RAM was available, but it wasn't much... Zilog Z80... as wit

RE: [Tutor] Help required

2009-09-26 Thread waqas ahmad
Hi, First of all thanks a lot for your reply. "search.findall" is not working. here is my complete small program. def getAcl(request, pg): pged = PageEditor(request, pg) pagetext = pged.get_raw_body() search=re.compile("^#acl InternationalGroup.*\n", re.M).search(pagetext) i

Why the file mode of .pyc files has x?

2009-09-26 Thread Peng Yu
Hi, It is strange that the file mode of .pyc files are changed to executable (x mode) after the corresponding .py files have been run. I have the follow python, which is compiled from source code by me. $ python --version Python 2.6.2 Should .pyc files have the x mode? Regards, Peng -- http://

Re: Format string with single quotes in it

2009-09-26 Thread Bahadir
On Sep 26, 6:33 am, "Gabriel Genellina" wrote: > > So, look in your file for lines ending in % > > -- > Gabriel Genellina Hello All, I fixed it with your help. Sometimes you need that extra insight from comp.lang.python. Thank you so much, Bahadir -- http://mail.python.org/mailman/listinfo/p

Re: flow control and nested loops

2009-09-26 Thread Raymond Hettinger
On Sep 25, 12:01 pm, kj wrote: > In Perl, one can label loops for finer flow control.  For example: > > X: for my $x (@X) { >   Y: for my $y (@Y) { >     for my $z (@Z) { >       next X if test1($x, $y, $z); >       next Y if test2($x, $y, $z); >       frobnicate($x, $y, $z); >     } >     glortz(

Re: raise errors

2009-09-26 Thread Gabriel Genellina
En Mon, 21 Sep 2009 06:17:20 -0300, daved170 escribió: I need help with exceptions raising. My goal is to print at the outer functions all the errors including the most inner one. The default exception report contains a lot of information, you don't have to do anything special. def foo1(

Re: nested structure with "internal references"

2009-09-26 Thread Hendrik van Rooyen
On Friday, 25 September 2009 19:11:06 Torsten Mohr wrote: > I'd like to use a nested structure in memory that consists > of dict()s and list()s, list entries can be dict()s, other list()s, > dict entries can be list()s or other dict()s. > > The lists and dicts can also contain int, float, string,

Re: Signing extensions

2009-09-26 Thread Roger Binns
Neil Hodgson wrote: >Code signing certificates that will be be valid for Windows > Authenticode cost $129 per year through CodeProject That isn't an amount I am prepared to pay either :-) (I don't even use Windows except as a glorified boot loader for Rise of Nations and to build Python exten

Is there a method (similar to str() method in R) that can print the data structure in python?

2009-09-26 Thread Peng Yu
Hi, I am looking for a method in python that is similar to the function str() in R, if you are familiar with R, If you have no idea of R, what I want is to print the class information of an object and the values of its members. Overloading '__expr__' and '__repr__' then using 'print' can sort of

Re: How to control I/O buffering besides -u?

2009-09-26 Thread Dave Angel
kj wrote: Is there any way to specify unbuffered I/O from *within* the code (rather than via the command-line -u flag)? TIA! kynn When creating a file object, specify a buffer size of zero. I don't know how to change the buffering of a file object that's already been created, as stdin, s

Re: How python source code in large projects are organized?

2009-09-26 Thread Christopher Arndt
On 20 Sep., 22:10, exar...@twistedmatrix.com wrote: > On 07:10 pm, pengyu...@gmail.com wrote: > > >On Sun, Sep 20, 2009 at 11:31 AM, Daniel Fetchinson > > wrote: > >>>I am wondering what is the best way of organizing python source code > >>>in a large projects. There are package code, testing code.