Re: [Tutor] iterators -- oops!

2014-01-18 Thread spir
erratum: On 01/18/2014 12:13 PM, spir wrote: [Note, just to compare: in Lua, this little magic making builtin sequences special does not exist. So, to iterate over all items or pairs of a Lua table, one would write explicitely, resp.: for key,val in pairs(t) for item in ipairs(t

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 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] 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

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 #

Re: [Tutor] string indexing -- side note, rather OT

2014-01-20 Thread spir
On 01/20/2014 01:19 AM, Keith Winston wrote: 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 o

Re: [Tutor] Understanding Classes

2014-01-20 Thread spir
On 01/19/2014 10:59 PM, Christian Alexander wrote: 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 concep

Re: [Tutor] Understanding Classes

2014-01-21 Thread spir
On 01/21/2014 05:20 AM, Christian Alexander wrote: Alan, The concept and purpose of classes is starting to sink in a little bit, but I still haven't had my "Ah-ha" moment yet. I just can't seem to visualize the execution of classes, nor am I able to explain to myself how it actually works. Fo

Re: [Tutor] How to print certain elements

2014-01-21 Thread spir
On 01/21/2014 07:18 AM, Adriansanchez wrote: Hello everyone, I am newbie to Python and programming in general. My question is, given a list: X=['washington','adams','jefferson','madison','monroe'] And a string: Y='washington,adams,jefferson,madison,monroe' Side note: you can generate X automati

Re: [Tutor] Stuck on Challenge in Google Python Class

2014-01-22 Thread spir
On 01/22/2014 05:24 AM, Adam Hurwitz wrote: Hi, This is a coding challenge in the Google Developers Python Course. I have been working on this challenge for hours without being able to solve. A. match_ends # Given a list of strings, retu

Re: [Tutor] iter class

2014-01-23 Thread spir
On 01/23/2014 06:53 AM, Keith Winston wrote: I suppose I should practice running my questions on old code through 2to3 before I pester the Tutor list, since that's probably also a good way to learn the differences. Yes, but that way others learn as well :-) And many people prefere learning via

Re: [Tutor] Iterator vs. iterable cheatsheet, was Re: iter class

2014-01-24 Thread spir
On 01/24/2014 10:22 AM, Peter Otten wrote: There's an odd outlier that I probably shouldn't tell you about [...] I guess there is a whole class of outliers; not really sure how to classify them. This is the case of defining a wrapper or "proxy" type, for a underlying data structure which is

Re: [Tutor] Iterator vs. iterable cheatsheet, was Re: iter class

2014-01-24 Thread spir
On 01/24/2014 06:44 PM, Peter Otten wrote: There is no infinite recursion. The for loop is currently implemented as # expect an iterable # handle iterators through an idempotent iter() tmp = iter(xs) # here you must check that tmp actually implements the iterator protocol, # else raise an erro

Re: [Tutor] Iterator vs. iterable cheatsheet, was Re: iter class

2014-01-24 Thread spir
On 01/25/2014 04:13 AM, eryksun wrote: On Fri, Jan 24, 2014 at 8:50 AM, spir wrote: xs is an iterator (__next__ is there), then Python uses it directly, thus what is the point of __iter__ there? In any case, python must check whether Python doesn't check whether a type is alrea

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-25 Thread spir
On 01/25/2014 05:14 AM, Steven D'Aprano wrote: On Fri, Jan 24, 2014 at 10:28:09PM -0500, bob gailer wrote: And please call () parends and [] brackets, and{} braces. Saves a lot of confusion. If you think that parentheses are spelt with a "d", you're certainly confused :-) They're all bracket

Re: [Tutor] How to correct decimal addition.

2014-01-25 Thread spir
On 01/24/2014 06:57 PM, Leon S wrote: Here is what I'm trying to do, accept a price of gas, but I want to add the .009 to the price, so that people do not have to type the full amount. Example, 3.49 /gallon would return 3.499 /gallon. This is what I have tried and the results of it. def gas_p

Re: [Tutor] How to correct decimal addition.

2014-01-25 Thread spir
On 01/25/2014 09:46 AM, spir wrote: On 01/24/2014 06:57 PM, Leon S wrote: Here is what I'm trying to do, accept a price of gas, but I want to add the .009 to the price, so that people do not have to type the full amount. Example, 3.49 /gallon would return 3.499 /gallon. This is what I

Re: [Tutor] How to correct decimal addition.

2014-01-25 Thread spir
On 01/25/2014 10:01 PM, Keith Winston wrote: On Sat, Jan 25, 2014 at 3:57 AM, spir wrote: .009 to the price, so that people do not have to type the full amount. Example, 3.49 /gallon would return 3.499 /gallon. This is what I have tried and the results of it. def gas_price(price

Re: [Tutor] How to correct decimal addition.

2014-01-25 Thread spir
On 01/25/2014 10:19 PM, Keith Winston wrote: On Sat, Jan 25, 2014 at 3:57 AM, spir wrote: Note: AFAIK most financial software use integers for this reason and to avoid (or control) rounding errors. I don't think this is true (no flame intended, hopefully you know I'm forever in

Re: [Tutor] How to correct decimal addition.

2014-01-25 Thread spir
On 01/25/2014 10:38 PM, Keith Winston wrote: Also, just to be clear: I'd suggest floats because decimal requires importing a module and using the non-built-in features thereof The issue is not that much whether it's supported by builtins, in software, but by CPU's; which is not the case, so th

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-25 Thread spir
On 01/26/2014 02:12 AM, Steven D'Aprano wrote: On Sat, Jan 25, 2014 at 09:11:56AM +0100, spir wrote: As a foreigner, I noticed that english native speakers use both the series round / square / curly / angle brackets, and individual terms parens (no 'd' ;-) / brackets / braces

Re: [Tutor] How to correct decimal addition.

2014-01-26 Thread spir
On 01/26/2014 04:22 AM, Keith Winston wrote: On Sat, Jan 25, 2014 at 5:09 PM, Oscar Benjamin wrote: Perhaps it would be better though to point at this: round(D('0.123456'), 3) Decimal('0.123') I think you are right. I didn't even think of round(). I think we have confounded two issues in th

Re: [Tutor] When is = a copy and when is it an alias

2014-01-27 Thread spir
On 01/27/2014 07:16 AM, Denis Heidtmann wrote: Running python 2.7 in linux Below are two extremes. Can I get some guidance on this? Thanks, -Denis H a=zeros((2,3),dtype=int) b=a a[:,0]=[1,2] a array([[1, 0, 0], [2, 0, 0]]) b array([[1, 0, 0], [2, 0, 0]]) a=2 a 2 b arra

Re: [Tutor] Multi Layered Graphs

2014-01-27 Thread spir
On 01/26/2014 11:23 PM, Ankit Arora wrote: I'm working on a project which involves network graphs. Is there a library that can help me do this: I want to create multi-layered graphs i.e. graphs which contain a set number of vertices but multiple 'layers' of edges i.e. same set of vertices repres

Re: [Tutor] When is = a copy and when is it an alias

2014-01-28 Thread spir
On 01/27/2014 06:04 PM, Denis Heidtmann wrote: Apparently a[0]=b[0] does not qualify as "symbolic assignment" in this case. a[0] is not a reference to b[0]. I think I see the essential distinction. Experience will complete the picture for me. "symolic assignment" is my term, so whatever I mea

Re: [Tutor] If, elif, else

2014-01-28 Thread spir
On 01/28/2014 11:46 PM, Michael L. Pierre wrote: I am a newbie with Python (programming in general) and I am trying to create a program that will take user name and dob and pump out their age, while on a person's birthday the output not only states their name and age, but also prints out ***HA

Re: [Tutor] When is = a copy and when is it an alias

2014-01-28 Thread spir
On 01/29/2014 02:10 AM, Dave Angel wrote: Denis Heidtmann Wrote in message: What is going on? I am more confused than I was a week ago. Simple. spir has copy/paste editing errors. Oops! sorry d ___ Tutor maillist - Tutor@python.org To

Re: [Tutor] When is = a copy and when is it an alias

2014-01-29 Thread spir
On 01/29/2014 02:34 AM, Denis Heidtmann wrote: Glad to hear it. That is what I was hoping, but I did not want to question a helpful person. (you could & should, we need helpful feedback too, to improve our skills; i mean, as long as it's honest indeed) d

Re: [Tutor] Unit testing infinite loops

2014-01-31 Thread spir
On 01/31/2014 12:31 PM, James Chapman wrote: try: while self.attribute: time.sleep(1) except KeyboardInterrupt: Maybe I'm missing apoint or reasoning wrongly, but I'd rather do: while self.attribute: try: time.sleep(1) except KeyboardInterrupt: ... or something lik

Re: [Tutor] creating Turtle() object using 2 different ways

2014-02-01 Thread spir
On 01/31/2014 10:38 PM, Alan Gauld wrote: If you want multiple turtles you should use the first version. Yes, the turtle module has a global turtle that can be used by people playing with a single turtle, and prefere conventional procedural programming style, rather than object-oriented (OO).

Re: [Tutor] sorting and writing to data file

2014-02-02 Thread spir
On 02/02/2014 04:08 AM, adrian wrote: Hello community, Newbie here. I have a data (.dat) file with integers (2,9,1,5,7,3,9) in it just as shown. My instructions are to sort the numbers and rewrite them back to the data file. *here is my code:** * lab3int=[2,9,1,5,7,3,9] lab3int.sort() print(la

Re: [Tutor] most useful ide

2014-02-02 Thread spir
On 02/02/2014 09:10 PM, Pierre Dagenais wrote: On 14-02-02 01:16 PM, Kodiak Firesmith wrote: Pycharm is nice for bigger projects (since tou can collapse any section); but it's crazy resource intensive. For Linux Gedit can be made very nice I prefer Geany as it will run my code with a click

Re: [Tutor] most useful ide

2014-02-03 Thread spir
On 02/02/2014 09:10 PM, Pierre Dagenais wrote: On 14-02-02 01:16 PM, Kodiak Firesmith wrote: Pycharm is nice for bigger projects (since tou can collapse any section); but it's crazy resource intensive. For Linux Gedit can be made very nice I prefer Geany as it will run my code with a click

Re: [Tutor] Traversing lists or getting the element you want.

2014-02-03 Thread spir
On 02/02/2014 09:46 PM, Kipton Moravec wrote: I am new to Python, and I do not know how to traverse lists like I traverse arrays in C. This is my first program other than "Hello World". I have a Raspberry Pi and they say Python is the language of choice for that little machine. So I am going to t

Re: [Tutor] Splitting email headers when using imaplib

2014-02-04 Thread spir
On 02/04/2014 06:38 PM, Some Developer wrote: I'm currently trying to download emails from an IMAP server using Python. I can download the emails just fine but I'm having an issue when it comes to splitting the relevant headers. Basically I'm using the following to fetch the headers of an email m

Re: [Tutor] Advice on Python codes - A recursive function to output entire directory subkeys of Windows Registry

2014-02-06 Thread spir
On 02/05/2014 04:30 PM, Alan Ho wrote: Hi, I am a novice in Python, having attended a course few weeks ago and I'm working on my assignment now, and I encounter this issue when I was trying to print the entire Windows Registry (WR) sub-keys directories (trying that first with the below codes

Re: [Tutor] Which computer operating system is best for Python

2014-02-06 Thread spir
On 02/06/2014 12:13 AM, Alan Gauld wrote: On 05/02/14 18:34, Colin Chinsammy wrote: I am considering purchasing the Acer c720 chromebook for my 13yo to begin learning Python for Kids. Obviously I am on a budget. I wouldn't consider a Chromebpook for anyone learning programming. They are fine f

Re: [Tutor] Which computer operating system is best for Python

2014-02-06 Thread spir
On 02/06/2014 02:51 AM, Tim Krupinski wrote: The reason I suggest Linux is because a lot of Python is used in it already. People was also designed (according to Guido vR) to please Unix/C hackers. d ___ Tutor maillist - Tutor@python.org To unsubscr

Re: [Tutor] Recommendation For A Complete Noob

2014-02-09 Thread spir
On 02/09/2014 11:37 PM, Altrius wrote: Hi, I’m completely new to programming in general and everything I have read so far has pointed me to Python. I’ll put this another way: All I know is that a programming language is a medium for a human to tell a computer what to do. After that I’m kinda

Re: [Tutor] trace / profile function calls with inputs

2014-02-10 Thread spir
On 02/08/2014 05:36 PM, Richard Cziva wrote: Hi All, I am trying to print out every function that is being called while my Python program is running (own functions and library calls too). I can not modify the Python programs I am trying to profile. Let me give an example. A program contains a f

Re: [Tutor] Better flow for this?

2014-02-12 Thread spir
On 02/12/2014 03:06 AM, R. Alan Monroe wrote: I started on an implementation of a solitaire board game simulating a B52 bombing run ( http://victorypointgames.com/details.php?prodId=119 ). It seems like there ought to be a better way to structure this program flow, but it's escaping me at the mom

Re: [Tutor] Better flow for this?

2014-02-12 Thread spir
On 02/12/2014 10:51 AM, spir wrote: On 02/12/2014 03:06 AM, R. Alan Monroe wrote: I started on an implementation of a solitaire board game simulating a B52 bombing run ( http://victorypointgames.com/details.php?prodId=119 ). It seems like there ought to be a better way to structure this program

Re: [Tutor] Beginner - explaining 'Flip a coin' bug

2014-02-12 Thread spir
On 02/12/2014 10:14 PM, Steven D'Aprano wrote: On Wed, Feb 12, 2014 at 03:25:22PM +, Marc Eymard wrote: I want to emulate a coin flip and count how many heads and tails when flipping it a hundred times. In my last reply, I said I'd next give you some pointers to improve the code. If you'

Re: [Tutor] Performing an union of two files containing keywords

2014-02-17 Thread spir
On 02/17/2014 10:07 AM, Aaron Misquith wrote: I have 2 different text files. File1.txt contains: file RAMPython parser File2.txt contains: file1234 program I want to perform an union of these both files such that i get an output file3.txt which contains: file RAMPython parser1234 program

Re: [Tutor] constructing semi-arbitrary functions

2014-02-18 Thread spir
On 02/18/2014 12:02 AM, Oscar Benjamin wrote: On 17 February 2014 22:15, "André Walker-Loud " wrote: This particular case is easily solved: def f_lambda(x,pars): return lambda x: poly(x,*pars) You let the closure take care of pars and return a function that takes exactly one argument x.

Re: [Tutor] constructing semi-arbitrary functions

2014-02-18 Thread spir
On 02/17/2014 08:23 PM, "André Walker-Loud " wrote: Hello python tutors, I am utilizing a 3rd party numerical minimization routine. This routine requires an input function, which takes as arguments, only the variables with which to solve for. But I don’t want to define all possible input fun

Re: [Tutor] Regular expression - I

2014-02-18 Thread spir
On 02/18/2014 08:39 PM, Zachary Ware wrote: Hi Santosh, On Tue, Feb 18, 2014 at 9:52 AM, Santosh Kumar wrote: Hi All, If you notice the below example, case I is working as expected. Case I: In [41]: string = "test" In [42]: re.match('',string).group() Out[42]: '' But why is the raw string

Re: [Tutor] constructing semi-arbitrary functions

2014-02-20 Thread spir
On 02/20/2014 01:56 AM, "André Walker-Loud " wrote: On Feb 19, 2014, at 7:45 PM, André Walker-Loud wrote: OK - I have not seen an email from Peter. So I looked up the thread online, and see I did not receive half the emails on this thread :O My first inclination was to blame my mac mavericks

Re: [Tutor] I can't understand where python class methods come from

2014-02-24 Thread spir
On 02/23/2014 10:59 PM, voger wrote: I have a really hard time understanding where methods are defined in python classes. My first contact with programming was with C++ and Java and even if I was messing with them in a very amateurish level, I could find where each class was defined and what meth

Re: [Tutor] Class decorator on a derived class not initialising the base classes using super - TypeError

2014-02-24 Thread spir
On 02/24/2014 08:19 PM, Sangeeth Saravanaraj wrote: Sorry, I should have described what I was trying! I want to create a decorator which should do the following things: - When an object of the decorated class is created, the objects name (say the value of the incoming "id" argument) sho

Re: [Tutor] Why does the last loop not work?

2014-02-25 Thread spir
On 02/25/2014 01:59 AM, Gregg Martinson wrote: I am trying to generate a list of teams using objects that I collect into a list that I can cycle through. But when I run the last loop there is nothing produced. Look at your last line of code: x.print_team This is just the _name_ of the m

Re: [Tutor] Help with "Guess the number" script

2014-03-01 Thread spir
On 03/01/2014 07:46 AM, Scott W Dunning wrote: Hello, i am working on a project for learning python and I’m stuck. The directions are confusing me. Please keep in mind I’m very ne to this. The directions are long so I’ll just add the paragraphs I’m confused about and my code if someone coul

Re: [Tutor] Help with "Guess the number" script

2014-03-03 Thread spir
On 03/03/2014 05:03 AM, Scott W Dunning wrote: Ben Finney makes numerous fine comments already. I'll add a few, some on the same points but but expressed a bit differently (case it helps). This is what Im having trouble with now. Here are the directions I’m stuck on and what I have so far,

Re: [Tutor] Help with "Guess the number" script

2014-03-03 Thread spir
On 03/03/2014 11:27 AM, spir wrote: How would you define what these variables represent, using everyday language? My own definitions would lead me to choose the following variable names: guess_text = raw_input(promt) guess_number = int(user_guess) return guess_number sorry

Re: [Tutor] HTML Parser woes

2014-03-04 Thread spir
On 03/04/2014 05:38 PM, Alan Gauld wrote: On 04/03/14 16:31, Steven D'Aprano wrote: On Tue, Mar 04, 2014 at 04:26:01PM +, Alan Gauld wrote: My turn to ask a question. This has me pulling my hair out. Hopefully it's something obvious... [...] And the output looks like: start test Class Va

Re: [Tutor] How to determine which function code is being called from

2014-03-06 Thread spir
On 03/06/2014 06:00 PM, Jignesh Sutar wrote: Hi I'm trying to exclude a certain line of code if the function is called by another function, see illustration below: def funcA(): print "running from funcA" # print only if running from funcA print "running from funcA or funcB" #print whe

Re: [Tutor] Help with Guess the number script

2014-03-07 Thread spir
On 03/07/2014 06:30 AM, Scott W Dunning wrote: I am trying to write a script for class for a game called guess the number. I’m almost done but, I’m having a hard time getting the hints to print correctly. I’ve tried ‘if’’ ‘elif’ nested, it seems like everything….I’m posting my code for the h

Re: [Tutor] Help with Guess the number script

2014-03-08 Thread spir
On 03/08/2014 10:13 AM, Alan Gauld wrote: On 08/03/14 01:23, Scott W Dunning wrote: On Mar 7, 2014, at 11:02 AM, Alan Gauld wrote: GOT IT!! Finally! Thanks for all of your help!! This is what I got, not sure if it’s correct but it’s working! Well done. And now that you have the right set

Re: [Tutor] Help with Guess the number script

2014-03-11 Thread spir
On 03/11/2014 04:32 AM, Scott W Dunning wrote: On Mar 8, 2014, at 11:50 AM, Scott dunning wrote: And now that you have the right set of tests you can half the number of lines by combining your if conditions again, like you had in the original post. ie. Bring your hot/cold/warm tests together.

Re: [Tutor] Help with Guess the number script

2014-03-11 Thread spir
On 03/11/2014 09:57 AM, Alan Gauld wrote: On 11/03/14 04:07, Scott W Dunning wrote: On Mar 8, 2014, at 3:57 AM, spir mailto:denis.s...@gmail.com>> wrote: And now that you have the right set of tests you can half the number of lines by combining your if conditions again, like you had

Re: [Tutor] Help with Guess the number script

2014-03-11 Thread spir
On 03/11/2014 05:07 AM, Scott W Dunning wrote: On Mar 8, 2014, at 3:57 AM, spir wrote: Well done. And now that you have the right set of tests you can half the number of lines by combining your if conditions again, like you had in the original post. ie. Bring your hot/cold/warm tests together

Re: [Tutor] Help with Guess the number script

2014-03-12 Thread spir
On 03/12/2014 05:13 AM, Scott Dunning wrote: >> if guess < secret - 10 or guess > secret - 10: > >This is the right idea for cutting the line count but you >have the comparison values wrong. Look back to earlier >emails, you are repeating the same error as before. >Manually think through wha

Re: [Tutor] Loop Issue

2014-03-13 Thread spir
On 03/13/2014 12:40 AM, Danny Yoo wrote: The context is the beginning of the thread: https://mail.python.org/pipermail/tutor/2014-March/100543.html with the loop: ### while health != 0: ... ### The point, and reason why this loop was (potentially) infinite, is that the condition

Re: [Tutor] Project suggestions

2014-03-13 Thread spir
On 03/13/2014 03:29 AM, Scott W Dunning wrote: Hey Everyone, I just got through doing a Guess-the-number script and was looking for something else to practice on. Do any of you have any suggestions on some things I could work on? Keep in mind I am not only extremely new to python I am new t

Re: [Tutor] Project suggestions

2014-03-13 Thread spir
On 03/13/2014 07:17 AM, Ben Finney wrote: Scott W Dunning writes: I just got through doing a Guess-the-number script and was looking for something else to practice on. Do any of you have any suggestions on some things I could work on? Keep in mind I am not only extremely new to python I am new

Re: [Tutor] Project suggestions

2014-03-13 Thread spir
On 03/13/2014 03:29 AM, Scott W Dunning wrote: Hey Everyone, I just got through doing a Guess-the-number script and was looking for something else to practice on. Do any of you have any suggestions on some things I could work on? Keep in mind I am not only extremely new to python I am new t

Re: [Tutor] Loop Issue

2014-03-14 Thread spir
On 03/13/2014 04:42 PM, Dave Angel wrote: spir Wrote in message: On 03/13/2014 12:40 AM, Danny Yoo wrote: The context is the beginning of the thread: https://mail.python.org/pipermail/tutor/2014-March/100543.html with the loop: ### while health != 0: ... ### The point, and

Re: [Tutor] Multiple for and if/else statements into a single list comprehension

2014-03-17 Thread spir
On 03/17/2014 11:22 AM, Jignesh Sutar wrote: Is it possible to get two nested for statements followed by a nested if/else statement all into a single list comprehension ie. the equivalent of the below: for i in xrange(1,20): for j in xrange(1,10): if j<6: j=int("8"+st

Re: [Tutor] (no subject)

2014-03-22 Thread spir
On 03/21/2014 09:57 PM, Jerry Hill wrote: On Fri, Mar 21, 2014 at 3:25 PM, Gary Engstrom wrote: I am trying to understand function fibc code line a,b = b, a + b and would like to see it written line by line without combining multiply assignment. If possible. I sort of follow the right to left e

Re: [Tutor] Understanding code line

2014-03-22 Thread spir
On 03/21/2014 06:14 PM, Gary wrote: Pythonists I am trying to understand the difference between a = b b = a + b and a,b = b, a+ b When used in my Fibonacci code the former generates 0,1,2,4,8,16,32 and the later Generates 0,1,1,2,3,5,8,13,21,34,55,89. The second is the sequence I want, bu

Re: [Tutor] Fib sequence code assignment

2014-03-22 Thread spir
On 03/21/2014 10:21 PM, Gary wrote: Dear Jerry, Thank you so much, once you see it it seems so clear, but to see it I might as well be in the Indian Ocean. Got kinda close using temporary variable,but didn't know enough to use del. A lesson learn. You don't need del (here). Every variable i

Re: [Tutor] please help

2014-03-22 Thread spir
On 03/21/2014 10:39 PM, Cameron Simpson wrote: On 21Mar2014 20:31, Mustafa Musameh wrote: Please help. I have been search the internet to understand how to write a simple program/script with python, and I did not do anything. I have a file that look like this ID 1 agtcgtacgt… ID 2 aaaa

Re: [Tutor] character counting

2014-03-23 Thread spir
On 03/23/2014 07:28 AM, Mustafa Musameh wrote: Hi; I have a file that looks like this: title 1 AAATTTGGGCCCATA... TTAACAAGTTAAAT… title 2 AAATTTAAACCC… ATATATATA… … I wrote the following to count the As, Cs, Gs anTs for each title I wrote the following import sys file = open('file.fna'

Re: [Tutor] 2 Very basic queries

2014-03-26 Thread spir
On 03/26/2014 02:32 AM, Jim Byrnes wrote: 2. Another problem is that the Python shell is allowing me to copy/paste any code at all. Is there something I am not doing right? I was able to copy from idle using Ctrl-C and paste to my newreader using Ctrl-V and then copy from my newsreader back to

Re: [Tutor] Help Noob Question

2014-03-28 Thread spir
On 03/28/2014 02:17 AM, Alan Gauld wrote: On 27/03/14 21:01, Chris “Kwpolska” Warrick wrote: On Mar 27, 2014 8:58 PM, "Alan Gauld" mailto:alan.ga...@btinternet.com>> wrote: > > On 27/03/14 06:43, Leo Nardo wrote: >> >> Im on windows 8 and i need to open a file called string1.py that is on >

Re: [Tutor] Slices of lists of lists

2014-03-28 Thread spir
On 03/28/2014 10:42 AM, Jose Amoreira wrote: [...] If we want to access individual rows of this matrix like object, the standard slice notation (on the second index) works as expected also: In [3]: l[0][:] Out[3]: [11, 12, 13] In [4]: l[1][:] Out[4]: [21, 22, 23] Again, fine! No! You *made

Re: [Tutor] conditional execution

2014-04-02 Thread spir
On 04/01/2014 06:24 PM, Zachary Ware wrote: Hi Patti, On Tue, Apr 1, 2014 at 11:07 AM, Patti Scott wrote: I've been cheating: comment out the conditional statement and adjust the indents. But, how do I make my program run with if __name__ == 'main': main() at the end? I thought I understood

Re: [Tutor] One on one tutor

2014-04-06 Thread spir
On 04/05/2014 01:49 AM, Keith Adu wrote: Hi my name is Keith, am a beginner with no experience in python or computer science. Am looking for someone to work with me one on one, I have many question that I need answered, my question are basic as of the moment because am starting, I don't wan

Re: [Tutor] Question about equality of sets

2014-04-06 Thread spir
On 04/05/2014 07:46 PM, Jim Byrnes wrote: Ubuntu 12.04 python 3.3 I was working through an exercise about sets. I needed to find the duplicates in a list and put them in a set. I figured the solution had to do with sets not supporting duplicates. I finally figured it out but along the way I wa

Re: [Tutor] Python help please

2010-03-23 Thread spir
On Mon, 22 Mar 2010 22:31:58 + laura castañeda wrote: > > Hi my name is Laura and im currently trying to solve one of the > challenges in the book: "Python Programming, second edition" by Michael > Dawson... I'm stuck in the 5 chapter because of this challenge, im the > kinda person who dont

[Tutor] func headline & module inspect

2010-03-23 Thread spir
Hello, I was looking for a way to get info about func definition, esp. its param list. The aim beeing to reproduce more or less its header line. Found useful hints at http://stackoverflow.com/questions/582056/getting-list-of-parameters-inside-python-function. Example: =

[Tutor] a bug I cannot solve myself ;-)

2010-03-25 Thread spir
, key if sign == "ATTR":# sign == ATTR='.' print "getAttr" data = data.getAttr(key) else: # sign == ITEM='#' print "getItem" data = data.getItem(key)

[Tutor] inter-module global variable

2010-03-28 Thread spir
Hello, I have a main module importing other modules and defining a top-level variable, call it 'w' [1]. I naively thought that the code from an imported module, when called from main, would know about w, but I have name errors. The initial trial looks as follows (this is just a sketch, the orig

Re: [Tutor] Introduction to modelling with Python

2010-03-28 Thread spir
On Sun, 28 Mar 2010 10:26:43 +0100 AG wrote: > Modulok wrote: > > Could you further define 'modeling' in context? [...] > The modelling I was referring to is not about 3-D design, but about > scenario modelling. For example, to understand the impacts of climate > change on particular bodies o

Re: [Tutor] inter-module global variable

2010-03-28 Thread spir
On Sun, 28 Mar 2010 21:50:46 +1100 Steven D'Aprano wrote: > On Sun, 28 Mar 2010 08:31:57 pm spir ☣ wrote: > > Hello, > > > > I have a main module importing other modules and defining a top-level > > variable, call it 'w' [1]. I naively thought that

Re: [Tutor] Script Feedback

2010-03-30 Thread spir
On Tue, 30 Mar 2010 10:27:43 -0400 Damon Timm wrote: > As a self-taught Python user I am still looking for insight on the > most pythonic and programmatically-friendly way of accomplishing a > given task. In this case, I have written a script that will perform a > “clean bzip2″ of a directory (or

Re: [Tutor] Sequences of letter

2010-04-12 Thread spir
On Mon, 12 Apr 2010 00:12:59 -0500 Juan Jose Del Toro wrote: > Dear List; > > I have embarked myself into learning Python, I have no programming > background other than some Shell scripts and modifying some programs in > Basic and PHP, but now I want to be able to program. > > I have been readi

[Tutor] "value" ~ "data" ~ "object"

2010-04-15 Thread spir
Hello, I have been recently thinking at lexical distinctions around the notion of data. (--> eg for a starting point http://c2.com/cgi/wiki?WhatIsData) Not only but especially in Python. I ended up with the following questions: Can one state "in Python value=data=object"? Can one state "in Pytho

Re: [Tutor] Creating class instances through iteration

2010-04-15 Thread spir
On Thu, 15 Apr 2010 21:03:52 -0500 Tim Goddard wrote: > I came across a situation where what I thought I wanted to do was to create > a class that was spawned from data in a .csv file. Where column 1 was the > name I wanted to use for each instance. I had it all figured out and > working except

Re: [Tutor] How to map different keys together ?

2010-04-18 Thread spir
On Sat, 17 Apr 2010 11:57:28 -0400 Damon Timm wrote: > Hello - I am writing a script that converts an entire music library > into a single desired output format. The source music library has a > variety of music filetypes (flac, mp3, m4a, ogg, etc) and I am > attempting to use mutagen (a music f

Re: [Tutor] How to map different keys together ?

2010-04-18 Thread spir
On Sun, 18 Apr 2010 13:42:46 -0400 Damon Timm wrote: > Hi Alan, et al - thanks for your response and your ideas. I sat down > and did a little more coding so that I might tackle what I can and > bring back where I am having trouble. I have implemented the basic > 'tag_map' you suggested without

Re: [Tutor] List index usage: is there a more pythonesque way?

2010-04-19 Thread spir
On Mon, 19 Apr 2010 00:37:11 +0100 C M Caine wrote: > That's two new things I've learnt. I didn't realise that for loops > could be used like that (with more than one... key?). Consider considering things differently: a for loop always iterates over items of a collection you indicate: l = [1,2

Re: [Tutor] the binary math "wall"

2010-04-20 Thread spir
On Tue, 20 Apr 2010 09:58:06 -0700 (PDT) Lowell Tackett wrote: > I'm running headlong into the dilemma of binary math representation, with > game-ending consequences, e.g.: > > >>> 0.15 > 0.14999 > [...] > The last line should be zero, and needs to be for me to continue this > algo

Re: [Tutor] the binary math "wall"

2010-04-20 Thread spir
On Tue, 20 Apr 2010 14:45:50 -0400 Dave Angel wrote: > If all values are made up of degrees/minutes/seconds, and seconds is a > whole number, then store values as num-seconds, and do all arithmetic on > those values. Only convert them back to deg/min/sec upon output. This seems the most dire

Re: [Tutor] the binary math "wall"

2010-04-21 Thread spir
On Tue, 20 Apr 2010 19:11:24 -0700 (PDT) Lowell Tackett wrote: > > >>> round(18.15*100) == 1815 > > True > > Interestingly, this is the [above] result when I tried entered the same > snippet: > > Python 2.5.1 (r251:54863, Oct 14 2007, 12:51:35) > [GCC 3.4.1 (Mandrakelinux 10.1 3.4.1-4mdk)]

Re: [Tutor] Modify inherited methods

2010-04-28 Thread spir
On Wed, 28 Apr 2010 07:53:06 +0100 Walter Wefft wrote: > Steven D'Aprano wrote: > > And for guru-level mastery, replace to call to dict.__init__ with ... > nothing at all, because dict.__init__ doesn't do anything. > > > > > > > > (Sorry, should have sent to list). > > I don't understand t

Re: [Tutor] Any

2010-04-29 Thread spir
On Thu, 29 Apr 2010 13:04:20 +0100 "Alan Gauld" wrote: > IDLE? > The IDE that comes with Python ias wtten in Python and the > source comes as part of the standard library. There's also a free software programming editor --editra, I guess-- written in and mainly for python. (But I would not re

[Tutor] python list, right! but concretely?

2010-05-01 Thread spir
Hello, Is there anywhere some introduction material to the implementation of python lists (or to fully dynamic and flexible sequences, in general)? More precisely, I'd like to know what kind of base data-structure is used (linked list, dynamic array, something else -- and in case of array, how i

Re: [Tutor] python list, right! but concretely?

2010-05-02 Thread spir
On Sun, 02 May 2010 19:44:22 +1000 Lie Ryan wrote: > On 05/02/10 15:49, spir ☣ wrote: > > Hello, > > > > Is there anywhere some introduction material to the implementation of > > python lists > > (or to fully dynamic and flexible sequences, in general)? >

Re: [Tutor] python list, right! but concretely?

2010-05-02 Thread spir
On Sun, 2 May 2010 18:57:41 +1000 Steven D'Aprano wrote: > On Sun, 2 May 2010 03:49:02 pm spir ☣ wrote: > > Hello, > > > > Is there anywhere some introduction material to the implementation of > > python lists (or to fully dynamic and flexible sequences, in > &

<    1   2   3   4   5   6   7   >