Re: .split() Qeustion

2013-08-15 Thread Steven D'Aprano
On Wed, 14 Aug 2013 13:05:50 -0400, random832 wrote: > On Wed, Aug 14, 2013, at 10:32, wxjmfa...@gmail.com wrote: >> I'm always and still be suprised by the number of hard coded '\n' one >> can find in Python code when the portable (here win) >> >> >>> os.linesep >> '\r\n' >> >> exists. > > Bec

Re: Reading log and saving data to DB

2013-08-15 Thread Guy Tamir
On Thursday, August 15, 2013 1:34:38 AM UTC+3, Dennis Lee Bieber wrote: > On Wed, 14 Aug 2013 06:18:08 -0700 (PDT), Guy Tamir > > declaimed the following: > > > > >Hi all, > > > > > >I have a Ubuntu server running NGINX that logs data for me. > > > > Is the log coming from NGINX or

Re: many constructors in a class?

2013-08-15 Thread Steven D'Aprano
On Wed, 14 Aug 2013 14:16:31 +, climb65 wrote: > Hello, > > here is a small basic question : > > Is it possible to have more than one constructor (__init__ function) in > a class? For instance, to create an object with 2 different ways? If my > memory is good, I think that with C++ it is pos

Re: Reading log and saving data to DB

2013-08-15 Thread Guy Tamir
On Wednesday, August 14, 2013 4:46:09 PM UTC+3, mar...@python.net wrote: > On Wed, Aug 14, 2013, at 09:18 AM, Guy Tamir wrote: > > > Hi all, > > > > > > I have a Ubuntu server running NGINX that logs data for me. > > > I want to write a python script that reads my customized logs and after >

Re: .split() Qeustion

2013-08-15 Thread wxjmfauth
Le mercredi 14 août 2013 19:14:59 UTC+2, Chris Angelico a écrit : > On Wed, Aug 14, 2013 at 6:05 PM, wrote: > > > On Wed, Aug 14, 2013, at 10:32, wxjmfa...@gmail.com wrote: > > >> I'm always and still be suprised by the number of hard coded > > >> '\n' one can find in Python code when the port

Re: .split() Qeustion

2013-08-15 Thread Duncan Booth
Joshua Landau wrote: > That's true with this example, but is: > > lines = [ > "Developments in high-speed rail, and high-speed", > "transport more generally, have historically been", > "impeded by the difficulties in managing friction", > "and air resistance, both of which become

Define a class containing methods for reading a file and then store lines in external variable

2013-08-15 Thread Joug Raw
Hi, I am really new in python programming and I want to build a class that perform various functions to the content(or lines) of any given file. I want to first include the opening and reading file function into that class, then add other methods. Here is what I wrote for opening file and read

Re: Define a class containing methods for reading a file and then store lines in external variable

2013-08-15 Thread Chris Angelico
On Thu, Aug 15, 2013 at 10:33 AM, Joug Raw wrote: > class FileOpration: > def __init__(self,name): > self.name = name > self.filename = self.name > def readAllline(self): > open(self.name).readlines() > > file1 = FileOpration("myfile.txt") > print file1.filename > a

Re: .split() Qeustion

2013-08-15 Thread wxjmfauth
A technical ascpect of triple quoted strings is that the "end of lines" are not respected. >>> import zzz >>> zzz.__doc__ 'abc\ndef\n' >>> with open('zzz.py', 'rb') as fo: ... r = fo.read() ... >>> r b'"""abc\r\ndef\r\n"""\r\n' Now, one can argue... jmf -- http://mail.python.org/mailma

Re: .split() Qeustion

2013-08-15 Thread Chris Angelico
On Thu, Aug 15, 2013 at 10:46 AM, wrote: > A technical ascpect of triple quoted strings is > that the "end of lines" are not respected. > import zzz zzz.__doc__ > 'abc\ndef\n' with open('zzz.py', 'rb') as fo: > ... r = fo.read() > ... r > b'"""abc\r\ndef\r\n"""\r\n' > > No

Re: many constructors in a class?

2013-08-15 Thread Fábio Santos
I agree with Steven here. classmethod is the best practise, most practical, readable, future-proof, one obvious way to do it. On 15 Aug 2013 08:29, "Steven D'Aprano" wrote: > On Wed, 14 Aug 2013 14:16:31 +, climb65 wrote: > > > Hello, > > > > here is a small basic question : > > > > Is it po

Re: .split() Qeustion

2013-08-15 Thread Steven D'Aprano
On Thu, 15 Aug 2013 02:46:20 -0700, wxjmfauth wrote: > A technical ascpect of triple quoted strings is that the "end of lines" > are not respected. > import zzz zzz.__doc__ > 'abc\ndef\n' You are misinterpreting what you are seeing. You are not reading lines of text from a file. You

Re: many constructors in a class?

2013-08-15 Thread Roy Smith
In article <520c81f6$0$29885$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > [1] The constructor is __new__, not __init__. __init__ is called to > initialise the instance after __new__ constructs it. True, but be warned that writing your own __new__() is quite rare and probably

Re: .split() Qeustion

2013-08-15 Thread wxjmfauth
I perfectly knows what Python does. I missinterpreting nothing. I opened my example in binary mode just to show the real endings. It still remains the """...""" has its owns EOL and one has to be aware of it. No more, no less. ("""...""" and tokenize.py is funny) jmf -- http://mail.p

Want to learn Python

2013-08-15 Thread prem kumar
Hi All, Presently Iam working with QTP(VBscript)..Now planning to learn PYTHON..Could you please suggest me like is ti good to learn what is the present condition for Python in IT Companies.. Iam not thinking abt only testing purpose even Iam interested to shift to development side on python..

Re: .split() Qeustion

2013-08-15 Thread Lele Gaifax
wxjmfa...@gmail.com writes: > As a stupid scientist, I have the habbit to compare > things of the same nature with the same units. > > This *string* containing one *character* > sys.getsizeof('a') > 26 > > consumes 26 *bytes*. I'm not an expert in stupid science, and I fail to see the "commo

Re: .split() Qeustion

2013-08-15 Thread MRAB
On 15/08/2013 15:38, Lele Gaifax wrote: wxjmfa...@gmail.com writes: As a stupid scientist, I have the habbit to compare things of the same nature with the same units. This *string* containing one *character* sys.getsizeof('a') 26 consumes 26 *bytes*. I'm not an expert in stupid science,

Re: .split() Qeustion

2013-08-15 Thread Lele Gaifax
MRAB writes: > On 15/08/2013 15:38, Lele Gaifax wrote: >> wxjmfa...@gmail.com writes: >>> PS A "mole" is not a number. >> >> Oh, nice to know. And OOC, what is a "mole" in your stupid science? >> OTOH, WTF does that matter in current thread and with Python in general? >> > A "mole" is a term from

Re: .split() Qeustion

2013-08-15 Thread Chris Angelico
On Thu, Aug 15, 2013 at 4:30 PM, Lele Gaifax wrote: > MRAB writes: > >> On 15/08/2013 15:38, Lele Gaifax wrote: >>> wxjmfa...@gmail.com writes: PS A "mole" is not a number. >>> >>> Oh, nice to know. And OOC, what is a "mole" in your stupid science? >>> OTOH, WTF does that matter in current t

Re: Pair of filenos read/write each other?

2013-08-15 Thread Jack Bates
On Wed, Aug 14, 2013 at 01:17:40AM +0100, Rhodri James wrote: > On Wed, 14 Aug 2013 00:10:41 +0100, Jack Bates > wrote: > > > Can anyone suggest a way to get a pair of file descriptor numbers such > > that data written to one can be read from the other and vice versa? > > > > Is there anythin

Re: Pair of filenos read/write each other?

2013-08-15 Thread Jack Bates
On Wed, Aug 14, 2013 at 01:55:38AM +0100, Chris Angelico wrote: > On Wed, Aug 14, 2013 at 1:17 AM, Rhodri James > wrote: > > On Wed, 14 Aug 2013 00:10:41 +0100, Jack Bates > > wrote: > > > >> Can anyone suggest a way to get a pair of file descriptor numbers such > >> that data written to one can

Re: Pair of filenos read/write each other?

2013-08-15 Thread Jack Bates
On Wed, Aug 14, 2013 at 08:34:36AM +, Antoine Pitrou wrote: > Nobody nowhere.com> writes: > > On Tue, 13 Aug 2013 16:10:41 -0700, Jack Bates wrote: > > > Is there anything like os.pipe() where you can read/write both ends? > > > > There's socket.socketpair(), but it's only available on Unix.

Re: "Nested" virtual environments

2013-08-15 Thread Marcel Rodrigues
I don't know how to completely solve this problem, but here is something that can alleviate it considerably. If you have a recent version of pip, you can use wheels [1] to save built packages locally. First create a new virtualenv and install the common packages. Then put these packages in a wheel

nose config help?

2013-08-15 Thread Tim
hi, I'm using nose to generate and run some tests not for python code, but for an html repository. I know this isn't the typical way to use nose, and so I'm asking here if the following code smells wrong. I pass some args with the testconfig plugin and run a class setup method one time to get s

Re: Want to learn Python

2013-08-15 Thread Joel Goldstick
On Thu, Aug 15, 2013 at 10:21 AM, prem kumar wrote: > Hi All, > > Presently Iam working with QTP(VBscript)..Now planning to learn PYTHON..Could > you please suggest me like is ti good to learn what is the present condition > for Python in IT Companies.. I don't really understand the previous sen

Re: .split() Qeustion

2013-08-15 Thread Joshua Landau
On 15 August 2013 16:43, Chris Angelico wrote: > A mole is as much a number (6e23) as the light year is a number (9.5e15). A mole is a number. A light year is a unit. -- http://mail.python.org/mailman/listinfo/python-list

Re: Want to learn Python

2013-08-15 Thread Jordi Riera
On Thursday, August 15, 2013 4:21:43 PM UTC+2, prem kumar wrote: > Hi All, > > > > Presently Iam working with QTP(VBscript)..Now planning to learn PYTHON..Could > you please suggest me like is ti good to learn what is the present condition > for Python in IT Companies.. > > Iam not thinking a

question about posting data using MultipartPostHandler

2013-08-15 Thread cerr
Hi, I want to use http post to upload data to a webserver but I want to pass multiple arguments within the post i.e. I know that you can load one item (data)in there like this: data = {"data":open(filename,"rb")} response = opener.open(url, data, ti

Re: Pair of filenos read/write each other?

2013-08-15 Thread Antoine Pitrou
Jack Bates nottheoilrig.com> writes: > > > > An alternative is to use multiprocessing.Pipe(): > > http://docs.python.org/3.3/library/multiprocessing.html#multiprocessing.Pipe > > > > In any case, Python doesn't lack facilities for doing what you want. > > Thank you for your help, I need to sati

Re: .split() Qeustion

2013-08-15 Thread Chris Angelico
On Thu, Aug 15, 2013 at 5:54 PM, Joshua Landau wrote: > On 15 August 2013 16:43, Chris Angelico wrote: >> A mole is as much a number (6e23) as the light year is a number (9.5e15). > > A mole is a number. A light year is a unit. A mole is an amount of something. Avogadro's Number is a number, whi

Re: .split() Qeustion

2013-08-15 Thread Joshua Landau
On 15 August 2013 19:28, Chris Angelico wrote: > On Thu, Aug 15, 2013 at 5:54 PM, Joshua Landau wrote: >> On 15 August 2013 16:43, Chris Angelico wrote: >>> A mole is as much a number (6e23) as the light year is a number (9.5e15). >> >> A mole is a number. A light year is a unit. > > A mole is a

How can I redirect or launch a html file in wsgi coding?

2013-08-15 Thread Hans
Hi, I have code like this: root@lin-ser-1:~# cat /usr/local/www/wsgi-scripts/myapp.py def application(environ, start_response): import sys ... status = '200 OK' req_method=environ['REQUEST_METHOD'] if req_method == 'POST' : json_received = environ['wsgi.input'].read

http post goes into $_REQUEST instead into $_FILES

2013-08-15 Thread cerr
Hi, I have a Python script that is executing an http POST to transfer a file from the client to the server. I have achieved this with below code: from binascii import hexlify, unhexlify from httplib import HTTPConnection, HTTPException import os import hashlib import socket import urllib2 import

Re: .split() Qeustion

2013-08-15 Thread Terry Reedy
On 8/15/2013 2:28 PM, Chris Angelico wrote: On Thu, Aug 15, 2013 at 5:54 PM, Joshua Landau wrote: On 15 August 2013 16:43, Chris Angelico wrote: A mole is as much a number (6e23) as the light year is a number (9.5e15). A mole is a number. A light year is a unit. A mole is an amount of som

Re: .split() Qeustion

2013-08-15 Thread Dave Angel
Terry Reedy wrote: > On 8/15/2013 2:28 PM, Chris Angelico wrote: >> On Thu, Aug 15, 2013 at 5:54 PM, Joshua Landau wrote: >>> On 15 August 2013 16:43, Chris Angelico wrote: A mole is as much a number (6e23) as the light year is a number (9.5e15). >>> >>> A mole is a number. A light year is

Re: question about posting data using MultipartPostHandler

2013-08-15 Thread Chris Angelico
On Thu, Aug 15, 2013 at 7:12 PM, cerr wrote: > multipart = ({"data":data}, {"fname":fname}, {"f":f}) > > but I get an error saying "'tuple' object has no attribute 'items'"... how do > I do this correctly? You're no longer providing a dictionary, but a tuple of dictionaries. What you wan

Re: .split() Qeustion

2013-08-15 Thread Steven D'Aprano
On Thu, 15 Aug 2013 16:43:41 +0100, Chris Angelico wrote: > A mole is as much a number (6e23) as the light year is a number > (9.5e15). Not quite. A mole (abbreviation: mol) is a name for a specific number, like couple (2) or dozen (12) or gross (144), only much bigger: 6.02e23. And I can't bel

Re: .split() Qeustion

2013-08-15 Thread Steven D'Aprano
On Thu, 15 Aug 2013 19:28:46 +0100, Chris Angelico wrote: > On Thu, Aug 15, 2013 at 5:54 PM, Joshua Landau wrote: >> On 15 August 2013 16:43, Chris Angelico wrote: >>> A mole is as much a number (6e23) as the light year is a number >>> (9.5e15). >> >> A mole is a number. A light year is a unit.

Re: .split() Qeustion

2013-08-15 Thread Steven D'Aprano
On Thu, 15 Aug 2013 17:40:43 -0400, Terry Reedy wrote: > On 8/15/2013 2:28 PM, Chris Angelico wrote: >> On Thu, Aug 15, 2013 at 5:54 PM, Joshua Landau >> wrote: >>> On 15 August 2013 16:43, Chris Angelico wrote: A mole is as much a number (6e23) as the light year is a number (9.5e15).

Re: .split() Qeustion

2013-08-15 Thread Roy Smith
In article <520da6d1$0$3$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > On Thu, 15 Aug 2013 16:43:41 +0100, Chris Angelico wrote: > > > A mole is as much a number (6e23) as the light year is a number > > (9.5e15). > > Not quite. A mole (abbreviation: mol) is a name for a spe

Re: .split() Qeustion

2013-08-15 Thread Steven D'Aprano
On Thu, 15 Aug 2013 22:56:57 +, Dave Angel wrote: > To expand a little on that, the unit of "amount of something" is a "gram > mole", which is 6.2 **23 grams times the molecular (or atomic) weight. The unit of amount of substance is mole. Gram-mole is an unfortunate synonym for mole. Unfortu

Re: .split() Qeustion

2013-08-15 Thread Steven D'Aprano
On Fri, 16 Aug 2013 04:39:16 +, Steven D'Aprano wrote: > On Thu, 15 Aug 2013 22:56:57 +, Dave Angel wrote: > >> To expand a little on that, the unit of "amount of something" is a >> "gram mole", which is 6.2 **23 grams times the molecular (or atomic) >> weight. > > The unit of amount of

Re: .split() Qeustion

2013-08-15 Thread Dave Angel
Roy Smith wrote: > In article <520da6d1$0$3$c3e8da3$54964...@news.astraweb.com>, > Steven D'Aprano wrote: > >> On Thu, 15 Aug 2013 16:43:41 +0100, Chris Angelico wrote: >> >> > A mole is as much a number (6e23) as the light year is a number >> > (9.5e15). >> >> Not quite. A mole (abbreviat

Re: .split() Qeustion

2013-08-15 Thread Ben Finney
Steven D'Aprano writes: > Not quite. A mole (abbreviation: mol) is a name for a specific number, > like couple (2) or dozen (12) or gross (144), only much bigger: 6.02e23. > And I can't believe I still remember that value :-) Avogadro's Number is worth remembering, for mocking the pseudo-scien