Re: Python profiler usage with objects

2010-06-30 Thread rik
Ben Kaplan case.edu> writes: > First thin it does is evaluate foo(), which returns None. So you're calling > profile.run(None) > > There's nothing special about profile.run- you have to hand it something to > execute, not something already executed. Try calling > Profile.run(doSomething) # no p

Re: Python profiler usage with objects

2010-06-30 Thread Rami Chowdhury
On 2010-06-30 06:39, rik wrote: > Ben Kaplan case.edu> writes: > > > > > Let's take this code as an example: > > > > def foo() : > > return None > > > > import profile > > profile.run(foo()) > > > > What does the profile.run call do? > > > > First thin it does is evaluate foo(), which r

Re: Python profiler usage with objects

2010-06-30 Thread rik
Ben Kaplan case.edu> writes: > There's nothing special about profile.run- you have to hand it something to > execute, not something already executed. Try calling > Profile.run(doSomething) # no parenthesis for doSomething. your hint and REREADING THE DOCUMENTATION made me realize it was the QUO

Re: A question about the posibility of raise-yield in Python

2010-06-30 Thread Дамјан Георгиевски
> I'm writing this as a complete newbie (on the issue), so don't be > surprised if it's the stupidest idea ever. > > I was wondering if there was ever a discusision in the python > community on a 'raise-yield' kind-of combined expression. I'd like to > know if it was proposed/rejected/discussed/

Re: Find slope of function given empirical data.

2010-06-30 Thread Peter Otten
Thomas wrote: > Trying to find slope of function using numpy. > Getting close, but results are a bit off. Hope someone out here can > help. You don't make it easy to understand your post. In the future please try to rely more on plain english than on lots of numbers and code that doesn't run.

Re: PDF Generation With Reportlab

2010-06-30 Thread Tim Roberts
Albert Leibbrandt wrote: > >I am hoping there is someone out there that knows reportlab quite well. >I posted this on the reportlab mailing list but there is not much >activity on that list Never the less, that is the correct forum for this question. The ReportLab mailing list is operated and

Re: [python] how to ensure item in list or dict bind with "an uuid meaning" integer type ID?

2010-06-30 Thread Tim Roberts
kee chen wrote: > >I have 2 lists stored in 2 text files may have duplicated records, the raw >data looks like this: >lfruit lcountry >== = >orange japan >pear

pyc runtime error

2010-06-30 Thread Baris CUHADAR
Can anyone explain this unexpected behavior? all files chmod 755, i've compiled x.py with py_compilefiles, also tried within python console with "import x" system: centos 5.4 32bit This a PATH related problem i think? [r...@centos-14 cgi-bin]# ./x.pyc : command not found ./x.pyc: line 2: synta

Re: pyc runtime error

2010-06-30 Thread Chris Rebert
On Wed, Jun 30, 2010 at 1:06 AM, Baris CUHADAR <189...@gmail.com> wrote: > Can anyone explain this unexpected behavior? > all files chmod 755, i've compiled x.py with py_compilefiles, > also tried within python console with "import x" > > system:  centos 5.4 32bit > > This a PATH related problem i

Re: pyc runtime error

2010-06-30 Thread Rami Chowdhury
On 2010-06-30 01:06, Baris CUHADAR wrote: > Can anyone explain this unexpected behavior? I'm sorry -- can you let us know what behavior you're expecting? > all files chmod 755, i've compiled x.py with py_compilefiles, > also tried within python console with "import x" > > system: centos 5.4 32b

Re: git JSONRPC web service and matching pyjamas front-end

2010-06-30 Thread Martin P. Hellwig
On 06/30/10 03:29, CM wrote: On Jun 29, 6:54 pm, Luke Kenneth Casson Leighton wrote: as more than just a proof-of-concept but to get pyjamas out of looking like "a nice toy, doesn't do much, great demos, shame about real life", If may be generated with pyjamas but I'm not sure how this fulfil

Build unordered list in HTML from a python list

2010-06-30 Thread Nico Grubert
Dear list members I have this python list that represets a sitemap: tree = [{'indent': 1, 'title':'Item 1', 'hassubfolder':False}, {'indent': 1, 'title':'Item 2', 'hassubfolder':False}, {'indent': 1, 'title':'Folder 1', 'hassubfolder':True}, {'indent': 2, 'title':'Sub Ite

Re: pyc runtime error

2010-06-30 Thread Baris CUHADAR
On Jun 30, 11:31 am, Rami Chowdhury wrote: > On 2010-06-30 01:06, Baris CUHADAR wrote: > > > Can anyone explain this unexpected behavior? > > I'm sorry -- can you let us know what behavior you're expecting? > > > all files chmod 755, i've compiled x.py with py_compilefiles, > > also tried within p

Re: Python dynamic attribute creation

2010-06-30 Thread Andre Alexander Bell
On 06/29/2010 06:46 PM, WANG Cong wrote: > On 06/29/10 17:48, Andre Alexander Bell wrote: > var a > a >> -> should raise an variable 'unset' exception >> >> Keep in mind that the module you are writing in is just an object as is >> any function or method. So using local variables therein y

Re: [OT] Re: Why Is Escaping Data Considered So Magical?

2010-06-30 Thread Jorgen Grahn
On Wed, 2010-06-30, Michael Torrie wrote: > On 06/29/2010 10:17 PM, Michael Torrie wrote: >> On 06/29/2010 10:05 PM, Michael Torrie wrote: >>> #include >>> >>> int main(int argc, char ** argv) >>> { >>> char *buf = malloc(512 * sizeof(char)); >>> const int a = 2, b = 3; >>> snprintf(&b

Re: pyc runtime error

2010-06-30 Thread Christian Heimes
> Actually i wrote some scripts in python that are working as gateway > controlling scripts iptables/tc/squid-proxy, and i want to execute > them as cgi. Protection of source code is also important. These > scripts works fine with ubuntu 9.10 and ubuntu 10.04, trying to > eleminate this execution e

Ancient C string conventions (was Re: Why Is Escaping Data Considered So Magical?)

2010-06-30 Thread Jorgen Grahn
On Wed, 2010-06-30, Carl Banks wrote: > On Jun 28, 2:44 am, Gregory Ewing wrote: >> Carl Banks wrote: >> > Indeed, strncpy does not copy that final NUL if it's at or beyond the >> > nth element.  Probably the most mind-bogglingly stupid thing about the >> > standard C library, which has lots of mi

1.5.1 Py_XDECREF Core

2010-06-30 Thread Sunil
Hi,   We are using a legacy product which is using 1.5.1 version of Python and we have seen frequent core dumps offlate which is as below   #0  0x2b79b0 in list_dealloc (op=0x414b11d0) at listobject.c:220 #1  0x283c48 in dict_dealloc (mp=0x415b8c18) at dictobject.c:491 #2  0x2b4760 in frame_deallo

Re: Why Is Escaping Data Considered So Magical?

2010-06-30 Thread Cameron Simpson
On 29Jun2010 21:49, Carl Banks wrote: | On Jun 28, 2:44 am, Gregory Ewing wrote: | > Carl Banks wrote: | > > Indeed, strncpy does not copy that final NUL if it's at or beyond the | > > nth element.  Probably the most mind-bogglingly stupid thing about the | > > standard C library, which has lots

Re: 1.5.1 Py_XDECREF Core

2010-06-30 Thread Thomas Jollans
On 06/30/2010 11:39 AM, Sunil wrote: > Hi, > > We are using a legacy product which is using 1.5.1 version of Python and > we have seen frequent core dumps offlate which is as below > > #0 0x2b79b0 in list_dealloc (op=0x414b11d0) at listobject.c:220 > #1 0x283c48 in dict_dealloc (mp=0x415b8c18

Re: Build unordered list in HTML from a python list

2010-06-30 Thread Kushal Kumaran
On Wed, Jun 30, 2010 at 2:04 PM, Nico Grubert wrote: > Dear list members > > I have this python list that represets a sitemap: > > tree = [{'indent': 1, 'title':'Item 1', 'hassubfolder':False}, >        {'indent': 1, 'title':'Item 2', 'hassubfolder':False}, >        {'indent': 1, 'title':'Folder 1

Re: Build unordered list in HTML from a python list

2010-06-30 Thread Stefan Behnel
Nico Grubert, 30.06.2010 10:34: I have this python list that represets a sitemap: tree = [{'indent': 1, 'title':'Item 1', 'hassubfolder':False}, {'indent': 1, 'title':'Item 2', 'hassubfolder':False}, {'indent': 1, 'title':'Folder 1', 'hassubfolder':True}, {'indent': 2, 'title':'Sub Item 1.1', 'h

Re: Build unordered list in HTML from a python list

2010-06-30 Thread Nico Grubert
Use a stack? Whenever you start a new list, push the corresponding closing tag onto a stack. Whenever your "indent level" decreases, pop the stack and write out the closing tag you get. It's straightforward to use a python list as a stack. Thanks for the tip, Kushal. Do you have a short code

Re: pyc runtime error

2010-06-30 Thread Baris CUHADAR
On Jun 30, 12:06 pm, Christian Heimes wrote: > > Actually i wrote some scripts in python that are working as gateway > > controlling scripts iptables/tc/squid-proxy, and i want to execute > > them as cgi. Protection of source code is also important. These > > scripts works fine with ubuntu 9.10 an

Re: pyc runtime error

2010-06-30 Thread Baris CUHADAR
On Jun 30, 2:20 pm, Baris CUHADAR <189...@gmail.com> wrote: > On Jun 30, 12:06 pm, Christian Heimes wrote: > > > > Actually i wrote some scripts in python that are working as gateway > > > controlling scripts iptables/tc/squid-proxy, and i want to execute > > > them as cgi. Protection of source co

Re: pyc runtime error

2010-06-30 Thread Thomas Jollans
On 06/30/2010 01:20 PM, Baris CUHADAR wrote: > On Jun 30, 12:06 pm, Christian Heimes wrote: >>> Actually i wrote some scripts in python that are working as gateway >>> controlling scripts iptables/tc/squid-proxy, and i want to execute >>> them as cgi. Protection of source code is also important. T

Re: Build unordered list in HTML from a python list

2010-06-30 Thread Remi Carton
> Dear list members > > I have this python list that represets a sitemap: > > tree = [{'indent': 1, 'title':'Item 1', 'hassubfolder':False}, > {'indent': 1, 'title':'Item 2', 'hassubfolder':False}, > {'indent': 1, 'title':'Folder 1', 'hassubfolder':True}, > {'indent': 2

Re: Why are String Formatted Queries Considered So Magical?

2010-06-30 Thread Nobody
On Tue, 29 Jun 2010 08:41:03 -0400, Roy Smith wrote: >> > And what about regular expressions? >> >> What about them? As the saying goes: >> >> Some people, when confronted with a problem, think >> "I know, I'll use regular expressions." >> Now they have two problems. > > That's s

Re: Why Is Escaping Data Considered So Magical?

2010-06-30 Thread Roy Smith
In article , Cameron Simpson wrote: > Jeez. PDP-11s, 16 bit addressing, tiny tiny disc drives! What you talking about, tiny? An RK-05 was huge! Why would anybody ever need more than that? > The original V7 (and probably earlier) UNIX filesystem has 16 byte directory > entries Certainly ear

Re: I strongly dislike Python 3

2010-06-30 Thread Lie Ryan
On 06/27/10 11:24, Steven D'Aprano wrote: >> > Producing print function takes a little bit more effort than producing a >> > print statement. > > (1) The main use-cases for print are quick (and usually dirty) scripts, > interactive use, and as a debugging aid. That is precisely how the quick-and

Re: Find slope of function given empirical data.

2010-06-30 Thread Thomas
On Jun 30, 3:28 am, Peter Otten <__pete...@web.de> wrote: > Thomas wrote: > > Trying to find slope of function using numpy. > > Getting close, but results are a bit off. Hope someone out here can > > help. > > You don't make it easy to understand your post. In the future please try to > rely more o

Re: PDF Generation With Reportlab

2010-06-30 Thread Albert Leibbrandt
On 2010/06/30 10:52 AM, Tim Roberts wrote: Albert Leibbrandt wrote: I am hoping there is someone out there that knows reportlab quite well. I posted this on the reportlab mailing list but there is not much activity on that list Never the less, that is the correct forum for this quest

Re: Build unordered list in HTML from a python list

2010-06-30 Thread Dave Angel
Nico Grubert wrote: Use a stack? Whenever you start a new list, push the corresponding closing tag onto a stack. Whenever your "indent level" decreases, pop the stack and write out the closing tag you get. It's straightforward to use a python list as a stack. Thanks for the tip, Kushal.

Re: pyc runtime error

2010-06-30 Thread Baris CUHADAR
On Jun 30, 3:10 pm, Thomas Jollans wrote: > On 06/30/2010 01:20 PM, Baris CUHADAR wrote: > > > > > On Jun 30, 12:06 pm, Christian Heimes wrote: > >>> Actually i wrote some scripts in python that are working as gateway > >>> controlling scripts iptables/tc/squid-proxy, and i want to execute > >>>

Re: [OT] Re: Why Is Escaping Data Considered So Magical?

2010-06-30 Thread Michael Torrie
On 06/30/2010 03:00 AM, Jorgen Grahn wrote: > On Wed, 2010-06-30, Michael Torrie wrote: >> On 06/29/2010 10:17 PM, Michael Torrie wrote: >>> On 06/29/2010 10:05 PM, Michael Torrie wrote: #include int main(int argc, char ** argv) { char *buf = malloc(512 * sizeof(char));

Re: Why are String Formatted Queries Considered So Magical?

2010-06-30 Thread Jorgen Grahn
On Tue, 2010-06-29, Stephen Hansen wrote: > On 6/29/10 5:41 AM, Roy Smith wrote: >> Nobody wrote: >> And what about regular expressions? >>> >>> What about them? As the saying goes: >>> >>> Some people, when confronted with a problem, think >>> "I know, I'll use regular expressions."

Re: Find slope of function given empirical data.

2010-06-30 Thread Grant Edwards
On 2010-06-29, Thomas wrote: > Trying to find slope of function using numpy. Getting close, but > results are a bit off. Hope someone out here can help. > > import numpy as np > > def deriv(y): > x = list(range(len(y))) > x.reverse() # Change from [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] >

Re: Build unordered list in HTML from a python list

2010-06-30 Thread Jorgen Grahn
On Wed, 2010-06-30, Kushal Kumaran wrote: > On Wed, Jun 30, 2010 at 2:04 PM, Nico Grubert wrote: >> Dear list members >> >> I have this python list that represets a sitemap: >> >> tree = [{'indent': 1, 'title':'Item 1', 'hassubfolder':False}, >>        {'indent': 1, 'title':'Item 2', 'hassubfolder

Re: Why are String Formatted Queries Considered So Magical?

2010-06-30 Thread Stephen Hansen
On 6/30/10 7:14 AM, Jorgen Grahn wrote: On Tue, 2010-06-29, Stephen Hansen wrote: On 6/29/10 5:41 AM, Roy Smith wrote: Nobody wrote: And what about regular expressions? What about them? As the saying goes: Some people, when confronted with a problem, think "I know, I'll u

Re: I strongly dislike Python 3

2010-06-30 Thread Stephen Hansen
On 6/30/10 5:52 AM, Lie Ryan wrote: On 06/27/10 11:24, Steven D'Aprano wrote: Producing print function takes a little bit more effort than producing a print statement. (1) The main use-cases for print are quick (and usually dirty) scripts, interactive use, and as a debugging aid. That is pre

Re: I strongly dislike Python 3

2010-06-30 Thread Michele Simionato
On Jun 30, 2:52 pm, Lie Ryan wrote: > On 06/27/10 11:24, Steven D'Aprano wrote: > > >> > Producing print function takes a little bit more effort than producing a > >> > print statement. > > > (1) The main use-cases for print are quick (and usually dirty) scripts, > > interactive use, and as a debu

Re: Build unordered list in HTML from a python list

2010-06-30 Thread Daniel Fetchinson
> I have this python list that represets a sitemap: > > tree = [{'indent': 1, 'title':'Item 1', 'hassubfolder':False}, > {'indent': 1, 'title':'Item 2', 'hassubfolder':False}, > {'indent': 1, 'title':'Folder 1', 'hassubfolder':True}, > {'indent': 2, 'title':'Sub Item 1.1'

numpy - save many arrays into a file object

2010-06-30 Thread Laszlo Nagy
import numpy data = numpy.array(...) numpy.save("test.np",data) This is very good, but I want to save the data into a file object with a write() method. E.g. not a real file. (My purpose right now is to save many arrays into one binary file, while recording starting positions of the arrays.)

Re: git JSONRPC web service and matching pyjamas front-end

2010-06-30 Thread CM
On Jun 30, 4:27 am, "Martin P. Hellwig" wrote: > On 06/30/10 03:29, CM wrote:> On Jun 29, 6:54 pm, Luke Kenneth Casson > Leighton > > wrote: > >> as more than just a proof-of-concept but to get pyjamas out of looking > >> like "a nice toy, doesn't do much, great demos, shame about real > >> life"

Re: numpy - save many arrays into a file object

2010-06-30 Thread Terry Reedy
On 6/30/2010 11:48 AM, Laszlo Nagy wrote: import numpy data = numpy.array(...) numpy.save("test.np",data) This is very good, but I want to save the data into a file object with a write() method. E.g. not a real file. (My purpose right now is to save many arrays into one binary file, while record

Re: I strongly dislike Python 3

2010-06-30 Thread Lie Ryan
On 07/01/10 01:30, Stephen Hansen wrote: > On 6/30/10 5:52 AM, Lie Ryan wrote: >> On 06/27/10 11:24, Steven D'Aprano wrote: > Producing print function takes a little bit more effort than > producing a > print statement. >>> >>> (1) The main use-cases for print are quick (and usually dir

Re: I strongly dislike Python 3

2010-06-30 Thread Lie Ryan
On 07/01/10 01:42, Michele Simionato wrote: > On Jun 30, 2:52 pm, Lie Ryan wrote: >> On 06/27/10 11:24, Steven D'Aprano wrote: >> > Producing print function takes a little bit more effort than producing a > print statement. >> >>> (1) The main use-cases for print are quick (and usually dir

Re: dynamically modify help text

2010-06-30 Thread Aahz
In article , Thomas Jollans wrote: > >% python2.6 >Python 2.6.5+ (release26-maint, Jun 28 2010, 19:46:36) >[GCC 4.4.4] on linux2 >Type "help", "copyright", "credits" or "license" for more information. class OLD: pass >... class NEW(object): pass >... OLD.__doc__ = "foo" NEW.__

Re: A question about the posibility of raise-yield in Python

2010-06-30 Thread John Nagle
On 6/30/2010 12:13 AM, Дамјан Георгиевски wrote: A 'raise-yield' expression would break the flow of a program just like an exception, going up the call stack until it would be handled, but also like yield it would be possible to continue the flow of the program from where it was raise-yield-ed.

Re: numpy - save many arrays into a file object

2010-06-30 Thread Peter Otten
Laszlo Nagy wrote: > import numpy > data = numpy.array(...) > numpy.save("test.np",data) > > This is very good, but I want to save the data into a file object with a > write() method. E.g. not a real file. (My purpose right now is to save > many arrays into one binary file, while recording starti

Re: Why are String Formatted Queries Considered So Magical?

2010-06-30 Thread Terry Reedy
On 6/30/2010 8:22 AM, Nobody wrote: I've noticed over the years a significant anti-RE sentiment in the Python community. IMHO, the sentiment isn't so much against REs per se, but against excessive or inappropriate use. Apart from making it easy to write illegible code, they also make it easy t

Re: Why are String Formatted Queries Considered So Magical?

2010-06-30 Thread Ethan Furman
Terry Reedy wrote: On 6/30/2010 8:22 AM, Nobody wrote: I've noticed over the years a significant anti-RE sentiment in the Python community. IMHO, the sentiment isn't so much against REs per se, but against excessive or inappropriate use. Apart from making it easy to write illegible code, they

Re: I strongly dislike Python 3

2010-06-30 Thread Stephen Hansen
On 6/30/10 9:22 AM, Lie Ryan wrote: On 07/01/10 01:30, Stephen Hansen wrote: On 6/30/10 5:52 AM, Lie Ryan wrote: On 06/27/10 11:24, Steven D'Aprano wrote: Producing print function takes a little bit more effort than producing a print statement. (1) The main use-cases for print are quick (and

Using Python for web applications

2010-06-30 Thread Wyatt Schwartz
Dear Python-List members, Sorry for asking such a simple (or possibly complicated) question, as I am new to Python programming. Anyways, I have read online that many popular websites use Python for some of their web-based applications (for example, Reddit), and that lead me to wonder how is

Hwy doesn't len(None) return zero ?

2010-06-30 Thread Stef Mientki
hello, I've lot of functions that returns their result in some kind of tuple / list / array, and if there is no result, these functions return None. Now I'm often what to do something if I've more than 1 element in the result. So I test: if len ( Result ) > 1 : But to prevent exceptions, i'

Re: Hwy doesn't len(None) return zero ?

2010-06-30 Thread Stephen Hansen
On 6/30/10 11:39 AM, Stef Mientki wrote: hello, I've lot of functions that returns their result in some kind of tuple / list / array, and if there is no result, these functions return None. Now I'm often what to do something if I've more than 1 element in the result. So I test: if len ( Resul

Re: Using Python for web applications

2010-06-30 Thread Daniel Fetchinson
> Sorry for asking such a simple (or possibly complicated) question, as > I am new to Python programming. Anyways, I have read online that many > popular websites use Python for some of their web-based applications > (for example, Reddit), and that lead me to wonder how is this done? There are var

Re: Hwy doesn't len(None) return zero ?

2010-06-30 Thread Zubin Mithra
On Thu, Jul 1, 2010 at 12:09 AM, Stef Mientki wrote: > hello, > > I've lot of functions that returns their result in some kind of tuple / > list / array, > and if there is no result, these functions return None. > Now I'm often what to do something if I've more than 1 element in the > result. > S

Re: Hwy doesn't len(None) return zero ?

2010-06-30 Thread Gary Herron
On 06/30/2010 11:39 AM, Stef Mientki wrote: hello, I've lot of functions that returns their result in some kind of tuple / list / array, and if there is no result, these functions return None. Now I'm often what to do something if I've more than 1 element in the result. So I test: if len

Re: Using Python for web applications

2010-06-30 Thread Zubin Mithra
On Wed, Jun 30, 2010 at 11:34 PM, Wyatt Schwartz wrote: > Dear Python-List members, > > Sorry for asking such a simple (or possibly complicated) question, as I am > new to Python programming. Anyways, I have read online that many popular > websites use Python for some of their web-based applicatio

Re: Hwy doesn't len(None) return zero ?

2010-06-30 Thread Stefan Behnel
Stef Mientki, 30.06.2010 20:39: I've lot of functions that returns their result in some kind of tuple / list / array, and if there is no result, these functions return None. Now I'm often what to do something if I've more than 1 element in the result. So I test: if len ( Result )> 1 : But

Re: Hwy doesn't len(None) return zero ?

2010-06-30 Thread Tim Chase
On 06/30/2010 01:50 PM, Stephen Hansen wrote: On 6/30/10 11:39 AM, Stef Mientki wrote: if len ( Result )> 1 : But to prevent exceptions, i've to write ( I often forget) if Result and ( len ( Result )> 1 ) : Just do: if Result: You don't have to do a length check> 1; because if Resul

Re: Why Is Escaping Data Considered So Magical?

2010-06-30 Thread Carl Banks
On Jun 30, 2:55 am, Cameron Simpson wrote: > On 29Jun2010 21:49, Carl Banks wrote: > | On Jun 28, 2:44 am, Gregory Ewing wrote: > | > Carl Banks wrote: > | > > Indeed, strncpy does not copy that final NUL if it's at or beyond the > | > > nth element.  Probably the most mind-bogglingly stupid thi

Re: Hwy doesn't len(None) return zero ?

2010-06-30 Thread Stephen Hansen
On 6/30/10 12:02 PM, Tim Chase wrote: On 06/30/2010 01:50 PM, Stephen Hansen wrote: On 6/30/10 11:39 AM, Stef Mientki wrote: if len ( Result )> 1 : But to prevent exceptions, i've to write ( I often forget) if Result and ( len ( Result )> 1 ) : Just do: if Result: You don't have to do a le

Re: Hwy doesn't len(None) return zero ?

2010-06-30 Thread Dave Angel
Stephen Hansen wrote: On 6/30/10 11:39 AM, Stef Mientki wrote: hello, I've lot of functions that returns their result in some kind of tuple / list / array, and if there is no result, these functions return None. Now I'm often what to do something if I've more than 1 element in the result. So

Re: Ancient C string conventions

2010-06-30 Thread Paul Rubin
Jorgen Grahn writes: > It's somewhat believable. If I handled thousands of student names in a > big C array char[30][], I would resent the fact that 1/30 of the > memory was wasted on NUL bytes. But you'd be wasting even more of the memory on bytes left unused when the student's name is less tha

Re: Why Is Escaping Data Considered So Magical?

2010-06-30 Thread Paul Rubin
Cameron Simpson writes: > The original V7 (and probably earlier) UNIX filesystem has 16 byte directory > entries: 2 bytes for an inode and 14 bytes for the name. You could use 14 > bytes of that name, and strncpy makes it effective to work with that data > structure. Why not use memcpy for that

Python/C++ timer intermittent bug

2010-06-30 Thread Paul
I have a problem with threading using the Python/C API. I have an extension that implements a timer, and the C++ timer callback function calls a Python function. The relevant code looks like this: static PyObject *timer_setmodname( PyObject *pSelf, PyObject *pArgs ) { char *b; PyA

Re: Python as a scripting language. Alternative to bash script?

2010-06-30 Thread Mithrandir
Michael Torrie wrote in news:mailman.2313.1277759925.32709.python-l...@python.org: > On 06/28/2010 02:06 PM, Mithrandir wrote: >> I can't see Python as an alt. to bash. (As I recall) Python is much >> more object-oriented than bash, but also there are many commands >> (such as apt- get, etc.) th

Re: Hwy doesn't len(None) return zero ?

2010-06-30 Thread Ian Kelly
On Wed, Jun 30, 2010 at 12:39 PM, Stef Mientki wrote: > So I wonder why len is not allowed on None > and if there are objections to extend the len function . For the same reason that (None + 42) doesn't return 42, and that (None.upper()) doesn't return NONE. -- http://mail.python.org/mailman/lis

Re: Hwy doesn't len(None) return zero ?

2010-06-30 Thread Emile van Sebille
On 6/30/2010 11:39 AM Stef Mientki said... hello, I've lot of functions that returns their result in some kind of tuple / list / array, and if there is no result, these functions return None. Now I'm often what to do something if I've more than 1 element in the result. So I test: which work

Re: Why are String Formatted Queries Considered So Magical?

2010-06-30 Thread Steven D'Aprano
On Wed, 30 Jun 2010 14:14:38 +, Jorgen Grahn wrote: > On Tue, 2010-06-29, Stephen Hansen wrote: >> On 6/29/10 5:41 AM, Roy Smith wrote: >>> Nobody wrote: >>> > And what about regular expressions? What about them? As the saying goes: Some people, when confronted with

Re: I strongly dislike Python 3

2010-06-30 Thread Steven D'Aprano
On Wed, 30 Jun 2010 22:52:06 +1000, Lie Ryan wrote: > On 06/27/10 11:24, Steven D'Aprano wrote: >>> > Producing print function takes a little bit more effort than >>> > producing a print statement. >> >> (1) The main use-cases for print are quick (and usually dirty) scripts, >> interactive use, an

Re: Ignorance and Google Groups (again)

2010-06-30 Thread D'Arcy J.M. Cain
On Wed, 30 Jun 2010 13:10:43 -0700 (PDT) garryTX wrote: > On Jun 29, 5:31 pm, nanothermite911fbibustards [...] > you ignorant mf. stfu. You shouldn't be calling people ignorant for what they post if you are just going to repost every word again. Everything that applies to him applies to you. I

Re: Ignorance and Google Groups (again)

2010-06-30 Thread Stephen Hansen
On 6/30/10 1:55 PM, D'Arcy J.M. Cain wrote: I have had it with GG. For the last few months I have been filtering all mail from gmail.com that comes through the news gateway into a separate folder to see where the spam and abuse comes from. Over that time about 99% of all the useless crap has be

Re: Ignorance and Google Groups (again)

2010-06-30 Thread D'Arcy J.M. Cain
On Wed, 30 Jun 2010 14:06:05 -0700 Stephen Hansen wrote: > Gmail and Google Groups are not one and the same. There's a number of > people who subscribe to the list directly, use Gmail, and don't go > anywhere near Google Groups. I know that. My filter doesn't catch them. > > If anyone is inte

Re: Ignorance and Google Groups (again)

2010-06-30 Thread Stephen Hansen
On 6/30/10 2:15 PM, D'Arcy J.M. Cain wrote: If anyone is interested in the procmail recipe I will be using, here it is in all it's glory. :0: Hir * ^List-Id:.*python-list.python.org * ^From:@gmail.com * ^Newsgroups: /dev/null As you can see, to be caught in the filter you need to have a gm

Re: I strongly dislike Python 3

2010-06-30 Thread geremy condra
On Wed, Jun 30, 2010 at 4:34 PM, Steven D'Aprano wrote: > On Wed, 30 Jun 2010 22:52:06 +1000, Lie Ryan wrote: > >> On 06/27/10 11:24, Steven D'Aprano wrote: > Producing print function takes a little bit more effort than > producing a print statement. >>> >>> (1) The main use-cases for pr

Re: Ignorance and Google Groups (again)

2010-06-30 Thread geremy condra
On Wed, Jun 30, 2010 at 5:15 PM, D'Arcy J.M. Cain wrote: > On Wed, 30 Jun 2010 14:06:05 -0700 > Stephen Hansen wrote: >> Gmail and Google Groups are not one and the same. There's a number of >> people who subscribe to the list directly, use Gmail, and don't go >> anywhere near Google Groups. > >

Re: Ignorance and Google Groups (again)

2010-06-30 Thread D'Arcy J.M. Cain
On Wed, 30 Jun 2010 17:25:55 -0400 geremy condra wrote: > If you get this, you get the gmail-but-not-google-groups stuff. Hello. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP)

Re: Using Python for web applications

2010-06-30 Thread Mithrandir
Wyatt Schwartz wrote in news:mailman.33.1277921551.1673.python-l...@python.org: > Dear Python-List members, > > Sorry for asking such a simple (or possibly complicated) question, as > I am new to Python programming. Anyways, I have read online that many > popular websites use Python for som

Re: Ignorance and Google Groups (again)

2010-06-30 Thread rantingrick
On Jun 30, 3:55 pm, "D'Arcy J.M. Cain" wrote: > I have had it with GG.  For the last few months I have been filtering > all mail from gmail.com that comes through the news gateway into a > separate folder to see where the spam and abuse comes from.  Over that > time about 99% of all the useless c

Re: Ignorance and Google Groups (again)

2010-06-30 Thread D'Arcy J.M. Cain
On Wed, 30 Jun 2010 14:18:55 -0700 Stephen Hansen wrote: > Okay, un-Bye :) Nice to be back. :-) -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http

Re: Ignorance and Google Groups (again)

2010-06-30 Thread Philip Semanchuk
On Jun 30, 2010, at 4:55 PM, D'Arcy J.M. Cain wrote: On Wed, 30 Jun 2010 13:10:43 -0700 (PDT) garryTX wrote: On Jun 29, 5:31 pm, nanothermite911fbibustards [...] you ignorant mf. stfu. You shouldn't be calling people ignorant for what they post if you are just going to repost every word

Re: Ignorance and Google Groups (again)

2010-06-30 Thread Thomas Jollans
On 06/30/2010 10:55 PM, D'Arcy J.M. Cain wrote: > in all it's glory. > > :0: Hir > * ^List-Id:.*python-list.python.org > * ^From:@gmail.com > * ^Newsgroups: > /dev/null * X-Complaints-To: groups-ab...@google.com looks like a nice header to filter on -- http://mail.python.org/mailman/listi

Re: Hwy doesn't len(None) return zero ?

2010-06-30 Thread Steven D'Aprano
Please pardon me for breaking threading, but Stef's original post has not come through to me. On 6/30/10 11:39 AM, Stef Mientki wrote: > hello, > > I've lot of functions that returns their result in some kind of tuple / > list / array, > and if there is no result, these functions return None.

Re: I strongly dislike Python 3

2010-06-30 Thread Steven D'Aprano
On Wed, 30 Jun 2010 17:21:32 -0400, geremy condra wrote: > On Wed, Jun 30, 2010 at 4:34 PM, Steven D'Aprano > wrote: >> On Wed, 30 Jun 2010 22:52:06 +1000, Lie Ryan wrote: >> >>> On 06/27/10 11:24, Steven D'Aprano wrote: > > Producing print function takes a little bit more effort than > >

Re: I strongly dislike Python 3

2010-06-30 Thread Brian Blais
On Jun 30, 2010, at 8:52 , Lie Ryan wrote: On 06/27/10 11:24, Steven D'Aprano wrote: Producing print function takes a little bit more effort than producing a print statement. (1) The main use-cases for print are quick (and usually dirty) scripts, interactive use, and as a debugging aid.

Re: Hwy doesn't len(None) return zero ?

2010-06-30 Thread Stef Mientki
On 30-06-2010 20:56, Gary Herron wrote: > On 06/30/2010 11:39 AM, Stef Mientki wrote: >> hello, >> >> I've lot of functions that returns their result in some kind of tuple / list >> / array, >> and if there is no result, these functions return None. >> Now I'm often what to do something if I've m

Re: I strongly dislike Python 3

2010-06-30 Thread geremy condra
On Wed, Jun 30, 2010 at 6:30 PM, Steven D'Aprano wrote: > On Wed, 30 Jun 2010 17:21:32 -0400, geremy condra wrote: > >> On Wed, Jun 30, 2010 at 4:34 PM, Steven D'Aprano >> wrote: >>> On Wed, 30 Jun 2010 22:52:06 +1000, Lie Ryan wrote: >>> On 06/27/10 11:24, Steven D'Aprano wrote: >> > Pr

Re: I strongly dislike Python 3

2010-06-30 Thread Mark Lawrence
On 30/06/2010 23:30, Steven D'Aprano wrote: [snips] The rule against premature optimization doesn't just apply to *code*. +1QOTW Kindest regards. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list

Re: Why Is Escaping Data Considered So Magical?

2010-06-30 Thread Cameron Simpson
On 30Jun2010 12:19, Paul Rubin wrote: | Cameron Simpson writes: | > The original V7 (and probably earlier) UNIX filesystem has 16 byte directory | > entries: 2 bytes for an inode and 14 bytes for the name. You could use 14 | > bytes of that name, and strncpy makes it effective to work with that d

Re: A question about the posibility of raise-yield in Python

2010-06-30 Thread ru...@yahoo.com
On Jun 30, 10:48 am, John Nagle wrote: > On 6/30/2010 12:13 AM, Дамјан Георгиевски wrote: > > >> A 'raise-yield' expression would break the flow of a program just like > >> an exception, going up the call stack until it would be handled, but > >> also like yield it would be possible to continue th

automate minesweeper with python

2010-06-30 Thread Jay
I would like to create a python script that plays the Windows game minesweeper. The python code logic and running minesweeper are not problems. However, "seeing" the 1-8 in the minesweeper map and clicking on squares is. I have no idea how to proceed. -- http://mail.python.org/mailman/listinfo/py

Re: Need instruction on how to use isinstance

2010-06-30 Thread Hans Mulder
alex23 wrote: Stephen Hansen wrote: P.S. The removal of callable is something I don't understand in Python 3: while generally speaking I do really believe and use duck typing, I too have on occassion wanted to dispatch based on 'is callable? do x'. Sometimes its not convenient to do so via duck

Re: I strongly dislike Python 3

2010-06-30 Thread ru...@yahoo.com
On Jun 30, 9:42 am, Michele Simionato wrote: > Actually when debugging I use pdb which uses "p" (no parens) for > printing, so having > print or print() would not make any difference for me. Perhaps you don't use CJK strings much? p u'\u30d1\u30a4\u30c8\u30f3' give quite a different result than

Re: I strongly dislike Python 3

2010-06-30 Thread rantingrick
On Jun 30, 4:21 pm, geremy condra wrote: > Actually, I agree with this complaint though- it is much easier to type > spaces than parens. Oh Geremy please. If you're going to whine about something at least find something worth whining about! Yes a few more key strokes are needed. But print should

Re: [OT] Re: Why Is Escaping Data Considered So Magical?

2010-06-30 Thread Lawrence D'Oliveiro
In message , Michael Torrie wrote: > Okay, I will. Your code passes a char** when a char* is expected. No it doesn’t. > Consider this variation where I use a dynamically allocated buffer > instead of static: And so you misunderstand the difference between a C array and a pointer. -- http://ma

Re: I strongly dislike Python 3

2010-06-30 Thread geremy condra
On Wed, Jun 30, 2010 at 8:25 PM, rantingrick wrote: > On Jun 30, 4:21 pm, geremy condra wrote: > >> Actually, I agree with this complaint though- it is much easier to type >> spaces than parens. > > Oh Geremy please. If you're going to whine about something at least > find something worth whining

Re: automate minesweeper with python

2010-06-30 Thread Justin Ezequiel
On Jul 1, 7:39 am, Jay wrote: > I would like to create a python script that plays the Windows game > minesweeper. > > The python code logic and running minesweeper are not problems. > However, "seeing" the 1-8 in the minesweeper map and clicking on > squares is. I have no idea how to proceed. you

  1   2   >