Re: [Tutor] Question on os.popen

2014-01-19 Thread SM
> In the upper left corner of that page is a dropdown you can use to get to 3.3 for example. Thanks for that info. On Sun, Jan 19, 2014 at 11:42 PM, Dave Angel wrote: > SM Wrote in message: > > Sorry for not giving details on the OS and python version I am using: > Ubuntu and Python3 > > > O

Re: [Tutor] Question on os.popen

2014-01-19 Thread SM
Eryksun: Thanks for your reply. Yes, as I mentioned in my reply to Allen, I used subprocess.check_output and it worked for me. -SM On Sun, Jan 19, 2014 at 11:33 PM, eryksun wrote: > On Sun, Jan 19, 2014 at 6:36 PM, SM wrote: > > > > This time it probably ran for a few more iterations than befo

Re: [Tutor] Question on os.popen

2014-01-19 Thread Dave Angel
SM Wrote in message: > Sorry for not giving details on the OS and python version I am using: Ubuntu > and Python3 On Sun, Jan 19, 2014 at 8:20 PM, Alan Gauld wrote: On 19/01/14 23:36, SM wrote: >> I read about os.popen in >> http://docs.python.org/2/library/subprocess.html#subprocess.Popen >

Re: [Tutor] Question on os.popen

2014-01-19 Thread eryksun
On Sun, Jan 19, 2014 at 6:36 PM, SM wrote: > > This time it probably ran for a few more iterations than before and stopped > with the same error message. This time it also output the following > messages: > > IOError: [Errno 4] Interrupted system call > Attribute not found in file (tsk_fs_attrlist

Re: [Tutor] Question on os.popen

2014-01-19 Thread SM
Hi Alan, Thanks for your reply. My answer to why I am using os.popen could be a lame one - I have used it extensively in various places before and it has been working well and so was hung up on using it. Now I replaced it by subprocess.check_output with appropriate parameters and it seems to be wor

Re: [Tutor] Question on os.popen

2014-01-19 Thread Alan Gauld
On 19/01/14 23:36, SM wrote: I read about os.popen in http://docs.python.org/2/library/subprocess.html#subprocess.Popen This doesn't answer the question but I'm curious. If you read about os.popen in the subprocess module docs why did you use it? The subprocess module replaces all the os.popen

Re: [Tutor] string indexing

2014-01-19 Thread Keith Winston
On Sun, Jan 19, 2014 at 3:50 PM, Alan Gauld wrote: >> How would Python know whether you want find for gettext, mmap, str, >> xml.etree.ElementTree.Element or xml.etree.ElementTree.ElementTree? > > > Absolutely, but a newbie doesn't even guess that more than one find would > exist. Or even that the

Re: [Tutor] Understanding Classes

2014-01-19 Thread Alan Gauld
On 19/01/14 21:59, Christian Alexander wrote: Looked all over the net for class tutorials Unable to understand the "self" argument Attempting to visual classes If you read my OOP tutorial there is a section there specifically about self. And the v3 tutor includes an introduction to the forma

[Tutor] Question on os.popen

2014-01-19 Thread SM
Hello, I am using os.popen repeatedly to run Unix shell commands within my Python program. To be more specific, I am running in a loop which could iterate as many times as there are lines in an input file - in this example, close to 150 iterations. Each loop has two calls to os.popen. It works fine

[Tutor] Understanding Classes

2014-01-19 Thread Christian Alexander
Hello Tutorians, Looked all over the net for class tutorials Unable to understand the "self" argument Attempting to visual classes I have searched high and low, for easy to follow tutorials regarding classes. Although I grok the general concept of classes, I am unable to visually understand wha

Re: [Tutor] Naming variables

2014-01-19 Thread eryksun
On Sun, Jan 19, 2014 at 9:21 AM, spir wrote: > I guess (not sure) python optimises access of dicts used as scopes (also of > object attributes) by interning id-strings and thus beeing able to replace > them by hash values already computed once for interning, or other numeric A string object cache

Re: [Tutor] string indexing

2014-01-19 Thread Alan Gauld
On 19/01/14 19:53, Mark Lawrence wrote: On 19/01/2014 19:34, Keith Winston wrote: Erm, getting what you want from help can be work. Help(find) # doesn't work at all. How would Python know whether you want find for gettext, mmap, str, xml.etree.ElementTree.Element or xml.etree.ElementTree

Re: [Tutor] Python as Teaching Language

2014-01-19 Thread Alan Gauld
On 19/01/14 19:18, Keith Winston wrote: On Sun, Jan 19, 2014 at 11:55 AM, Alan Gauld wrote: It has reached the point that I'm back to looking for a new teaching language. ... But what else is there? that's the problem :-( Hi Alan, since this is off-topic from it's original thread, but I

Re: [Tutor] string indexing

2014-01-19 Thread Mark Lawrence
On 19/01/2014 19:34, Keith Winston wrote: On Sun, Jan 19, 2014 at 11:33 AM, Alan Gauld wrote: help(''.find) Help on built-in function find: Erm, getting what you want from help can be work. Help(find) # doesn't work at all. How would Python know whether you want find for gettext, mmap,

Re: [Tutor] string indexing

2014-01-19 Thread Keith Winston
On Sun, Jan 19, 2014 at 11:33 AM, Alan Gauld wrote: help(''.find) > Help on built-in function find: Erm, getting what you want from help can be work. Help(find) # doesn't work at all. What Alan did above was create an empty string, by using two single quotes next to each other ('', not t

[Tutor] Python as Teaching Language

2014-01-19 Thread Keith Winston
On Sun, Jan 19, 2014 at 11:55 AM, Alan Gauld wrote: > It has reached the point that I'm back to looking for a new teaching > language. In Python 3 the decision has clearly been made to focus on > supporting Python's role as a professional software engineering language > at the expense of being a s

Re: [Tutor] iterators

2014-01-19 Thread Keith Winston
On Sun, Jan 19, 2014 at 2:02 PM, Oscar Benjamin wrote: > I think that's just an editing mistake. If you replace the word "iterator" > with "construct" then it makes sense: We have seen that the for statement is > such a construct. Fair enough. Thanks. But I think that it underlines the ease with

Re: [Tutor] iterators

2014-01-19 Thread Oscar Benjamin
On Jan 19, 2014 6:49 PM, "Keith Winston" wrote: > > Well, as usual thanks for all this, it's really great. I'd worked out > that it was a distinction between iterators and iterables, though I'm > going to Oscar's description a few more times: most of it made sense, > but there are subtleties. > >

Re: [Tutor] iterators

2014-01-19 Thread Keith Winston
Well, as usual thanks for all this, it's really great. I'd worked out that it was a distinction between iterators and iterables, though I'm going to Oscar's description a few more times: most of it made sense, but there are subtleties. For example, this from the Python 3.3 tutorial: We say such a

Re: [Tutor] iterators

2014-01-19 Thread Alan Gauld
On 19/01/14 16:18, Oscar Benjamin wrote: It's not really that complicated. Basically range on 3.x (or xrange on 2.x) returns a range object: Sadly though it is complicated, at least for newbies :-( Python 3 has cleaned up much of the language from a Comp Sci point of view but from the point

Re: [Tutor] string indexing

2014-01-19 Thread Alan Gauld
On 19/01/14 13:59, rahmad akbar wrote: hey guys, super noob here, i am trying to understand the following code from google tutorial which i failed to comprehend Others have answered the specifics but some general advice here: 1) never forget the Python >>> prompt. Try things out if you don't

Re: [Tutor] iterators

2014-01-19 Thread Oscar Benjamin
On 19 January 2014 12:55, spir wrote: > > 'range' ('xrange' in python2) is certainly (at least in my view) a kind of > iterator in the latter, more general sense used in programming (some thing > providing items one at a time); however, it does not implement python's > iterator protocal. Thus, it

Re: [Tutor] string indexing

2014-01-19 Thread Peter Otten
rahmad akbar wrote: > hey guys, super noob here, i am trying to understand the following code > from google tutorial which i failed to comprehend > > #code start > # E. not_bad > # Given a string, find the first appearance of the > # substring 'not' and 'bad'. If the 'bad' follows > # the 'not',

Re: [Tutor] string indexing

2014-01-19 Thread spir
On 01/19/2014 02:59 PM, rahmad akbar wrote:> hey guys, super noob here, i am trying to understand the following code from google tutorial which i failed to comprehend #code start # E. not_bad # Given a string, find the first appearance of the # substring 'not' and 'bad'. If the 'bad' follows #

[Tutor] string indexing

2014-01-19 Thread rahmad akbar
hey guys, super noob here, i am trying to understand the following code from google tutorial which i failed to comprehend #code start # E. not_bad # Given a string, find the first appearance of the # substring 'not' and 'bad'. If the 'bad' follows # the 'not', replace the whole 'not'...'bad' subs

Re: [Tutor] Naming variables

2014-01-19 Thread spir
On 01/19/2014 02:59 PM, Mark Lawrence wrote: On 19/01/2014 13:23, spir wrote: On 01/18/2014 07:20 PM, Pierre Dagenais wrote: Hello, I wish to fill a list called years[] with a hundred lists called year1900[], year1901[], year1902[], ..., year1999[]. That is too much typing of course. Any way o

Re: [Tutor] Naming variables

2014-01-19 Thread Mark Lawrence
On 19/01/2014 13:23, spir wrote: On 01/18/2014 07:20 PM, Pierre Dagenais wrote: Hello, I wish to fill a list called years[] with a hundred lists called year1900[], year1901[], year1902[], ..., year1999[]. That is too much typing of course. Any way of doing this in a loop? I've tried stuff like

Re: [Tutor] Naming variables

2014-01-19 Thread spir
On 01/18/2014 07:20 PM, Pierre Dagenais wrote: Hello, I wish to fill a list called years[] with a hundred lists called year1900[], year1901[], year1902[], ..., year1999[]. That is too much typing of course. Any way of doing this in a loop? I've tried stuff like ("year" + str(1900)) = [0,0] but n

Re: [Tutor] iterators

2014-01-19 Thread spir
On 01/19/2014 12:24 AM, Keith Winston wrote: On Sat, Jan 18, 2014 at 2:19 PM, eryksun wrote: `xrange` and 3.x `range` aren't iterators. They're sequences. A sequence implements `__len__` and `__getitem__`, which can be used to implement an iterator, reversed iterator, and the `in` operator (i.e

Re: [Tutor] Naming variables

2014-01-19 Thread Wiktor Matuszewski
W dniu 2014-01-18 19:20, Pierre Dagenais pisze: I wish to fill a list called years[] with a hundred lists called year1900[], year1901[], year1902[], ..., year1999[]. That is too much typing of course. Any way of doing this in a loop? I've tried stuff like ("year" + str(1900)) = [0,0] but nothing

Re: [Tutor] Naming variables

2014-01-19 Thread Wiktor Matuszewski
W dniu 2014-01-18 19:20, Pierre Dagenais pisze: I wish to fill a list called years[] with a hundred lists called year1900[], year1901[], year1902[], ..., year1999[]. That is too much typing of course. Any way of doing this in a loop? I've tried stuff like ("year" + str(1900)) = [0,0] but nothing

Re: [Tutor] Naming variables

2014-01-19 Thread Peter Otten
Pierre Dagenais wrote: > I wish to fill a list called years[] with a hundred lists called > year1900[], year1901[], year1902[], ..., year1999[]. That is too much > typing of course. Any way of doing this in a loop? I've tried stuff like > ("year" + str(1900)) = [0,0] but nothing works. > Any solut

Re: [Tutor] ValueError: could not convert string to float: '13,2'

2014-01-19 Thread Peter Otten
Pierre Dagenais wrote: > > > On 13-12-31 04:09 PM, Keith Winston wrote: >> Hi PierreD, I think if you iterate over your strings with something like >> this, it will do what you want, if I understand correctly (snum is your >> string number, like "123,321"): >> >> fnum = float(snum.replace(",",