[Tutor] Help installing Python3 in a particular folder
Hi there, I am doing this: cd /temp wget -c http://www.python.org/ftp/python/3.3.2/Python-3.3.2.tar.xz tar xvf Python-3.3.2.tar.xz cd Python-3.3.2 ./configure --prefix=/sw/arch make make test make install Then, when I try: /sw/arch/bin/python3 Traceback (most recent call last): File /sw/arch/lib/python3.3/site.py, line 69, in module import os File /sw/arch/lib/python3.3/os.py, line 659, in module from collections.abc import MutableMapping File /sw/arch/lib/python3.3/collections/__init__.py, line 12, in module from keyword import iskeyword as _iskeyword ImportError: No module named 'keyword' But if I do: export PYTHONPATH=/temp/Python-3.3.2/Lib then python3 will work. However, this does seems correct for me. I shouldn't depend on the installation folder (which I want to delete btw). I compared /sw/arch/lib/python3.3/ X /temp/Python-3.3.2/Lib and found this files missing: Only in /temp/Python-3.3.2/Lib: base64.py Only in /temp/Python-3.3.2/Lib: cgi.py Only in /temp/Python-3.3.2/Lib: cProfile.py Only in /temp/Python-3.3.2/Lib: keyword.py Only in /temp/Python-3.3.2/Lib: msilib Only in /temp/Python-3.3.2/Lib: pdb.py Only in /temp/Python-3.3.2/Lib: plat-aix4 Only in /temp/Python-3.3.2/Lib: plat-darwin Only in /temp/Python-3.3.2/Lib: platform.py Only in /temp/Python-3.3.2/Lib: plat-freebsd4 Only in /temp/Python-3.3.2/Lib: plat-freebsd5 Only in /temp/Python-3.3.2/Lib: plat-freebsd6 Only in /temp/Python-3.3.2/Lib: plat-freebsd7 Only in /temp/Python-3.3.2/Lib: plat-freebsd8 Only in /temp/Python-3.3.2/Lib: plat-generic Only in /temp/Python-3.3.2/Lib: plat-netbsd1 Only in /temp/Python-3.3.2/Lib: plat-next3 Only in /temp/Python-3.3.2/Lib: plat-os2emx Only in /temp/Python-3.3.2/Lib: plat-sunos5 Only in /temp/Python-3.3.2/Lib: plat-unixware7 Only in /temp/Python-3.3.2/Lib: profile.py Only in /temp/Python-3.3.2/Lib: pydoc.py Only in /temp/Python-3.3.2/Lib: quopri.py Only in /temp/Python-3.3.2/Lib: smtpd.py Only in /temp/Python-3.3.2/Lib: symbol.py Only in /temp/Python-3.3.2/Lib: tabnanny.py Only in /temp/Python-3.3.2/Lib: token.py Only in /temp/Python-3.3.2/Lib: uu.py During make install I noticed this: /sw/arch/lib/python3.3 already exist, returning without doing anything arguments where -c ./Lib/keyword.py /sw/arch/lib/python3.3 /sw/arch/bin/install -c ./Lib/keyword.py /sw/arch/lib/python3.3 So, apparently keyword.py should have been copied into /sw/arch/lib/python3.3 but it's really not happening. What am I doing wrong here? Thanks, Alan -- Alan Wilter SOUSA da SILVA, DSc Bioinformatician, UniProt - PANDA, EMBL-EBI CB10 1SD, Hinxton, Cambridge, UK +44 1223 49 4588 ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Problems understanding code output
I'm not really sure what you are asking, but the formatting for your code is pretty screwy. I reformatted it and changed the print statements slightly to make it more readable and it works fine from what I can see. def printMax(a, b): if a b: print a, 'is maximum' elif a == b: print a, 'is equal to', b else: print b, 'is maximum' printMax(3,4) On Wed, Jul 10, 2013 at 5:05 PM, s...@luo.to wrote: def printMax(a, b): if a b: print(a, 'is maximum') elif a == b: print(a, 'is equal to', b) else: print(b, 'is maximum') printMax(3, 4) # directly give literal values x = 5 y = 7 printMax(x, y) # give variables as arguments How the code above values to: 4 is maximum 7 is maximum and not to: 5 is maximum 7 is maximum This is going a little over my head, please advice, what am I missing in here? ___ 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] Cannot understand what this means
Hello All, I have just started out with python and was feeling pretty comfortable and confident to the point of solving problems from websites. But now, there is a program from Google's Python Exercises whose main() part is already given to you. def main(): # This command-line parsing code is provided. # Make a list of command line arguments, omitting the [0] element # which is the script itself. args = sys.argv[1:] if not args: print 'usage: [--summaryfile] file [file ...]' sys.exit(1) # Notice the summary flag and remove it from args if it is present. summary = False if args[0] == '--summaryfile': summary = True del args[0] The problem is one where you have to define a function to read a html file containing the 1000 most popular baby names of a particular year(separate files for different years) and print each name in alphabetical order with their corresponding rank for that year. My problem is that I cannot understand anything in this main() module. Nothing at all. So can somebody please explain what this means and what is its significance? Thank You ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Interpret the contents of a line
Hi, I am working on a parser and my input file is a description about bunch of things written line by line. So for instance, consider the following two lines and what the corresponding variables in python should look like. example Line1: position = 1, 1, rotation = 90, 0, 0, mass = 120; Here I want the variables to be position = [1,1,0], rotation = [90,0,0], mass = [120] example Line2: position = 1, 1, 2, mass = 120, rotation = 90, 0; Here I want the variables to be position = [1,1,2], rotation = [90,0,0], mass = [120] example Line3: mass = 120, rotation = 90, 0; Here I want the variables to be position = [0,0,0], rotation = [90,0,0], mass = [120] I know the maximum number of arguments possible for each variable. For example, in the first line above, only two numbers for position ares specified; that means that the third entry in position list is zero. So I need to handle these cases while reading in the file as well. Additionally, the text might not always be in the same order; like shown in the second line above. And finally, sometimes numbers for one variable might not exist at all; like shown in line 3. Here, the position is then read as position = [0,0,0]. How do I implement such stuff? Is there some smart way of doing this? All I have in mind is this: read a line as comma or a space delimited list of words variable and then some how use if else + len(list) to figure out whats going on. But that seems way too tedious and I feel that there might be an easier way to read such things. Any help is highly appreciated. Thank you ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] A list of 100+ projects to complete to master Python.
First thing you should learn is offsite backups, I've lost several projects in the works because of a hd mishap. Secondarily, I would recommend using existing primarily used python projects to 'reinvent the wheel' so to speak. Thirdly, make sure the code is properly documented, and serves a purpose. And lastly, utilize other programs with python api's, such as blender, which can make your apps pop, or diversify into game development kits. On Tue, Jul 16, 2013 at 1:09 PM, Karan Goel karanma...@gmail.com wrote: Hey guys and gals Just a plug here. My repo: https://github.com/thekarangoel/Projects was one of the trending repos on Gh this week and I thought folks on this list might be interested in knowing about it. In a nutshell, I'm trying to complete over a 100 practical language- agnostic projects in Python only. I haven't read the project details yet, and I'm not filtering things out. If you would like to do the same, join me. Fork or star the repo, and start coding (in any language, really). https://github.com/thekarangoel/Projects Let me know if you have any questions or suggestions. - Karan Goel Goel.im http://www.goel.im/ | Resumehttp://www.goel.im/Karan.Goel.Resume.pdf | Github https://github.com/thekarangoel ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor -- Best Regards, David Hutto *CEO:* *http://www.hitwebdevelopment.com* ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Timestamp issues when importing from FireFox sqlite field
All- Newb here so apologies upfront. Attempting timestamp translation via python importing info from sqlite datetime item in firefox ,'1369751000393000'. Typical unix date time translation fails. I noted micro second addition but even '1369751000393000' / 1e6 does not get a chew-able range, at least in python datetime module. Any suggestions? Best regards, Paul Failing code examples: import datetime print datetime.datetime.fromtimestamp(int(1369751000393000)).strftime('%Y-%m-%d %H:%M:%S') Traceback (most recent call last): File pyshell#11, line 1, in module print datetime.datetime.fromtimestamp(int(1369751000393000)).strftime('%Y-%m-%d %H:%M:%S') ValueError: timestamp out of range for platform localtime()/gmtime() function microseconds /1e6? import datetime print datetime.datetime.fromtimestamp(int(1369751000393000/1e6)).strftime('%Y-%m-%d %H:%M:%S') Traceback (most recent call last): File pyshell#18, line 1, in module print datetime.datetime.fromtimestamp(int(1369751000393000/1e6)).strftime('%Y-%m-%d %H:%M:%S') ValueError: invalid literal for int() with base 10: '1369751000393000/1e6' ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Python noob
Hi :) I am a programming noob, but i dont consider myself as complete noob cause i did some C programming and i do have basic knowledge how programming works. Problem is that i did C programming 4 years ago when i was in high school. Now i study computer science and i was thinking to get some programming experience before i leave college. I live in screwed up country, named Croatia and i cant get any job/experience/quick start unless i am guru at it. And i am not a guru. I do have interest in learning Python and i got myself a book programming in python 4th edition and i plan to learn from it during summer holidays. My question is, can you recommend me some learning materials? Or any kind of advice for me? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] New to programing and the tutoring system
Hello I am very very new to programing entirely, I have this book I am following, and I made a word jumbling game, it chooses a word from random from a turple I made, then scrambles the word and asks you to guess it, it is very simple but for some reason it only works when it's in idle. Here is the script. import random WORDS=(python,jumble,easy,difficult,answer,xylophone) word=random.choice(WORDS) correct=word jumble= while word: position=random.randrange(len(word)) jumble+=word[position] word=word[:position]+word[(position+1):] print(Welcome to Word Jumble! Unscramble the letters to make a word. (Press the enter key at the prompt to quit.) ) print(The jumble is:,jumble) # Working as intened at this point guess=input(\nYour guess: ) while guess != correct and guess !=: print(Sorry, that's not it.) guess=input(Your guess: ) if guess==correct: print(That's it! You guessed it!\n) print(Thanks for playing.) input(\n\nPress the enter key to exit.) Also I am using the most recently updated version of python33. Thank you ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] install on windows
On 10/07/13 17:10, larry seibold wrote: this, as it must be the case with almost everyone, with similar issues with later windows releases. Here is what I found out. Even though I had administrator rights (my user was in the administrator group) on the windows XP machine, I was not the Administrator user. I've installed Python on many Windows boxes and never had to be Adminisatrator nor even in the Admin group. (I am usually a PowerUser though.) What I chose to try that worked, was to start a command shell with the runas administrator feature. From there I changed to the directory where the python msi was downloaded, and then ran the install program. from Start -- Search programs and files: runas /user:domain/adminusername msiexec /i msiname.msi And I've never had to do anything but double click the msi file and the installer has run just fine. All very odd. Glad you got it installed though. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] install on windows
On 11/07/13 06:46, larry seibold wrote: I am not sure what the problem is, but I responded to this thread in detail more than 12 hours ago, but have yet to see that response in the forum digest. Administrator rights and Adminstrator user were both required to install on windows XP. The problem of the delay was that it got caught in the moderation queue which I only clear out once or twice a week at most (its normally low volume apart from spam). Possibly you posted from a different address to the one you registered? -- Alan G Moderator. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Cannot understand what this means
On 15/07/13 09:53, #PATHANGI JANARDHANAN JATINSHRAVAN# wrote: websites. But now, there is a program from Google's Python Exercises whose main() part is already given to you. def main(): # This command-line parsing code is provided. # Make a list of command line arguments, omitting the [0] element # which is the script itself. args = sys.argv[1:] if not args: print 'usage: [--summaryfile] file [file ...]' sys.exit(1) # Notice the summary flag and remove it from args if it is present. summary = False if args[0] == '--summaryfile': summary = True del args[0] My problem is that I cannot understand anything in this main() module. Nothing at all. It sounds like you need a more basic tutorial then. Do you really not know what def main(): means? Hint: its a function not a module... And do you know what command line arguments are? Or what sys.argv represents? Do you understand sys.exit()? I assume 'print' is self explanatory? Does the 'if' test mean anything? If you really don't understand any of those things you need to find a more basic tutorial and work through it. (You might try the first part of mine, see below, as an example) If you do understand those constructs, then you understand quite a lot of main and need to ask a more specific question. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Selecting from list
hi list: In the following list, is there a simply way to find element less than 200 sandwiched between two numbers greater than 1000. a = [3389, 178, 2674, 2586, 13731, 3189, 785, 1038, 25956, 33551] in a, 178 is between 3389 and 2674. How this particular list can be selected for further processing. (sorry this is not homework question. I want to avoid looping, because I have 300K lines to parse through) Thanks Hs.___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] hi
On Fri, Jul 12, 2013 at 6:08 AM, Vick vick1...@orange.mu wrote: Hi, ** ** I’m using Windows 7 and Python 2.7.3 ** ** I have written a code to perform a numerical solution to 1st order Ordinary Differential Equations (ODEs). I have written codes for the famous Runge Kutta 4th order and the DOPRI 8(7)13. However the codes are for 1 variable only; viz. the “y” variable. ** ** I have written another code in Excel VBA for DOPRI 8 for a multi-variable capability. However I have not been able to reproduce it in Python. I’m having trouble in making arrays or lists, I don’t know which is supposed to work. ** ** I have attached my Excel VBA code for a multi-variable numerical integrator in PDF format. This does work in Excel. I have also attached my python code. ** ** Can anyone help me out please? So are you saying your python code doesn't run, or it runs but doesn't give the same answers as your vb code? If your python code throws an exception you should list the traceback for better help. Also, try using a better subject line next time. Thanks Vick ** ** ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor -- Joel Goldstick http://joelgoldstick.com ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python noob
On 16/07/13 13:31, Luka Radoš wrote: My question is, can you recommend me some learning materials? Or any kind of advice for me? Visit the Python.org website. It has lists of online tutorials you can use. Find one you like and make a start. If you get stuck ask questions here. Let us know what OS you use, which Python version. And provide full printout of any error messages not just a summary. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] New to programing and the tutoring system
On 16/07/13 15:15, Samuel Kroger wrote: guess it, it is very simple but for some reason it only works when it's in idle. What doesn't work? Do you get any output? An error message? How are you running it outside IDLE? -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Problems understanding code output
On 07/10/2013 05:05 PM, s...@luo.to wrote: snip This is going a little over my head, please advice, what am I missing in here? While you're watching, we could also point out that you posted a message in html format. There were actually two messages inside there, and many people will see the garbled one. This newsgroup is a text newsgroup. This mailing list is a text mailing list. Please post your messages in text format. Otherwise, some people will have problems seeing your code. -- DaveA ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] What every computer science major should know
On 14/07/13 02:12, boB Stepp wrote: This may be of interest to some of us: http://matt.might.net/articles/what-cs-majors-should-know/ Interesting post Bob, thanks. I think I've covered about 50-60% of the recommended reading and about 75% of the topics. But... I think its a tad old fashioned and neglects the biggest areas of weakness and growth in my experience of modern software engineering - large scale systems. More and more systems don't run on single hosts. They don't even run on single CPU architectures within a single box(the mention of GPU processing and CUDA hints at that). But learning parallelism on a single computer is only the tip of the iceberg. The vast majority of corporate programming today builds systems running across dozens and sometimes hundreds of physical servers. (One CRM implementation I did had over 200 servers across 3 sites all integrated and self managed as part of the project design.) There is one disparaging comment about UML but UML is about the only tool we have for documenting large scale systems effectively. It's far from perfect but a critical skill for grads IMHO. (Ironically it's usually taught as a tool for designing OOP programs with a few classes and that is its weakest area of application.) The other problem in all of this is that it is effectively impossible to teach all of that in a standard 3 or 4 year Bachelors course. Even with 2 years extra for a Masters degree. I did my degree in Electrical/Electronic engineering with specialism in software. It took me about 5 more years to read up on all the CS bits I wanted to cover that weren't in our course. I discovered these areas by discussion with colleagues who had attended other colleges or done other degrees. None of us had done all that was needed. And that's the problem. Computing has become too widely encompassing for anyone to learn the breadth of material needed in the time available in an undergraduate and/or masters course. Other engineering/science disciplines have addressed this by specializing and that is already happening with Games programming degrees becoming increasingly common and many courses in Business computing. I think we will see more of this in the future. It's simply unrealistic to ever expect college grads to have the breadth suggested in the article - they may aspire to it and maybe after 10 years or more attain it. But by then there will be another array of paradigms to absorb... -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Selecting from list
On 18/07/13 18:27, Hs Hs wrote: hi list: Hi, please don't use an old thread to start a new one. This message appeared under a thread dated back in January. I nearly gave up looking for the unread message that my reader said was there. Start a new thread - you'll get better responses if you do. In the following list, is there a simply way to find element less than 200 sandwiched between two numbers greater than 1000. a = [3389, 178, 2674, 2586, 13731, 3189, 785, 1038, 25956, 33551] You example is ambiguous. What should happen in this example: a = [3389, 178, 66, 2674, 2586, 13731, 3189, 785, 1038, 25956, 33551] Should it list 178 and 66, one of them(which?) or neither? Or what about: a = [389, 178, 2674, 2586, 13731, 3189, 785, 1038, 25956, 33551] Should 178 now be ignored because 389 is lower than 1000? (sorry this is not homework question. I want to avoid looping, because I have 300K lines to parse through) If you have to parse 300K lines you will need a loop. It may not be explicit but it will be there. Get used to that idea and worry about how you process the data. And maybe making sure you only loop over everything once! -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] What every computer science major should know
On 18/07/13 23:39, Jim Mooney wrote: Here is how every computer on earth works, even those using Java. It's also how DNA works. I just saved you 200 grand in ruinous student loans ;') Computer Science in six lines: Read serial input device: Until: if serial input device says Stop, stop do something or go somewhere else on serial input, as instructed advance serial input one frame and read serial input device repeat: The 'do something' part can involve complications. Except not all input devices are serial and not all systems take input, some only generate output... But as a generalization its not bad :-) -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] What every computer science major should know
On Thu, Jul 18, 2013 at 7:13 PM, Jim Mooney cybervigila...@gmail.comwrote: Alan Gauld alan.ga...@btinternet.com Except not all input devices are serial and not all systems take input, some only generate output... But as a generalization its not bad :-) Except I stole it from Alan Turing ;') points for that! Jim ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor -- Joel Goldstick http://joelgoldstick.com ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Selecting from list
On 19/07/13 10:18, Jim Mooney wrote: On 18 July 2013 10:27, Hs Hs ilhs...@yahoo.com wrote: [...] (sorry this is not homework question. I want to avoid looping, because I have 300K lines to parse through) Thanks Hs. Not sure what you want to do. If you only want to fulfill the test once, here is a way without a loop, using a list comprehension. A list comprehension *is* a loop. It even includes a for inside it. I really don't understand why people so often say things like I have a bunch of stuff to do repeatedly, but I want to do it without a loop. To put it another way, I want to repeat something without repeating it. WTF??? The only way to avoid a loop *somewhere* is to have a parallel-processing computer with at least as many parallel processes as you have things to repeat. So if Hs has 300K lines to process, he would need 300K processors, one per line. Since that's impractical unless you're Google or the NSA[1] you're going to need a loop, the only question is whether it is an *explicit* loop or an *implicit* loop. For example, a standard for-loop: for line in many_lines: process(line) or a list-comprehension: [process(line) for line in many_lines] are explicit loops. The map built-in is implicit: map(process, many_lines) So are many of numpy's array functions. But regardless of whether *you* write the loop, or Python does it for you, there is still a loop. [1] Hi guys! -- Steven ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor