[Tutor] help with program from learning python the hard way
good day i seem to be stuck, my code is from sys import argv script, user_name = argv and i get an error ValueError: need more than 1 value to unpack http://learnpythonthehardway.org/book/ex14.html i am using PyCharm 1.5.4 to run thanks in advance jason ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] help with program from learning python the hard way
On Thu, Jan 19, 2012 at 6:32 PM, Jason Loeve jasonlo...@gmail.com wrote: good day i seem to be stuck, my code is from sys import argv script, user_name = argv Are you passing an additional parameter while executing the script ?? you must execute it passing an additional parameter which will get assigned to user_name and i get an error ValueError: need more than 1 value to unpack http://learnpythonthehardway.org/book/ex14.html i am using PyCharm 1.5.4 to run thanks in advance jason ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor -- Vishwajeet Singh +91-9657702154 | dextrou...@gmail.com | http://bootstraptoday.com Twitter: http://twitter.com/vishwajeets | LinkedIn: http://www.linkedin.com/in/singhvishwajeet ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] help with program from learning python the hard way
If I say that sys.argv is a list, does that help you? Also, run things from a command prompt for this kind of thing, at least then you can guarantee what args get passed Bodsda Sent from my BlackBerry® wireless device -Original Message- From: Jason Loeve jasonlo...@gmail.com Sender: tutor-bounces+bodsda=googlemail@python.org Date: Thu, 19 Jan 2012 15:02:41 To: tutor@python.org Subject: [Tutor] help with program from learning python the hard way ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] help with program from learning python the hard way
Hi Jason, On 19 January 2012 13:02, Jason Loeve jasonlo...@gmail.com wrote: good day i seem to be stuck, my code is from sys import argv script, user_name = argv and i get an error ValueError: need more than 1 value to unpack The implication of this message is that the value of argv contains only one value, which would be true if the script was run with no command line parameters. http://learnpythonthehardway.org/book/ex14.html i am using PyCharm 1.5.4 to run I'm not familiar with PyCharm but by default IDE's obviously would not be passing any command line parameters to programs they run. Most IDE's have some way of specifying the command line parameters to pass the script, but I can't tell you how to do this in PyCharm, so if you insist on running from PyCharm you'll have to find out how to do that on your own. I however suggest tha you instead use PyCharm purely as an editor, and follow the instructions in the Excercise which is to run the script from the command prompt, with the parameters as shown in the excercise. Then you should have not have this problem and you should be able to follow what the book is doing more closely. Additionally I suggest you go back to the previous section, Excecise 13 on Parameters, Unpacking, Variables since I get the sense from your question that you may not have completed this section properly or may have glossed over it, since if you had successfully completed this then you should not have had the above problem in the first place. Cheers Walter ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Question about install.py
Hi, I'm new to Python and was wondering if someone could answer a question I have. Say that I have a python library, arithmetic-0.5, located at /X/arithmetic-0.5 I'd like to run setup and install it. But I guess since /X/arithmetic-0.5 is not in install.py's default search path, it comes back with an error saying that it cannot find the necessary files. Can you please tell me how I can change the search path of install.py? What parameter do I need to modify? I don't know about install.py. Perhaps you can give a pointer to that (eg, a webpage)? As far as I my knowledge goes, you install libraries (modules) using setup.py. In that case, a command like $ python setup.py install should do it. That assumes you're working from the command line. Python will automatically install the library in a place where it can find it. See also http://docs.python.org/install/index.html It can be easier to use a binary installer though, especially if you're not used to working on command lines. If you're just trying to install a Python library, it can help if you mention which library you want to install, what you are using for the installation (source code, or installer), which python version and on which OS you are working. Also, you mention an error, but don't specify it. Python usually comes with a whole backtrace, which you can copy-paste into your email. Cheers, Evert Thanks in advance. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] appending to a file on a new line
Hi everyone, is there an easy way to write to a file (that already exists with data contained) on a new line. I understand that the file pointer appends where it left off but how do i write to the next line or even skip a line if possible? User_info=open(C:\\Documents and Settings\\akelly\\Desktop\\details.txt,'a') User_info.write(\n.join(Details)) all the best, Adrian___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] appending to a file on a new line
On Thu, Jan 19, 2012 at 9:32 AM, ADRIAN KELLY kellyadr...@hotmail.com wrote: Hi everyone, is there an easy way to write to a file (that already exists with data contained) on a new line. I understand that the file pointer appends where it left off but how do i write to the next line or even skip a line if possible? User_info=open(C:\\Documents and Settings\\akelly\\Desktop\\details.txt,'a') User_info.write(\n.join(Details)) all the best, Adrian ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor What you wrote looks fine. When you open a file to append, it does just that with the write method. You can learn more here http://docs.python.org/tutorial/inputoutput.html#methods-of-file-objects When you run your code what happens? -- Joel Goldstick ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] appending to a file on a new line
On 01/19/2012 09:32 AM, ADRIAN KELLY wrote: Hi everyone, is there an easy way to write to a file (that already exists with data contained) on a new line. I understand that the file pointer appends where it left off but how do i write to the next line or even skip a line if possible? User_info=open(C:\\Documents and Settings\\akelly\\Desktop\\details.txt,'a') User_info.write(\n.join(Details)) all the best, Adrian Presumably this is a text file. By convention, they end with a newline character. So your data should follow that, and appear on a separate line. If the file is broken, you can start your data with a \n, just in case. Or you could do a separate test, to decide if you need it. If you want a (an extra) blank line between, simply start your data with a \n . You can also do this as a separate user_info.write(\n) of course. -- DaveA ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] appending to a file on a new line
guys, its a text file i am writing to and when i write the first time its fine, i get 3 lines of input collected from a user and written to my text file, however if i run the program again the next 3 lines begin at the end of the previous users details. It works fine but starts from where the pointer left off. i dont know how to solve this. where do i put the '\n'? to be honest the .join i dont understand but otherwise it prints as a list e.g. ('name','age','etc') Adrian Date: Thu, 19 Jan 2012 09:42:45 -0500 Subject: Re: [Tutor] appending to a file on a new line From: joel.goldst...@gmail.com To: kellyadr...@hotmail.com CC: tutor@python.org On Thu, Jan 19, 2012 at 9:32 AM, ADRIAN KELLY kellyadr...@hotmail.com wrote: Hi everyone, is there an easy way to write to a file (that already exists with data contained) on a new line. I understand that the file pointer appends where it left off but how do i write to the next line or even skip a line if possible? User_info=open(C:\\Documents and Settings\\akelly\\Desktop\\details.txt,'a') User_info.write(\n.join(Details)) all the best, Adrian ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor What you wrote looks fine. When you open a file to append, it does just that with the write method. You can learn more here http://docs.python.org/tutorial/inputoutput.html#methods-of-file-objects When you run your code what happens? -- Joel Goldstick ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] appending to a file on a new line
On 01/19/2012 10:04 AM, ADRIAN KELLY wrote: guys, its a text file i am writing to and when i write the first time its fine, i get 3 lines of input collected from a user and written to my text file, however if i run the program again the next 3 lines begin at the end of the previous users details. It works fine but starts from where the pointer left off. i dont know how to solve this. where do i put the '\n'? to be honest the .join i dont understand but otherwise it prints as a list e.g. ('name','age','etc') Adrian You top-posted. Please put your response *after* what you're quoting. Anyway, since you're the one writing the original file, the problem is, as I said, the file is broken. You don't write a trailing newline. So the simplest fix is to add another write() call. User_info.write(\n.join(Details)) User_info.write(\n) The join command puts the specified text *between* the list elements, but not after the last one. -- DaveA ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Facebook apps with python
On Wed, Jan 18, 2012 at 8:34 AM, karthik s sur...@live.com wrote: Well, my question is simple.. How do I create facebook apps with python. I have couple of interesting/ funky programs and want to make them as apps. So, 1. What all things I should know for writing facebook apps. 2. I read that we should first upload our app to 'google app engine' and need do link it to facebook.. Is that right? 3. Actually, I am not aware of Network/ Web programming.. can I be able to do that? 4. Please do mention a couple of books (ebooks) from which I can learn.. That will help me. I don't know if this will help, but the Facebook Graph API allows you do neat things. https://developers.facebook.com/docs/reference/api/ Here's something small I wrote a little while ago that just grabs all your friends profile photos and saves them with their name as the filename. Not necessarily anything useful, but a small example of what you can do with it. #!/usr/bin/env python import os import httplib import json from urllib import urlretrieve server = 'graph.facebook.com' myID = 'username' accessToken = 'this is the token' URL = /usernam/friends?access_token= + accessToken def getfriends(): conn = httplib.HTTPSConnection(server) conn.request(GET, URL) response = conn.getresponse() data = response.read() list = json.loads(data)['data'] IDs = [(friends['id'], friends['name']) for friends in list] return IDs def getphotos(): if not os.path.exists(photos): os.makedirs(photos) for id, name in getfriends(): url = https://graph.facebook.com/; + id + /picture filename = os.path.join(photos, %s.jpg % (name)) urlretrieve(url, filename) def main(): getphotos() if __name__ == '__main__': main() ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] finding a polymer of letters in a string
Hi: I am writing to see if I could any help. I am trying to find if a mutation in gene falls in a polymer region of DNA. To explain in simplistic terms, Given a piece of DNA string, with following characters, I know where mutation happens. Happens at T (in quotes with spaces.) 3 As before T and 4 As after T are removed in a disease. Given following sequence, I should be able to find if this T is in a polymer region. such as 'AAA' T '. AAATAGCAGAAA 'T' GGATTGGAACTAGGTCAG I am not sure if there are any methods in python to find these. Do you think a script has to be written with more logic involving some known algorithms. Please advise. thanks Hs. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] finding a polymer of letters in a string
Hi ! Have you considered regular expressions in Python ? Please take a look at Regular Expression HOWTO, at http://docs.python.org/howto/regex.html All the best, Hilton On Thu, Jan 19, 2012 at 4:09 PM, Hs Hs ilhs...@yahoo.com wrote: Hi: I am writing to see if I could any help. I am trying to find if a mutation in gene falls in a polymer region of DNA. To explain in simplistic terms, Given a piece of DNA string, with following characters, I know where mutation happens. Happens at T (in quotes with spaces.) 3 As before T and 4 As after T are removed in a disease. Given following sequence, I should be able to find if this T is in a polymer region. such as 'AAA' T '. AAATAGCAGAAA 'T' GGATTGGAACTAGGTCAG I am not sure if there are any methods in python to find these. Do you think a script has to be written with more logic involving some known algorithms. Please advise. thanks Hs. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor -- (11)8131-5213 ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] finding a polymer of letters in a string
Hi Hilton. Thanks for your suggestion. I saw re module. I should have explain a little bit in my message that patter of polymer is not constant. There could be variety of combinations given A, T G and C. it could be AAATAAA, ATATATAT, or GTAGTAGTA or GGGACCCGAAAT etc. so I do not know what that pattern would be when I read in a string. I do not know if regex could solve my kind of problem too. Thanks Hs. From: Hilton Fernandes hgfer...@gmail.com To: tutor@python.org tutor@python.org Cc: Hs Hs ilhs...@yahoo.com Sent: Thursday, January 19, 2012 1:39 PM Subject: Re: [Tutor] finding a polymer of letters in a string Hi ! Have you considered regular expressions in Python ? Please take a look at Regular Expression HOWTO, at http://docs.python.org/howto/regex.html All the best, Hilton On Thu, Jan 19, 2012 at 4:09 PM, Hs Hs ilhs...@yahoo.com wrote: Hi: I am writing to see if I could any help. I am trying to find if a mutation in gene falls in a polymer region of DNA. To explain in simplistic terms, Given a piece of DNA string, with following characters, I know where mutation happens. Happens at T (in quotes with spaces.) 3 As before T and 4 As after T are removed in a disease. Given following sequence, I should be able to find if this T is in a polymer region. such as 'AAA' T '. AAATAGCAGAAA 'T' GGATTGGAACTAGGTCAG I am not sure if there are any methods in python to find these. Do you think a script has to be written with more logic involving some known algorithms. Please advise. thanksHs. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor -- (11)8131-5213___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] finding a polymer of letters in a string
On Thu, Jan 19, 2012 at 1:44 PM, Hs Hs ilhs...@yahoo.com wrote: so I do not know what that pattern would be when I read in a string. I do not know if regex could solve my kind of problem too. Ignore the python portion of the problem for now. Imagine someone handed you a piece of paper with the letters AAATAGCAGAAATGGATTGGAACTAGGTCAG written on it, and asked you to circle the section that you're trying to identify. How would you do it, without using a computer? How do you figure out where there was a mutation, and then how do you discover if that location is in a polymer region? If you can describe that process to us, maybe we can help you turn that into a python program. -- Jerry ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] finding a polymer of letters in a string
Hi, The explanation you have given isn't good enough to get us anywhere. What are the possible patterns? Do you have a fixed number of As you're looking out for? What defines a polymer region? The different DNA samples, how are they separated? With commas, new lines etc? You can do a line by line explanation and we could get some people in here to help you get python codes to achieve what you just explained. Regards. Sent from my BlackBerry wireless device from MTN -Original Message- From: Hs Hs ilhs...@yahoo.com Sender: tutor-bounces+delegbede=dudupay@python.org Date: Thu, 19 Jan 2012 10:09:27 To: tutor@python.orgtutor@python.org Reply-To: Hs Hs ilhs...@yahoo.com Subject: [Tutor] finding a polymer of letters in a string ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Detail your problem, privately (was Re: finding a polymer of letters in a string)
Hi, Hs ! I believe that in this list there are people that know a lot about either regular expressions in Python, or about DNA strings. They will be able to give you qualified help about what you are asking, since you provide them enough data. In any case, you can write to me privately if you'd like to teach this General Purpose programmer about DNA strings, i'd happy to learn about them, as well to think about regular expressions in this context. Maybe the two of us can think about an interesting solution for your problem. All the best, Hilton On Thu, Jan 19, 2012 at 4:44 PM, Hs Hs ilhs...@yahoo.com wrote: Hi Hilton. Thanks for your suggestion. I saw re module. I should have explain a little bit in my message that patter of polymer is not constant. There could be variety of combinations given A, T G and C. it could be AAATAAA, ATATATAT, or GTAGTAGTA or GGGACCCGAAAT etc. so I do not know what that pattern would be when I read in a string. I do not know if regex could solve my kind of problem too. Thanks Hs. -- *From:* Hilton Fernandes hgfer...@gmail.com *To:* tutor@python.org tutor@python.org *Cc:* Hs Hs ilhs...@yahoo.com *Sent:* Thursday, January 19, 2012 1:39 PM *Subject:* Re: [Tutor] finding a polymer of letters in a string Hi ! Have you considered regular expressions in Python ? Please take a look at Regular Expression HOWTO, at http://docs.python.org/howto/regex.html All the best, Hilton On Thu, Jan 19, 2012 at 4:09 PM, Hs Hs ilhs...@yahoo.com wrote: Hi: I am writing to see if I could any help. I am trying to find if a mutation in gene falls in a polymer region of DNA. To explain in simplistic terms, Given a piece of DNA string, with following characters, I know where mutation happens. Happens at T (in quotes with spaces.) 3 As before T and 4 As after T are removed in a disease. Given following sequence, I should be able to find if this T is in a polymer region. such as 'AAA' T '. AAATAGCAGAAA 'T' GGATTGGAACTAGGTCAG I am not sure if there are any methods in python to find these. Do you think a script has to be written with more logic involving some known algorithms. Please advise. thanks Hs. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor -- (11)8131-5213 -- (11)8131-5213 ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor