Re: My own accounting python euler problem

2009-11-07 Thread Martin P. Hellwig
vsoler wrote: As mentioned in the other answers, your problem is best solved by a long overdue organisational decision instead of a technical one. Most popular solutions are: - All invoices are essential a single credit amount, money coming in is taken of from the big pile. - Invoices are spli

Re: Most efficient way to "pre-grow" a list?

2009-11-07 Thread Paul Rudin
kj writes: > The best I can come up with is this: > > arr = [None] * 100 > > Is this the most efficient way to achieve this result? > Depends on what you take as given. You can do it with ctypes more efficiently, but you can also shoot yourself in the foot. Another possibility is to use a n

Re: is None or == None ?

2009-11-07 Thread Alf P. Steinbach
* Hrvoje Niksic: "Alf P. Steinbach" writes: Speedup would likely be more realistic with normal implementation (not fiddling with bit-fields and stuff) I'm not sure I understand this. How would you implement tagged integers without encoding type information in bits of the pointer value? A

Re: Cancelling a python thread (revisited...)

2009-11-07 Thread John Nagle
Carl Banks wrote: Arguing that there are good reasons to allow killing threads isn't going to get you very far. The language developers already know killing a thread is useful, yet the disallowed it anyway. The drawbacks were judged too severe (it makes enforcing invariants pretty much impossib

RE: How to parse HTTP time header?

2009-11-07 Thread Kevin Ar18
Page 20 of RFC2616 (HTTP) describes the format(s) for the time header. It wouldn't be too difficult for me to code up a solution for the 3 standard formats, but what get's me is the little note about how some servers may still send badly format time headers. :( So, I'm cu

Re: How to parse HTTP time header?

2009-11-07 Thread Philip Semanchuk
On Nov 7, 2009, at 10:56 PM, Kevin Ar18 wrote: Basically, I'm wondering if it is part of the standard library somewhere before I code my own. Page 20 of RFC2616 (HTTP) describes the format(s) for the time header. It wouldn't be too difficult for me to code up a solution for the 3 standard f

Re: How to parse HTTP time header?

2009-11-07 Thread Kevin Ar18
>> Basically, I'm wondering if it is part of the standard library >> somewhere before I code my own. >> >> Page 20 of RFC2616 (HTTP) describes the format(s) for the time >> header. It wouldn't be too difficult for me to code up a solution >> for the 3 standard formats, but what get's me is

Re: How to parse HTTP time header?

2009-11-07 Thread Philip Semanchuk
On Nov 7, 2009, at 10:39 PM, Kevin Ar18 wrote: Basically, I'm wondering if it is part of the standard library somewhere before I code my own. Page 20 of RFC2616 (HTTP) describes the format(s) for the time header. It wouldn't be too difficult for me to code up a solution for the 3 stan

How to parse HTTP time header?

2009-11-07 Thread Kevin Ar18
Basically, I'm wondering if it is part of the standard library somewhere before I code my own. Page 20 of RFC2616 (HTTP) describes the format(s) for the time header. It wouldn't be too difficult for me to code up a solution for the 3 standard formats, but what get's me is the little note abou

Re: Cancelling a python thread (revisited...)

2009-11-07 Thread Carl Banks
On Nov 7, 6:04 pm, Sven Marnach wrote: > So do I really have to refactor my C library just because Python > Thread objects lack a cancel method?  Is there really no other way? It doesn't sound like the thread is communicating with the process much. Therefore: 1. Run the C code in a separate pro

Re: An assessment of Tkinter and IDLE

2009-11-07 Thread r
More on canvas widget... The Canvas widget should return objects and not simple tags/ids for canvas items *OR* at least allow for me to add attributes to the canvasitems "obj". I find that the id/tag system --while quite simple and strait forward-- can really leave you with both hands tied behind

Cancelling a python thread (revisited...)

2009-11-07 Thread Sven Marnach
Hi, the Python threading module does not seem to provide a means to cancel a running thread. There are many discussions on the web dealing with this issue and many solutions are offered, but none of them seems to be applicable to my situation, which is as follows: I have a C library which does s

Re: Spam Bot, broken pipe

2009-11-07 Thread Someone Something
anyone? On Sat, Nov 7, 2009 at 9:06 PM, Someone Something wrote: > > > I'm just testing it on my channel! I promise! Besides, I'm doing it to > learn about sockets! Please! > > > On Sat, Nov 7, 2009 at 8:07 PM, Krister Svanlund < > krister.svanl...@gmail.com> wrote: > >> On Sun, Nov 8, 2009 at 2:

Re: PyQt processEvents not processing

2009-11-07 Thread DarkBlue
On Nov 8, 12:04 am, David Boddie wrote: > On Saturday 07 November 2009 05:12, DarkBlue wrote: > > > > > qt 4.5.3 > > pyqt 4.6.1 > > python 2.6 > > > I have this QtTable widget which I want to refresh once about every 2 > > seconds with new data. > > > so I do : > > >  def updateSchedule(self): > >

Re: is None or == None ?

2009-11-07 Thread Hrvoje Niksic
"Alf P. Steinbach" writes: > Speedup would likely be more realistic with normal implementation (not > fiddling with bit-fields and stuff) I'm not sure I understand this. How would you implement tagged integers without encoding type information in bits of the pointer value? -- http://mail.pytho

Re: Web development with Python 3.1

2009-11-07 Thread Alan Harris-Reid
mario ruggier wrote: With respect to to original question regarding web frameworks + database and Python 3, all the following have been available for Python 3 since the day Python 3.0 was released: QP, a Web Framework http://pypi.python.org/pypi/qp/ Durus, a Python Object Database (the "defaul

Spam Bot, broken pipe

2009-11-07 Thread Someone Something
I'm just testing it on my channel! I promise! Besides, I'm doing it to learn about sockets! Please! On Sat, Nov 7, 2009 at 8:07 PM, Krister Svanlund wrote: > On Sun, Nov 8, 2009 at 2:00 AM, Someone Something > wrote: > > I have a irc spam bot (only testing on my channel :P ) whose main loop is

Re: How convert string '1e7' to an integer?

2009-11-07 Thread Tim Chase
Mick Krippendorf wrote: Peng Yu wrote: It seems that int() does not convert '1e7'. It seems it does, though: int('1e7', base=16) 487 Bah...so narrow-minded ;-) >>> print '\n'.join("Base %i: %i" % (base, int('1e7', base=base)) for base in range(15,37)) Base 15: 442 Base 16: 487 Base 17:

Re: How convert string '1e7' to an integer?

2009-11-07 Thread Christian Heimes
Peng Yu wrote: > It seems that int() does not convert '1e7'. I'm wondering what > function to use to convert '1e7' to an integer? 1e7 is a way to express a float in science and math. Try float("1e7") Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: How convert string '1e7' to an integer?

2009-11-07 Thread Benjamin Kaplan
On Sat, Nov 7, 2009 at 8:17 PM, Peng Yu wrote: > It seems that int() does not convert '1e7'. I'm wondering what > function to use to convert '1e7' to an integer? > int('1e7') > Traceback (most recent call last): >  File "", line 1, in > ValueError: invalid literal for int() with base 10: '1e

Re: How convert string '1e7' to an integer?

2009-11-07 Thread Gary Herron
Mensanator wrote: On Nov 7, 7:17 pm, Peng Yu wrote: It seems that int() does not convert '1e7'. Because 'e' isn't a valid character in base 10. But 1e7 is a valid float, so this works: >>> int(float('1e7')) 1000 That has a problem though, if you surpass the ability of a flo

Re: How convert string '1e7' to an integer?

2009-11-07 Thread Ben Finney
Mick Krippendorf writes: > Peng Yu wrote: > > It seems that int() does not convert '1e7'. > It seems it does, though: > > >>> int('1e7', base=16) > 487 Well played, sir. -- \ “It is wrong to think that the task of physics is to find out | `\ how nature *is*. Physics concerns w

Re: How convert string '1e7' to an integer?

2009-11-07 Thread MRAB
Peng Yu wrote: It seems that int() does not convert '1e7'. I'm wondering what function to use to convert '1e7' to an integer? int('1e7') Traceback (most recent call last): File "", line 1, in ValueError: invalid literal for int() with base 10: '1e7' In Python the e-form indicates a float,

Re: How convert string '1e7' to an integer?

2009-11-07 Thread Mick Krippendorf
Peng Yu wrote: > It seems that int() does not convert '1e7'. It seems it does, though: >>> int('1e7', base=16) 487 Mick. -- http://mail.python.org/mailman/listinfo/python-list

Re: How convert string '1e7' to an integer?

2009-11-07 Thread Mensanator
On Nov 7, 7:17 pm, Peng Yu wrote: > It seems that int() does not convert '1e7'. Because 'e' isn't a valid character in base 10. > I'm wondering what > function to use to convert '1e7' to an integer? > > >>> int('1e7') >>> int(1e7) 1000 > > Traceback (most recent call last): >   File "", l

Re: Most efficient way to "pre-grow" a list?

2009-11-07 Thread exarkun
On 01:18 am, pavlovevide...@gmail.com wrote: On Nov 7, 5:05�pm, sturlamolden wrote: On 7 Nov, 03:46, gil_johnson wrote:> > I don't have the code with me, but for huge arrays, I have used > something like: > >>> arr[0] = initializer > >>> for i in range N: > >>> � � �arr.extend(arr) > This d

Re: Most efficient way to "pre-grow" a list?

2009-11-07 Thread Carl Banks
On Nov 7, 5:05 pm, sturlamolden wrote: > On 7 Nov, 03:46, gil_johnson wrote:> > > > I don't have the code with me, but for huge arrays, I have used > > something like: > > > >>> arr[0] = initializer > > >>> for i in range N: > > >>>      arr.extend(arr) > > > This doubles the array every time thr

How convert string '1e7' to an integer?

2009-11-07 Thread Peng Yu
It seems that int() does not convert '1e7'. I'm wondering what function to use to convert '1e7' to an integer? >>> int('1e7') Traceback (most recent call last): File "", line 1, in ValueError: invalid literal for int() with base 10: '1e7' -- http://mail.python.org/mailman/listinfo/python-list

Re: Most efficient way to "pre-grow" a list?

2009-11-07 Thread sturlamolden
On 6 Nov, 22:03, kj wrote: > As I said, this is considered an optimization, at least in Perl, > because it lets the interpreter allocate all the required memory > in one fell swoop, instead of having to reallocate it repeatedly > as the array grows. Python does not need to reallocate repeatedly

Re: feedback on function introspection in argparse

2009-11-07 Thread Carl Banks
On Nov 7, 3:44 pm, Yuv wrote: > On Nov 8, 1:33 am, Carl Banks wrote: > > > Is the docstring expected to be formatted according to some > > convention? [snippage] > We tried to comply to PEP 257 and we're open to suggestions on this. Ah, so we finally get to the answer: the convention is PEP 2

Re: Most efficient way to "pre-grow" a list?

2009-11-07 Thread sturlamolden
On 7 Nov, 03:46, gil_johnson wrote:> > I don't have the code with me, but for huge arrays, I have used > something like: > > >>> arr[0] = initializer > >>> for i in range N: > >>>      arr.extend(arr) > > This doubles the array every time through the loop, and you can add > the powers of 2 to get

Re: Most efficient way to "pre-grow" a list?

2009-11-07 Thread sturlamolden
On 6 Nov, 13:12, kj wrote: > > The best I can come up with is this: > > arr = [None] * 100 > > Is this the most efficient way to achieve this result? Yes, but why would you want to? Appending to a Python list has amortized O(1) complexity. I am not sure about Perl, but in MATLAB arrays are p

Spam Bot, broken pipe

2009-11-07 Thread Someone Something
I have a irc spam bot (only testing on my channel :P ) whose main loop is the following: privc="PRIVMSG "+self.channel while True: self.sock.send(privc=" :SPAM SPAM SPAM!"); time.sleep(2); And it gives an error "Broken Pipe". How can I fix this? -- http://mail.python.org/mailman/listin

Re: Most efficient way to "pre-grow" a list?

2009-11-07 Thread kj
In Luis Alberto Zarrabeitia Gomez writes: >Quoting Andre Engels : >> On Sat, Nov 7, 2009 at 8:25 PM, Luis Alberto Zarrabeitia Gomez >> wrote: >> > >> > Ok, he has a dict. >> > >> > Now what? He needs a non-sparse array. >> >> Let d be your dict. >> >> Call the zeroeth place in your array d

Re: feedback on function introspection in argparse

2009-11-07 Thread Yuv
On Nov 8, 1:33 am, Carl Banks wrote: > Is the docstring expected to be formatted according to some > convention? Yes it does, we parse the docstring as explained in argparse.py: def _parse_docstring(function): """Parses a function's docstring for a description of the function and for help

Re: feedback on function introspection in argparse

2009-11-07 Thread Carl Banks
On Nov 7, 2:45 pm, Yuv wrote: > This was posted to the argparse mailing list by Steven Bethard and now > we'd like some feedback from comp.lang.python. > > We now have a branch[5] of argparse that supports an ``argparse.run`` > function[6] which does > some function introspection to build a comman

Re: Microsoft research on code quality

2009-11-07 Thread Mensanator
On Nov 6, 3:15 pm, a...@pythoncraft.com (Aahz) wrote: > http://research.microsoft.com/en-us/news/features/nagappan-100609.aspx > -- > Aahz (a...@pythoncraft.com)           <*>        http://www.pythoncraft.com/ > > [on old computer technologies and programmers]  "Fancy tail fins on a > brand new '5

Re: exception due to NoneType

2009-11-07 Thread Ben Finney
asit writes: > for s in users: > print > print "##" > try: > print "user id : " + str(s.id) > print "user name : " + s.name > print "user location : " + s.location > print "user description : " + s.description >

Re: is None or == None ?

2009-11-07 Thread Steven D'Aprano
On Sat, 07 Nov 2009 14:22:28 -0800, sturlamolden wrote: > On 6 Nov, 14:35, "Alf P. Steinbach" wrote: > >> As I understand it, 'is' will always work and will always be efficient >> (it just checks the variable's type), while '==' can depend on the >> implementation of equality checking for the ot

Re: feedback on function introspection in argparse

2009-11-07 Thread geremy condra
On Sat, Nov 7, 2009 at 5:45 PM, Yuv wrote: > This was posted to the argparse mailing list by Steven Bethard and now > we'd like some feedback from comp.lang.python. > > We now have a branch[5] of argparse that supports an ``argparse.run`` > function[6] which does > some function introspection to b

Re: database handling

2009-11-07 Thread Bruno Desthuilliers
asit a écrit : > I need some tutorial about python-mysql connectivity(database > handling). > > Somebody please help me !! You didn't search very far, did you ? http://wiki.python.org/moin/DatabaseProgramming/ -- http://mail.python.org/mailman/listinfo/python-list

Re: exception due to NoneType

2009-11-07 Thread Bruno Desthuilliers
asit a écrit : > On Nov 7, 10:36 pm, Bruno Desthuilliers > wrote: >> asit a écrit : >> >>> In my program I want to catch exception which is caused by accessing >>> NoneType object. >>> Can anyone suggest me how this can be done ?? >> Not without the minimal working code exposing your problem, or t

Re: is None or == None ?

2009-11-07 Thread sturlamolden
On 6 Nov, 17:54, "Alf P. Steinbach" wrote: > But wow. That's pretty hare-brained: dynamic allocation for every stored value > outside the cache range, needless extra indirection for every operation. First, integers are not used the same way in Python as they are in C+ +. E.g. you typically don't

feedback on function introspection in argparse

2009-11-07 Thread Yuv
This was posted to the argparse mailing list by Steven Bethard and now we'd like some feedback from comp.lang.python. We now have a branch[5] of argparse that supports an ``argparse.run`` function[6] which does some function introspection to build a command line parser from a function definition:

Re: Serious Privileges Problem: Please Help

2009-11-07 Thread Rami Chowdhury
On Saturday 07 November 2009 13:51:06 Victor Subervi wrote: > httpd.conf: > > > ServerAdmin m...@creative.vi > DocumentRoot /var/www/html/angrynates.com > ServerName angrynates.com > Options +ExecCGI -IncludesNoExec > You may want to change this to: If you want regular expression syn

Re: Program to compute and print 1000th prime number

2009-11-07 Thread Wayne Brehaut
On Sat, 7 Nov 2009 19:34:47 +0100, Andre Engels wrote: >On Sat, Nov 7, 2009 at 6:40 PM, Mensanator wrote: > >>> Tongue in cheek solution: >>> >>> import urllib2 >>> >>> url = 'http://primes.utm.edu/lists/small/1.txt' >>> primes = [] >>> for line in urllib2.urlopen(url).read().splitlines(): >

Re: Command parsing... best module to use?

2009-11-07 Thread van Asselt
Hello Colin, I have been using 'cmdloop.py' from Crutcher Dunnavant in a few programs See http://py-cmdloop.googlecode.com/svn/trunk/cmdloop.py Regards, Henk - "Collin D" wrote in message news:94dbc92b-0682-4995-b358-0c615c95a...@x6g2000prc.googlegroups.com... > Hey ev

Re: is None or == None ?

2009-11-07 Thread sturlamolden
On 6 Nov, 18:28, "Alf P. Steinbach" wrote: > Dynamic allocation isn't hare-brained, but doing it for every stored integer > value outside a very small range is, because dynamic allocation is (relatively > speaking, in the context of integer operations) very costly even with a > (relatively speaki

Re: Most efficient way to "pre-grow" a list?

2009-11-07 Thread Ivan Illarionov
On Nov 6, 3:12 pm, kj wrote: > The best I can come up with is this: > > arr = [None] * 100 > > Is this the most efficient way to achieve this result? It is the most efficient SAFE way to achieve this result. In fact, there IS the more efficient way, but it's dangerous, unsafe, unpythonic and

Re: is None or == None ?

2009-11-07 Thread sturlamolden
On 6 Nov, 14:35, "Alf P. Steinbach" wrote: > As I understand it, 'is' will always work and will always be efficient (it > just > checks the variable's type), while '==' can depend on the implementation of > equality checking for the other operand's class. '==' checks for logical equality. 'is'

Re: exception due to NoneType

2009-11-07 Thread Diez B. Roggisch
api = twitter.Api('asitdhal','swordfish') You just gave the world the account-information to your twitter-account. You'd rather change these asap, or somebody hijacks your account... Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: Most efficient way to "pre-grow" a list?

2009-11-07 Thread Terry Reedy
Steven D'Aprano wrote: On Fri, 06 Nov 2009 18:46:33 -0800, gil_johnson wrote: I don't have the code with me, but for huge arrays, I have used something like: arr[0] = initializer for i in range N: arr.extend(arr) This doubles the array every time through the loop, and you can add the po

Re: My own accounting python euler problem

2009-11-07 Thread Robert P. J. Day
On Sat, 7 Nov 2009, vsoler wrote: > In the accounting department I am working for we are from time to > time confronted to the following problem: > > A customer sends us a check for a given amount, but without > specifying what invoices it cancels. It is up to us to find out > which ones the payme

Re: Serious Privileges Problem: Please Help

2009-11-07 Thread Victor Subervi
httpd.conf: ServerAdmin m...@creative.vi DocumentRoot /var/www/html/angrynates.com ServerName angrynates.com Options +ExecCGI -IncludesNoExec Options +ExecCGI AllowOverride Options AllowOverride FileInfo #AddHandler mod_python .py #PythonHandler mod_python.publisher #PythonDebug On #l

Re: My own accounting python euler problem

2009-11-07 Thread Robert P. J. Day
On Sat, 7 Nov 2009, vsoler wrote: > In the accounting department I am working for we are from time to > time confronted to the following problem: > > A customer sends us a check for a given amount, but without > specifying what invoices it cancels. It is up to us to find out > which ones the payme

Re: My own accounting python euler problem

2009-11-07 Thread Jack Diederich
On Sat, Nov 7, 2009 at 4:39 PM, vsoler wrote: > In the accounting department I am working for we are from time to time > confronted to the following problem: [snip] > For example, say that the customer has the following outstanding > invoices:  $300, $200, $50; and say that the check is for $250.

My own accounting python euler problem

2009-11-07 Thread vsoler
In the accounting department I am working for we are from time to time confronted to the following problem: A customer sends us a check for a given amount, but without specifying what invoices it cancels. It is up to us to find out which ones the payment corresponds to. For example, say that the

Re: imputil.py, is this a bug ?

2009-11-07 Thread Terry Reedy
lkcl wrote: On Nov 7, 2:20 am, "Gabriel Genellina" wrote: Yes, seems to be a bug. But given the current status of imputil, it's not likely to be fixed; certainly not in 2.5 which only gets security fixes now. well, that bug's not the only one. the other one that i found, which i have been s

Re: Serious Privileges Problem: Please Help

2009-11-07 Thread Rami Chowdhury
On Saturday 07 November 2009 06:13:11 Victor Subervi wrote: > I have a serious privileges problem that is making it impossible to serve > python pages on a CentOS server. It appears that nobody on the CentOS > discussion list has a solution to this problem. I'm desperate and hoping > someone on thi

Re: imputil.py, is this a bug ?

2009-11-07 Thread Terry Reedy
Stef Mientki wrote: Gabriel Genellina wrote: En Fri, 06 Nov 2009 18:33:37 -0300, Stef Mientki escribió: I get an error compiling with pyjamas, in the standard module imputil, _import_top_module Note that imputil is undocumented in 2.5, deprecated in 2.6 and definitively gone in 3.0 It w

Re: database handling

2009-11-07 Thread Nick Touran
The mysqldb module works well for me. It's available on sourceforge. Find some examples in the documentation here: http://mysql-python.sourceforge.net/MySQLdb.html#some-mysql-examples -Nick On Sat, Nov 7, 2009 at 11:24 AM, asit wrote: > I need some tutorial about python-mysql connectivity(data

Re: Most efficient way to "pre-grow" a list?

2009-11-07 Thread Luis Alberto Zarrabeitia Gomez
Quoting Andre Engels : > On Sat, Nov 7, 2009 at 8:25 PM, Luis Alberto Zarrabeitia Gomez > wrote: > > > > Ok, he has a dict. > > > > Now what? He needs a non-sparse array. > > Let d be your dict. > > Call the zeroeth place in your array d[0], the first d[1], the 1th > d[10]. Following

Re: Pyfora, a place for python

2009-11-07 Thread Terry Reedy
Saketh wrote: On Nov 4, 5:28 pm, Alan Franzoni My small effort to create a place for discussing Python seems to have sparked a larger discussion than I had anticipated. My intent in creating Pyfora is not to splinter the community or encroach upon comp.lang.python users, but to create an alte

Re: is None or == None ?

2009-11-07 Thread Terry Reedy
Steven D'Aprano wrote: On Fri, 06 Nov 2009 16:51:18 +0100, Marco Mariani wrote: Using "x is y" with integers makes no sense and has no guaranteed behaviour AFAIK Of course it makes sense. `x is y` means *exactly the same thing* for ints as it does with any other object: it tests for object i

Re: Most efficient way to "pre-grow" a list?

2009-11-07 Thread Andre Engels
On Sat, Nov 7, 2009 at 8:25 PM, Luis Alberto Zarrabeitia Gomez wrote: > > Quoting Bruno Desthuilliers : > >> > Another situation where one may want to do this is if one needs to >> > initialize a non-sparse array in a non-sequential order, >> >> Then use a dict. > > Ok, he has a dict. > > Now what

Re: Most efficient way to "pre-grow" a list?

2009-11-07 Thread Luis Alberto Zarrabeitia Gomez
Quoting Bruno Desthuilliers : > > Another situation where one may want to do this is if one needs to > > initialize a non-sparse array in a non-sequential order, > > Then use a dict. Ok, he has a dict. Now what? He needs a non-sparse array. -- Luis Zarrabeitia Facultad de Matemática y Comput

database handling

2009-11-07 Thread asit
I need some tutorial about python-mysql connectivity(database handling). Somebody please help me !! -- http://mail.python.org/mailman/listinfo/python-list

Re: exception due to NoneType

2009-11-07 Thread asit
On Nov 7, 10:36 pm, Bruno Desthuilliers wrote: > asit a écrit : > > > In my program I want to catch exception which is caused by accessing > > NoneType object. > > > Can anyone suggest me how this can be done ?? > > Not without the minimal working code exposing your problem, or the full > tracebac

Re: Most efficient way to "pre-grow" a list?

2009-11-07 Thread Bruno Desthuilliers
kj a écrit : > > As I said, this is considered an optimization, at least in Perl, > because it lets the interpreter allocate all the required memory > in one fell swoop, instead of having to reallocate it repeatedly > as the array grows. IIRC, CPython has it's own way to optimize list growth. >

Re: how to display the return type of an os method?

2009-11-07 Thread Robert P. J. Day
On Sat, 7 Nov 2009, Bruno Desthuilliers wrote: > Robert P. J. Day a écrit : > > once again, a thoroughly newbie question but what's the quickest way > > to display the return type of, say, os.stat()? i can obviously do > > this in two steps: > > > x=os.stat('/etc/passwd') > type(x) >

Re: What is the best way to delete strings in a string list that that match certain pattern?

2009-11-07 Thread Peter Otten
Robert P. J. Day wrote: > On Sat, 7 Nov 2009, Peng Yu wrote: > >> On Fri, Nov 6, 2009 at 5:57 PM, Dave Angel wrote: > >> > But if you have an expression you want to match each dir against, >> > the list comprehension is the best answer. And the trick to >> > stuffing that new list into the ori

Re: Microsoft research on code quality

2009-11-07 Thread Bruno Desthuilliers
Aahz a écrit : > http://research.microsoft.com/en-us/news/features/nagappan-100609.aspx An interesting reading. Thanks for the link. -- http://mail.python.org/mailman/listinfo/python-list

Re: Program to compute and print 1000th prime number

2009-11-07 Thread Andre Engels
On Sat, Nov 7, 2009 at 6:40 PM, Mensanator wrote: >> Tongue in cheek solution: >> >> import urllib2 >> >> url = 'http://primes.utm.edu/lists/small/1.txt' >> primes = [] >> for line in urllib2.urlopen(url).read().splitlines(): >>     values = line.split() >>     if len(values) == 10: >>      

Re: exception due to NoneType

2009-11-07 Thread Bruno Desthuilliers
asit a écrit : > In my program I want to catch exception which is caused by accessing > NoneType object. > > Can anyone suggest me how this can be done ?? Not without the minimal working code exposing your problem, or the full traceback you got. Merely "accessing NoneType object" doesn't by itsel

Re: how to display the return type of an os method?

2009-11-07 Thread Bruno Desthuilliers
Robert P. J. Day a écrit : > once again, a thoroughly newbie question but what's the quickest way > to display the return type of, say, os.stat()? i can obviously do > this in two steps: > x=os.stat('/etc/passwd') type(x) > > > i'd just like to see that os.stat() returns a posix.s

Re: What is the best way to delete strings in a string list that that match certain pattern?

2009-11-07 Thread Robert P. J. Day
On Sat, 7 Nov 2009, Peng Yu wrote: > On Fri, Nov 6, 2009 at 5:57 PM, Dave Angel wrote: > > But if you have an expression you want to match each dir against, > > the list comprehension is the best answer.  And the trick to > > stuffing that new list into the original list object is to use > > sli

Re: Program to compute and print 1000th prime number

2009-11-07 Thread John Posner
Robert P. J. Day said: the ubiquitous sieve of eratosthenes requires you to pre-specify your maximum value, after which -- once the sieve completes -- all you know is that you have all of the prime numbers up to n. whether you'll have 1000 of them isn't clear, which means that you might have t

how to display the return type of an os method?

2009-11-07 Thread Robert P. J. Day
once again, a thoroughly newbie question but what's the quickest way to display the return type of, say, os.stat()? i can obviously do this in two steps: >>> x=os.stat('/etc/passwd') >>> type(x) >>> i'd just like to see that os.stat() returns a posix.stat_result object in one line. how du

Re: What is the correct way to port codecs.open to python 3.1?

2009-11-07 Thread Antoine Pitrou
Le Sat, 07 Nov 2009 12:56:54 +0100, Baptiste Lepilleur a écrit : > > After applying 2to3.py to port a 2.6 script to 3.1, I get the following > error when running my script: > File "purekeyworddbtest.py", line 143, in __init__ > f = codecs.open(EXCLUDED_KEYWORDS_FILE, 'rt', 'utf-8') > File

exception due to NoneType

2009-11-07 Thread asit
In my program I want to catch exception which is caused by accessing NoneType object. Can anyone suggest me how this can be done ?? -- http://mail.python.org/mailman/listinfo/python-list

Re: Program to compute and print 1000th prime number

2009-11-07 Thread Mensanator
On Nov 7, 11:23 am, Raymond Hettinger wrote: > > > On Nov 7, 2009, at 9:44 AM, Ray Holt wrote: > > > >       I am taking the MIT online course Introduction to Computer Science > > > and > > >       Programming. I have a assignment to write a program to compute and > > > print > > >       the 100

Re: extracting info from media files

2009-11-07 Thread Sean DiZazzo
MediaInfo is your best bet. http://mediainfo.sourceforge.net/en ~Sean On Nov 6, 11:59 pm, Michele Simionato wrote: > I would like to extract some simple info from media files, such as > size, resolution, duration, codec. What's the simplest way to do it? > Once in a time there was pymedia but I

Re: Program to compute and print 1000th prime number

2009-11-07 Thread Xavier Ho
On Sun, Nov 8, 2009 at 12:44 AM, Ray Holt wrote: > I have a assignment to write a program to compute and print the 1000th. > prime number. Can someone give me some leads on the correct code? > Ray, if you really want an answer out of this list, you'll have to at least show us what efforts you'v

Re: Program to compute and print 1000th prime number

2009-11-07 Thread Robert P. J. Day
On Sat, 7 Nov 2009, Raymond Hettinger wrote: > > > On Nov 7, 2009, at 9:44 AM, Ray Holt wrote: > > > > >       I am taking the MIT online course Introduction to Computer > > > Science and       Programming. I have a assignment to write a > > > program to compute and print       the 1000th. prime n

Re: Program to compute and print 1000th prime number

2009-11-07 Thread Raymond Hettinger
> > On Nov 7, 2009, at 9:44 AM, Ray Holt wrote: > > >       I am taking the MIT online course Introduction to Computer Science and > >       Programming. I have a assignment to write a program to compute and > > print > >       the 1000th. prime number. Can someone give me some leads on the > > c

Can't Find Module

2009-11-07 Thread Victor Subervi
Hi; I'm getting this error: Mod_python error: "PythonHandler mod_python.publisher" Traceback (most recent call last): File "/usr/lib64/python2.4/site-packages/mod_python/apache.py", line 299, in HandlerDispatch result = object(req) File "/usr/lib64/python2.4/site-packages/mod_python/pub

Re: What is the best way to delete strings in a string list that that match certain pattern?

2009-11-07 Thread Peng Yu
On Fri, Nov 6, 2009 at 5:57 PM, Dave Angel wrote: > > > Peng Yu wrote: >> >> On Fri, Nov 6, 2009 at 10:42 AM, Robert P. J. Day >> wrote: >> >>> >>> On Fri, 6 Nov 2009, Peng Yu wrote: >>> >>> On Fri, Nov 6, 2009 at 3:05 AM, Diez B. Roggisch wrote: > > Peng Yu schrieb:

Re: What is the best way to delete strings in a string list that that match certain pattern?

2009-11-07 Thread Peng Yu
On Sat, Nov 7, 2009 at 8:54 AM, Steven D'Aprano wrote: > On Fri, 06 Nov 2009 10:16:58 -0600, Peng Yu wrote: > >> What is a list-comprehension? > > Time for you to Read The Fine Manual. > > http://docs.python.org/tutorial/index.html > > >> I tried the following code. The list 'l' will be ['a','b','

Re: PyQt processEvents not processing

2009-11-07 Thread David Boddie
On Saturday 07 November 2009 05:12, DarkBlue wrote: > qt 4.5.3 > pyqt 4.6.1 > python 2.6 > > I have this QtTable widget which I want to refresh once about every 2 > seconds with new data. > > so I do : > > def updateSchedule(self): > for j in range(0,10): > doUpd

Re: Pyfora, a place for python

2009-11-07 Thread Aneesh Kulkarni
Imagine if no one ever created anything new out of fear of "fragmenting the community". Should we hurl the same accusation at Guido for fragmenting the programmer community and creating Python, when perfectly fine languages like Perl, Lisp & Smalltalk already existed? Creating new things is a par

Re: Program to compute and print 1000th prime number

2009-11-07 Thread Robert P. J. Day
On Sat, 7 Nov 2009, sstein...@gmail.com wrote: > > On Nov 7, 2009, at 9:44 AM, Ray Holt wrote: > > I am taking the MIT online course Introduction to Computer Science and > Programming. I have a assignment to write a program to compute and print > the 1000th. prime number. Can som

Re: Defining re pattern for matching list of numbers

2009-11-07 Thread Steven D'Aprano
On Fri, 06 Nov 2009 10:16:31 -0800, Chris Rebert wrote: > Your format seems so simple I have to ask why you're using regexes in > the first place. Raymond Hettinger has described some computing techniques as "code prions" -- programming advice or techniques which are sometimes useful but often

Re: Most efficient way to "pre-grow" a list?

2009-11-07 Thread Steven D'Aprano
On Fri, 06 Nov 2009 18:46:33 -0800, gil_johnson wrote: > I don't have the code with me, but for huge arrays, I have used > something like: > arr[0] = initializer for i in range N: arr.extend(arr) > > This doubles the array every time through the loop, and you can add the > po

Re: is None or == None ?

2009-11-07 Thread Steven D'Aprano
On Fri, 06 Nov 2009 16:51:18 +0100, Marco Mariani wrote: > Using "x is y" with integers > makes no sense and has no guaranteed behaviour AFAIK Of course it makes sense. `x is y` means *exactly the same thing* for ints as it does with any other object: it tests for object identity. That's all it

Re: Docs Typo

2009-11-07 Thread Steven D'Aprano
On Sat, 07 Nov 2009 01:09:51 +1300, Lawrence D'Oliveiro wrote: > In message <87eioghrsk@benfinney.id.au>, Ben Finney wrote: > >> Lawrence D'Oliveiro writes: >> >>> -- “ScrolledCavas” should >>> be “ScrolledCanvas”. >> >> Thanks for finding and d

Re: What is the best way to delete strings in a string list that that match certain pattern?

2009-11-07 Thread Steven D'Aprano
On Fri, 06 Nov 2009 10:16:58 -0600, Peng Yu wrote: > What is a list-comprehension? Time for you to Read The Fine Manual. http://docs.python.org/tutorial/index.html > I tried the following code. The list 'l' will be ['a','b','c'] rather > than ['b','c'], which is what I want. It seems 'remove'

Re: Program to compute and print 1000th prime number

2009-11-07 Thread sstein...@gmail.com
On Nov 7, 2009, at 9:44 AM, Ray Holt wrote: I am taking the MIT online course Introduction to Computer Science and Programming. I have a assignment to write a program to compute and print the 1000th. prime number. Can someone give me some leads on the correct code? Thanks, Ray Copying co

Program to compute and print 1000th prime number

2009-11-07 Thread Ray Holt
I am taking the MIT online course Introduction to Computer Science and Programming. I have a assignment to write a program to compute and print the 1000th. prime number. Can someone give me some leads on the correct code? Thanks, Ray -- http://mail.python.org/mailman/listinfo/python-list

Re: What is the correct way to port codecs.open to python 3.1?

2009-11-07 Thread Baptiste Lepilleur
2009/11/7 MRAB > Baptiste Lepilleur wrote: > [..] >> Do I need to replace all codecs.open with the built-in open function? If >> so, why does codecs.open still exist? >> >> The documentation says of codecs.open() that "Files are always opened in > binary mode, even if no binary mode was specifi

Serious Privileges Problem: Please Help

2009-11-07 Thread Victor Subervi
I have a serious privileges problem that is making it impossible to serve python pages on a CentOS server. It appears that nobody on the CentOS discussion list has a solution to this problem. I'm desperate and hoping someone on this list can help. [Fri Nov 06 11:50:40 2009] [error] [client 66.248.

  1   2   >