Re: learnpython.org - an online interactive Python tutorial

2011-04-24 Thread harrismh777
Steven D'Aprano wrote: It seems to me that weak typing is a Do What I Mean function, and DWIM is a notoriously bad anti-pattern that causes far more trouble than it is worth. I'm even a little suspicious of numeric coercions between integer and float. (But only a little.) I'm wondering about th

Re: learnpython.org - an online interactive Python tutorial

2011-04-24 Thread harrismh777
Dave Angel wrote: time echo "scale = 1010; 16 * a(1/5) - 4 * a(1/239)" |bc -lq Wouldn't it be shorter to say: time echo "scale = 1010; 4 * a(1)" |bc -lq Well, you can check it out by doing the math... (its fun...) ... you will notice that 'time' is called first, which on *nix systems c

Re: Vectors

2011-04-24 Thread rusi
On Apr 25, 4:49 am, Robert Kern wrote: > On 4/22/11 7:32 PM, Algis Kabaila wrote: > > > > > On Saturday 23 April 2011 06:57:23 sturlamolden wrote: > >> On Apr 20, 9:47 am, Algis Kabaila > > wrote: > >>> Are there any modules for vector algebra (three dimensional > >>> vectors, vector addition, sub

Re: Function __defaults__

2011-04-24 Thread Steven D'Aprano
On Sun, 24 Apr 2011 10:07:02 -0700, Ken Seehart wrote: > On 4/24/2011 2:58 AM, Steven D'Aprano wrote: [...] >> Is this an accident of implementation, or can I trust that changing >> function defaults in this fashion is guaranteed to work? > > This is documented in python 3, so I would expect it t

Re: Vectors

2011-04-24 Thread Robert Kern
On 4/22/11 7:32 PM, Algis Kabaila wrote: On Saturday 23 April 2011 06:57:23 sturlamolden wrote: On Apr 20, 9:47 am, Algis Kabaila wrote: Are there any modules for vector algebra (three dimensional vectors, vector addition, subtraction, multiplication [scalar and vector]. Could you give me a re

Re: Pls chk my login script

2011-04-24 Thread Chris Rebert
On Sun, Apr 24, 2011 at 3:05 PM, nusrath ahmed wrote: > I have written a python script for logging into a website. My script pulls > up a browser page but does not log me in. Can any one suggest if I i am > wrong in nay way,though the script is correct I am sure > > My script is as below > > > ***

Pls chk my login script

2011-04-24 Thread nusrath ahmed
I have written a python script for logging into a website. My script pulls up a browser page but does not log me in. Can any one suggest if I i am wrong in nay way,though the script is correct I am sure My script is as below * import cookielib import

Re: Function __defaults__

2011-04-24 Thread Ken Seehart
Gotta love that email latency. :-D Ken On 4/24/2011 2:47 PM, Daniel Kluev wrote: On Mon, Apr 25, 2011 at 8:21 AM, Ken Seehart wrote: Good point, Benjamin. I didn't think of testing on Jython before answering. For practical purposes it's a really good idea to test obscure features against all

Re: Function __defaults__

2011-04-24 Thread Terry Reedy
On 4/24/2011 5:21 PM, Ken Seehart wrote: Good point, Benjamin. I didn't think of testing on Jython before answering. For practical purposes it's a really good idea to test obscure features against all potential target platforms. In this case, I would argue that**Benjamin's test demonstrates a bu

Re: Function __defaults__

2011-04-24 Thread Daniel Kluev
On Mon, Apr 25, 2011 at 8:21 AM, Ken Seehart wrote: > Good point, Benjamin.  I didn't think of testing on Jython before > answering.  For practical purposes it's a really good idea to test obscure > features against all potential target platforms. > > In this case, I would argue that Benjamin's te

Re: Function __defaults__

2011-04-24 Thread Ken Seehart
Oops, I must correct myself. Please ignore my previous post. As Daniel points out, Writable is specified in the Python 3 documentation. Apparently I was reading the documentation with only my right eye open, and the Writable tag fell on my blind spot. I concur that this unambiguously implies

Re: Function __defaults__

2011-04-24 Thread Ken Seehart
Good point, Benjamin. I didn't think of testing on Jython before answering. For practical purposes it's a really good idea to test obscure features against all potential target platforms. In this case, I would argue that**Benjamin's test demonstrates a bug in Jython. One could counter by p

Re: Include me in the list

2011-04-24 Thread Chris Angelico
On Mon, Apr 25, 2011 at 6:34 AM, nusrath ahmed wrote: > urlLogin = > 'file:///C:/Documents%20and%20Settings/Fat/Desktop/New%20Folder/Login.html' > This is a file on your hard disk. You'll need to change the URL to point to the actual login page on the actual web site. Chris Angelico -- http://m

Include me in the list

2011-04-24 Thread nusrath ahmed
I have written a python script for logging into a website. For the time being I have created a login page and a website which I want to log in. My script pulls up the login page but does not post the username and password and log me in. It simple displays the login page. I wanted my scrip

Re: Groups in regular expressions don't repeat as expected

2011-04-24 Thread John Nagle
On 4/21/2011 6:16 AM, Neil Cerutti wrote: On 2011-04-20, John Nagle wrote: Findall does something a bit different. It returns a list of matches of the entire pattern, not repeats of groups within the pattern. Consider a regular expression for matching domain names: kre = re.compi

Re: Function __defaults__

2011-04-24 Thread Ken Seehart
On 4/24/2011 2:58 AM, Steven D'Aprano wrote: Consider this in Python 3.1: def f(a=42): ... return a ... f() 42 f.__defaults__ = (23,) f() 23 Is this an accident of implementation, or can I trust that changing function defaults in this fashion is guaranteed to work? This is documen

Re: Function __defaults__

2011-04-24 Thread Daniel Kluev
http://docs.python.org/dev/reference/datamodel.html Callable types ... Special attributes: ... __defaults__A tuple containing default argument values for those arguments that have defaults, or None if no arguments have a default value Writable I don't see any 'implementation detail' mark the

Re: Function __defaults__

2011-04-24 Thread Benjamin Kaplan
On Sun, Apr 24, 2011 at 5:58 AM, Steven D'Aprano wrote: > Consider this in Python 3.1: > > def f(a=42): > ...     return a > ... f() > 42 f.__defaults__ = (23,) f() > 23 > > > Is this an accident of implementation, or can I trust that changing > function defaults in this fashio

Re: Function __defaults__

2011-04-24 Thread Terry Reedy
On 4/24/2011 5:58 AM, Steven D'Aprano wrote: Consider this in Python 3.1: def f(a=42): ... return a ... f() 42 f.__defaults__ = (23,) f() 23 Is this an accident of implementation, or can I trust that changing function defaults in this fashion is guaranteed to work? Interesting que

Re: learnpython.org - an online interactive Python tutorial

2011-04-24 Thread jmfauth
On 24 avr, 05:10, harrismh777 wrote: > >     I've been giving this some more thought. From the keyboard, all I am > able to enter are character strings (not numbers). Presumably these are > UTF-8 strings in python3.  If I enter ... In Python 3, input() returns a unicode, a sequence/table/array o

ANN: SuPy 1.6 for Snow Leopard and Python 2.7

2011-04-24 Thread Greg Ewing
New Binaries of SuPy 1.6 Available -- http://www.cosc.canterbury.ac.nz/greg.ewing/SuPy/ I have released two new builds of SuPy 1.6 for MacOSX: MacOSX 10.6 (Snow Leopard) System Python 2.6 User Python 2.7 What is SuPy? - SuPy is a plugin f

[SOLVED] detecting newline character

2011-04-24 Thread Thomas 'PointedEars' Lahn
Daniel Geržo wrote: > On 23.4.2011 21:18, Thomas 'PointedEars' Lahn wrote: >> Daniel Geržo wrote: >>> [f = codecs.open(…, mode='rU', encoding='ascii') and f.newlines] >> >> […] >> The only reason I can think of for this not working ATM comes from the >> documentation, where it says that 'U' requir

Re: detecting newline character

2011-04-24 Thread Thomas 'PointedEars' Lahn
Daniel Geržo wrote: > Thomas 'PointedEars' Lahn wrote: >> It is clear now that codecs.open() would not support universal newlines >> from at least Python 2.6 forward as it is *documented* that it opens >> files in *binary mode* only. The source code that I have posted shows >> that it therefore a

Re: Re: learnpython.org - an online interactive Python tutorial

2011-04-24 Thread Dave Angel
On 01/-10/-28163 02:59 PM, harrismh777 wrote: Cameron Simpson wrote: | folks are not aware that 'bc' also has arbitrary precision floating | point math and a standard math library. Floating point math? I thought, historically at least, that bc is built on dc (arbitrary precision integer math, r

Function __defaults__

2011-04-24 Thread Steven D'Aprano
Consider this in Python 3.1: >>> def f(a=42): ... return a ... >>> f() 42 >>> f.__defaults__ = (23,) >>> f() 23 Is this an accident of implementation, or can I trust that changing function defaults in this fashion is guaranteed to work? -- Steven -- http://mail.python.org/mailman/lis

Re: detecting newline character

2011-04-24 Thread Daniel Geržo
On 24.4.2011 11:19, Thomas 'PointedEars' Lahn wrote: It is clear now that codecs.open() would not support universal newlines from at least Python 2.6 forward as it is *documented* that it opens files in *binary mode* only. The source code that I have posted shows that it therefore actively remov

Re: detecting newline character

2011-04-24 Thread Thomas 'PointedEars' Lahn
Daniel Geržo wrote: > On 24.4.2011 9:05, jmfauth wrote: >> Use the io module. > > For the record, when I use io.open(file=self.path, mode="rt", > encoding=enc)) as fobj: > > my tests are passing and everything seems to work fine. > > That indicates there is a bug with codecs module and universa

Re: learnpython.org - an online interactive Python tutorial

2011-04-24 Thread Steven D'Aprano
On Sat, 23 Apr 2011 22:10:47 -0500, harrismh777 wrote: > I've been giving this some more thought. From the keyboard, all I am > able to enter are character strings (not numbers). Presumably these are > UTF-8 strings in python3. If I enter the character string 57 then > python converts my ch

Re: detecting newline character

2011-04-24 Thread Daniel Geržo
On 24.4.2011 9:05, jmfauth wrote: Use the io module. For the record, when I use io.open(file=self.path, mode="rt", encoding=enc)) as fobj: my tests are passing and everything seems to work fine. That indicates there is a bug with codecs module and universal newline support. -- S pozdrav

Re: learnpython.org - an online interactive Python tutorial

2011-04-24 Thread Chris Angelico
On Sun, Apr 24, 2011 at 6:13 PM, Steven D'Aprano wrote: > suppose an implementation might choose to trade off memory for time, > skipping string -> bignum conversations at the cost of doubling the > memory requirements. But even if I grant you bignums, you have to do the > same for floats. Re-impl

Re: learnpython.org - an online interactive Python tutorial

2011-04-24 Thread Steven D'Aprano
On Sun, 24 Apr 2011 11:35:28 +1000, Chris Angelico wrote: > On Sun, Apr 24, 2011 at 10:42 AM, Steven D'Aprano > wrote: >> This is much like my experience with Apple's Hypertalk, where the only >> data structure is a string. I'm very fond of Hypertalk, but it is >> hardly designed with machine eff

Re: detecting newline character

2011-04-24 Thread Daniel Geržo
On 23.4.2011 21:18, Thomas 'PointedEars' Lahn wrote: Daniel Geržo wrote: I need to detect the newline characters used in the file I am reading. For this purpose I am using the following code: def _read_lines(self): with contextlib.closing(codecs.open(self.path, "rU")) as fobj:

Re: detecting newline character

2011-04-24 Thread jmfauth
On 23 avr, 22:25, Daniel Geržo wrote: > > Well I am doing this on: > Python 2.7.1 (r271:86832, Mar  7 2011, 14:28:09) > [GCC 4.2.1 (Apple Inc. build 5664)] on darwin > > So what do you guys advise me to do? > > -- Use the io module. jmf -- http://mail.python.org/mailman/listinfo/python-list