Can't use subprocess.Popen() after os.chroot() - why?

2011-09-04 Thread Erik
h the following exception: Traceback (most recent call last): File "./test.py", line 7, in p = Popen("/bin/date", stdin=PIPE, stdout=PIPE, stderr=PIPE) File "/home/erik/lib/python2.7/subprocess.py", line 679, in __init__ File "/home/erik/lib/python2.7/sub

Re: a *= b not equivalent to a = a*b

2016-08-26 Thread Erik
On 26/08/16 08:44, mlzarathus...@gmail.com wrote: Here's the key: $ python2 Python 2.7.10 ... 1/2 0 $ python Python 3.5.1 ... 1/2 0.5 1//2 0 I read about this awhile ago, but it's not until it bites you that you remember fully. How is this related to your question? The example e

Re: a *= b not equivalent to a = a*b

2016-08-26 Thread Erik
On 26/08/16 08:14, mlzarathus...@gmail.com wrote: I was being facetious, but behind it is a serious point. Neither the APL nor the J languages use precedence even though their inventor, Ken Iverson, was a mathematician. That was to support functional programming dating back to the 1970's. P

Re: Question on multiple Python users in one application

2016-10-06 Thread Erik
On 06/10/16 22:11, Paul Rubin wrote: "Jolly Good Spam" writes: Can someone please suggest what I should be looking at and doing to be able to effectively run multiple independent Pythons in a single program? Put each Python in a separate process and communicate by IPC. Loren says that this

Re: Question on multiple Python users in one application

2016-10-06 Thread Erik
On 06/10/16 22:40, Loren Wilton wrote: the multi-user program is a virtual machine implementation That's not relevant (unless you mean each user is running in their own VM, in which case you _really_ need to describe your execution environment). BTW, you _really_ need to describe your execut

Re: Halp in if

2016-11-13 Thread Erik
Hi, On 13/11/16 20:09, menta...@gmail.com wrote: HI want to make a script that if somthing happens, it stop, and if it doesnt, it couninues. I dont finding a smart way. Read the documentation for the "while", "break" and "continue" keywords. Regards, E. -- https://mail.python.org/mailman/li

Re: help on "from deen import *" vs. "import deen"

2016-11-15 Thread Erik
On 15/11/16 14:43, Michael Torrie wrote: As you've been told several times, if you "import deen" then you can place a new object into the deen namespace using something like: deen.foo=bar Importing everything from an imported module into the current module's namespace is not the best idea But

Re: The right way to 'call' a class attribute inside the same class

2016-12-15 Thread Erik
On 13/12/16 06:14, Gregory Ewing wrote: Ned Batchelder wrote: if a C++ constructor raises an exception, will the corresponding destructor be run, or not? (No, because it never finished making an object of type T.) So it just leaks any memory that's been allocated by the partially-run construct

Re: The right way to 'call' a class attribute inside the same class

2016-12-15 Thread Erik
On 12/12/16 23:23, Chris Angelico wrote: In JavaScript, it's normal to talk about "calling a function as a constructor". When you do, there is a 'this' object before you start. No there isn't. There is an implicit binding of a variable called "this" based on the syntactic sugar of whether you'

Re: The right way to 'call' a class attribute inside the same class

2016-12-17 Thread Erik
On 16/12/16 01:17, Chris Angelico wrote: On Fri, Dec 16, 2016 at 11:36 AM, Erik wrote: On 12/12/16 23:23, Chris Angelico wrote: In JavaScript, it's normal to talk about "calling a function as a constructor". When you do, there is a 'this' object before you start.

Re: The right way to 'call' a class attribute inside the same class

2016-12-18 Thread Erik
r this sub-thread when searching in future. On 18/12/16 01:21, Chris Angelico wrote: On Sun, Dec 18, 2016 at 12:01 PM, Erik wrote: I wish I could find the resource I originally learned this stuff from, because it's quite enlightening and I'd like to link to it here Sounds like

Re: Cleaning up conditionals

2016-12-30 Thread Erik
On 30/12/16 23:00, Deborah Swanson wrote: Oops, indentation was messed up when I copied it into the email. Should be this: if len(l1[st]) == 0: if len(l2[st]) > 0: l1[st] = l2[st] elif len(l2[st]) == 0: if len(l1[st]

Re: learning and experimenting python.

2016-12-30 Thread Erik
On 30/12/16 23:34, einstein1...@gmail.com wrote: You are also confusing me. But there mustbe some reason. What happens if your student questions you like this.? And may be those who questions like this will surely be the developer of its successor language. Because out of thousands, only one ma

Re: Cleaning up conditionals

2016-12-30 Thread Erik
On 31/12/16 00:26, Deborah Swanson wrote: As Mr. Bieber points out, what I had above greatly benefits from the use of conjunctions. It now reads: if not len(l1[st]) and len(l2[st]): IMHO, "if not len(l)" is a _terrible_ way of spelling "if len(l) == 0" (mentally, I have to read that as "if le

Re: learning and experimenting python.

2016-12-31 Thread Erik
On 31/12/16 05:22, Wildman via Python-list wrote: On Fri, 30 Dec 2016 19:23:17 -0700, Michael Torrie wrote: On 12/30/2016 07:05 PM, Wildman via Python-list wrote: On Fri, 30 Dec 2016 23:39:43 +, Erik wrote: Do not feed the troll. E. Please explain how what I said is trolling. Perhaps

Re: Clickable hyperlinks

2017-01-03 Thread Erik
Hi. On 03/01/17 19:46, Deborah Swanson wrote: Excel has a formula: When you start a new topic on the list, could you please write a new message rather than replying to an existing message and changing the title/subject? For those reading the list in a threaded email client, this message is

Re: Screwing Up looping in Generator

2017-01-03 Thread Erik
Hi, On 03/01/17 22:14, Deborah Swanson wrote: ...you have to create the generator object first and use it to call the next function. And I really don't think you can use a generator as your range in a for loop. So I'd use a 'while True', and break out of the loop when you hit the StopIteration e

Re: Screwing Up looping in Generator

2017-01-03 Thread Erik
On 03/01/17 23:05, Deborah Swanson wrote: And yes, we usually used for loops for generators, unless you don't know when the generator will be exhausted. As in this case, where the number of files the generator can provide is unknown. Then we used the while True, break on StopIteration method. O

Re: Hey, I'm new to python so don't judge.

2017-01-03 Thread Erik
On 03/01/17 23:56, Chris Angelico wrote: On Wed, Jan 4, 2017 at 10:49 AM, wrote: #think of a number computer_number = number.randint(1,100) What's wrong is that you aren't showing us the exception you get on this line. *Copy and paste* that exception - the whole thing. It's very helpful. I

Re: How Best to Coerce Python Objects to Integers?

2017-01-03 Thread Erik
On 03/01/17 22:47, Chris Angelico wrote: On Wed, Jan 4, 2017 at 9:42 AM, Ethan Furman wrote: Aside from calling "except Exception" a "naked except" If you read the comments, you'll see that he originally had an actual bare except clause, but then improved the code somewhat in response to a re

Re: Hey, I'm new to python so don't judge.

2017-01-03 Thread Erik
Hi Callum, On 04/01/17 00:02, Callum Robinson wrote: > When i check the code it comes up with invalid syntax and my writing line gets re directed here > > def is_same(target, number: > if target == number: > result="win" > elif target > number: > result="

Re: Hey, I'm new to python so don't judge.

2017-01-03 Thread Erik
Hi Callum, On 04/01/17 00:30, Callum Robinson wrote: I feel like im missing something so blatantly obvious. That's because you are ;). I don't want to come across as patronising, but I want you to see it for yourself, so, here's a function definition similar to yours that doesn't have the sa

Re: Hey, I'm new to python so don't judge.

2017-01-03 Thread Erik
On 04/01/17 00:32, Callum Robinson wrote: I forgot a bloody bracket xD Cool, you got it ;) It's the sort of thing your brain will see instantly once you've done it a few times :D and now theirs a new error ill try to figure this out on my own. You need to look back to Chris's original rep

Re: Screwing Up looping in Generator

2017-01-03 Thread Erik
Hi, On 04/01/17 01:12, Deborah Swanson wrote: The main reason you might want to catch the StopIteration exception is to do something else before your code simply stops running. If all you're doing is run a generator til it's out of gas, and that's all you want it to do, then there's no need to c

Re: How Best to Coerce Python Objects to Integers?

2017-01-03 Thread Erik
On 04/01/17 01:10, Steve D'Aprano wrote: On Wed, 4 Jan 2017 11:22 am, Erik wrote: What he *should* have done is just validated his input strings before presenting the string to int() - i.e., process the input with knowledge that is specific to the problem domain before calling the ge

Re: Hey, I'm new to python so don't judge.

2017-01-03 Thread Erik
On 04/01/17 02:24, Callum Robinson wrote: On Wednesday, January 4, 2017 at 3:05:48 PM UTC+13, MRAB wrote: What values can 'is_same' return? Which of those values are you checking for in the loop? I'm sorry but i do not completely understand what you are stating You need to think about the s

Re: Hey, I'm new to python so don't judge.

2017-01-03 Thread Erik
On 04/01/17 02:47, Callum Robinson wrote: On Wednesday, January 4, 2017 at 3:35:53 PM UTC+13, Erik wrote: I did it and this is what it states when i run it hello. I have thought of a number between 1 and 100. Can you guess it? 5 Low Sorry , you are too high. Try again. Does this mean the

Re: Hey, I'm new to python so don't judge.

2017-01-03 Thread Erik
On 04/01/17 03:25, Steven D'Aprano wrote: On Wednesday 04 January 2017 12:25, Callum Robinson wrote: Hey man thanks, the sad thing is i have no idea why i put that in. I must be having a terrible day. Don't worry about it. The difference between a beginner and an expert is *not* that experts

Re: Clickable hyperlinks

2017-01-05 Thread Erik
Hi. On 03/01/17 19:46, Deborah Swanson wrote: > Excel has a formula: When you start a new topic on the list, could you please write a new message rather than replying to an existing message and changing the title/subject? For those reading the list in a threaded email client, this message is sh

Re: Screwing Up looping in Generator

2017-01-05 Thread Erik
Hi, On 03/01/17 22:14, Deborah Swanson wrote: > ...you have to create the generator object first and use it to call the > next function. And I really don't think you can use a generator as your > range in a for loop. So I'd use a 'while True', and break out of the > loop when you hit the StopItera

Re: Hey, I'm new to python so don't judge.

2017-01-05 Thread Erik
On 03/01/17 23:56, Chris Angelico wrote: > On Wed, Jan 4, 2017 at 10:49 AM, wrote: >> #think of a number >> computer_number = number.randint(1,100) > > What's wrong is that you aren't showing us the exception you get on > this line. *Copy and paste* that exception - the whole thing. It's > very h

Re: Screwing Up looping in Generator

2017-01-05 Thread Erik
On 03/01/17 23:05, Deborah Swanson wrote: > And yes, we usually used for loops for generators, unless you don't know > when the generator will be exhausted. As in this case, where the number > of files the generator can provide is unknown. Then we used the while > True, break on StopIteration metho

Re: Hey, I'm new to python so don't judge.

2017-01-05 Thread Erik
Hi Callum, On 04/01/17 00:02, Callum Robinson wrote: > When i check the code it comes up with invalid syntax and my writing line gets re directed here > > def is_same(target, number: > if target == number: > result="win" > elif target > number: > resu

Re: Hey, I'm new to python so don't judge.

2017-01-05 Thread Erik
On 04/01/17 00:32, Callum Robinson wrote: > I forgot a bloody bracket xD Cool, you got it ;) It's the sort of thing your brain will see instantly once you've done it a few times :D > and now theirs a new error ill try to figure this out on my own. You need to look back to Chris's original reply

Re: How Best to Coerce Python Objects to Integers?

2017-01-06 Thread Erik
On 03/01/17 22:47, Chris Angelico wrote: > On Wed, Jan 4, 2017 at 9:42 AM, Ethan Furman wrote: >> Aside from calling "except Exception" a "naked except" > > If you read the comments, you'll see that he originally had an actual > bare except clause, but then improved the code somewhat in response t

Re: Hey, I'm new to python so don't judge.

2017-01-06 Thread Erik
Hi Callum, On 04/01/17 00:30, Callum Robinson wrote: > I feel like im missing something so blatantly obvious. That's because you are ;). I don't want to come across as patronising, but I want you to see it for yourself, so, here's a function definition similar to yours that doesn't have the sam

Re: Screwing Up looping in Generator

2017-01-06 Thread Erik
Hi, On 04/01/17 01:12, Deborah Swanson wrote: > The main reason you might want to catch the StopIteration exception is > to do something else before your code simply stops running. If all > you're doing is run a generator til it's out of gas, and that's all you > want it to do, then there's no nee

Re: How Best to Coerce Python Objects to Integers?

2017-01-06 Thread Erik
On 04/01/17 01:10, Steve D'Aprano wrote: > On Wed, 4 Jan 2017 11:22 am, Erik wrote: >> What he *should* have done is just validated his input strings before >> presenting the string to int() - i.e., process the input with knowledge >> that is specific to the problem

Re: Hey, I'm new to python so don't judge.

2017-01-06 Thread Erik
On 04/01/17 02:24, Callum Robinson wrote: > On Wednesday, January 4, 2017 at 3:05:48 PM UTC+13, MRAB wrote: >> What values can 'is_same' return? >> >> Which of those values are you checking for in the loop? > > I'm sorry but i do not completely understand what you are stating You need to think abo

Re: Hey, I'm new to python so don't judge.

2017-01-06 Thread Erik
On 04/01/17 03:25, Steven D'Aprano wrote: > On Wednesday 04 January 2017 12:25, Callum Robinson wrote: > >> Hey man thanks, the sad thing is i have no idea why i put that in. I must be >> having a terrible day. > > Don't worry about it. The difference between a beginner and an expert is *not* > tha

Re: Hey, I'm new to python so don't judge.

2017-01-06 Thread Erik
On 04/01/17 02:47, Callum Robinson wrote: > On Wednesday, January 4, 2017 at 3:35:53 PM UTC+13, Erik wrote: > I did it and this is what it states when i run it > > hello. > I have thought of a number between 1 and 100. > Can you guess it? > 5 > Low > Sorry , you are to

Re: Using namedtuples field names for column indices in a list of lists

2017-01-09 Thread Erik
On 10/01/17 00:54, Deborah Swanson wrote: Since I won't change the order of the records again after the sort, I'm using records.sort(key=operator.attrgetter("Description", "Date")) once, which also works perfectly. So both sorted() and sort() can be used to sort namedtuples. Good to know! A

Re: Using namedtuples field names for column indices in a list of lists

2017-01-09 Thread Erik
On 10/01/17 03:02, Deborah Swanson wrote: Erik wrote, on January 09, 2017 5:47 PM IIRC, you create it using a list comprehension which creates the records. A list comprehension always creates a list. Well no. The list is created with: records.extend(Record._make(row) for row in rows) No

Re: How can I make a sentinel value NOT be initialized in a class/method - OOP?

2017-01-13 Thread Erik
Hi, On 13/01/17 22:26, daviddsch...@gmail.com wrote: The issue I am having is that when i enter the sentinel value of QUIT, it gets initialized as the name and printed out. How can I get around this? If I understand the question correctly (which looks like it's just a re-worded homework que

Re: How can I make a sentinel value NOT be initialized in a class/method - OOP?

2017-01-14 Thread Erik
[Replying to direct email. David - please respond to the list so that you can receive other people's suggestions also] Hi David, On 14/01/17 15:30, David D wrote: > 1) No this is not homework, I am doing this all on my own. In that case I apologise - I gave you the benefit of the doubt though

Re: working with classes, inheritance, _str_ returns and a list

2017-01-15 Thread Erik
Hi, On 15/01/17 19:58, David D wrote: I am creating a parent class and a child class. I am inheriting from the parent with an additional attribute in the child class. I am using __str__ to return the information. When I run the code, it does exactly what I want, it returns the __str__ informa

Re: Emulating Final classes in Python

2017-01-17 Thread Erik
Hi Steven, On 17/01/17 07:05, Steven D'Aprano wrote: I wish to emulate a "final" class using Python, similar to bool: [snip] It doesn't have to be absolutely bulletproof, but anyone wanting to subclass my class should need to work for it, which hopefully will tell them that they're doing som

Re: Need reviews for my book on introductory python

2017-01-27 Thread Erik
On 27/01/17 21:36, MRAB wrote: "loose"? Don't you mean "lose"? (Or possible "lack"?) Don't you mean 'Or possibly "lack"'? https://en.wikipedia.org/wiki/Muphry%27s_law ;) E. -- https://mail.python.org/mailman/listinfo/python-list

Re: How coding in Python is bad for you

2017-01-29 Thread Erik
On 29/01/17 14:42, Steve D'Aprano wrote: 1. for...else is misspelled, and should be for...then; 2. Same for while...else; I don't think I'll ever agree with you on this one. "then", to me, implies the code following it is always executed. "else" implies it's conditional. In those constructs

Re: How coding in Python is bad for you

2017-02-01 Thread Erik
On 30/01/17 02:14, Steve D'Aprano wrote: On Mon, 30 Jan 2017 10:52 am, Erik wrote: It would be even better if it was "else if not break:" to make the meaning clearer. break is not the only way to exit the for loop Fine - "else if not break or raise or return:"

Re: How to know what to install (Ubuntu/Debian) for a given import?

2017-02-01 Thread Erik
On 01/02/17 23:20, Wildman via Python-list wrote: On Wed, 01 Feb 2017 21:29:00 +, Chris Green wrote: Wildman wrote: On Wed, 01 Feb 2017 19:15:13 +, Chris Green wrote: OK, no problem, but isn't it very non-portable? I don't see why not. It should work on any system that has Python3

Re: How coding in Python is bad for you

2017-02-01 Thread Erik
On 02/02/17 02:05, MRAB wrote: Both suggestions are a little long-winded. Couldn't we just abbreviate them to "else:"? :-) You are not wrong ;) E. -- https://mail.python.org/mailman/listinfo/python-list

Re: How coding in Python is bad for you

2017-02-01 Thread Erik
On 02/02/17 01:41, Chris Angelico wrote: On Thu, Feb 2, 2017 at 10:49 AM, Erik wrote: Well, _logically_ there is a flag (in as much as it could be thought of like that to make it easy to understand - and in C, that's pretty much what you have to actually do unless you really want to use

Re: Strange range

2016-04-01 Thread Erik
On 01/04/16 15:34, Marko Rauhamaa wrote: Chris Angelico : *A range object is not an iterator.* We now have learned as much. However, doesn't that extra level of indirection seem like an odd choice? If you write your own class which has an __iter__ method, would you expect: >>> o = MyCla

Re: [Beginner] - Hanging in the code, can't figure out what's wrong

2016-04-03 Thread Erik
Hi Loop.IO, On 03/04/16 15:41, Loop.IO wrote: If you don't want the user to enter anything, then I explained how before, just use: name='C:\\Documents\\PythonCoding\\launch2.bat' if that's the file name you need. -- Bartc Hi Bartc, i tried that, didn't work FYI, for the future. Te

Re: i cant seem to figure out the error

2016-04-03 Thread Erik
Hi Anthony, On 03/04/16 16:06, anthony uwaifo wrote: please i need help with this assignment. I have written a code and i still get an error. please help me debug my code. We see this assignment come up a lot. The "tutor" list is a better place to go, but well done for at least attempting it

Re: [Beginner] - Hanging in the code, can't figure out what's wrong

2016-04-03 Thread Erik
On 03/04/16 20:54, Loop.IO wrote: The original post said what did happen, the code runs and hangs on the create file, and once i press Enter it then finishes and creates the file, not sure how you missed that but thanks Yes, I read your original post. That was days ago. The comment I was reply

Re: [Beginner] - Hanging in the code, can't figure out what's wrong

2016-04-03 Thread Erik
Loop.IO: On 03/04/16 21:25, Loop.IO wrote: On Sunday, April 3, 2016 at 9:15:22 PM UTC+1, Erik wrote: On 03/04/16 20:54, Loop.IO wrote: The original post said what did happen, the code runs and hangs on the create file, and once i press Enter it then finishes and creates the file, not sure how

Re: [Beginner] - Hanging in the code, can't figure out what's wrong

2016-04-03 Thread Erik
On 03/04/16 22:49, Loop.IO wrote: You now seem to be on some sort of rampage I offered you some valuable advice. *plonk* E. -- https://mail.python.org/mailman/listinfo/python-list

Re: good way to avoid recomputations?

2016-04-05 Thread Erik
Hi Maurice, On 05/04/16 21:54, Maurice wrote: Hi. I working on a project where I have 5 scripts loading the same file at the very beginning so I would like to know the best way I can get this file without having to compute it 5 times. I also perform, in all the scripts, a list comprehension usi

Re: python script for .dat file

2016-04-05 Thread Erik
Hi Muhammad, On 05/04/16 22:49, Muhammad Ali wrote: Would any one paste here some reference/sample python code for such extraction of data into text file? You haven't really explained what you want to achieve. What is the input format, what is the output format, what constraints are there on

Re: Fraud

2016-04-16 Thread Erik
On 16/04/16 23:02, Joel Goldstick wrote: On Sun, Apr 17, 2016 at 3:12 AM, Mel Drosis via Python-list wrote: My phone my accounts my home network have all been affected because of someone using coding from Python and Linux and GitHub and json. I don't even know what this stuff is but how do I

Re: Need help understanding list structure

2016-05-02 Thread Erik
On 02/05/16 22:30, moa47...@gmail.com wrote: Can someone help me understand why or under what circumstances a list shows pointers instead of the text data? When Python's "print" statement/function is invoked, it will print the textual representation of the object according to its class's __str

Re: for / while else doesn't make sense

2016-05-20 Thread Erik
On 20/05/16 00:51, Gregory Ewing wrote: It's not so bad with "else" because you need to look back to find out what condition the "else" refers to anyway. With my tongue only slightly in my cheek, if it was desirable to "fix"/clarify this syntax then I would suggest adding some optional (exist

Re: for / while else doesn't make sense

2016-05-21 Thread Erik
On 20/05/16 01:06, Steven D'Aprano wrote: In my experience, some people (including me) misunderstand "for...else" to mean that the else block runs if the for block *doesn't*. It took me the longest time to understand why this didn't work as I expected: for x in seq: pass else: print("

Re: for / while else doesn't make sense

2016-05-21 Thread Erik
On 21/05/16 11:39, Steven D'Aprano wrote: Just for the record, that's not my mental model *now*. Sure. And I should have written "one's mental model" - the model of anyone writing that code (not you personally) who thought the same at the time. It took me a long time to work out what for..

Re: Exended ASCII and code pages [was Re: for / while else doesn't make sense]

2016-05-25 Thread Erik
On 25/05/16 11:19, Steven D'Aprano wrote: On Wednesday 25 May 2016 19:10, Christopher Reimer wrote: Back in the early 1980's, I grew up on 8-bit processors and latin-1 was all we had for ASCII. It really, truly wasn't. But you can be forgiven for not knowing that, since until the rise of the

Re: Exended ASCII and code pages [was Re: for / while else doesn't make sense]

2016-05-26 Thread Erik
On 26/05/16 02:28, Dennis Lee Bieber wrote: On Wed, 25 May 2016 22:03:34 +0100, Erik declaimed the following: Indeed - at that time, I was working with COBOL on an IBM S/370. On that system, we used EBCDIC ASCII. That was the wierdest ASCII of all ;) It would have to be... Extended

Re: Exended ASCII and code pages [was Re: for / while else doesn't make sense]

2016-05-26 Thread Erik
On 26/05/16 10:20, Marko Rauhamaa wrote: ASCII has taken new meanings. For most coders, in relaxed style, it refers to any byte-oriented character encoding scheme. In C terms, ASCII == char * Is this really true? So by "taken new meanings" you are saying that it has actually lost all mea

Re: Exended ASCII and code pages [was Re: for / while else doesn't make sense]

2016-05-26 Thread Erik
On 26/05/16 08:21, Jussi Piitulainen wrote: UTF-8 ASCII is nice UTF-16 ASCII is weird. I am dumbstruck. E. -- https://mail.python.org/mailman/listinfo/python-list

Re: Operator Precedence/Boolean Logic

2016-06-22 Thread Erik
On 22/06/16 04:40, Elizabeth Weiss wrote: I am a little confused as to how this is False: False==(False or True) Other people have explained why the expression evaluates as it does - the sub-expression "False or True" evaluates to True (as one of the operands is truthy). Your expression then

Re: I can't understand re.sub

2015-11-30 Thread Erik
On 29/11/15 21:36, Mr Zaug wrote: I need to use re.sub to replace strings in a text file. Do you? Is there any other way? result = re.sub(pattern, repl, string, count=0, flags=0); I think I understand that pattern is the regex I'm searching for and repl is the thing I want to substitute for

Re: I can't understand re.sub

2015-11-30 Thread Erik
On 30/11/15 08:51, Jussi Piitulainen wrote: Surely the straight thing to say is: >>> foo.replace(' CONTENT_PATH ', ' Substitute ') 'foo bar baz spam Substitute bar spam' Not quite the same thing (but yes, with a third argument of 1, it would be). But there was no guarantee of spaces

Re: I can't understand re.sub

2015-12-01 Thread Erik
On 01/12/15 05:28, Jussi Piitulainen wrote: A real solution should be aware of the actual structure of those lines, assuming they follow some defined syntax. I think that we are in violent agreement on this ;) E. -- https://mail.python.org/mailman/listinfo/python-list

Re: Could you explain this rebinding (or some other action) on "nums = nums"?

2015-12-01 Thread Erik
On 01/12/15 21:37, Denis McMahon wrote: The assignment succeeds. That's imo a bug. If it's a TypeError to try and assign a value to tup[1], then tup[1] should not allow the mutated list to be assigned. Nothing got assigned. That original list object remains in that slot. However, it has been

Re: Could you explain this rebinding (or some other action) on "nums = nums"?

2015-12-01 Thread Erik
Apologies for self-replying, On 01/12/15 22:34, Erik wrote: what you're asking for is that the *container* object whose element is being assigned to is first queried as to whether it will accept a mutated element being assigned to it before that element is mutated. What I said abo

Re: "Downloading"

2015-12-01 Thread Erik
On 01/12/15 23:28, Ian Kelly wrote: What about transfers that are initiated by neither? scp remote_host1:path/to/file remote_host2:path/to/destination Regardless of how the transfer is invoked, in traditional parlance the source uploads, the target downloads. Why is this on the Python list?

Re: static variables

2015-12-01 Thread Erik
On 02/12/15 01:02, Steven D'Aprano wrote: On Tue, 1 Dec 2015 08:15 pm, Grobu wrote: # - >>> def test(arg=[0]): ... print arg[0] ... arg[0] += 1 Awesome! Hideous! using a mutable default as static storage. Exposing something a calle

Re: Question about split method

2015-12-05 Thread Erik
On 05/12/15 20:27, Mark Lawrence wrote: On 05/12/2015 19:51, Robert wrote: On Saturday, December 5, 2015 at 2:29:28 PM UTC-5, Peter Pearson wrote: On Wed, 2 Dec 2015 14:44:30 -0600, Ian Kelly wrote: On Wed, Dec 2, 2015 at 2:37 PM, Robert wrote: [snip] ss0="1, 2, 4, 8, 16".split(", ") [sni

Re: Accessing container's methods

2015-12-07 Thread Erik
Hi Tony, On 07/12/15 18:10, Tony van der Hoff wrote: A highly contrived example, where I'm setting up an outer class in a Has-a relationship, containing a number of Actors. The inner class needs to access a method of the outer class; here the method get_name. Generally, an object should not ne

Re: Help on for loop understanding

2015-12-07 Thread Erik
Hi Robert, On 08/12/15 01:39, Robert wrote: I don't find a way to show __next__ yet. Can we explicitly get the iterator for a list? Thanks, Excuse me. I find it as the following: xx.__iter__().next Out[16]: xx.__iter__().next() Out[17]: 1 Robin has told you how things work under the hood

Re: Help on for loop understanding

2015-12-07 Thread Erik
On 08/12/15 01:50, Robert wrote: One example, see below please, is in the above mentioned link. I don't see the purpose of the example. OK, so there are two parts to this. The first, is "how do I iterate over something". The answer to that is using "for" or using "iter()" followed by zero or

Re: Accessing container's methods

2015-12-08 Thread Erik
x27; Lahn wrote: Erik wrote: ^^^^ Please fix, Erik #75656. Fixed(*) Thomas 'PointerEars', you have chosen to selectively quote snippets of code and comments out of context, so I think it's futile to respond to those arguments individually. The original request (if you read it

Re: Can anyone help me modify the code so the ball starts in random directions

2015-12-11 Thread Erik
Hi, On 11/12/15 23:19, phamton...@gmail.com wrote: Can anyone direct me in the direction where to start the code for the randomized of the ball to start. Your questions over the last week or so appear to be homework assignments. However, I'll give you a hint: in the interactive interprete

Re: Can anyone help me modify the code so the ball starts in random directions

2015-12-11 Thread Erik
Hi, On 11/12/15 23:19, phamton...@gmail.com wrote: Can anyone direct me in the direction where to start the code for the randomized of the ball to start. Your questions over the last week or so appear to be homework assignments. However, I'll give you a hint: in the interactive interprete

Re: appending a line to a list based off of a string found in a previous list

2015-12-12 Thread Erik
Hi Pedro, It would be _really useful_ if you included code that could be pasted into an interpreter or file directly to show your problem. You are referencing several data sources ("satellite_dataread" and "list2") that we can only guess at. On 12/12/15 21:48, Pedro Vincenty wrote: Hello, I'm w

Re: Why doesn't response pydoc on my Python 2.7?

2015-12-12 Thread Erik
Hi Robert, On 12/12/15 23:01, Robert wrote: I want to use pydoc as some online tutorial shows, but it cannot run as below. What is wrong? "some online tutorial"? import pydoc pydoc Correct - in the interactive interpreter, typing the name of an object prints its value. You have imported

Re: Why doesn't response pydoc on my Python 2.7?

2015-12-12 Thread Erik
On 12/12/15 23:08, Robert wrote: In fact, I wanted to run the following code. When it failed, I moved to the original question above. How did it fail? Tell us what _did_ happen. It works fine for me: $ pydoc module1 Help on module module1: NAME module1 FILE /tmp/robert/module1.py D

Re: Why doesn't response pydoc on my Python 2.7?

2015-12-12 Thread Erik
Hi Robert, On 13/12/15 00:04, Robert wrote: Excuse me for the incomplete information on previous posts. Here is the message when I run it on Canopy (module1.py and module2.py are in the current folder): Welcome to Canopy's interactive data-analysis environment! with pylab-backend set to: qt T

Re: Why doesn't response pydoc on my Python 2.7?

2015-12-12 Thread Erik
On 13/12/15 00:19, Robert wrote: It turns out that Enthought does not allow pydoc as the link said: http://stackoverflow.com/questions/12063718/using-help-and-pydoc-to-list-python-modules-not-working I don't think that's what the article is telling you. Try what I said in my previous message.

Re: Weird list conversion

2015-12-13 Thread Erik
On 13/12/15 20:05, KP wrote: On Sunday, 13 December 2015 11:57:57 UTC-8, Laura Creighton wrote: In a message of Sun, 13 Dec 2015 11:45:19 -0800, KP writes: Hi all, f = open("stairs.bin", "rb") data = list(f.read(16)) print data returns ['=', '\x04', '\x00', '\x05', '\x00', '\x01', '\x00', '

Re: Weird list conversion

2015-12-13 Thread Erik
On 13/12/15 20:28, Erik wrote: When you call "print", then the list class's __repr__() method is called which in turn calls the contained objects' __repr__() methods in turn I mean the __str__() method, not __repr__() in this case - however, the answer is otherwise the

Re: Installing PyCharm on Windows

2015-12-20 Thread Erik
Hello Thomas, On 19/12/15 18:32, Thomas 'PointedEars' Lahn wrote: > (and you should seriously > consider upgrading Windows or even better, to switch to a real operating > system, like GNU/Linux On 20/12/15 08:28, Thomas 'PointedEars' Lahn wrote: > Anyhow, *I* was not intending to start an OS fla

Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2015-12-24 Thread Erik
On 24/12/15 19:36, malitic...@gmail.com wrote: you are right chris it is a homework, but we are to figure out the solution first , all we need is some guidance please and not to be spoon fed like many thought From your response, it seems that this is a homework question that a group of you ar

Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2015-12-25 Thread Erik
Hi, I appreciate that you've made an effort this time to write some code, but have you attempted to try to _execute_ any of this? [I can see that the answer must be "no"] On 25/12/15 23:09, princeud...@gmail.com wrote: > #my solution is: > def manipulate_data(dic,dict_data = {'name':'prince'

Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2015-12-27 Thread Erik
On 27/12/15 15:02, lee wrote: the code i have tested base on Cameron's code def manipulate_data(kind, data): if kind == 'list': return list(data)[::-1] elif kind == 'set': return set(data) elif kind == 'dictionary': return dict( data) manipulate_data("list", ran

Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2015-12-27 Thread Erik
On 27/12/15 20:32, Prince Udoka wrote: thanks mr cameron simpson, finally at i got the solution, God bless you: def manipulate_data(kind, data): if kind == 'list': for data in [1, 2, 3, 4, 5]: return data.reverse() elif kind == 'set': for data in {"a", "b"

Re: I'm missing something here...

2016-01-11 Thread Erik
On 11/01/16 23:26, Skip Montanaro wrote: If I change the last line of find_problems to call prob_dates.update(), the message disappears. Why is pylint (1.4.2 BTW) complaining that the prob_dates argument of find_problems is unused when I use the |= operator? Is it complaining about that, or is

Re: I'm missing something here...

2016-01-12 Thread Erik
On 12/01/16 07:13, Cameron Simpson wrote: On 11Jan2016 23:55, Erik wrote: Is it complaining about that, or is it because the 'for' loop body might be executed zero times? The former. Almost any loop _might_ be executed zero times. Compilers and linters etc should only complain i

Re: I'm missing something here...

2016-01-12 Thread Erik
Apologies for self-replying On 12/01/16 08:24, Erik wrote: On 12/01/16 07:13, Cameron Simpson wrote: The former. Almost any loop _might_ be executed zero times. Compilers and linters etc should only complain if they can prove the loop is always executed zero times. I was just raising the

  1   2   3   4   5   6   7   8   9   10   >