Re: adding methods at runtime and lambda

2007-05-03 Thread James Stroud
Mike wrote: > I was messing around with adding methods to a class instance at > runtime and saw the usual code one finds online for this. All the > examples I saw say, of course, to make sure that for your method that > you have 'self' as the first parameter. I got to thinking and thought > "I have

Re: tkinter listboxes

2007-05-03 Thread James Stroud
[EMAIL PROTECTED] wrote: > I will give a simplified example of the problem at hand -- > > I have a case in which I have two listboxes - listbox1 and listbox2, > if I click on an item in listbox1 the item gets highlighted as > expected. Now if I click on an item in listbox2 the selected item in > l

Re: Firefighters at the site of WTC7 "Move away the building is going to blow up, get back the building is going to blow up."

2007-05-04 Thread James Stroud
mike3 wrote: > On May 2, 9:10 pm, Midex <[EMAIL PROTECTED]> wrote: >> 100% EVIDENCE - SEE THE TRUTH FINALLY - ON THE GROUND VIDEO >> WITNESSEShttp://www.youtube.com/watch?v=YNN6apj5B2U >> >> In order to appreciate just what Truthers are talking about when they >> cry Treason over WTC7, you would

Re: Firefighters at the site of WTC7 "Move away the building is going to blow up, get back the building is going to blow up."

2007-05-04 Thread James Stroud
default wrote: > On 2 May 2007 20:10:20 -0700, Midex <[EMAIL PROTECTED]> wrote: > >> LIES LIES LIES LIES LIES > > Trying to understand the World Trade Center events is like waking up > to act fifteen of a long Greek Tragedy. It needs a complex fabric of > description to give a full picture. In ex

Re: Firefighters at the site of WTC7 "Move away the building is going to blow up, get back the building is going to blow up."

2007-05-04 Thread James Stroud
default wrote: > On Fri, 04 May 2007 03:26:17 -0700, James Stroud > <[EMAIL PROTECTED]> wrote: > >> default wrote: >>> On 2 May 2007 20:10:20 -0700, Midex <[EMAIL PROTECTED]> wrote: >>> >>>> LIES LIES LIES LIES LIES >>> Trying to

Re: behavior difference for mutable and immutable variable in function definition

2007-05-04 Thread James Stroud
[EMAIL PROTECTED] wrote: > Hi, > > Can anyone explain the following: > > Python 2.5 (r25:51908, Apr 9 2007, 11:27:23) > [GCC 4.1.1 20060525 (Red Hat 4.1.1-1)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > def foo(): > > ... x = 2 > ... > foo(

Re: Firefighters at the site of WTC7 "Move away the building is going to blow up, get back the building is going to blow up."

2007-05-04 Thread James Stroud
MooseFET wrote: > On May 4, 12:32 pm, James Stroud <[EMAIL PROTECTED]> wrote: > [] > >>The Marxist contribution to western thought is that it put everything in >>terms of labor and thus allowed us to quantify the human component of >>economies. > > &g

Re: Firefighters at the site of WTC7 "Move away the building is going to blow up, get back the building is going to blow up."

2007-05-04 Thread James Stroud
Charles wrote: > On Fri, 04 May 2007 20:19:33 -0700, James Stroud > <[EMAIL PROTECTED]> wrote: > > >>MooseFET wrote: >> >>>On May 4, 12:32 pm, James Stroud <[EMAIL PROTECTED]> wrote: >>>[] >>> >>> >>>>The Mar

Re: Firefighters at the site of WTC7 "Move away the building is going to blow up, get back the building is going to blow up."

2007-05-04 Thread James Stroud
MooseFET wrote: > On May 4, 8:19 pm, James Stroud <[EMAIL PROTECTED]> wrote: >> MooseFET wrote: >>> On May 4, 12:32 pm, James Stroud <[EMAIL PROTECTED]> wrote: >>> [] >>>> The Marxist contribution to western thought is that it put every

Re: Firefighters at the site of WTC7 "Move away the building is going to blow up, get back the building is going to blow up."

2007-05-05 Thread James Stroud
[EMAIL PROTECTED] wrote: > In article <[EMAIL PROTECTED]>, >MooseFET <[EMAIL PROTECTED]> wrote: >> On May 4, 8:19 pm, James Stroud <[EMAIL PROTECTED]> wrote: >>> MooseFET wrote: >> Groucho Marx. > > Give that man a cigar. > > /BAH

Re: assisging multiple values to a element in dictionary

2007-05-07 Thread James Stroud
[EMAIL PROTECTED] wrote: > Like i want the > key 170 to take either the name 'dataPackageID' or the name > 'LocalId'.I use this in my code,and hence if either comes it should > work . It should work to do what exactly? Cause a perturbation in the orbit of Mars, or something else entirely? James

Re: SkimpyGimpy PNG canvas w/ Javascript mouse tracking

2007-05-07 Thread James Stroud
[EMAIL PROTECTED] wrote: > SkimpyGimpy is a collection of tools for generating > HTML visual, PNG image, and WAVE audio components > for use in web based applications including CAPTCHA Can you advertise "CAPTCHA" as it is trademarked by Carnegie Mellon? James -- http://mail.python.org/mailman/li

Re: How to make Python poll a PYTHON METHOD

2007-05-07 Thread James Stroud
johnny wrote: > Is there a way to call a function on a specified interval(seconds, > milliseconds) every time, like polling user defined method? > > Thanks. > A very literal interpretation of your question yields the following very simple answer: import time while True: time.sleep(some

Re: BUSTED!!! 100% VIDEO EVIDENCE that WTC7 was controlled demolition!! NEW FOOTAGE!!! Ask yourself WHY havn't I seen this footage before?

2007-05-07 Thread James Stroud
quasi wrote: > On Mon, 7 May 2007 17:00:01 -0400, krw <[EMAIL PROTECTED]> wrote: > > >>In article <[EMAIL PROTECTED]>, >>[EMAIL PROTECTED] says... >> >>>On Mon, 7 May 2007 10:55:55 -0400, James Beck >>><[EMAIL PROTECTED]> wrote: >>> >>> In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED]

Re: BUSTED!!! 100% VIDEO EVIDENCE that WTC7 was controlled demolition!! NEW FOOTAGE!!! Ask yourself WHY havn't I seen this footage before?

2007-05-07 Thread James Stroud
Tonico wrote: > On May 4, 2:08 am, quasi <[EMAIL PROTECTED]> wrote: > >>On Fri, 04 May 2007 09:37:37 +1200, Gib Bogle >> >><[EMAIL PROTECTED]> wrote: >> >>>Ah, so the firefighters were in on the conspiracy! >> >>No, but the firefighters are very much aware that there is more to >>9/11 than has bee

Re: interesting exercise

2007-05-07 Thread James Stroud
Michael Tobis wrote: > I want a list of all ordered permutations of a given length of a set > of tokens. Each token is a single character, and for convenience, they > are passed as a string in ascending ASCII order. > > For example > > permute("abc",2) > > should return ["aa","ab","ac","ba","bb"

Re: interesting exercise

2007-05-08 Thread James Stroud
sherry wrote: > On May 8, 9:31 am, Steven D'Aprano > <[EMAIL PROTECTED]> wrote: >> On Mon, 07 May 2007 20:45:52 -0700, Michael Tobis wrote: >>> I have a reasonably elegant solution but it's a bit verbose (a couple >>> dozen lines which I'll post later if there is interest). Is there some >>> clever

Re: interesting exercise

2007-05-08 Thread James Stroud
Steven D'Aprano wrote: > On Tue, 08 May 2007 10:22:05 +0000, James Stroud wrote: > > >>This takes annoying past annoying to some new level of hell to which >>even satan himself wouldn't venture. > > > And thank you for sharing that piece of spam with u

Re: Suggestions for how to approach this problem?

2007-05-08 Thread James Stroud
John Salerno wrote: > Marc 'BlackJack' Rintsch wrote: > Here's what it looks like now: > > 1. Levy, S.B. (1964) Isologous interference with ultraviolet and X-ray > irradiated > bacteriophage T2. J. Bacteriol. 87:1330-1338. > 2. Levy, S.B. and T. Watanabe (1966) Mepacrine and transfer of R >

Re: tkinter get widget option value

2007-05-08 Thread James Stroud
[EMAIL PROTECTED] wrote: > Hi, > If I have a button widget > > w = Button(root, text = "Button", state = 'disabled') > > How can I get the value of option 'state' from the widget 'w'. > I want something like -- > > print w.state >> to print out >> 'disabled' > > Thanks > Rahul > print w["sta

Re: Suggestions for how to approach this problem?

2007-05-09 Thread James Stroud
John Salerno wrote: > John Salerno wrote: > >> So I need to remove the line breaks too, but of course not *all* of >> them because each reference still needs a line break between it. > > > After doing a bit of search and replace for tabs with my text editor, I > think I've narrowed down the pro

Re: SQLObject 0.9.0

2007-05-10 Thread James Stroud
[EMAIL PROTECTED] wrote: > Why was this released 3 times with different version numbers in less > than an hour? > > Mike > For reasons others will know, there are different branches to the SQLObject project. I think, analogously, python still has an active 2.4 branch, if that helps make sense

Re: searching algorithm

2007-05-10 Thread James Stroud
Gordon Airporte wrote: > >> For the above (abrideged) dictionary, you would generate (use a >> fixed-width "programmers" font so the tree looks good): >> >> a >> | >> b >> | >> s >> / \ >>

Re: name capitalization of built-in types, True, and False

2007-05-11 Thread James Stroud
[EMAIL PROTECTED] wrote: > I see that naming conventions are such that classes usually get named > CamelCase. So why are the built-in types named all lowercase (like > list, dict, set, bool, etc.)? > > And names for instances of classes are usually written in lowercase, > like foo in ``foo = Camel

Re: customary way of keeping your own Python and module directory in $HOME

2007-05-14 Thread James Stroud
[EMAIL PROTECTED] wrote: > What's the customary way to keep your own local Python and package > directory? For example, when you're on a server where you don't have > root access, and everything must go in your home directory. > > * What directories do you create? > * What environment variables do

Re: tkinter button state = DISABLED

2007-05-14 Thread James Stroud
[EMAIL PROTECTED] wrote: > I have created a button widget with a button click binding. The button > initially has a state=disabled. I can see the greyed out version of > the button in the GUI. But If I click on the button it still invokes > the callback/binding function. > > Any suggestions as to

Re: Name of function caller

2007-05-15 Thread James Stroud
HMS Surprise wrote: > Is there a way that a function may access the doc string or func_name > of the caller? > > Thanks, > > jvh > Add a parameter to the function to avoid mutilating your code with implementation specific inspection: def fun(caller, *original_parameters): do_something_to_c

Re: How do I tell the difference between the end of a text file, and an empty line in a text file?

2007-05-16 Thread James Stroud
walterbyrd wrote: > Python's lack of an EOF character is giving me a hard time. > > I've tried: > [ stuff ] for s in f: do_whatever_with_s(s) James -- http://mail.python.org/mailman/listinfo/python-list

Re: How do I count the number of spaces at the left end of a string?

2007-05-16 Thread James Stroud
walterbyrd wrote: > I don't know exactly what the first non-space character is. I know the > first non-space character will be * or an alphanumeric character. > This is another of the hundreds of ways: py> for i,c in enumerate(astring): ... if c != ' ': break ... py> print i -- http://mail.p

Re: How do I tell the difference between the end of a text file, and an empty line in a text file?

2007-05-16 Thread James Stroud
Grant Edwards wrote: > On 2007-05-16, walterbyrd <[EMAIL PROTECTED]> wrote: > > >>Python's lack of an EOF character is giving me a hard time. > > > No it isn't. > > >>s = f.readline() >>while s: >>. >>. >>s = f.readline() > > > > >>s = f.readline() >>while s != '' >>. >>. >>s = f.readline

Re: remove all elements in a list with a particular value

2007-05-16 Thread James Stroud
John Zenger wrote: print [x for x in items if x != ''] > > ['SRCPARAM', '1', '6.35e-07', '15.00', '340.00', '1.10', '3.0'] > This can be shortened to [x for x in items if x] James -- http://mail.python.org/mailman/listinfo/python-list

Re: Regexes: How to handle escaped characters

2007-05-17 Thread James Stroud
Torsten Bronger wrote: > Hallöchen! > > I need some help with finding matches in a string that has some > characters which are marked as escaped (in a separate list of > indices). Escaped means that they must not be part of any match. > > My current approach is to look for matches in substrings

Re: Regexes: How to handle escaped characters

2007-05-17 Thread James Stroud
Torsten Bronger wrote: > Hallöchen! > > James Stroud writes: > > >>Torsten Bronger wrote: >> >> >>>I need some help with finding matches in a string that has some >>>characters which are marked as escaped (in a separate list of >>>indi

Re: converting strings to most their efficient types '1' --> 1, 'A' ---> 'A', '1.2'---> 1.2

2007-05-18 Thread James Stroud
py_genetic wrote: > Hello, > > I'm importing large text files of data using csv. I would like to add > some more auto sensing abilities. I'm considing sampling the data > file and doing some fuzzy logic scoring on the attributes (colls in a > data base/ csv file, eg. height weight income etc.) t

Re: converting strings to most their efficient types '1' --> 1, 'A' ---> 'A', '1.2'---> 1.2

2007-05-19 Thread James Stroud
John Machin wrote: > The approach that I've adopted is to test the values in a column for all > types, and choose the non-text type that has the highest success rate > (provided the rate is greater than some threshold e.g. 90%, otherwise > it's text). > > For large files, taking a 1/N sample ca

Re: converting strings to most their efficient types '1' --> 1, 'A' ---> 'A', '1.2'---> 1.2

2007-05-20 Thread James Stroud
John Machin wrote: >Against that background, please explain to me how I can use > "results from previous tables as priors". > > Cheers, > John It depends on how you want to model your probabilities, but, as an example, you might find the following frequencies of columns in all tables you have

Re: converting strings to most their efficient types '1' --> 1, 'A' ---> 'A', '1.2'---> 1.2

2007-05-20 Thread James Stroud
James Stroud wrote: > Now with one test positive for Int, you are getting pretty certain you > have an Int column. Now we take a second cell randomly from the same > column and find that it too casts to Int. > > P_2(H) = 0.9607843--> Confidence its an Int column from round

Re: converting strings to most their efficient types '1' --> 1, 'A' ---> 'A', '1.2'---> 1.2

2007-05-20 Thread James Stroud
John Machin wrote: > So, all in all, Bayesian inference doesn't seem much use in this scenario. This is equivalent to saying that any statistical analysis doesn't seem much use in this scenario--but you go ahead and use statistics anyway? -- http://mail.python.org/mailman/listinfo/python-list

Re: converting strings to most their efficient types '1' --> 1, 'A' ---> 'A', '1.2'---> 1.2

2007-05-20 Thread James Stroud
John Machin wrote: > The model would have to be a lot more complicated than that. There is a > base number of required columns. The kind suppliers of the data randomly > add extra columns, randomly permute the order in which the columns > appear, and, for date columns I'm going to ignore this b

Re: converting strings to most their efficient types '1' --> 1, 'A' ---> 'A', '1.2'---> 1.2

2007-05-21 Thread James Stroud
I need to correct myself here before someone else does. I didn't actually reverse the probabilities as promised for the failing case. It was late last night and I was starting to get a little cloudy. > Pf(D|H) = 0.2 (We *guess* a 20% chance by random any column is Int.) This can be read instea

Re: converting strings to most their efficient types '1' --> 1, 'A' ---> 'A', '1.2'---> 1.2

2007-05-21 Thread James Stroud
py_genetic wrote: > Using a baysian method were my inital thoughts as well. The key to > this method, I feel is getting a solid random sample of the entire > file without having to load the whole beast into memory. If you feel only the first 1000 rows are representative, then you can take a rand

Re: Call script which accepts com. line par. from another script and error control

2007-05-23 Thread James Stroud
Karim Ali wrote: > def MAIN(expression2parse)<- add a main so can > call from other script Of course you don't mean you want another python interpreter to fire up and run the other script? Here is an example of the way to do what you are suggesting: # mod1.py def doit(

Re: Creating Graphs for the Web

2007-05-23 Thread James Stroud
Michael Bentley wrote: > > On May 23, 2007, at 4:17 PM, erikcw wrote: > >> I'm working on a django powered website, and need to dynamically >> generate some graphs (bar, pie, and line) from users' data stored in >> MySQL. >> >> Can anyone recommend a good library I can use for this? > > > Matpl

Re: read file to a dictionary

2007-05-23 Thread James Stroud
rohit wrote: > i want to implement a dictionary in python > the query is : > without explicitly doing the following steps > 1. reading from file to list > 2. processing list to dictionary > is there a module or a built in function that helps me "read" a file > directly into a dictionary > or any m

Re: 0 == False but [] != False?

2007-05-23 Thread James Stroud
Rajarshi wrote: > This is a slightly naive question, but I know that 0 can be used to > represent False. So > > 0 == False > > True > > But, I know I can use [] to represent False as in > > if not []: print 'empty' > > ... > empty > > But then doing the following gives a surprising

Re: Sort lines in a text file

2007-07-23 Thread James Stroud
Daniel wrote: > On Sun, 22 Jul 2007 06:03:17 +0300, leegold <[EMAIL PROTECTED]> wrote: >> say I have a text file: >> >> zz3 uaa4a ss 7 uu >> zz 3 66 ppazz9 >> a0zz0 >> >> I want to sort the text file. I want the key to be the number after >> the two "zz". Or I guess a string of t

Re: Good String Tokenizer

2007-07-24 Thread James Stroud
gt; Does anyone know of a tokenizer that will allow for this sort of use? > > Thanks in advance, > Jim Howard > Pyparsing: http://pyparsing.wikispaces.com/ James -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list

Cleaning up a string

2007-07-24 Thread James Stroud
ring at each round. Does some function or library exist for these types of transformations that works more like string.translate or is the above the best one can hope to do without writing some C? I'm guessing that "if s in astr" type optimizations are already done in the replace

Re: Cleaning up a string

2007-07-24 Thread James Stroud
Peter Otten wrote: > unicode.translate() supports this kind of replacement... > and re.compile(...).sub() accepts a function: Thanks Peter! -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.pyth

Re: Flatten a list/tuple and Call a function with tuples

2007-07-25 Thread James Stroud
beginner wrote: > On Jul 25, 10:19 am, Stargaming <[EMAIL PROTECTED]> wrote: >> On Wed, 25 Jul 2007 14:50:18 +, beginner wrote: >>> Hi, >>> I am wondering how do I 'flatten' a list or a tuple? For example, I'd >>> like to transform[1, 2, (3,4)] or [1,2,[3,4]] to [1,2,3,4]. >> A recursive funct

Re: I am giving up perl because of assholes on clpm -- switching to Python

2007-07-25 Thread James Stroud
proliferate and self > reinforce. All honest people have left this sad newsgroup. Buy bye, > assholes, I am not going to miss you!!! > > Martha You have convinced me to subscribe to clpm! Sounds like it will be fun reading. -- James Stroud UCLA-DOE Institute for Genomics and P

Re: first, second, etc line of text file

2007-07-25 Thread James Stroud
o access the file multiple times at arbitrary positions, you may need to seek(0), cache lines already read, or slurp the whole thing, which has already been suggested. James -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: I am giving up perl because of assholes on clpm -- switching to Python

2007-07-26 Thread James Stroud
em and wandered into the interior design department by accident and found what I like to call "the motherload". No, the girls definitely weren't doing the sciency stuff back then. But that has been a few years already, so maybe things have changed. James -- James Stroud UCLA-DOE I

Re: OOP in Python book?

2007-07-30 Thread James Stroud
ck > > Balme your professors. They are not paying for the books. Of course most will be give a lot of lip-service to educational access for disadvantaged groups but thier choice of books usually suggests otherwise. The high price of textbooks and the tendency for professors to overlook alternativ

Help text embedding in C code?

2007-07-30 Thread James Stroud
d I should just start typing HTML.reStructuredText for this sort of thing? James -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Help text embedding in C code?

2007-07-30 Thread James Stroud
Carsten Haese wrote: > On Mon, 2007-07-30 at 16:24 -0700, James Stroud wrote: > >>Hello All, >> >>I have a python module I wrote in C some time ago and I have since >>forgotten how to use my functions and so I wanted to add some >>doc-strings such that "

Re: What is the "functional" way of doing this?

2007-07-30 Thread James Stroud
x27;functional' way to do the same. > > Thanks, > beginner > Does it get any more functional than lambda? py> f = lambda n, r=None: f(n/26, (r if r else [])) + [n%26] if n/26 else [n%26] py> f(30) [17, 1, 20, 12] py> f(30000) [1, 18, 9, 22] py> f(3000) [4, 11, 10] py

Re: What is the "functional" way of doing this?

2007-07-30 Thread James Stroud
James Stroud wrote: > py> f = lambda n, r=None: f(n/26, (r if r else [])) + [n%26] if n/26 > else [n%26] > py> f(30) > [17, 1, 20, 12] > py> f(3) > [1, 18, 9, 22] > py> f(3000) > [4, 11, 10] > py> f(1000) > [1, 12, 12] > > Oops, th

Re: What is the "functional" way of doing this?

2007-07-30 Thread James Stroud
quite painful in Python (no tail >>>recursion, and look at all that list copying). >> > > It might actually be : > > def f(n): > if n > 0: > return ([n%26] + f(n/26)) > else: > return [] > > Wouldn't t

Re: Encryption recommendation

2007-07-31 Thread James Stroud
implementation for production software. -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: __call__ considered harmful or indispensable?

2007-08-02 Thread James Stroud
sable(object): def __init__(self, func): self.func = func def __call__(self, *args, **kwargs): return functools.partial(self.func, *args, **kwargs) For example: @enclosable def do_something_with(a, b): [etc] James -- James Stroud UCLA-DOE Institute for Genomics and

Re: __call__ considered harmful or indispensable?

2007-08-02 Thread James Stroud
James Stroud wrote: > import functools > class enclosable(object): > def __init__(self, func): > self.func = func > def __call__(self, *args, **kwargs): > return functools.partial(self.func, *args, **kwargs) > > For example: > > @enclosable > def

How to pass a reference to the current module

2007-08-03 Thread James Stroud
mething_with(AModule, funcname) Ideally, it would be nice to leave out AModule if the functions were designed in the same namespace in which do_something_with is called. Thanks in advance for any suggestions. James -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Ang

Re: How to pass a reference to the current module

2007-08-03 Thread James Stroud
James Stroud wrote: > Basically, what I am trying to acomplish is to be able to do this in any > arbitrary module or __main__: > > > funcname = determined_externally() > ModuleUser.do_something_with(AModule, funcname) > > > Ideally, it would be nice to leave out AM

Re: How to pass a reference to the current module

2007-08-03 Thread James Stroud
James Stroud wrote: > James Stroud wrote: > >> Basically, what I am trying to acomplish is to be able to do this in >> any arbitrary module or __main__: >> >> >> funcname = determined_externally() >> ModuleUser.do_something_with(AModule, funcname) >&

Re: How to pass a reference to the current module

2007-08-03 Thread James Stroud
like it much, however, because it seems unnatural. James -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: How to pass a reference to the current module

2007-08-03 Thread James Stroud
current module when all you have is the name of the function in a > string. The answer to that would be "globals()[funcname]". This is like a bad case of phone-tag. Please see my response to your previous post for why this does not seem feasible to me. James -- James Stroud

Re: How to pass a reference to the current module

2007-08-03 Thread James Stroud
Steven D'Aprano wrote: > On Fri, 03 Aug 2007 17:22:40 -0700, James Stroud wrote: > > >>Basically, what I am trying to acomplish is to be able to do this in any >>arbitrary module or __main__: >> >> >>funcname = determined_externally() >

Re: How to pass a reference to the current module

2007-08-03 Thread James Stroud
Carsten Haese wrote: > On Fri, 2007-08-03 at 18:31 -0700, James Stroud wrote: >>Carsten Haese wrote: >>You sound like my former thesis adviser. > > > Thanks. I guess. Yes, its a compliment in disguise--just check his CV. >>OK. From an external source, such as con

Re: How to pass a reference to the current module

2007-08-03 Thread James Stroud
Paul Rubin wrote: > James Stroud <[EMAIL PROTECTED]> writes: > >> ModuleBehavior >> == >>UserDefined1 Imports FunctionUser >>ThirdParty Contains U

Re: How to pass a reference to the current module

2007-08-03 Thread James Stroud
Paul Rubin wrote: > Hmm, it's a pain that there's no clean way to get at the current > module. PEP 3130 shows some icky and unreliable ways, e.g. > >func = getattr(sys.modules[__name__], 'f') > > PEP 3130's goal was to add a clean way to do this. Unfortunately it > was rejected. Yes, this

Re: How to pass a reference to the current module

2007-08-04 Thread James Stroud
Steven D'Aprano wrote: > I suggest you're falling for the anti-pattern of "Big Design Up Front", > and are overly complicating your system "just in case it's useful". Why > not just _insist_ that main.py and UserDefined1.py must be different > modules? You're the application developer, you're allow

Re: Gotcha I never ran into before

2007-08-09 Thread James Stroud
Blah"].upper() ... blah = property(fget=get_blah) ... py> print SpecializedDelegator("Doesn't Matter").blah Traceback (most recent call last): File "", line 1, in File "", line 8, in __getattr__ File "", line 3, in get_blah : 'list' object has no attribute 'upper' James -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list

Importing to

2007-08-09 Thread James Stroud
namespace = __import__(modname).globals() fname = branch.get('__function__', name) function = namespace[fname] # etc. I'm wondering if this approach seems problematic to anyone. Thanks again for all of the help I've received. James -- James Stroud UCLA-DO

Re: beginner whitespace question

2007-08-09 Thread James Stroud
James Stroud wrote: > def __unicode__(self): > return self.choice Laughing to hard at the tab & spaces thing to notice the lack of indentation here. James -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.james

Re: beginner whitespace question

2007-08-09 Thread James Stroud
and spaces. 3. Don't use tabs! Tabs are for tables, hence the name. "Use spaces for space and use tabs for tables" can be a little mnemonic to help you remember the rules. We can make a little song together if you can think of some things that rhyme with "don't&quo

Re: beginner whitespace question

2007-08-09 Thread James Stroud
Dan Bishop wrote: >> Tabs are for tables, hence the name. "Use spaces for space and use tabs >> for tables" can be a little mnemonic to help you remember the rules. We >> can make a little song together if you can think of some things that >> rhyme with "don't" and "use" and "tabs". > > "won't" >

Re: Module imports during object instantiation

2007-08-10 Thread James Stroud
know if it depends > on any modules. > > Currently, the way I'm left is to globally go and import the module and set > a flag there. > > > Ritesh You do realize your import statement will only be called for nt and dos systems don't you? James -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: buggie in else syntax ?

2007-08-14 Thread James Stroud
est\JALsPy\JAL_simulation_file.py", line 265 >else: JSM(230) ; \ > > I guess it's not the preferred syntax, but the resemblance with the > original language it optimal. > Why is it sometimes accepted an sometimes give an error message ? > > thanks, > Stef Mientki > > Looks like you've escaped a space. James -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: accessing keys in dict

2007-08-14 Thread James Stroud
> for key in a_dict.keys(): > > > which is more preferred? Use the first. any difference in performance? It doesn't matter. Wait until later to do these types of optimizations. Ask the list how to go about optimizing when the time comes. James -- James Stroud UCLA-

Re: encrypting files + filestreams?

2007-08-15 Thread James Stroud
practical security issue in most cases. Other than the pad generation, the encryption algorithm is drop-in and I use the pycrypto implementation of AES. Read at least Schneier if you want to get started with such things as there are many caveats to using cryptographic systems. James -- James

Re: How to say $a=$b->{"A"} ||={} in Python?

2007-08-16 Thread James Stroud
27;m afraid you've asked a non sequiter: euler 40% cat test.pl $a=$b->{"A"} ||={} ; print "$a\n" ; $b->{"B"} = 0 ; $a=$b->{"B"} ||={} ; print "$a\n" ; $b->{"X"} = 15 ; $a=$b->{"X"} ||={} ; print "$a\n&quo

Re: Cancelling events on a COM Object

2007-08-16 Thread James Stroud
Oliver, wait a while before you panic about your post not getting through! James -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: How to say $a=$b->{"A"} ||={} in Python?

2007-08-16 Thread James Stroud
beginner wrote: > On Aug 16, 6:21 pm, James Stroud <[EMAIL PROTECTED]> wrote: >>I'm afraid you've asked a non sequiter: >> >>euler 40% cat test.pl >> >>$a=$b->{"A"} ||={} ; >>print "$a\n" ; >> >>

Re: How to say $a=$b->{"A"} ||={} in Python?

2007-08-16 Thread James Stroud
. >> >>HTH, >> >>-- >>Carsten Haesehttp://informixdb.sourceforge.net > > > I use tuples this way all the time. It is indeed very neat. But it is > not a replacement for double hash-table. If I want to retrieve > information just by K1, it is not eff

Re: Python and Tkinter Programming--Expensive!

2007-08-17 Thread James Stroud
our iphone. James -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Understanding closures

2007-08-19 Thread James Stroud
Ramashish Baranwal wrote: > Hi, > > I want to use variables passed to a function in an inner defined > function. Something like- > > def fun1(method=None): > def fun2(): > if not method: method = 'GET' > print '%s: this is fun2' % method > return > fun2() > > fun1

Re: Syntax Question - list multiplication

2007-08-19 Thread James Stroud
MC wrote: > Classic Thanks Michel, but maybe this bit of programming jargon needs some translation for the uninitiated: Classic \Clas"sic\ (kl[a^]s"s[i^]k), Classical \Clas"sic*al\, a. 0. Read the FAQ 1. First rate 2. Greek 3. Refined James -- James Stroud UCLA-DOE Inst

Re: How do I call anonymous classes from imported modules?

2007-08-19 Thread James Stroud
t; Quick and dirty (you could also use a try: except:): f = __import__(module_name) for anobj in f.__dict__.values(): if hasattr(anobj, 'do_foobar'): anobj.do_foobar() Note that this does not test whether anobj is a class as this would entail a type-check, which hints to poor

Re: How do I call anonymous classes from imported modules?

2007-08-19 Thread James Stroud
JoeSox wrote: > On 8/19/07, James Stroud <[EMAIL PROTECTED]> wrote: >> Quick and dirty (you could also use a try: except:): >> >> f = __import__(module_name) >> for anobj in f.__dict__.values(): >> if hasattr(anobj, 'do_foobar'): >>

Re: popen4 not returning output

2007-08-19 Thread James Stroud
[EMAIL PROTECTED] wrote: > I am trying to run the following script: > > > #!/usr/bin/python > > import popen2 > > commandToRun = """scp scp_trial.py [EMAIL PROTECTED]:/targetDirectory""" > #commandToRun = "ls" > print commandToRun > p_out, p_in = popen2.popen4 (commandToRun) > > theOut = p_out

Re: popen4 not returning output

2007-08-19 Thread James Stroud
James Stroud wrote: > [EMAIL PROTECTED] wrote: >> I am trying to run the following script: >> >> >> #!/usr/bin/python >> >> import popen2 >> >> commandToRun = """scp scp_trial.py [EMAIL PROTECTED]:/targetDirectory""&q

Re: yet another indentation proposal

2007-08-19 Thread James Stroud
Dennis Lee Bieber wrote: > On Sat, 18 Aug 2007 13:22:54 -0500, "Aaron" > <[EMAIL PROTECTED]> declaimed the following in > comp.lang.python: > > >> column to make sure that everything lines up. I, on the other hand, >> generally find my self counting a lot of spaces. >> > Forgive me, but

Re: Newbee Question

2007-08-20 Thread James Stroud
till, that is beyond dumb! Nice code, by the way. >> >>Mike- Hide quoted text - >> >>- Show quoted text - > > > Thanks for the help. By the way I am trying to learn the python after > work and on weekends. If it was a dumb question, to this group, I will > no

Re: Retrieving a variable's name.

2007-08-20 Thread James Stroud
7;a', 'b']: ... print '%s is %s' % (aname, globals()[aname]) ... a is 4 b is 4 But this is tantamount to using a dict: py> mydict = {'a':4, 'b':2} py> for aname in ['a', 'b']: ... print '%s is %s' % (aname, mydic

Re: Adjusting the names of custom exceptions (since raising strings is deprecated)

2007-08-21 Thread James Stroud
Silfheed wrote: > Heyas > > So this probably highlights my lack of understanding of how naming > works in python, but I'm currently using FailUnlessRaises in a unit > test and raising exceptions with a string exception. It's working > pretty well, except that I get the deprecation warning that ra

Re: searching dict key with reqex

2007-08-21 Thread James Stroud
james_027 wrote: > hi, > > can I use regex instead of a plain string with this kind of syntax ... > > 'name' in a_dictionary > > something like > > r'name_\D+' in a_dictionary? > > Thanks > james > This makes it a one-liner: import re def rgxindict(rgx, adict): return any(re.match(rgx,k

Re: libgmail failure

2007-08-22 Thread James Stroud
[EMAIL PROTECTED] wrote: > Hey all, > > I've been using libgmail to send out automated notification emails for > my company's nightly regression testing. Last night these emails > started failing, though the python code has not changed. I updated to > the latest libgmail, but that isn't helping.

Re: introspection and functions

2007-08-22 Thread James Stroud
yagyala wrote: > Hi. I would like to be able to tell, at run time, how many parameters > a function requires. Ideally I would like to be able to tell which are > optional as well. I've tried looking at the functions attributes, but > haven't found one that helps in this. How can I do this? > > Tha

Re: libgmail failure

2007-08-22 Thread James Stroud
[EMAIL PROTECTED] wrote: > On Aug 22, 10:26 am, James Stroud <[EMAIL PROTECTED]> wrote: >> Have you thought about spoofing explorer? Always spoof explorer. >> >> James > > > I have not heard of this. How do you spoof IE in libgmail? You might have to edit l

<    2   3   4   5   6   7   8   9   10   11   >