Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-24 Thread Russ P.
On Jan 24, 9:54 pm, Luis Zarrabeitia wrote: > Quoting "Russ P." : > > > Once again, if you have the source code for the library (and the right > > to modify it), how does the "power" lie with the library implementer > > rather than you the user? > > > You say you don't want to "fork" the library.

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-24 Thread Luis Zarrabeitia
Quoting "Russ P." : > Once again, if you have the source code for the library (and the right > to modify it), how does the "power" lie with the library implementer > rather than you the user? > > You say you don't want to "fork" the library. Let's stipulate for the > sake of argument that a one-

Re: OCaml, Language syntax, and Proof Systems

2009-01-24 Thread Xah Lee
Addendum: The above is not a terrible insight, but i suppose it should be useful for some application. Today, there's huge number of languages, each screaming ME! To name a few that are talked about by geekers, there's Arc, Clojure, Scalar, F#, Erlang, Ruby, Groovy, Python 3, Perl6. (for a big lis

Re: Two import questions in Python 3.0

2009-01-24 Thread Kay Schluehr
On 24 Jan., 18:51, Scott David Daniels wrote: > Kay Schluehr wrote: > > On 24 Jan., 09:21, "Gabriel Genellina" wrote: > >> If you run A.py as a script, it does not "know" it lives inside a package. > >> You must *import* A for it to become aware of the package. > >> Also, the directory containing

Re: OCaml, Language syntax, and Proof Systems

2009-01-24 Thread Xah Lee
Language, Purity, Cult, and Deception Xah Lee, 2009-01-24 [this essay is roughly a 10 years personal retrospect of some languages, in particular Scheme and Haskell.] I learned far more Ocaml in the past 2 days than the fucking 2 months i tried to learn Haskell, with 10 years of “I WANT TO BELIEV

Re: Is (-1 ==True) True or False? Neither

2009-01-24 Thread Oktay Şafak
Terry Reedy wrote: Oktay Şafak wrote: That's what I'm trying to say: it would be more meaningful if int.__eq__ did a boolean comparison when the other operand is a boolean. For that to be done, int would have to know about its subclass, which generally is bad design. Good point, but of cou

syntax color lang source code in blogs or website

2009-01-24 Thread Xah Lee
For those of you using emacs, here's the elisp code that allows you to syntax color computer language source code in your blog or website. http://xahlee.org/emacs/elisp_htmlize.html to comment, here: http://xahlee.blogspot.com/2009/01/dehtmlize-source-code-in-emacs-lisp.html Xah ∑ http://xahle

Re: Is (-1 ==True) True or False? Neither

2009-01-24 Thread Oktay Şafak
I don't see how fixing this makes harder to treat True and False as first-class objects. If doing the right thing takes some special casing then be it, but I don't think it's so. True in ['something', False] In your semantics, this would evaluate to True because ('something' == True) is True.

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-24 Thread Rhodri James
On Sun, 25 Jan 2009 00:31:14 -, Tim Rowe wrote: 2009/1/24 Rhodri James : My experience with medium-sized organisations (50-100 people) is that either you talk to Fred directly, or it doesn't happen. In particular the more people (especially PHBs) that get involved, the slower the change

Re: *.python.org broken?

2009-01-24 Thread Tim Chase
Is anybody else having trouble accessing sites (including www, docs, wiki) in the python.org tree, or is it just me? (Or just .au?) I've had problems[1] browsing them (most irksomely, the docs) from Dillo thanks to what are apparently poor handling of IPv6 fallback rules. Dillo gets an IPv6 I

Re: Possible to slice a string with unpacked tuple?

2009-01-24 Thread python
Terry, Hi, I'm the OP in question. > the OP should simply write myString[slice(*myTuple)] My tuples define positions in a fixed width string for parsing values. So rather than 'unpacking' tuples, I'm using slice() to directly define actual field positions, eg. field_1 = slice( 4, 7 ) field_2 =

Re: Possible to slice a string with unpacked tuple?

2009-01-24 Thread Terry Reedy
Benjamin Peterson wrote: MRAB mrabarnett.plus.com> writes: Does myString[myTuple[0] : myTuple[1]] count as unpacking? If it does, then how about myString.__getslice__(*myTuple)? Please don't use special method names directly and especially not __getslice__(). It's deprecated and will be remov

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-24 Thread Russ P.
On Jan 24, 5:09 pm, Luis Zarrabeitia wrote: > I didn't say "at all". Those were your words, not mine. > I said that it makes no sense that the power lies on _you_ instead of on _my > team_. And, when I said that, I recall we were talking about the python > language, not C. Once again, if you hav

Re: String comparision

2009-01-24 Thread Gabriel Genellina
En Sat, 24 Jan 2009 15:08:08 -0200, S.Selvam Siva escribió: I am developing spell checker for my local language(tamil) using python. I need to generate alternative word list for a miss-spelled word from the dictionary of words.The alternatives must be as much as closer to the miss-spelled wor

Re: *.python.org broken?

2009-01-24 Thread tgvaughan
On Jan 25, 12:19 pm, Philip Semanchuk wrote: > On Jan 24, 2009, at 8:06 PM, tgvaug...@gmail.com wrote: > > > Hi all, > > > Is anybody else having trouble accessing sites (including www, docs, > > wiki) in the python.org tree, or is it just me? (Or just .au?) > > No problem here in Durham, NC, USA.

Re: Is (-1 ==True) True or False? Neither

2009-01-24 Thread Terry Reedy
Oktay Şafak wrote: That's what I'm trying to say: it would be more meaningful if int.__eq__ did a boolean comparison when the other operand is a boolean. For that to be done, int would have to know about its subclass, which generally is bad design. The reason is that when someone writes (-

Re: Is (-1 ==True) True or False? Neither

2009-01-24 Thread Robert Kern
On 2009-01-24 19:07, Oktay Şafak wrote: Robert Kern wrote: On 2009-01-24 17:00, oktaysa...@superonline.com wrote: Hi all, I ran into a strange case. Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32 ... >>> -1 == True False >>> -1 == False False This works

Re: *.python.org broken?

2009-01-24 Thread Philip Semanchuk
On Jan 24, 2009, at 8:06 PM, tgvaug...@gmail.com wrote: Hi all, Is anybody else having trouble accessing sites (including www, docs, wiki) in the python.org tree, or is it just me? (Or just .au?) No problem here in Durham, NC, USA. -- http://mail.python.org/mailman/listinfo/python-list

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-24 Thread Russ P.
On Jan 24, 4:17 pm, Luis Zarrabeitia wrote: > Quoting "Russ P." : > > > On Jan 23, 6:36 pm, Luis Zarrabeitia wrote: > > > > > Makes *no* sense? There's *no* good reason *at all* for the original > > > > author to hide or protect internals? > > > > My bad, sorry. > > > It makes sense... if the ori

Re: *.python.org broken?

2009-01-24 Thread r
On Jan 24, 7:06 pm, tgvaug...@gmail.com wrote: > Hi all, > > Is anybody else having trouble accessing sites (including www, docs, > wiki) in the python.org tree, or is it just me? (Or just .au?) > > Cheers, > > Tim No problem here??? -- http://mail.python.org/mailman/listinfo/python-list

*.python.org broken?

2009-01-24 Thread tgvaughan
Hi all, Is anybody else having trouble accessing sites (including www, docs, wiki) in the python.org tree, or is it just me? (Or just .au?) Cheers, Tim -- http://mail.python.org/mailman/listinfo/python-list

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-24 Thread Luis Zarrabeitia
Quoting Steven D'Aprano : > On Fri, 23 Jan 2009 21:36:59 -0500, Luis Zarrabeitia wrote: > > > Quoting Steven D'Aprano : > >> Makes *no* sense? There's *no* good reason *at all* for the original > >> author to hide or protect internals? > > > > My bad, sorry. > > It makes sense... if the origina

Re: Is (-1 ==True) True or False? Neither

2009-01-24 Thread Terry Reedy
oktaysa...@superonline.com wrote: Hi all, I ran into a strange case. Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32 ... >>> -1 == True False >>> -1 == False False This works though: >>> if -1: print "OK" OK After some head scratching, I realize

Re: Is (-1 ==True) True or False? Neither

2009-01-24 Thread Oktay Şafak
Robert Kern wrote: On 2009-01-24 17:00, oktaysa...@superonline.com wrote: Hi all, I ran into a strange case. Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32 ... >>> -1 == True False >>> -1 == False False This works though: >>> if -1: print "OK" OK Af

Re: RegEx issues

2009-01-24 Thread Gabriel Genellina
En Sat, 24 Jan 2009 19:03:26 -0200, Sean Brown gmail.com> <" escribió: Using python 2.4.4 on OpenSolaris 2008.11 I have the following string created by opening a url that has the following string in it: td[ct] = [[ ... ]];\r\n The ... above is what I'm interested in extracting which is rea

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-24 Thread Tim Rowe
2009/1/24 Rhodri James : > My experience with medium-sized organisations (50-100 people) is that > either you talk to Fred directly, or it doesn't happen. In particular > the more people (especially PHBs) that get involved, the slower the > change will come and the less like your original requir

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-24 Thread Luis Zarrabeitia
Quoting "Russ P." : > On Jan 23, 6:36 pm, Luis Zarrabeitia wrote: > > > > Makes *no* sense? There's *no* good reason *at all* for the original > > > author to hide or protect internals? > > > > My bad, sorry. > > It makes sense... if the original author is an egotist who believes he > must > >

Re: I'm a python addict !

2009-01-24 Thread Russ P.
On Jan 24, 4:03 pm, Robert Kern wrote: > On 2009-01-23 22:25, Aahz wrote: > > > In article, > > Linuxguy123  wrote: > >> I just started using python last week and I'm addicted. > > > Welcome!  Just be aware that excessive Perl-bashing is considered > > somewhat tasteless on this newsgroup, but the

Re: Parsing a string into a datetime object

2009-01-24 Thread Mark.Petrovic
On Jan 24, 10:56 am, Hrvoje Niksic wrote: > "Mark.Petrovic" writes: > > Might someone comment on why %f is not accepted as a valid field > > directive in: > > from datetime import datetime > created="2009-01-24 16:04:55.882788" > dt = datetime.strptime(created,"%Y-%m-%d %H:%M:%S.%f

Re: Regex for Python 2.7

2009-01-24 Thread John Machin
On Jan 25, 7:23 am, MRAB wrote: > Some time ago I discovered this difference between regular expressions > in Python and Perl: > > Python > >         \A matches at start of string >         \Z matches at end of string > > Perl > >         \A matches at start of string >         \Z matches before t

Re: Possible to slice a string with unpacked tuple?

2009-01-24 Thread Benjamin Peterson
MRAB mrabarnett.plus.com> writes: > Does myString[myTuple[0] : myTuple[1]] count as unpacking? If it does, > then how about myString.__getslice__(*myTuple)? Please don't use special method names directly and especially not __getslice__(). It's deprecated and will be removed. -- http://mail.p

Re: why is this invalid b = a += b ?

2009-01-24 Thread Terry Reedy
Stef Mientki wrote: hello, I can assign a value to more than 1 variable (name) in one line: a = b = 3 So evaluation of this line must start at the right part. But the following is not allowed: b = 2 a = b += 1 This strikes me as slightly incoherent. Given that v op=exp is mostly that sam

Re: RegEx issues

2009-01-24 Thread John Machin
On Jan 25, 5:59 am, Scott David Daniels wrote: > Sean Brown wrote: > > I have the following string ...:  "td[ct] = [[ ... ]];\r\n" > > The ... (representing text in the string) is what I'm extracting > > So I think the regex \[\[(.*)\]\]; should do it. > > The problem is it appears that pytho

Re: Can webbrowser module get source code?

2009-01-24 Thread Benjamin Peterson
Muddy Coder yahoo.com> writes: > I want to go > further: to get the source code of the webpage being displayed. Is it > possible to do it? I tried webbrow.get() but didn't work. Somebody can > help? Thanks! To do this, you actually need to fetch the page yourself: import urllib2 page_source = ur

Re: I'm a python addict !

2009-01-24 Thread Robert Kern
On 2009-01-23 22:25, Aahz wrote: In article, Linuxguy123 wrote: I just started using python last week and I'm addicted. Welcome! Just be aware that excessive Perl-bashing is considered somewhat tasteless on this newsgroup, but the occasional snide comment should be fine. ;-) Or bash-bashi

Re: Is (-1 ==True) True or False? Neither

2009-01-24 Thread Robert Kern
On 2009-01-24 17:00, oktaysa...@superonline.com wrote: Hi all, I ran into a strange case. Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32 ... >>> -1 == True False >>> -1 == False False This works though: >>> if -1: print "OK" OK After some head scratc

Re: I'm a python addict !

2009-01-24 Thread MRAB
Terry Reedy wrote: Benjamin Kaplan wrote: On Sat, Jan 24, 2009 at 5:35 PM, Lie Ryan > wrote: On Fri, 23 Jan 2009 19:58:09 -0700, Linuxguy123 wrote: > I just started using python last week and I'm addicted. you need to try this: import antigravit

Re: Regex for Python 2.7

2009-01-24 Thread MRAB
Gabriel Genellina wrote: > En Sat, 24 Jan 2009 18:23:51 -0200, MRAB > escribió: > >> Some time ago I discovered this difference between regular expressions >> in Python and Perl: >> >> Python >> >> \A matches at start of string >> \Z matches at end of string >> >> Perl >> >> \A matche

Re: why is this invalid b = a += b ?

2009-01-24 Thread MRAB
Stef Mientki wrote: hello, I can assign a value to more than 1 variable (name) in one line: a = b = 3 So evaluation of this line must start at the right part. But the following is not allowed: b = 2 a = b += 1 I would think that if b has a value, and the formula is evaluated from right to l

Re: I'm a python addict !

2009-01-24 Thread Terry Reedy
Benjamin Kaplan wrote: On Sat, Jan 24, 2009 at 5:35 PM, Lie Ryan > wrote: On Fri, 23 Jan 2009 19:58:09 -0700, Linuxguy123 wrote: > I just started using python last week and I'm addicted. you need to try this: import antigravity http://xkcd.c

Re: Regex for Python 2.7

2009-01-24 Thread Gabriel Genellina
En Sat, 24 Jan 2009 18:23:51 -0200, MRAB escribió: Some time ago I discovered this difference between regular expressions in Python and Perl: Python \A matches at start of string \Z matches at end of string Perl \A matches at start of string \Z matches befo

why is this invalid b = a += b ?

2009-01-24 Thread Stef Mientki
hello, I can assign a value to more than 1 variable (name) in one line: a = b = 3 So evaluation of this line must start at the right part. But the following is not allowed: b = 2 a = b += 1 I would think that if b has a value, and the formula is evaluated from right to left, there's nothing

Can webbrowser module get source code?

2009-01-24 Thread Muddy Coder
Hi All, I played the demo of webbrowser module, with the code below: import webbrowser url = 'https://login.yahoo.com' webbrowser.open_new_tab(url) when I ran the code, it popped out a webpage nicely. I want to go further: to get the source code of the webpage being displayed. Is it possible to

Re: TEST=`which test` equivalent in python?

2009-01-24 Thread Gabriel Genellina
En Sat, 24 Jan 2009 17:03:33 -0200, Jay Jesus Amorin escribió: *SVNLOOK_PATH=os.system('which svnlook')* You've been told what's wrong with that. But instead of fixing how to invoke "which", use distutils.spawn.find_executable instead: py> from distutils.spawn import find_executable py>

Is (-1 ==True) True or False? Neither

2009-01-24 Thread oktaysafak
Hi all, I ran into a strange case. Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32 ... >>> -1 == True False >>> -1 == False False This works though: >>> if -1:     print "OK" OK After some head scratching, I realized that: - bool is a subclass of int and

Re: Possible to slice a string with unpacked tuple?

2009-01-24 Thread python
MRAB, > Does myString[myTuple[0] : myTuple[1]] count as unpacking? I'm not sure my use of the term 'unpacking' was totally correct, but, yes, that's what I was hoping to avoid with a simpler solution. > then how about myString.__getslice__(*myTuple)? Very interesting. I'm going to try Ben's s

Re: Possible to slice a string with unpacked tuple?

2009-01-24 Thread python
Benjamin, > Use the built-in slice. Perfect!! That's exactly what I was looking for - I didn't know this object existed. > What's wrong with unpacking the tuple? I'm extracting fields from a huge, multi-gig log file. I was trying to avoid doing something like myString[ myTuple[ 0 ]: myTuple[ 1 ] )

Re: Possible to slice a string with unpacked tuple?

2009-01-24 Thread MRAB
pyt...@bdurham.com wrote: Is there a way to slice a string with a tuple without unpacking the tuple? >>> myString = "111-222-333-444" >>> myString[ 4: 7 ] '222' Is there some way I could perform an identical slicing operation with a tuple like ( 4, 7 ) without having to unpack the tuple?

Re: I'm a python addict !

2009-01-24 Thread Benjamin Kaplan
On Sat, Jan 24, 2009 at 5:35 PM, Lie Ryan wrote: > On Fri, 23 Jan 2009 19:58:09 -0700, Linuxguy123 wrote: > > > I just started using python last week and I'm addicted. > > you need to try this: > > import antigravity > > http://xkcd.com/353/ > Just be careful with that. That guy was still floati

Re: Possible to slice a string with unpacked tuple?

2009-01-24 Thread Benjamin Kaplan
On Sat, Jan 24, 2009 at 5:31 PM, wrote: > Is there a way to slice a string with a tuple without unpacking the tuple? > > >>> myString = "111-222-333-444" > >>> myString[ 4: 7 ] > '222' > > Is there some way I could perform an identical slicing operation with a > tuple like ( 4, 7 ) without havin

Possible to slice a string with unpacked tuple?

2009-01-24 Thread python
Is there a way to slice a string with a tuple without unpacking the tuple? >>> myString = "111-222-333-444" >>> myString[ 4: 7 ] '222' Is there some way I could perform an identical slicing operation with a tuple like ( 4, 7 ) without having to unpack the tuple? >>> myTuple = ( 4, 7 ) Thanks! Malco

Re: I'm a python addict !

2009-01-24 Thread Lie Ryan
On Fri, 23 Jan 2009 19:58:09 -0700, Linuxguy123 wrote: > I just started using python last week and I'm addicted. you need to try this: import antigravity http://xkcd.com/353/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there anyway Vpython and pyODE can be made to work with newer versions of Python 2.6.1 etc. without a lot of changes to source code?

2009-01-24 Thread Gerhard Häring
Casey Hawthorne wrote: Is there anyway Vpython and pyODE can be made to work with newer versions of Python 2.6.1 etc. without a lot of changes to source code? I suppose I'm thinking of an extra layer of indirection, which might slow things down to much. Aren't this just Python libraries that i

Re: Dynamic methods and lambda functions

2009-01-24 Thread Michael Torrie
unine...@gmail.com wrote: > The attributes are right, but the getter are not working. The problem > is that the lambda function always execute the last parameter passed > for all instances of the methods. How could it be done the right way? Basically, don't use a lambda. Create a real, local clos

Re: Why GIL? (was Re: what's the point of rpython?)

2009-01-24 Thread Carl Banks
On Jan 24, 12:05 pm, Carl Banks wrote: > The default metatype for Python classes would be > mutable_dict_type, which is a type wherein the object itself would be > mutable but it would still have all the mutator methods __init__, > __setattr__, etc., but they could only act on the __dict__. Not

Re: Why GIL?

2009-01-24 Thread Carl Banks
On Jan 24, 12:24 pm, Carl Banks wrote: > On Jan 24, 12:33 am, Hrvoje Niksic wrote: > > > Carl Banks writes: > > > Anyway, all you're doing is distracting attention from my claim that > > > instance objects wouldn't need to be locked.  They wouldn't, no > > > matter how mutable you insist these o

Re: Why GIL?

2009-01-24 Thread Carl Banks
On Jan 24, 12:33 am, Hrvoje Niksic wrote: > Carl Banks writes: > > Anyway, all you're doing is distracting attention from my claim that > > instance objects wouldn't need to be locked.  They wouldn't, no > > matter how mutable you insist these objects whose bits would never > > change are. > > On

Regex for Python 2.7

2009-01-24 Thread MRAB
Some time ago I discovered this difference between regular expressions in Python and Perl: Python \A matches at start of string \Z matches at end of string Perl \A matches at start of string \Z matches before terminal newline or at end of string \z match

Re: MaxInt on Vista-64bit?

2009-01-24 Thread googler . 1 . webmaster
Hi! Thanks for the fast answer. Yes, its enough but I never thought that Vista64 is not a real 64-bit operating system :-o. -- http://mail.python.org/mailman/listinfo/python-list

Re: MaxInt on Vista-64bit?

2009-01-24 Thread Martin v. Löwis
> I downloaded Python64 for Windows Vista64 but the value returned from > sys.maxint is just a 32bit integer. I found out, thats by design, > Microsoft decided to make the long value 32bit. What can I do to > compile python 2.6 with maxint of 64bit integers? At a minimum, you need to change ob_iva

Re: Why GIL? (was Re: what's the point of rpython?)

2009-01-24 Thread Carl Banks
On Jan 24, 12:40 am, "Gabriel Genellina" wrote: > En Sat, 24 Jan 2009 06:06:02 -0200, Carl Banks   > escribió: > > > > > On Jan 23, 11:45 pm, Bryan Olson wrote: > >> Carl Banks wrote: > >> > Classes in Python are mutable types, usually.  Class instances are > >> > (except for the refcount) immut

Re: understanding nested lists?

2009-01-24 Thread Vincent Davis
Thanks for the info. I did not know that. Thanks Vincent Davis On Sat, Jan 24, 2009 at 10:46 AM, Steve Holden wrote: > Vincent Davis wrote: > > I have a short peace of code that is not doing what I expect. when I > > assign a value to a list in a list alist[2][4]=z this seems replace all > > t

MaxInt on Vista-64bit?

2009-01-24 Thread googler . 1 . webmaster
Hi! I downloaded Python64 for Windows Vista64 but the value returned from sys.maxint is just a 32bit integer. I found out, thats by design, Microsoft decided to make the long value 32bit. What can I do to compile python 2.6 with maxint of 64bit integers? Can I replace the int values to a int64 va

Re: Byte oriented data types in python

2009-01-24 Thread skip
Ravi> packet_type (1 byte unsigned) || packet_length (1 byte unsigned) || Ravi> packet_data(variable) Ravi> How to construct these using python data types, as int and float have Ravi> no limits and their sizes are not well defined. Take a look at the struct and ctypes modules. -

Re: Byte oriented data types in python

2009-01-24 Thread Martin v. Löwis
> packet_type (1 byte unsigned) || packet_length (1 byte unsigned) || > packet_data(variable) > > How to construct these using python data types, as int and float have > no limits and their sizes are not well defined. In Python 2.x, use the regular string type: chr(n) will create a single byte, a

Re: ossaudiodev problem: sawtooth noise

2009-01-24 Thread Peter Pearson
On Fri, 23 Jan 2009 14:55:36 -0200, Gabriel Genellina wrote: > En Fri, 23 Jan 2009 14:36:46 -0200, Peter Pearson > escribió: >> On Thu, 22 Jan 2009 20:58:14 -0200, Gabriel Genellina wrote: >>> En Mon, 19 Jan 2009 21:57:04 -0200, Peter Pearson >>> escribió: >>> The following code uses ossaud

Re: RegEx issues

2009-01-24 Thread MRAB
Roy Smith wrote: [snip] Another trick when you're not 100% what you're looking at is to explode the string like this: [c for c in reg] > ['\\', '[', '\\', '[', '(', '.', '*', ')', '\\', ']', '\\', ']', ';'] > A shorter way is list(reg). -- http://mail.python.org/mailman/listinfo/python-lis

Re: TEST=`which test` equivalent in python?

2009-01-24 Thread Benjamin Kaplan
On Sat, Jan 24, 2009 at 2:03 PM, Jay Jesus Amorin wrote: > Hi, > > Kindly help. > > import sys, os, string > > *SVNLOOK_PATH=os.system('which svnlook')* Read the docs on os.system. It returns the program's return code, not the child processes stdout. Use the subprocess module. > > > def main(re

Re: Byte oriented data types in python

2009-01-24 Thread Stephen Hansen
I have following packet format which I have to send over Bluetooth. > > packet_type (1 byte unsigned) || packet_length (1 byte unsigned) || > packet_data(variable) > > How to construct these using python data types, as int and float have > no limits and their sizes are not well defined. Check out

Re: Parsing a string into a datetime object

2009-01-24 Thread Hrvoje Niksic
"Mark.Petrovic" writes: > Might someone comment on why %f is not accepted as a valid field > directive in: > from datetime import datetime created="2009-01-24 16:04:55.882788" dt = datetime.strptime(created,"%Y-%m-%d %H:%M:%S.%f") > Traceback (most recent call last): > File "", l

TEST=`which test` equivalent in python?

2009-01-24 Thread Jay Jesus Amorin
Hi, Kindly help. import sys, os, string *SVNLOOK_PATH=os.system('which svnlook')* def main(repos, txn): svnlook_cmd = '%s log -t "%s" "%s"' % (*SVNLOOK_PATH*, txn, repos) check_msg = os.popen(svnlook_cmd, 'r').readline().rstrip('\n') if len(check_msg) < 10: sys.stderr.write

Re: Porting 3.0 to 2.6 - from __future__ import super missing?

2009-01-24 Thread andrew cooke
On Jan 24, 2:32 pm, Benjamin Peterson wrote: > I would suggest that you use the 2.6 syntax, and run "2to3 -f metaclass" on > your > code. (ABCs have been backported to 2.6.) Thanks - with that hint I found this - http://mikewatkins.ca/2008/11/29/python-2-and-3-metaclasses/#using-the-metaclass-in

Re: RegEx issues

2009-01-24 Thread Scott David Daniels
Sean Brown wrote: I have the following string ...: "td[ct] = [[ ... ]];\r\n" The ... (representing text in the string) is what I'm extracting So I think the regex \[\[(.*)\]\]; should do it. The problem is it appears that python is escaping the \ in the regex because I see this: reg = '\[\

Re: RegEx issues

2009-01-24 Thread Roy Smith
Sean Brown wrote: > The problem is it appears that python is escaping the \ in the regex > because I see this: > >>>reg = '\[\[(.*)\]\];' The first trick of working with regexes in Python is to *always* use raw strings. Instead of reg = '\[\[(.*)\]\];' you want reg = r'\[\[(.*)\]\];' In th

Byte oriented data types in python

2009-01-24 Thread Ravi
I have following packet format which I have to send over Bluetooth. packet_type (1 byte unsigned) || packet_length (1 byte unsigned) || packet_data(variable) How to construct these using python data types, as int and float have no limits and their sizes are not well defined. -- http://mail.python

Re: RegEx issues

2009-01-24 Thread Steve Holden
Mark Tolonen wrote: > > "Sean Brown" wrote in message > news:glflaj$qr...@nntp.motzarella.org... >> Using python 2.4.4 on OpenSolaris 2008.11 >> >> I have the following string created by opening a url that has the >> following string in it: >> >> td[ct] = [[ ... ]];\r\n >> >> The ... above is wh

Re: Parsing a string into a datetime object

2009-01-24 Thread MRAB
Mark.Petrovic wrote: > Good day. > > Might someone comment on why %f is not accepted as a valid field > directive in: > from datetime import datetime created="2009-01-24 16:04:55.882788" dt = datetime.strptime(created,"%Y-%m-%d %H:%M:%S.%f") > Traceback (most recent call last): >

Re: Doc for extended call syntax; was: Re: unzip array of arrays?

2009-01-24 Thread Steve Holden
Bryan Olson wrote: > Tobiah wrote: >> Where can I read about >> this mysterious use of the '*'? > > Hmmm... that's a harder question than I thought. Am I missing it, or > does Python's doc need a write-up of the extended call syntax? > No, you aren't mistaken. Looking at the "*" symbol in the 2.6

Re: Web authentication urllib2

2009-01-24 Thread Scott David Daniels
Gabriel wrote: Yep, i realize this a minute after posting, sorry. And thank you again .) Steve Holden wrote: ... I'll offer a couple of pointers about what we all expect here. Please treat this as advice, not a shout of disapproval. (1) Do not top post (put your response above the previous i

Re: What is intvar?

2009-01-24 Thread Steve Holden
W. eWatson wrote: > W. eWatson wrote: >> r wrote: >>> here is a good explanation of control vars: >>> http://infohost.nmt.edu/tcc/help/pubs/tkinter/control-variables.html >>> >>> Here are 3 great Tkinter refernces in order: >>> http://infohost.nmt.edu/tcc/help/pubs/tkinter/ >>> http://effbot.org/tk

Re: RegEx issues

2009-01-24 Thread Mark Tolonen
"Sean Brown" wrote in message news:glflaj$qr...@nntp.motzarella.org... Using python 2.4.4 on OpenSolaris 2008.11 I have the following string created by opening a url that has the following string in it: td[ct] = [[ ... ]];\r\n The ... above is what I'm interested in extracting which is rea

Parsing a string into a datetime object

2009-01-24 Thread Mark.Petrovic
Good day. Might someone comment on why %f is not accepted as a valid field directive in: >>> from datetime import datetime >>> created="2009-01-24 16:04:55.882788" >>> dt = datetime.strptime(created,"%Y-%m-%d %H:%M:%S.%f") Traceback (most recent call last): File "", line 1, in File "/System/

RegEx issues

2009-01-24 Thread Sean Brown
Using python 2.4.4 on OpenSolaris 2008.11 I have the following string created by opening a url that has the following string in it: td[ct] = [[ ... ]];\r\n The ... above is what I'm interested in extracting which is really a whole bunch of text. So I think the regex \[\[(.*)\]\]; should do it.

Re: practical limits of urlopen()

2009-01-24 Thread Steve Holden
webcomm wrote: > Hi, > > Am I going to have problems if I use urlopen() in a loop to get data > from 3000+ URLs? There will be about 2KB of data on average at each > URL. I will probably run the script about twice per day. Data from > each URL will be saved to my database. > > I'm asking becau

Re: Two import questions in Python 3.0

2009-01-24 Thread Scott David Daniels
Kay Schluehr wrote: On 24 Jan., 09:21, "Gabriel Genellina" wrote: If you run A.py as a script, it does not "know" it lives inside a package. You must *import* A for it to become aware of the package. Also, the directory containing the script comes earlier than PYTHONPATH entries in sys.path --

Re: understanding nested lists?

2009-01-24 Thread Brian Allen Vanderburg II
vinc...@vincentdavis.net wrote: I have a short peace of code that is not doing what I expect. when I assign a value to a list in a list alist[2][4]=z this seems replace all the 4 elements in all the sub lists. I assume it is supposed to but this is not what I expect. How would I assign a value

Re: understanding nested lists?

2009-01-24 Thread Steve Holden
Vincent Davis wrote: > I have a short peace of code that is not doing what I expect. when I > assign a value to a list in a list alist[2][4]=z this seems replace all > the 4 elements in all the sub lists. I assume it is supposed to but this > is not what I expect. How would I assign a value to the

Re: Web authentication urllib2

2009-01-24 Thread Steve Holden
Gabriel wrote: > Yep, i realize this a minute after posting, sorry. > > And thank you again .) > A pleasure. Next time, you might consider posting an explanation along with the "it's working now" message, just to give closure to the thread for anyone who ends up reading it later after a search.

Re: Porting 3.0 to 2.6 - from __future__ import super missing?

2009-01-24 Thread Benjamin Peterson
andrew cooke acooke.org> writes: > Unfortunately, "metaclass=" is a syntax error in 2.6 so the following > still fails: > > from sys import version > > if version.startswith('2.'): > class Matcher(): > pass > else: > class Matcher(metaclass=ABCMeta): > pass I would sugge

practical limits of urlopen()

2009-01-24 Thread webcomm
Hi, Am I going to have problems if I use urlopen() in a loop to get data from 3000+ URLs? There will be about 2KB of data on average at each URL. I will probably run the script about twice per day. Data from each URL will be saved to my database. I'm asking because I've never opened that many

String comparision

2009-01-24 Thread S.Selvam Siva
Hi all, I am developing spell checker for my local language(tamil) using python. I need to generate alternative word list for a miss-spelled word from the dictionary of words.The alternatives must be as much as closer to the miss-spelled word.As we know, ordinary string comparison wont work here .

understanding nested lists?

2009-01-24 Thread Vincent Davis
I have a short peace of code that is not doing what I expect. when I assign a value to a list in a list alist[2][4]=z this seems replace all the 4 elements in all the sub lists. I assume it is supposed to but this is not what I expect. How would I assign a value to the 4th element in the 2nd sublis

Re: Mathematica 7 compares to other languages

2009-01-24 Thread Jerry Gerrone
On Jan 21, 1:06 pm, "soul.mirr...@gmail.com" wrote: > On Dec 4 2008, 5:11 am, Andreas Waldenburger > wrote: > > I vaguely remember you plonking [Xah Lee] before. Did you unplonk him in > > the meantime? Or was that just a figure of speech? > > > teasingly yours, > > /W > > Andreas Waldenburger, I

Doc for extended call syntax; was: Re: unzip array of arrays?

2009-01-24 Thread Bryan Olson
Tobiah wrote: Where can I read about this mysterious use of the '*'? Hmmm... that's a harder question than I thought. Am I missing it, or does Python's doc need a write-up of the extended call syntax? It only works in the context of the zip() function. It's hard to understand how the inter

Re: Counter Class -- Bag/Multiset

2009-01-24 Thread pataphor
On Thu, 22 Jan 2009 10:11:37 -0800 (PST) Raymond Hettinger wrote: > The collections module in Python 2.7 and Python 3.1 has gotten a new > Counter class that works like bags and multisets in other languages. I like that! Now that we have a multiset or Counter I think a redefinition of itertools.

Re: OCaml, Language syntax, and Proof Systems

2009-01-24 Thread Joe Riopel
On Fri, Jan 23, 2009 at 6:16 PM, Xah Lee wrote: > The haskell tutorials you can find online are the most mothefucking > stupid unreadable fuck. The Haskll community is almost stupid. What > they talk all day is about monads, currying, linder myer fuck type. > That's what they talk about all day. A

Re: Porting 3.0 to 2.6 - from __future__ import super missing?

2009-01-24 Thread andrew cooke
On Jan 24, 10:39 am, Benjamin Peterson wrote: > andrew cooke acooke.org> writes: > > > > > Hi, > > > I have some 3.0 code, which I would like to make work with 2.6. > > However, there does not seem to be support for the new super() (no > > args) via __future__.  Is that correct?  If so, what's th

Re: What is intvar?

2009-01-24 Thread W. eWatson
W. eWatson wrote: r wrote: here is a good explanation of control vars: http://infohost.nmt.edu/tcc/help/pubs/tkinter/control-variables.html Here are 3 great Tkinter refernces in order: http://infohost.nmt.edu/tcc/help/pubs/tkinter/ http://effbot.org/tkinterbook/ http://www.pythonware.com/librar

Re: What's the business with the asterisk?

2009-01-24 Thread Kay Schluehr
On 24 Jan., 13:31, mk wrote: > Hello everyone, > >  From time to time I spot an asterisk (*) used in the Python code > _outside_ the usual *args or **kwargs application. > > E.g. here:http://www.norvig.com/python-lisp.html > > def transpose (m): >    return zip(*m) >  >>> transpose([[1,2,3], [4,5,

Re: Porting 3.0 to 2.6 - from __future__ import super missing?

2009-01-24 Thread Benjamin Peterson
andrew cooke acooke.org> writes: > > Hi, > > I have some 3.0 code, which I would like to make work with 2.6. > However, there does not seem to be support for the new super() (no > args) via __future__. Is that correct? If so, what's the best way to > handle this? Just use the two argument su

  1   2   >