Re: [Tutor] using dynamic import statements

2012-07-09 Thread Hugo Arts
On Mon, Jul 9, 2012 at 3:10 AM, Chris Hare wrote: > > Here is what I want to do: > > I have a bunch of modules to import. instead of duplicating a lot of code > for each import, I want to do something like this: > > importList = [ "sys", "os", "imp", "stat", "re", "webbrowser", "Image", > "Strin

Re: [Tutor] Reading a csv of coordinates, trying to write a csv of bearings.

2012-07-09 Thread Hugo Arts
On Mon, Jul 9, 2012 at 3:10 AM, Gregory Lund wrote: > I'm Not looking for an absolute solution, but perhaps some insight > into some snippets of code, or > suggestions of where I should seek out answers to this issue. > Or where I've gone wrong below. > NOTE: currently this 'code' below r

Re: [Tutor] Mapping ID's for corresponding values in different Columns

2012-07-09 Thread Hugo Arts
On Sun, Jul 8, 2012 at 11:47 PM, Fred G wrote: > Hi-- > > My current input looks like the following: > > FILE1.csv > PERSON_IDPERSON_NAME > 1 Jen > 2 Mike > 3 Jim > 4 > 5 Jane > 6 Joe > 7

Re: [Tutor] using dynamic import statements

2012-07-09 Thread Alan Gauld
On 09/07/12 02:10, Chris Hare wrote: Here is what I want to do: I have a bunch of modules to import. instead of duplicating > a lot of code for each import, I want to do something like this: ...lots of code stripped Why not the more usual: import sys, os, imp, stat,\ re, web

Re: [Tutor] using dynamic import statements

2012-07-09 Thread ankur ~ अंकुर
On Mon, Jul 9, 2012 at 6:40 AM, Chris Hare wrote: > > Here is what I want to do: > > I have a bunch of modules to import. instead of duplicating a lot of code > for each import, I want to do something like this: > > importList = [ "sys", "os", "imp", "stat", "re", "webbrowser", "Image", > "Strin

Re: [Tutor] using dynamic import statements

2012-07-09 Thread Kwpolska
Why does this bloody ML want me to respond to the last person instead of tutor@python.org? --- On Mon, Jul 9, 2012 at 9:47 AM, Alan Gauld wrote: > On 09/07/12 02:10, Chris Hare wrote: >> >> >> Here is what I want to do: >> >> I have a bunch of modules to import. instead of duplicating > >> a lot o

Re: [Tutor] using dynamic import statements

2012-07-09 Thread Alan Gauld
On 09/07/12 10:19, Kwpolska wrote: Why does this bloody ML want me to respond to the last person instead of tutor@python.org? Because that's how it, along with many other mailing lists, works. If it helps, think of it as you receiving a mail from the sender and CCd to the list. Therefore hitti

Re: [Tutor] Reading a csv of coordinates, trying to write a csv of bearings.

2012-07-09 Thread Joel Goldstick
On Mon, Jul 9, 2012 at 3:14 AM, Hugo Arts wrote: > On Mon, Jul 9, 2012 at 3:10 AM, Gregory Lund wrote: >> >> I'm Not looking for an absolute solution, but perhaps some insight >> into some snippets of code, or >> suggestions of where I should seek out answers to this issue. >> Or where I'

Re: [Tutor] using dynamic import statements

2012-07-09 Thread Chris Hare
Thanks all for the ideas. I wanted to have my own error messages printed for the user - something a little more meaningful than the standard error. Thanks for the advice - very helpful! On Jul 9, 2012, at 6:12 AM, Alan Gauld wrote: > On 09/07/12 10:19, Kwpolska wrote: >> Why does this bloody

Re: [Tutor] using dynamic import statements

2012-07-09 Thread wolfrage8...@gmail.com
Might I recommend you use the logging module that is part of core Python rather than rolling your own if Debug. I found the logging module made growing my logging across multiple applications so easy! http://docs.python.org/library/logging.html On Mon, Jul 9, 2012 at 2:10 PM, Chris Hare wrote: >

Re: [Tutor] Mapping ID's for corresponding values in different Columns

2012-07-09 Thread Fred G
Thank you guys so much. I'm quite close now, but I'm having a bit of trouble on the final for-loop to create the new dictionary. I have the following 3 functions (note I'm re-typing it from a different computer so while the identation will be off here, it is correct in the actual code): #read in

[Tutor] TypeError: not all arguments converted during string formatting

2012-07-09 Thread Keitaro Kaoru
Traceback (most recent call last): File "bot.py", line 351, in mgr.main() File "/home/bot/bot/ch.py", line 1672, in main con._feed(data) File "/home/bot/bot/ch.py", line 628, in _feed self._process(food.decode("latin-1").rstrip("\r\n")) #numnumz ;3 File "/home/bot/bot/ch.py", l

Re: [Tutor] TypeError: not all arguments converted during string formatting

2012-07-09 Thread Joel Goldstick
On Mon, Jul 9, 2012 at 11:31 AM, Keitaro Kaoru wrote: > Traceback (most recent call last): > File "bot.py", line 351, in > mgr.main() > File "/home/bot/bot/ch.py", line 1672, in main > con._feed(data) > File "/home/bot/bot/ch.py", line 628, in _feed > self._process(food.decode("

Re: [Tutor] TypeError: not all arguments converted during string formatting

2012-07-09 Thread Steven D'Aprano
Keitaro Kaoru wrote: [...] TypeError: not all arguments converted during string formatting [...] return self.html % ca cant seem to find out whats wrong with it Try experimenting at the interactive interpreter: [steve@ando ~]$ python Python 2.6.7 (r267:88850, Mar 10 2012,

[Tutor] confusion about imports

2012-07-09 Thread Chris Hare
So, I have to admit, imports have me really confused. I am trying to break apart a 10,000+ line single file into various files, one for each class, and one containing a whole bunch of functions which are used by a lot of classes. Some of those functions use calls to methods in a Class. Even

Re: [Tutor] confusion about imports

2012-07-09 Thread Joel Goldstick
On Mon, Jul 9, 2012 at 11:56 AM, Chris Hare wrote: > > So, I have to admit, imports have me really confused. I am trying to break > apart a 10,000+ line single file into various files, one for each class, and > one containing a whole bunch of functions which are used by a lot of classes. > So

Re: [Tutor] confusion about imports

2012-07-09 Thread Walter Prins
Hi Chris > So, I have to admit, imports have me really confused. I am trying to break > apart a 10,000+ line single file into various files, one for each class, and > one containing a whole bunch of functions which are used by a lot of classes. > Some of those functions use calls to methods i

Re: [Tutor] confusion about imports

2012-07-09 Thread Mark Lawrence
On 09/07/2012 16:56, Chris Hare wrote: So, I have to admit, imports have me really confused. I am trying to break apart a 10,000+ line single file into various files, one for each class, and one containing a whole bunch of functions which are used by a lot of classes. Some of those function

Re: [Tutor] confusion about imports

2012-07-09 Thread Chris Hare
On Jul 9, 2012, at 12:42 PM, Walter Prins wrote: > Hi Chris > >> So, I have to admit, imports have me really confused. I am trying to break >> apart a 10,000+ line single file into various files, one for each class, and >> one containing a whole bunch of functions which are used by a lot of

Re: [Tutor] confusion about imports

2012-07-09 Thread David Rock
* Chris Hare [2012-07-09 13:33]: > import functions > import os > import db > > when everything was all in one file, that worked just fine. Now, with it all > split up, once I changed > > r = DbPath() > > to > > r = functions.DbPath() > > things seems to work now. I hope this is it!!! >

Re: [Tutor] Mapping ID's for corresponding values in different Columns

2012-07-09 Thread Fred G
Got it! Thanks guys for all your help--what a satisfying feeling! Just out of curiosity, in the following: def new_dict (csv_to_dict, nested_line): old_dict = csv_to_dict(file1) old_list = nested_line(file2) new_dict = {} #for item in old_list: #new_dict[item] = item f

Re: [Tutor] Mapping ID's for corresponding values in different Columns

2012-07-09 Thread Fred G
Sorry, just got that as well. It was the placement of the if-statement in the nested for-loop. so v was stuck on 3...thanks again for the help with this!!! On Mon, Jul 9, 2012 at 1:57 PM, Fred G wrote: > Got it! Thanks guys for all your help--what a satisfying feeling! Just > out of curiosity

[Tutor] updating step size while in loop

2012-07-09 Thread Abhishek Pratap
hey guys I want to know whether it is possible for dynamically update the step size in xrange or someother slick way. Here is what I am trying to do, if during a loop I find the x in list I want to skip next #n iterations. for x in xrange(start,stop,step): if x in list: step = 14

Re: [Tutor] updating step size while in loop

2012-07-09 Thread Hugo Arts
On Mon, Jul 9, 2012 at 11:59 PM, Abhishek Pratap wrote: > hey guys > > I want to know whether it is possible for dynamically update the step > size in xrange or someother slick way. > > Here is what I am trying to do, if during a loop I find the x in list > I want to skip next #n iterations. > >

Re: [Tutor] confusion about imports

2012-07-09 Thread Dave Angel
On 07/09/2012 11:56 AM, Chris Hare wrote: > So, I have to admit, imports have me really confused. I am trying to break > apart a 10,000+ line single file into various files, one for each class, and > one containing a whole bunch of functions which are used by a lot of classes. > Some of those

Re: [Tutor] updating step size while in loop

2012-07-09 Thread Abhishek Pratap
Ok thanks Hugo. I have the while loop working -A On Mon, Jul 9, 2012 at 3:06 PM, Hugo Arts wrote: > On Mon, Jul 9, 2012 at 11:59 PM, Abhishek Pratap > wrote: >> >> hey guys >> >> I want to know whether it is possible for dynamically update the step >> size in xrange or someother slick way. >>

Re: [Tutor] confusion about imports

2012-07-09 Thread Chris Hare
Good advice - thanks for that. And I think you're right - I think what is happening is in fact a bunch of circular references. As I resolve issues, I will be looking for those! Appreciate all the advice! On Jul 9, 2012, at 5:16 PM, Dave Angel wrote: > On 07/09/2012 11:56 AM, Chris Hare wrote

Re: [Tutor] confusion about imports

2012-07-09 Thread Steven D'Aprano
Mark Lawrence wrote: On 09/07/2012 16:56, Chris Hare wrote: So, I have to admit, imports have me really confused. I am trying to break apart a 10,000+ line single file into various files Please don't break the file up for the sake of doing it, you're writing python not java :-) Agreed, b

Re: [Tutor] updating step size while in loop

2012-07-09 Thread Wayne Werner
While you can't do it with a straight generator, you can create your own: class MyIter: def __init__(self, start, stop, step=1): self.start = start self.stop = stop self.step = step def __iter__(self): self.cur = self.start while self.cur < self.sto