[Tutor] pyton module index, windoes error 5

2011-03-05 Thread Travis Pierce
I am new to programming and am using Allen Downey's How to Think Like a Programmer, 2nd Edition Python edition to start learning. I am having trouble viewing the pydoc graphic on a local host. I know this is not necessarily a Python question, but I would appreciate any advice that can be prov

Re: [Tutor] Error while using calendar module in Python 2.7

2011-03-05 Thread Alan Gauld
"Steven D'Aprano" wrote File "C:\Python27\Foursoft\calendar.py", line 33, in What's "Foursoft"? I would say that the standard library calendar module is being shadowed Ah, good catch. I didn't notice the path was non standard. Alan G ___

Re: [Tutor] Sorting a dictionary by a value when the values are tuples

2011-03-05 Thread Steven D'Aprano
ranjan das wrote: This is a small example i created from operator import itemgetter temp={'4':(2,3), '2':(5,8)} print temp.items() new_temp=sorted(temp.items(), key=itemgetter(1) print new_temp Another syntax error. Please ensure that you test your code before posting. In this case, it's eas

Re: [Tutor] Help - want to display a number with two decimal places

2011-03-05 Thread Steven D'Aprano
Modulok wrote: Notice that 'd' in your string substitution means integers, not floats. Any decimal places will be truncated when using 'd'. For floats use 'f' instead. You an also specify a precision, such as '%.2f' shows two decimal places. However, to make all of your numbers line up nicely,

[Tutor] Sorting a dictionary by a value when the values are tuples

2011-03-05 Thread ranjan das
This is a small example i created from operator import itemgetter temp={'4':(2,3), '2':(5,8)} print temp.items() new_temp=sorted(temp.items(), key=itemgetter(1) print new_temp I want to sort the dictionary by the value in the first element of the tuple ((2,3) and (5,8)) and then the second

Re: [Tutor] Error while using calendar module in Python 2.7

2011-03-05 Thread Steven D'Aprano
Alan Gauld wrote: "ranjan das" wrote Error: Traceback (most recent call last): File "C:\Python27\Foursoft\calendar.py", line 33, in while friday.weekday() != calendar.FRIDAY: AttributeError: 'module' object has no attribute 'FRIDAY' The obvious solution is that calendar has changed be

Re: [Tutor] Error while using calendar module in Python 2.7

2011-03-05 Thread Steven D'Aprano
ranjan das wrote: I ran the following code in python 2.6 and then in python 2.7 (using calendar module) to manipulate dates and times The following code works fine in Python 2.6 but throws up an error in Python 2.7. Can anyone please say why? No it does not work fine at all. It generates a Syn

Re: [Tutor] Error while using calendar module in Python 2.7

2011-03-05 Thread Alan Gauld
"ranjan das" wrote The following code works fine in Python 2.6 but throws up an error in Python 2.7. Can anyone please say why? import datetime import calendar while monday.weekday() != calendar.MONDAY: where does 'monday' come from? Can you send a minimal example that could actually run

Re: [Tutor] Help - want to display a number with two decimal places

2011-03-05 Thread Alan Gauld
"Modulok" wrote However, to make all of your numbers line up nicely, regardless of how long they are, you need to look into advanced string formatting via the builtin string method 'format()'. It takes a little practice Or, if your version of Python doesn't support string.format() (pre 2.6

Re: [Tutor] Help! (solution)

2011-03-05 Thread Alan Gauld
"michael scott" wrote ...if something about my code could be better, please tell me, OK, Here are some stylistic things... def production_time(): creation_time = 127 time_till_rest = 18161 I'd move the constants out of the function to global level. And it is convention to make const

Re: [Tutor] Shared web host and setting the python environment...

2011-03-05 Thread Izz ad-Din Ruhulessin
Hi, I would go for appending sys.path. This is a simple way to do it, and perhaps not even needed for each python file (only files which use the modules that you have installed)) Another way to do it is adding the modules you need to sys.modules manually. 2011/3/5 Modulok > List, > > Backgroun