Re: Why does python not have a mechanism for data hiding?

2008-06-10 Thread Russ P.
On Jun 10, 1:04 am, Bruno Desthuilliers wrote: > If you hope to get a general agreement here in favor of a useless > keyword that don't bring anything to the language, then yes, I'm afraid > you're wasting your time. Actually, what I hope to do is to "take something away" from the language, and

Re: Why does python not have a mechanism for data hiding?

2008-06-10 Thread Russ P.
On Jun 10, 11:58 am, Jonathan Gardner > Who cares what the type of an object is? Only the machine. Being able > to tell, in advance, what the type of a variable is is a premature > optimization. Tools like psyco prove that computers (really, > programmers) nowadays are smart enough to figure thing

Re: Why does python not have a mechanism for data hiding?

2008-06-11 Thread Russ P.
On Jun 11, 2:36 am, Paul Boddie <[EMAIL PROTECTED]> wrote: > Maybe, but I'd hope that some of those programmers would be at least > able to entertain what Russ has been saying rather than setting > themselves up in an argumentative position where to concede any > limitation in Python might be cons

Re: Best Python packages?

2008-07-16 Thread Russ P.
On Jul 16, 7:16 am, Ben Sizer <[EMAIL PROTECTED]> wrote: > Although the standard library in Python is great, there are > undoubtedly some great packages available from 3rd parties, and I've > encountered a few almost by accident. However, I don't know how a user > would become aware of many of thes

Re: Attack a sacred Python Cow

2008-07-26 Thread Russ P.
> If, as I wrote, you permit the omission of "self" in method signatures > defined within class definitions, then you could still insist on > instance attribute qualification using "self" - exactly as one would > when writing Java according to certain style guidelines. I'm not sure exactly what p

Re: Attack a sacred Python Cow

2008-07-26 Thread Russ P.
> > So why not allow something like this?: > > > class MyClass: > > > def func( , xxx, yyy): > > > .xxx = xxx > > > local = .yyy > > > The "self" argument is replaced with nothing, but a comma is used as a > > placeholder. > > (+1) but why retain the leading comma in > the argu

Re: Attack a sacred Python Cow

2008-07-26 Thread Russ P.
On Jul 26, 2:25 pm, Terry Reedy > There is a lot of code you have not seen. Really. In informal code I > use 's' and 'o' for 'self' and 'other'. I don't usually post such > because it is not considered polite. So you have seen a biased sample > of the universe. You take the name down to a sing

Re: Attack a sacred Python Cow

2008-07-26 Thread Russ P.
On Jul 26, 7:23 pm, "Marcus.CM" > 1. python should hardcode the keyword "self". So whenever this keyword > is used, it would automatically implied that it is > referring to a class scope variable. This would be similar to how the > "this" keyword is used in C++. > > 2. Omit self from the parameter

Re: Attack a sacred Python Cow

2008-07-26 Thread Russ P.
On Jul 26, 11:18 pm, Terry Reedy <[EMAIL PROTECTED]> wrote: > Colin J. Williams wrote: > > Russ P. wrote: > >> class MyClass: > > >> def func( , xxx, yyy): > > >> .xxx = xxx > > >> local = .yyy > > The use of &

Re: Attack a sacred Python Cow

2008-07-26 Thread Russ P.
On Jul 26, 11:22 pm, Terry Reedy <[EMAIL PROTECTED]> wrote: > Russ P. wrote: > > On Jul 26, 2:25 pm, Terry Reedy > >> There is a lot of code you have not seen. Really. In informal code I > >> use 's' and 'o' for 'self' and '

Re: Attack a sacred Python Cow

2008-07-27 Thread Russ P.
On Jul 27, 3:11 am, alex23 <[EMAIL PROTECTED]> wrote: > On Jul 27, 4:26 pm, "Russ P." <[EMAIL PROTECTED]> wrote: > > > On Jul 26, 11:18 pm, Terry Reedy <[EMAIL PROTECTED]> wrote: > > > The use of '.' has been suggested before and rejec

Re: Attack a sacred Python Cow

2008-07-27 Thread Russ P.
On Jul 27, 1:19 am, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Sat, 26 Jul 2008 17:14:46 -0700, Russ P. wrote: > > You take the name down to a single letter. As I suggested in an earlier > > post on this thread, why not take it down to zero lette

Re: Attack a sacred Python Cow

2008-07-27 Thread Russ P.
On Jul 27, 12:39 pm, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > Derek Martin a écrit : > > > > > On Sun, Jul 27, 2008 at 08:19:17AM +, Steven D'Aprano wrote: > >>> You take the name down to a single letter. As I suggested in an earlier > >>> post on this thread, why not take it down to ze

Re: Attack a sacred Python Cow

2008-07-27 Thread Russ P.
On Jul 27, 3:11 pm, "Russ P." <[EMAIL PROTECTED]> wrote: > On Jul 27, 12:39 pm, Bruno Desthuilliers > > > > <[EMAIL PROTECTED]> wrote: > > Derek Martin a écrit : > > > > On Sun, Jul 27, 2008 at 08:19:17AM +, Steven D'Aprano wr

Re: Attack a sacred Python Cow

2008-07-27 Thread Russ P.
On Jul 27, 3:54 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Sun, 27 Jul 2008 12:33:16 -0700, Russ P. wrote: > > On Jul 27, 1:19 am, Steven D'Aprano <[EMAIL PROTECTED] > > cybersource.com.au> wrote: > >> On Sat, 26 Jul 2008 17

Re: Attack a sacred Python Cow

2008-07-27 Thread Russ P.
On Jul 27, 6:21 pm, Terry Reedy <[EMAIL PROTECTED]> wrote: > Russ P. wrote: > > On Jul 27, 12:39 pm, Bruno Desthuilliers > > All I am suggesting is that the programmer have the option of > > replacing "self.member" with simply ".member", since t

Re: Attack a sacred Python Cow

2008-07-27 Thread Russ P.
On Jul 27, 8:38 pm, alex23 <[EMAIL PROTECTED]> wrote: > On Jul 28, 4:59 am, "Russ P." <[EMAIL PROTECTED]> wrote: > > > On Jul 27, 3:11 am, alex23 <[EMAIL PROTECTED]> wrote: > > > > On Jul 27, 4:26 pm, "Russ P." <[EMAIL PROTECTED]>

Re: Attack a sacred Python Cow

2008-07-27 Thread Russ P.
On Jul 27, 8:58 pm, castironpi <[EMAIL PROTECTED]> wrote: > On Jul 27, 2:39 pm, Bruno Desthuilliers > > <[EMAIL PROTECTED]> wrote: > > Derek Martin a écrit : > > > It's bad programming, but the world is full of bad programmers, and we > > > don't always have the choice not to use their code. Isn't

Re: Attack a sacred Python Cow

2008-07-27 Thread Russ P.
On Jul 27, 9:44 pm, alex23 <[EMAIL PROTECTED]> wrote: > > > > > On Jul 27, 4:26 pm, "Russ P." <[EMAIL PROTECTED]> wrote: > > > > > > Terry Reedy <[EMAIL PROTECTED]> wrote: > > > > > > > The use of '.' has

Re: Attack a sacred Python Cow

2008-07-27 Thread Russ P.
On Jul 27, 10:32 pm, Terry Reedy <[EMAIL PROTECTED]> wrote: > Derek Martin wrote: > > Furthermore, as you described, defining the function within the scope > > of a class binds a name to the function and then makes it a method of > > the class. Once that happens, *the function has become a method*

Re: Attack a sacred Python Cow

2008-07-28 Thread Russ P.
On Jul 28, 4:23 am, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > Russ P. a écrit : > > > > > On Jul 27, 3:11 pm, "Russ P." <[EMAIL PROTECTED]> wrote: > >> On Jul 27, 12:39 pm, Bruno Desthuilliers > > >> <[EMAIL PROTECTED]> wr

Re: Attack a sacred Python Cow

2008-07-28 Thread Russ P.
On Jul 28, 2:52 am, alex23 <[EMAIL PROTECTED]> wrote: > On Jul 28, 3:07 pm, "Russ P." <[EMAIL PROTECTED]> wrote: > > > What was "suggested in rejected" on the thread you pointed me to was > > not what I suggested. Not even close. Get it, genius? &

Re: QOTW [was Re: Attack a sacred Python Cow]

2008-07-28 Thread Russ P.
On Jul 28, 7:07 am, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Sun, 27 Jul 2008 21:42:37 -0700, Russ P. wrote: > >> +1 QOTW > > > Do you realize what an insult that is to everyone else who has posted > > here in the past week? > &

Re: Attack a sacred Python Cow

2008-07-28 Thread Russ P.
On Jul 28, 5:44 pm, Ben Finney <[EMAIL PROTECTED]> wrote: > Bruno Desthuilliers <[EMAIL PROTECTED]> writes: > > Boy, I don't know who you think you're talking to, but you're > > obviously out of luck here. I'm 41, married, our son is now a > > teenager, I have an happy social life, quite a lot of w

Re: Attack a sacred Python Cow

2008-07-28 Thread Russ P.
On Jul 28, 12:08 pm, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > > It's a very simple idea that you insist on > > making complicated. As I said, I could write a pre-processor myself to > > implement it in less than a day. > > Preprocessor are not a solution. Sorry. I never said that a pre-pr

Re: Attack a sacred Python Cow

2008-07-28 Thread Russ P.
On Jul 28, 8:44 pm, alex23 <[EMAIL PROTECTED]> wrote: > On Jul 29, 4:46 am, "Russ P." <[EMAIL PROTECTED]> wrote: > > > As I said, I could write a pre-processor myself to > > implement it in less than a day. > > So WHY DON'T YOU WRITE IT ALREA

Re: static variables in Python?

2008-07-29 Thread Russ P.
On Jul 29, 1:40 pm, kj <[EMAIL PROTECTED]> wrote: > Yet another noob question... > > Is there a way to mimic C's static variables in Python? Or something > like it? The idea is to equip a given function with a set of > constants that belong only to it, so as not to clutter the global > namespace

Re: static variables in Python?

2008-07-29 Thread Russ P.
On Jul 29, 6:33 pm, "Russ P." <[EMAIL PROTECTED]> wrote: > On Jul 29, 1:40 pm, kj <[EMAIL PROTECTED]> wrote: > > > > > Yet another noob question... > > > Is there a way to mimic C's static variables in Python? Or something > > l

Re: Attack a sacred Python Cow

2008-07-29 Thread Russ P.
On Jul 29, 2:27 am, Iain King <[EMAIL PROTECTED]> wrote: > On Jul 29, 5:33 am, "Russ P." <[EMAIL PROTECTED]> wrote: > > > > > On Jul 28, 8:44 pm, alex23 <[EMAIL PROTECTED]> wrote: > > > > On Jul 29, 4:46 am, "Russ P." <[EMAI

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-29 Thread Russ P.
On Jul 29, 9:52 pm, Carl Banks <[EMAIL PROTECTED]> wrote: > On Jul 29, 11:17 pm, Terry Reedy <[EMAIL PROTECTED]> wrote: > > > > > Carl Banks wrote: > > >> As I wrote in the second reply email I sent, check out my integer set > > >> recipe on ASPN (and to save you the search: > > >> http://code.ac

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-29 Thread Russ P.
On Jul 29, 10:33 pm, Carl Banks <[EMAIL PROTECTED]> wrote: > On Jul 30, 1:15 am, "Russ P." <[EMAIL PROTECTED]> wrote: > > Having said that, it would sure be nice to be able to write > > > if myList is not empty: > > > instead of > > > if

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-29 Thread Russ P.
On Jul 29, 11:09 pm, Erik Max Francis <[EMAIL PROTECTED]> wrote: > I'm getting this sneaking suspicion that you guys are all putting us on. As I said in an earlier post, I realize that this would only work if there were only one copy of "empty" (as there is only one copy of "None"). I don't know

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-29 Thread Russ P.
On Jul 29, 11:16 pm, Erik Max Francis <[EMAIL PROTECTED]> wrote: > Russ P. wrote: > > On Jul 29, 10:33 pm, Carl Banks <[EMAIL PROTECTED]> wrote: > >> On Jul 30, 1:15 am, "Russ P." <[EMAIL PROTECTED]> wrote: > > >>> Having said that, it

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-29 Thread Russ P.
On Jul 29, 11:36 pm, Erik Max Francis <[EMAIL PROTECTED]> wrote: > Russ P. wrote: > > On Jul 29, 11:09 pm, Erik Max Francis <[EMAIL PROTECTED]> wrote: > > >> I'm getting this sneaking suspicion that you guys are all putting us on. > > > As I said in

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-29 Thread Russ P.
On Jul 29, 11:36 pm, Erik Max Francis <[EMAIL PROTECTED]> wrote: > Russ P. wrote: > > Come to think of it, shouldn't the list type have an "isempty" method? > > Or does it? > > Yes. It's written: > > if not aList: > ..

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-30 Thread Russ P.
On Jul 30, 12:03 am, Heiko Wundram <[EMAIL PROTECTED]> wrote: > Am Mittwoch, 30. Juli 2008 08:30:48 schrieb Russ P.: > > > On Jul 29, 11:09 pm, Erik Max Francis <[EMAIL PROTECTED]> wrote: > > > I'm getting this sneaking suspicion that you guys are all puttin

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-30 Thread Russ P.
On Jul 30, 12:49 am, Heiko Wundram <[EMAIL PROTECTED]> wrote: > Am Mittwoch, 30. Juli 2008 09:18:48 schrieb Russ P.: > > > Oh, Lordy. I understand perfectly well how boolean tests, __len__, and > > __nonzero__ work in Python. It's very basic stuff. You can quit >

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-30 Thread Russ P.
On Jul 30, 1:07 am, Erik Max Francis <[EMAIL PROTECTED]> wrote: > Russ P. wrote: > > Oh, Lordy. I understand perfectly well how boolean tests, __len__, and > > __nonzero__ work in Python. It's very basic stuff. You can quit > > patronizing me (and Carl too, I

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-30 Thread Russ P.
On Jul 30, 7:05 pm, Erik Max Francis <[EMAIL PROTECTED]> wrote: > Russ P. wrote: > > On Jul 30, 1:07 am, Erik Max Francis <[EMAIL PROTECTED]> wrote: > >> Russ P. wrote: > >>> Oh, Lordy. I understand perfectly well how boolean tests, __len__, and > &g

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-30 Thread Russ P.
On Jul 30, 8:03 pm, Erik Max Francis <[EMAIL PROTECTED]> wrote: > Russ P. wrote: > > The reason I wrote that "it would be nice to be able to write" > > > if x is not empty: > > > is that it reads naturally. It was not an actual proposal, and the > >

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-30 Thread Russ P.
On Jul 30, 8:24 pm, "Russ P." <[EMAIL PROTECTED]> wrote: > On Jul 30, 8:03 pm, Erik Max Francis <[EMAIL PROTECTED]> wrote: > > > Russ P. wrote: > > > The reason I wrote that "it would be nice to be able to write" > > > > if x is no

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-30 Thread Russ P.
On Jul 30, 9:27 pm, Erik Max Francis <[EMAIL PROTECTED]> wrote: > Russ P. wrote: > > I don't know if you can read minds, but you seem to have a lot of > > trouble reading words. > > > Can you read "it would be nice to be able to write ..."? Can you >

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-30 Thread Russ P.
On Jul 30, 10:43 pm, Erik Max Francis <[EMAIL PROTECTED]> wrote: > Russ P. wrote: > > On Jul 30, 9:27 pm, Erik Max Francis <[EMAIL PROTECTED]> wrote: > >> You're sure going on about a distinction without a difference for a guy > >> who childishly lik

Re: Strong/weak typing

2008-08-01 Thread Russ P.
On Aug 1, 8:31 am, [EMAIL PROTECTED] wrote: > I'm writing Python as if it were strongly typed, never recycling a > name to hold a type other than the original type. > > Is this good software engineering practice, or am I missing something > Pythonic? Reusing names for no reason can make debugging

Apology

2008-08-01 Thread Russ P.
Many of you probably consider me a real jerk. Well, I guess I have been one here. Believe it or not, I'm actually a pretty nice guy in real life. Something about the detachment and (partial) anonymity of being online makes me write things I would never say in person. For that I apologize. I had tw

Re: proposal, change self. to .

2008-08-05 Thread Russ P.
On Aug 3, 4:10 am, "Heiko Wundram" <[EMAIL PROTECTED]> wrote: > Am 03.08.2008, 12:51 Uhr, schrieb Equand <[EMAIL PROTECTED]>: > > > how about changing the precious self. to . > > imagine > > > self.update() > > > .update() > > > simple right? > > What about: > > class x: > > def x(self,ob): >

Re: proposal, change self. to .

2008-08-05 Thread Russ P.
On Aug 3, 5:44 am, Nick Dumas <[EMAIL PROTECTED]> wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > It's also worth noting that you can use a different name for the object > that represents your class. If you did def __init__(foo):pass, then you > would be able to access the class's obje

Perl to Python using MqSQLdb

2008-08-12 Thread Mike P
Hi All, I've been given a Perl script that i'm trying to convert into python. The aim of the script links to MqSQL database, but i'm stuck on one part my $sth = $dbh->prepare($sql)|| die "Could not prepare SQL statement ... maybe invalid?:$!\n$sql \n"; $sth->execute()|| die "C

Re: Perl to Python using MqSQLdb

2008-08-13 Thread Mike P
Thanks for that Daniel, I've been able to apply the logic to the rest of the script i'm converting. There are only two bits that i don't understand in the Perl script that i need to convert, my $sql = shift; and my @row = $sth->fetchrow_array; $$StartDate = $row[0]; $$EndDate = $row[1]

Re: Perl to Python using MqSQLdb

2008-08-13 Thread Mike P
That is a nice piece of code, I cracked the idea of the shift; problem, my final problem is still how to convert my @row = $sth->fetchrow_array; $$StartDate = $row[0]; $$EndDate = $row[1]; $sth->finish() into python code as i'm not sure what $$ means Any help on this final part woul

MLE in Python for distributions

2008-04-03 Thread Mike P
Hi All, Can anyone point me towards some code for Maximum Likilehood for distribution in python? Thanks Mike -- http://mail.python.org/mailman/listinfo/python-list

CSV reader and unique ids

2008-09-01 Thread Mike P
Hi All, I'm trying to use the CSV module to read in some data and then use a hashable method (as there are millions of records) to find unique ids and push these out to another file, can anyone advise? Below is the code so far fin = open(CSV_INPUT, "rb") fout = open(CSV_OUTPUT, "wb") reader = c

dict.update

2008-09-02 Thread Mike P
Hi All, I have two dictionaries e.g dict1 = {123:3,234:5,456:3} dict2 = {123:4,157:2,234:5,456:3,567:2} I want to merge these two dictionaries together so i have a resultant dictionary of: dict3 = {123:[4,3],157:[2,0],234:[5,5],456:[3,3],567:[2,0]} As later on i want to write a csv file that wo

Re: dict.update

2008-09-02 Thread Mike P
Thanks Diez, This is almost perfect! Is there a way to ensure each list has two elements, even if one of them is blank? Mike -- http://mail.python.org/mailman/listinfo/python-list

Re: dict.update

2008-09-02 Thread Mike P
Thanks Raymond, That's a neat trick, i'll look into learning more about this Mike -- http://mail.python.org/mailman/listinfo/python-list

String to hexadecimal conversion

2008-09-08 Thread Praveena P
Hi folks, I am new to Python... so am not too sure about how the type conversion works. I have to read a file that contains hexadecimal data and use the data further to do some arithmetic calculations. A sample of the input is : 20E032F8400022005E The problem I am facing i

Re: String to hexadecimal conversion

2008-09-08 Thread Praveena P
On Sep 8, 2:31 pm, John Machin <[EMAIL PROTECTED]> wrote: > On Sep 8, 7:05 pm, Praveena P <[EMAIL PROTECTED]> wrote: > > > Hi folks, > > > I am new to Python... so am not too sure about how the type conversion > > works. > > > I have to read a file

Dictionaries and loops

2008-09-08 Thread Mike P
Hi All i have a CSV file that i'm reading in and each line has the look of the below {None: ['User-ID', 'Count']} {None: ['576460847178667334', '1']} {None: ['576460847178632334', '8']} i want to make a dictionary of items in the form {576460847178667334:1, 576460847178632334:8, . } for all r

Re: String to hexadecimal conversion

2008-09-08 Thread Praveena P
On Sep 8, 2:05 pm, Praveena P <[EMAIL PROTECTED]> wrote: > Hi folks, > > I am new to Python... so am not too sure about how the type conversion > works. > > I have to read a file that contains hexadecimal data and use the data > further to do some arithmetic calculatio

Re: Dictionaries and loops

2008-09-08 Thread Mike P
Thanks for the solution above, The raw data looked like User-ID,COUNTS 576460840144207854,6 576460821700280307,2 576460783848259584,1 576460809027715074,3 576460825909089607,1 576460817407934470,1 and i used CSV_INPUT1 = "C:/Example work/Attr_model/Activity_test.csv" fin1 = open(CSV_INPUT1, "rb"

Re: python debugging question

2006-03-08 Thread P Boy
Install active python from http://activestate.com/Products/ActivePython/?mp=1 Run PythonWin for: coding, interactive commands, and debugging. Good luck. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python and C

2006-03-10 Thread P Boy
I have written some C extension before but it was pretty tedious. I have recently found another approach by using ctypes (http://starship.python.net/crew/theller/ctypes/). Which you develop your C module in dynamic library (DLL in Windows world), the from Python, you can call the C functions in the

Re: Python and C

2006-03-10 Thread P Boy
I have written some C extension before but it was pretty tedious. I have recently found another approach by using ctypes (http://starship.python.net/crew/theller/ctypes/). Which you develop your C module in dynamic library (DLL in Windows world), the from Python, you can call the C functions in the

Re: Python and C

2006-03-10 Thread P Boy
> Has anyone yet written a program to grab C struct declaration from the .h > to produce code like > > # Overlay configuration > class OverlayStoreConfig(ctypes.Structure): > _fields_ = [('FormatVersion', ctypes.c_ulong), > ('VolumeSize', ctypes.c_longlong), >

Splitting a string with extra parameters

2006-04-05 Thread Chris P
Hello list, I just started using python and I must say I enjoy it very much. I do have an issue in which I hope to get some pointers to. I have a string, which I need to split based on a delimiter. This I know how to do. But what I cannot figure out is, take for example the following: "column 1

Re: 32-bit python on Opteron, Solaris 10?

2006-04-09 Thread Olivier P
Gary Robinson wrote: > I'm in the market for a server to run some python code which is > optimized via psyco. > > Sun T2100 servers come with Solaris 10, which comes with python > pre-installed. You can always install a 32bits version of Linux or Solaris on the X2100 yourself. The X2100 is even

Tracking down DLL load errors in Windows ?

2009-10-15 Thread Fred P
Hi, a bit of platform-specific advice sought here... I'm trying to diagnose one of those mysteries Windows is so fond of... Say that I have code that imports some binary Python module from site- packages (in this case, libpyexiv2.pyd through pyexiv2.py, could be anythng else). On three Windows

Re: The rap against "while True:" loops

2009-10-16 Thread Russ P.
On Oct 10, 1:15 pm, kj wrote: > I'm coaching a group of biologists on basic Python scripting.  One > of my charges mentioned that he had come across the advice never > to use loops beginning with "while True".  Of course, that's one > way to start an infinite loop, but this seems hardly a sufficie

substituting list comprehensions for map()

2009-11-01 Thread Jon P.
I'd like to do: resultlist = operandlist1 + operandlist2 where for example operandlist1=[1,2,3,4,5] operandlist2=[5,4,3,2,1] and resultlist will become [6,6,6,6,6]. Using map(), I can do: map(lambda op1,op2: op1 + op2, operandlist1, operandlist2) Is there any reasonable way to do this via a

Psyco on 64-bit machines

2009-11-12 Thread Russ P.
I have a Python program that runs too slow for some inputs. I would like to speed it up without rewriting any code. Psyco seemed like exactly what I need, until I saw that it only works on a 32-bit architecture. I work in an environment of Sun Ultras that are all 64- bit. However, the Psyco docs sa

Re: Psyco on 64-bit machines

2009-11-13 Thread Russ P.
On Nov 12, 12:06 pm, "Russ P." wrote: > I have a Python program that runs too slow for some inputs. I would > like to speed it up without rewriting any code. Psyco seemed like > exactly what I need, until I saw that it only works on a 32-bit > architecture. I work in an env

Re: Psyco on 64-bit machines

2009-11-14 Thread Russ P.
On Nov 14, 10:15 am, "Diez B. Roggisch" wrote: > Russ P. schrieb: > > > I have a Python program that runs too slow for some inputs. I would > > like to speed it up without rewriting any code. Psyco seemed like > > exactly what I need, until I saw that it only wor

Re: Psyco on 64-bit machines

2009-11-14 Thread Russ P.
On Nov 12, 12:06 pm, "Russ P." wrote: > I have a Python program that runs too slow for some inputs. I would > like to speed it up without rewriting any code. Psyco seemed like > exactly what I need, until I saw that it only works on a 32-bit > architecture. I work in an env

Re: New syntax for blocks

2009-11-17 Thread Russ P.
On Nov 17, 7:28 am, Jonathan Saxton wrote: > On Thu, 12 Nov 2009 21:27:31 +0100, Bruno Desthuilliers wrote: > >> Congratulations, you just reinvented one of the most infamous source of > >> bugs in C, C++, Java, PHP, javascript and quite a few other languages. > >> Believe it or not, but not allow

Threading, Queue for a function so it only runs once at a time.

2010-03-12 Thread John P.
here? Thanks. -- John P. -- http://mail.python.org/mailman/listinfo/python-list

Re: Threading, Queue for a function so it only runs once at a time.

2010-03-12 Thread John P.
ons running at once, MySQL is a terrible choice. > Give PostgreSQL a try. It does a much better job with that kind of > load. > > On Thu, Mar 11, 2010 at 11:11 PM, John P. > wrote: >> Hi, >> >> Im programming a simple webcrawler with threading for the fun of it, >

Re: Threading, Queue for a function so it only runs once at a time.

2010-03-12 Thread John P.
On Fri, 12 Mar 2010 11:22:04 -0500, "D'Arcy J.M. Cain" wrote: > On Fri, 12 Mar 2010 15:56:12 + > "John P." wrote: >> Sorry but its not really an option for me with PostgreSQL. Thanks anyway. > > Why? It's your best option. Any other solut

Re: Threading, Queue for a function so it only runs once at a time.

2010-03-12 Thread John P.
On Fri, 12 Mar 2010 16:49:04 +, "John P." wrote: > On Fri, 12 Mar 2010 11:22:04 -0500, "D'Arcy J.M. Cain" > wrote: >> On Fri, 12 Mar 2010 15:56:12 + >> "John P." wrote: >>> Sorry but its not really an option for me with P

Re: did anybody play with python and window mobile broadband?

2010-03-18 Thread Sanjiva P.
On 03/18/2010 10:20 AM, News123 wrote: > I'm looking for examples: > - how to connect/disconnect a mobile broadband device (currently I use > rasdial. not sure it's the best solution) > - to obtain the device's current mode (GPRS / EDGE / . . . ) > - to obtain the current signal level > > Thanks

Re: "Usability, the Soul of Python"

2010-03-30 Thread Russ P.
; printf("Send one to abuse and Just Hit Delete,\n"); printf("%d slabs of spam in my mail!\n\n", i + 1); } On Mar 30, 4:40 am, "Alf P. Steinbach" wrote: > * Jean-Michel Pichavant: > > > John Nagle wrote: > >> Jonathan Hayward wrot

Re: (a==b) ? 'Yes' : 'No'

2010-03-30 Thread Russ P.
On Mar 30, 10:08 am, John Nagle wrote: > Chris Rebert wrote: > > On Tue, Mar 30, 2010 at 8:40 AM, gentlestone wrote: > >> Hi, how can I write the popular C/JAVA syntax in Python? > > >> Java example: > >>    return (a==b) ? 'Yes' : 'No' > > >> My first idea is: > >>    return ('No','Yes')[bool(a=

How to send an IP packet in Python?

2010-12-02 Thread yegorov-p
Hello. I have sniffed some packet and now I would like to send it with the help of python. It's some simple IGMP packet with VLAN tag. (01 00 5E 00 43 67 00 02 B3 C8 7F 44 81 00 00 DE 08 00 46 00 00 20 00 01 00 00 01 02 36 4C C0 A8 00 7B EA 00 43 67 94 04 00 00 16 00 BC 97 EA 00 43 67) At first I

Re: How to pretty-print cyclic dictionaries?

2010-04-29 Thread Garrick P
Chris Rebert rebertia.com> writes: ... > If you want a prettier print, you could try serializing it to YAML and > printing the result out; YAML has syntax for "tags". > > Cheers, > Chris > -- > http://blog.rebertia.com Works fairly well. $ python Python 2.6.4 (r264:75706, Mar 1 2010, 14:28:0

[Q] How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-16 Thread Standish P
xogenous stack so that element size can vary. ======= Standish P -- http://mail.python.org/mailman/listinfo/python-list

Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-16 Thread Standish P
On Aug 16, 12:47 am, Nick Keighley wrote: > this is heavily x-posted I'm answering from comp.lang.c > > On 16 Aug, 08:20, Standish P wrote: > > > [Q] How far can stack [LIFO] solve do automatic garbage collection and > > prevent memory leak ? > > I'm havin

Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-16 Thread Standish P
On Aug 16, 12:38 am, "Alf P. Steinbach /Usenet" wrote: > * Standish P, on 16.08.2010 09:20: > > > [garble garble] > > Nonsense article "We look for an exogenous stack" cross-posted to > >    [comp.lang.c], >    [comp.lang.c++], >    [comp.theor

Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-17 Thread Standish P
On Aug 16, 4:20 am, Malcolm McLean wrote: > On Aug 16, 10:20 am, Standish P wrote:> [Q] How far can > stack [LIFO] solve do automatic garbage collection and > > prevent memory leak ? > > Most programs can be written so that most of their memory allocations > are match

Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-17 Thread Standish P
> Garbage collection doesn't use a stack. It uses a "heap", which is in > the abstract a collection of memory blocks of different lengths, > divided into two lists, generally represented as linked lists: > > 1.  A list of blocks that are free and may be used to store new data > > 2.  A list of blo

Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-17 Thread Standish P
On Aug 16, 11:09 am, Elizabeth D Rather wrote: > On 8/15/10 10:33 PM, Standish P wrote: > > >>> If Forth is a general processing language based on stack, is it > >>> possible to convert any and all algorithms to stack based ones and > >>> thus av

Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-17 Thread Standish P
On Aug 17, 1:17 am, torb...@diku.dk (Torben Ægidius Mogensen) wrote: > Standish P writes: > > [Q] How far can stack [LIFO] solve do automatic garbage collection and > > prevent memory leak ? > > > Because a stack has push and pop, it is able to release and allocate &g

Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-17 Thread Standish P
On Aug 16, 12:20 am, Standish P wrote: > [Q] How far can stack [LIFO] solve do automatic garbage collection and > prevent memory leak ? > Because a stack has push and pop, it is able to release and allocate > memory. We envisage an exogenous stack which has malloc() associated >

Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-17 Thread Standish P
On Aug 17, 12:32 pm, John Passaniti wrote: > On Aug 17, 2:53 pm, Standish P wrote: > > > Another way to pose my question, as occurred to me presently is > > to ask if a stack is a good abstraction for programming ? > > Certainly, it is the main abstraction in Fort

Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-17 Thread Standish P
On Aug 17, 1:19 pm, Standish P wrote: > On Aug 17, 12:32 pm, John Passaniti wrote: > > > > > > > On Aug 17, 2:53 pm, Standish P wrote: > > > > Another way to pose my question, as occurred to me presently is > > > to ask if a stack is a good abstrac

Re: Python "why" questions

2010-08-17 Thread Russ P.
On Aug 7, 5:54 am, "D'Arcy J.M. Cain" wrote: > Would said beginner also be surprised that a newborn baby is zero years > old or would it be more natural to call them a one year old?  Zero > based counting is perfectly natural. You're confusing continuous and discrete variables. Time is a continu

Re: Python "why" questions

2010-08-18 Thread Russ P.
On Aug 18, 2:01 pm, AK wrote: > On 08/17/2010 10:15 PM, Russ P. wrote: > > > > > On Aug 7, 5:54 am, "D'Arcy J.M. Cain"  wrote: > > >> Would said beginner also be surprised that a newborn baby is zero years > >> old or would it be more natural

Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-18 Thread Standish P
On Aug 18, 12:30 pm, Elizabeth D Rather wrote: > On 8/18/10 12:09 AM, spinoza wrote: > > > On Aug 18, 1:21 am, Standish P  wrote: > >>> Garbage collection doesn't use a stack. It uses a "heap", which is in > >>> the abstract a collection o

Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-18 Thread Standish P
On Aug 17, 6:38 pm, John Passaniti wrote: > You asked if Forth "borrowed" lists from Lisp.  It did not.  In Lisp, > lists are constructed with pair of pointers called a "cons cell". > That is the most primitive component that makes up a list.  Forth has > no such thing; in Forth, the dictionary (

Re: Python "why" questions

2010-08-18 Thread Russ P.
On Aug 18, 7:58 pm, Steven D'Aprano wrote: > On Wed, 18 Aug 2010 14:47:08 -0700, Russ P. wrote: > > Is the top team in the league the number 1 team -- or the number 0 team? > > I have yet to hear anyone call the best team the number 0 team! > > Why is the top team the

Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-19 Thread Standish P
On Aug 18, 5:38 pm, Keith Thompson wrote: > Standish P writes: > > On Aug 18, 12:30 pm, Elizabeth D Rather wrote: > [...] > >> Mostly it had a "snowball's chance" because it was never picked up by > >> the CS gurus who, AFAIK, never really took a

Re: Python "why" questions

2010-08-19 Thread Russ P.
On Aug 19, 9:07 am, "J.B. Brown" wrote: > 2010/8/9 MRAB : > > > Default User wrote: > > >> Not to prolong a good "food fight", but IIRC, many years ago in QBasic, > >> one could choose > > >> OPTION BASE 0 > > >> or > > >> OPTION BASE 1 > > When I wrote my own C++ 2-D matrix class, I wrote a membe

<    1   2   3   4   5   6   7   8   9   10   >