Re: [Python-ideas] allow line break at operators

2011-09-01 Thread Yingjie Lan
Yeah, that might be a challenge for the Python interpreter, for it has to check if the next line is indented or not. But it might be worthwhile to take this trouble, so that the coder has more freedom, and the code is hopefully better to read. From: Matt Joiner

Re: [Python-ideas] allow line break at operators

2011-09-01 Thread Yingjie Lan
Hi Gabriel, == From: Gabriel AHTUNE Subject: Re: [Python-ideas] allow line break at operators So can be done with this syntax: > x = firstpart * secondpart  +  #line breaks here > anotherpart + #continue > stillanother #continue on. after a "

Re: Calling Script from Command line not working

2011-09-01 Thread Sathish S
One more thing I observed is, while running the script from IDLE it launches a seperate process of pythonw.exe and I could see this console window poping up. However while running it from command prompt this does not happens. I was wondering if the command prompt way of calling the script is not ab

Re: Detecting Ctrl-Alt-Del in Windows

2011-09-01 Thread Gregory Ewing
On Thu, 01 Sep 2011 08:52:49 -0700, Den wrote: Also, is there a corresponding key-sequence in Mac and Linux? The nearest equivalent in MacOSX is Command-Option-Escape, which brings up the force-quit dialog. I don't know how deep down in the system it's implemented. It's possible to use SetSys

Re: Calling Script from Command line not working

2011-09-01 Thread Sathish S
Hey Gabriel, Thanks a lot for replying. I was able to run this python script from console/command prompt using cygwin python. I'm not sure whats the difference between these two versions of python. But it seems to be working. Searching theough the web i found that having cygwin1.dll could be causin

Re: [Python-ideas] allow line break at operators

2011-09-01 Thread Gabriel AHTUNE
So can be done with this syntax: > x = firstpart * secondpart + #line breaks here > anotherpart + #continue > stillanother #continue on. after a "+" operator the line is clearly not finished yet. Gabriel AHTUNE 2011/9/2 Matt Joiner > I guess the issue here is that you can't tell if an expr

Re: Optparse buggy?

2011-09-01 Thread Carl Banks
On Thursday, September 1, 2011 7:16:13 PM UTC-7, Roy Smith wrote: > In article , > Terry Reedy wrote: > > > Do note "The optparse module is deprecated and will not be developed > > further; development will continue with the argparse module." > > One of the unfortunate things about optparse an

Re: [Python-ideas] allow line break at operators

2011-09-01 Thread Matt Joiner
I guess the issue here is that you can't tell if an expression is complete without checking the indent of the following line. This is likely not desirable. On Thu, Sep 1, 2011 at 11:43 PM, Yingjie Lan wrote: > Hi Matt, > === > From: Matt Joiner

Re: idiomatic analogue of Perl's: while (<>) { ... }

2011-09-01 Thread Cameron Simpson
On 01Sep2011 22:02, Sahil Tandon wrote: | [Thanks to everyone who responded] | | Steven D'Aprano wrote: | >On Thu, 1 Sep 2011 02:56 pm Sahil Tandon wrote: | >>%% | >># unbuffer STDOUT | >>sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0) | > | >I've never bothered with unbuffered stdout, but th

Re: Threads in Python

2011-09-01 Thread Grant Edwards
On 2011-09-01, Stephen Hansen wrote: > On 9/1/11 2:45 PM, George Kovoor wrote: >> Why doesn't python threads show an associated PID? On spawning >> python threads using the threading module I can only see the main >> thread's pid on using top or ps unix command, no subprocesses are >> displayed.

Re: slightly OT -- LaTeX

2011-09-01 Thread Miki Tebeka
I found http://tobi.oetiker.ch/lshort/lshort.pdf very useful. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python thread

2011-09-01 Thread Adam Skutt
On Sep 1, 5:14 pm, George wrote: > Hi, > Why doesn't python threads show an associated PID?  On spawning python > threads using the threading module I can only see the main thread's pid on > using top or ps unix command, no  subprocesses are displayed. In otherwords > top or ps in not aware of any

Re: idiomatic analogue of Perl's: while (<>) { ... }

2011-09-01 Thread Dan Sommers
On Thu, 01 Sep 2011 16:02:54 +1000, Steven D'Aprano wrote: > On Thu, 1 Sep 2011 02:56 pm Sahil Tandon wrote: >> # process input, line-by-line, and print responses after parsing input >> while 1: >> rval = parse(raw_input()) >> if rval == None: >> print('foo') >> else: >> print('bar'

Re: Python thread

2011-09-01 Thread Adam Skutt
On Sep 1, 5:54 pm, Terry Reedy wrote: > > Does it mean that python threads are not mapped to the core in the system. > > They all run on the same core. > No, CPython is a native thread implementation, so they'll be scheduled however the kernel sees fit. Only allowing one thread to run at a time

Re: Calling Script from Command line not working

2011-09-01 Thread Gabriel Genellina
En Mon, 29 Aug 2011 07:40:06 -0300, Sathish S escribió: We created a DLL using cygwin and have written a class based python module for the same. We have created a sample script for the class based python module, that creates an object of the class and calls various methods in the class. T

Re: Optparse buggy?

2011-09-01 Thread Ben Finney
Fulvio writes: > Terry Reedy wrote: > > > Do note "The optparse module is deprecated and will not be developed > > further; development will continue with the argparse module." > > Then,do you propose me to opt to argparse? Without argument, yes; though for now it is opt-in. -- \ “We are

Re: Optparse buggy?

2011-09-01 Thread Fulvio
Terry Reedy wrote: > Do note "The optparse module is deprecated and will not be developed > further; development will continue with the argparse module." Then,do you propose me to opt to argparse? -- Archlinux on $(uname -a) :P F -- http://mail.python.org/mailman/listinfo/python-list

Re: Optparse buggy?

2011-09-01 Thread Roy Smith
In article , Terry Reedy wrote: > Do note "The optparse module is deprecated and will not be developed > further; development will continue with the argparse module." One of the unfortunate things about optparse and argparse is the names. I can never remember which is the new one and which i

Re: slightly OT -- LaTeX

2011-09-01 Thread Ben Finney
Ethan Furman writes: > I asked a question a couple weeks ago about scripting WordPerfect with > Python, and a couple respondents suggested LaTeX was very good. Someone (you, or the respondents, or some combination of those) has omitted a few steps there, and what you've said here has become a no

Re: slightly OT -- LaTeX

2011-09-01 Thread Tomasz Rola
On Thu, 1 Sep 2011, Ethan Furman wrote: > I asked a question a couple weeks ago about scripting WordPerfect with Python, > and a couple respondents suggested LaTeX was very good. Where would I start > if I wanted to learn about it? > > ~Ethan~ 1. Leslie Lamport, "LaTeX: A Document Preparation S

Re: idiomatic analogue of Perl's: while (<>) { ... }

2011-09-01 Thread Sahil Tandon
[Thanks to everyone who responded] Steven D'Aprano wrote: On Thu, 1 Sep 2011 02:56 pm Sahil Tandon wrote: %% # unbuffer STDOUT sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0) I've never bothered with unbuffered stdout, but that looks fine to me. I'm not sure if it is necessary though, be

slightly OT -- LaTeX

2011-09-01 Thread Ethan Furman
I asked a question a couple weeks ago about scripting WordPerfect with Python, and a couple respondents suggested LaTeX was very good. Where would I start if I wanted to learn about it? ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: List comprehension timing difference.

2011-09-01 Thread MRAB
On 02/09/2011 01:35, Bart Kastermans wrote: In the following code I create the graph with vertices sgb-words.txt (the file of 5 letter words from the stanford graphbase), and an edge if two words differ by one letter. The two methods I wrote seem to me to likely perform the same computations, t

Re: fun with nested loops

2011-09-01 Thread Steven D'Aprano
Daniel wrote: > That's the form the specification is in, and it makes sense and is > very readable. > In pseudocode it looks like this, I am using @ to give loops a name: > > @loop1 > for c in configurations: > @loop2 > while not_done: > @loop3 > while step1_did_not_work:

List comprehension timing difference.

2011-09-01 Thread Bart Kastermans
In the following code I create the graph with vertices sgb-words.txt (the file of 5 letter words from the stanford graphbase), and an edge if two words differ by one letter. The two methods I wrote seem to me to likely perform the same computations, the list comprehension is faster though (281

Re: fun with nested loops

2011-09-01 Thread Daniel
I thought a bit about Carl's and Thomas' proposals, and it gave me an idea how this problem could be approached: Break is relatively easy to implement with a context manager that returns an iterable that throws an exception specific to that context manager: with named_loop(i for i in range(10)) as

Re: Detecting Ctrl-Alt-Del in Windows

2011-09-01 Thread Nobody
On Thu, 01 Sep 2011 08:52:49 -0700, Den wrote: > Obviously, this is a windows-based question. I know that Ctrl-Alt-Del > is handled deep inside the OS, and I'm not trying to interrupt that. > But is there some way to detect that a C-A-D has been pressed? Not reliably. You might infer that Ctrl-A

Re: PythonThreading

2011-09-01 Thread Terry Reedy
Please do not repeatedly post the same thing. Doing so, with different titles, will only annoy people. It takes awhile for a post to show up with whatever news or mail reader you are using. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Python thread

2011-09-01 Thread Christian Heimes
Am 02.09.2011 00:46, schrieb Benjamin Kaplan: > Threading is an OS-level construct to allow concurrency within a > single process (and address space). Threads are never supposed to be > separate processes (they aren't at the C-level, so I don't know what > Java is doing here). CPython code has a gl

Re: Python thread

2011-09-01 Thread Terry Reedy
On 9/1/2011 6:08 PM, George wrote: So what exactly does threading module do, if it doesn't create a subprocess. Does each thread have its own stack and PC. What advantage would a threading module provide over sequential execution. https://secure.wikimedia.org/wikipedia/en/wiki/Thread_%28compute

Re: Python thread

2011-09-01 Thread Benjamin Kaplan
On Thu, Sep 1, 2011 at 6:21 PM, Prasad, Ramit wrote: >>So what exactly does threading module do, if it doesn't create a subprocess. >>Does each thread have its own stack and PC. >>What advantage would a threading module provide over sequential execution. > > I believe it merely simulates multiple

Re: Threads in Python

2011-09-01 Thread Cameron Simpson
On 01Sep2011 15:27, Stephen Hansen wrote: | On 9/1/11 2:45 PM, George Kovoor wrote: | > Why doesn't python threads show an associated PID? On spawning python | > threads using the threading module I can only see the main thread's pid on | > using top or ps unix command, no subprocesses are displ

Re: Threads in Python

2011-09-01 Thread Stephen Hansen
On 9/1/11 2:45 PM, George Kovoor wrote: > Hi, > Why doesn't python threads show an associated PID? On spawning python > threads using the threading module I can only see the main thread's pid on > using top or ps unix command, no subprocesses are displayed. In otherwords > top or ps in not aware

RE: Python thread

2011-09-01 Thread Prasad, Ramit
>So what exactly does threading module do, if it doesn't create a subprocess. >Does each thread have its own stack and PC. >What advantage would a threading module provide over sequential execution. I believe it merely simulates multiple processes through scheduling (like the CPU). >From http://

Re: Python thread

2011-09-01 Thread George
So what exactly does threading module do, if it doesn't create a subprocess. Does each thread have its own stack and PC. What advantage would a threading module provide over sequential execution. On 01/09/2011 22:54, "Terry Reedy" wrote: > On 9/1/2011 5:14 PM, George wrote: >> Hi, >> Why doesn'

Re: Python thread

2011-09-01 Thread Terry Reedy
On 9/1/2011 5:14 PM, George wrote: Hi, Why doesn't python threads show an associated PID? On spawning python threads using the threading module I can only see the main thread's pid on using top or ps unix command, no subprocesses are displayed. In otherwords top or ps in not aware of any subpro

Re: Optparse buggy?

2011-09-01 Thread Terry Reedy
On 9/1/2011 5:12 PM, Fulvio wrote: I'm on python3.2, trying some experiment with OptionParser but no success Do note "The optparse module is deprecated and will not be developed further; development will continue with the argparse module." -- Terry Jan Reedy -- http://mail.python.org/mailm

Re:Threads in Python

2011-09-01 Thread George Kovoor
Hi, Why doesn't python threads show an associated PID? On spawning python threads using the threading module I can only see the main thread's pid on using top or ps unix command, no subprocesses are displayed. In otherwords top or ps in not aware of any subprocesses created using threading module

Re:PythonThreading

2011-09-01 Thread George
Hi, Why doesn't python threads show an associated PID? On spawning python threads using the threading module I can only see the main thread's pid on using top or ps unix command, no subprocesses are displayed. In otherwords top or ps in not aware of any subprocesses created using threading module

Re: Optparse buggy?

2011-09-01 Thread Jason Swails
On Thu, Sep 1, 2011 at 5:12 PM, Fulvio wrote: > Hello, > > I'm on python3.2, trying some experiment with OptionParser but no success > > >>> from optparse import OptionParser as parser > >>> parser.add_option('-n','--new', dest='new') > Here you've imported parser as an alias to the OptionParser

Re: Optparse buggy?

2011-09-01 Thread Ian Kelly
On Thu, Sep 1, 2011 at 3:12 PM, Fulvio wrote: > Hello, > > I'm on python3.2, trying some experiment with OptionParser but no success > from optparse import OptionParser as parser parser.add_option('-n','--new', dest='new') > Traceback (most recent call last): >  File "", line 1, in >  F

Optparse buggy?

2011-09-01 Thread Fulvio
Hello, I'm on python3.2, trying some experiment with OptionParser but no success >>> from optparse import OptionParser as parser >>> parser.add_option('-n','--new', dest='new') >>> Traceback (most recent

Re:Python thread

2011-09-01 Thread George
Hi, Why doesn't python threads show an associated PID? On spawning python threads using the threading module I can only see the main thread's pid on using top or ps unix command, no subprocesses are displayed. In otherwords top or ps in not aware of any subprocesses created using threading module

OSX application built with py2app can't see bundled PySide module?

2011-09-01 Thread Aaron Scott
I'm trying to deploy a Python app on OSX that was built with PySide. py2app packages it without issue, copying and linking a lot of PySide and Qt files in the process. But then, when I try to run the built app, I get this error: Traceback (most recent call last): File "/Users/sequence/Desktop

Re: Text file with mixed end-of-line terminations

2011-09-01 Thread woooee
You can use f.read() to read the entire file's contents into a string, providing the file isn't huge. Then, split on "\r" and replace "\n" when found. A simple test: input_data = "abc\rdef\rghi\r\njkl\r\nmno\r\n" first_split = input_data.split("\r") for rec in first_split: rec = rec.replace("\

Re: fun with nested loops

2011-09-01 Thread Carl Banks
On Wednesday, August 31, 2011 8:51:45 AM UTC-7, Daniel wrote: > Dear All, > > I have some complicated loops of the following form > > for c in configurations: # loop 1 > while nothing_bad_happened: # loop 2 > while step1_did_not_work: # loop 3 > for substeps in step1 # loo

Re: fun with nested loops

2011-09-01 Thread Terry Reedy
On 9/1/2011 10:05 AM, Daniel wrote: You seems to be requesting one of the options in http://python.org/dev/peps/pep-3136/ Labeled break and continue (The 'Other languages' section omits Fortran.) The rejection post is at http://mail.python.org/pipermail/python-3000/2007-July/008663.html I basica

Re: Help parsing a text file

2011-09-01 Thread William Gill
On 9/1/2011 1:58 PM, JT wrote: On Monday, August 29, 2011 1:21:48 PM UTC-5, William Gill wrote: I have a text file with XML like records that I need to parse. By XML like I mean records have proper opening and closing tags. but fields don't have closing tags (they rely on line ends). Not all

Re: Help parsing a text file

2011-09-01 Thread JT
On Monday, August 29, 2011 1:21:48 PM UTC-5, William Gill wrote: > > I have a text file with XML like records that I need to parse. By XML > like I mean records have proper opening and closing tags. but fields > don't have closing tags (they rely on line ends). Not all fields appear > in all

Re: Listing HAL devices

2011-09-01 Thread Ian Kelly
On Thu, Sep 1, 2011 at 9:46 AM, mukesh tiwari wrote: > dbus.exceptions.DBusException: > org.freedesktop.DBus.Error.ServiceUnknown: The name > org.freedesktop.Hal was not provided by any .service files > > Kindly some one please tell me why i am getting this error . > Thank you It looks like you d

Microphone Input

2011-09-01 Thread Ansuman Bebarta
I want to have a microphone input in a python program on cross platform. I don't want to use any third party module rather I want to have a module of my own. Please guide me in this direction. -- http://mail.python.org/mailman/listinfo/python-list

Re: Listing HAL devices

2011-09-01 Thread mukesh tiwari
On Sep 1, 8:46 pm, mukesh tiwari wrote: > Hello all > I am trying to write a python script which detects usb pen drive and > copy all the data into my home directory. After bit of searching , i > found these two links 1]http://en.wikibooks.org/wiki/Python_Programming/Dbus > and 2]http://stackoverf

Detecting Ctrl-Alt-Del in Windows

2011-09-01 Thread Den
Obviously, this is a windows-based question. I know that Ctrl-Alt-Del is handled deep inside the OS, and I'm not trying to interrupt that. But is there some way to detect that a C-A-D has been pressed? Also, is there a corresponding key-sequence in Mac and Linux? And how might one detect those t

Listing HAL devices

2011-09-01 Thread mukesh tiwari
Hello all I am trying to write a python script which detects usb pen drive and copy all the data into my home directory. After bit of searching , i found these two links 1] http://en.wikibooks.org/wiki/Python_Programming/Dbus and 2] http://stackoverflow.com/questions/469243/how-can-i-listen-for-us

Re: idiomatic analogue of Perl's: while (<>) { ... }

2011-09-01 Thread Anssi Saari
Sahil Tandon writes: > I've been tasked with converting some programs from Perl -> Python, and > am (as will soon be obvious) new to the language. If it's any help, I have usually done handling of standard input line by line with this kind of thing: for inputline in sys.stdin: -- http://mail.

Re: fun with nested loops

2011-09-01 Thread Thomas Rachel
Am 01.09.2011 16:05 schrieb Daniel: In pseudocode it looks like this, I am using @ to give loops a name: @loop1 for c in configurations: @loop2 while not_done: @loop3 while step1_did_not_work: @loop4 for substeps in step1 # loop 4a

Re: Why do class methods always need 'self' as the first parameter?

2011-09-01 Thread Ian Kelly
On Thu, Sep 1, 2011 at 6:45 AM, John Roth wrote: > I personally consider this to be a wart. Some time ago I did an > implementation analysis. The gist is that, if self and cls were made > special variables that returned the current instance and class > respectively, then the compiler could determi

Re: fun with nested loops

2011-09-01 Thread Daniel
Hi Steve, Thanks for your comments, I appreciate any input. > Do you think the software in the Apple iPod is "simple"? Or Microsoft No, that's much more complicated that what I am doing. But the iPod probably (?) doesn't get new algorithms based on a specification discussed with non-programmers on

Re: Constructors...BIIIIG PROBLEM!

2011-09-01 Thread Ian Kelly
On Thu, Sep 1, 2011 at 3:04 AM, Michiel Overtoom wrote: > > On Sep 1, 2011, at 10:24, Hegedüs Ervin wrote: > >> On Thu, Sep 01, 2011 at 10:00:27AM +0200, Michiel Overtoom wrote: >>> Derive your class from object, >> >> why's that better than just create a simple class, without >> derive? > > Among

Re: [Python-ideas] allow line break at operators

2011-09-01 Thread Yingjie Lan
Hi Matt, === From: Matt Joiner The "trailing \" workaround is nonobvious. Wrapping in () is noisy and already heavily used by other syntactical structures.  === How about only require inden

Re: Why do class methods always need 'self' as the first parameter?

2011-09-01 Thread John Roth
On Aug 31, 8:35 am, "T. Goodchild" wrote: > I’m new to Python, and I love it.  The philosophy of the language (and > of the community as a whole) is beautiful to me. > > But one of the things that bugs me is the requirement that all class > methods have 'self' as their first parameter.  On a gut l

Re: Why do class methods always need 'self' as the first parameter?

2011-09-01 Thread Michiel Overtoom
> On Aug 31, 5:35 pm, "T. Goodchild" wrote: >> So why is 'self' necessary on class methods? >> >> Just curious about the rationale behind this part of the language. When instance variables are accessed with the 'self.varname' syntax, it is clear to the programmer that an instance variable is

Invoking profile from command line prevent my sys.path modification

2011-09-01 Thread Yaşar Arabacı
Hi, I am new to profile module, so I am sorry if this is an absolute beginner question. In order to my code to run, I need to add a directory to sys.path. When I invole python -m profile myfile.py, my code won't work, saying that the thing that is supposed to be in path, isn't. Code works fine wit

Re: Why do class methods always need 'self' as the first parameter?

2011-09-01 Thread UncleLaz
On Aug 31, 5:35 pm, "T. Goodchild" wrote: > I’m new to Python, and I love it.  The philosophy of the language (and > of the community as a whole) is beautiful to me. > > But one of the things that bugs me is the requirement that all class > methods have 'self' as their first parameter.  On a gut l

Re: How to daemonize a HTTPServer

2011-09-01 Thread Martin P. Hellwig
On 01/09/2011 04:16, babbu Pehlwan wrote: I have written a http server using BaseHTTPServer module. Now I want to instantiate it through another python script. The issue here is after instantiate the control doesn't come back till the server is running. Please suggest. Sounds like something you

Re: Installing WebDAV server

2011-09-01 Thread Fokke Nauta
"Paul Kölle" wrote in message news:mailman.620.1314810894.27778.python-l...@python.org... > Hi, answers below... > > Am 31.08.2011 14:18, schrieb Fokke Nauta: >> "Paul Kölle" wrote in message >> news:mailman.595.1314780791.27778.python-l...@python.org... >>> Hi, >>> >>> Am 30.08.2011 22:00, schr

Re: Installing WebDAV server

2011-09-01 Thread Fokke Nauta
"Dennis Lee Bieber" wrote in message news:mailman.643.1314851358.27778.python-l...@python.org... > On Wed, 31 Aug 2011 14:18:00 +0200, "Fokke Nauta" > declaimed the following in > gmane.comp.python.general: > >> >> I also configured config.ini in D:\Python27\WebDAV\PyWebDAV\DAVServer >> >> In thi

Re: Regex to match all trailing whitespace _and_ newlines.

2011-09-01 Thread Peter Otten
Dotan Cohen wrote: > In the terrific Anki [1] application I am trying to remove trailing > whitespace from form fields. This is my regex: > [\n+\s+]$ My attempt: >>> sub = re.compile(r"\s*?(\n|$)").sub >>> sub("", "alpha \nbeta \r\n\ngamma\n") 'alphabetagamma' >>> sub("", "alpha \nbeta \

Regex to match all trailing whitespace _and_ newlines.

2011-09-01 Thread Dotan Cohen
In the terrific Anki [1] application I am trying to remove trailing whitespace from form fields. This is my regex: [\n+\s+]$ Actually, even simplifying it to [\n] or [\r\n] is not matching any newlines! What might be the cause of this? Note that I am not entering the regex in Python code, I am ent

Re: Constructors...BIIIIG PROBLEM!

2011-09-01 Thread Michiel Overtoom
On Sep 1, 2011, at 10:24, Hegedüs Ervin wrote: > On Thu, Sep 01, 2011 at 10:00:27AM +0200, Michiel Overtoom wrote: >> Derive your class from object, > > why's that better than just create a simple class, without > derive? Amongst other things, fixes to the type system and the method resolution

Re: Constructors...BIIIIG PROBLEM!

2011-09-01 Thread Hegedüs Ervin
hello, On Thu, Sep 01, 2011 at 10:00:27AM +0200, Michiel Overtoom wrote: > On Sep 1, 2011, at 09:48, Amogh M S wrote: [...] > > class S: > >def _init_(self, name=None): > >self.name = name > > s = S("MyName") > > Two things: Derive your class from object, why's that better than just

Re: Constructors...BIIIIG PROBLEM!

2011-09-01 Thread Michiel Overtoom
On Sep 1, 2011, at 09:48, Amogh M S wrote: > Hey guys... > I think we have a problem with my _init_ method and the constructor > When I create a class and its _init_ method and try to create an object of it > outside the class, > Say, something like > > class S: >def _init_(self, name=None

Re: Constructors...BIIIIG PROBLEM!

2011-09-01 Thread Peter Otten
Amogh M S wrote: > Hey guys... > I think we have a problem with my _init_ method and the constructor > When I create a class and its _init_ method and try to create an object of > it outside the class, > Say, something like > > class S: >def _init_(self, name=None): Your __init__() method ne

Constructors...BIIIIG PROBLEM!

2011-09-01 Thread Amogh M S
Hey guys... I think we have a problem with my _init_ method and the constructor When I create a class and its _init_ method and try to create an object of it outside the class, Say, something like class S: def _init_(self, name=None): self.name = name s = S("MyName") It says that the co

Re: idiomatic analogue of Perl's: while (<>) { ... }

2011-09-01 Thread Peter Otten
Peter Otten wrote: > A quick look into fileinput.py reveals that it uses readlines() and slurps > in the complete "file". I'm not sure that was a clever design decision... Correction: >>> with open("tmp.txt") as f: lines = f.readlines(0) ... >>> len(lines) 100 >>> with open("tmp.txt") as f: