Re: Financial Modeling with Python by Shayne Fletcher, Christopher Gardner

2008-04-22 Thread Sergio Correia
Searched on google and couldn't find anything :S On Mon, Apr 21, 2008 at 11:28 AM, [EMAIL PROTECTED] wrote: Just saw at amazon.com reference to the following book that might be available later this year: Financial Modeling with Python [IMPORT] (Hardcover) by Shayne Fletcher (Author),

Re: The big shots

2008-02-19 Thread Sergio Correia
I don't get this thread. At all. I want my 15 minutes back. (OTOH, some of your replies were quite funny or interesting, including - as usual - Gabriel and Steve's) On Feb 19, 2008 11:29 PM, Grant Edwards [EMAIL PROTECTED] wrote: On 2008-02-19, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: What

Re: Why the HELL has nobody answered my question !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

2008-01-30 Thread Sergio Correia
is this some kind of joke? if you get no answers, then the answer is no On Jan 30, 2008 7:40 PM, Blubaugh, David A. [EMAIL PROTECTED] wrote: I do not understand why no one has answered the following question: Has anybody worked with Gene Expression Programming David Blubaugh

Re: Has Anyone Worked with Gene Expression Programming ???????????????????????????

2008-01-30 Thread Sergio Correia
Try contacting Ryan O'Neil ryanjoneil at gmail.com. He is the author of pygep http://code.google.com/p/pygep/ , and is probably working here: http://www.gepsoft.com/ If you don't get an answer, it means that THEY found him first. This message will self destruct in ... range(3, 0, -1) ... On Jan

Re: Removing Pubic Hair Methods

2008-01-30 Thread Sergio Correia
So in this case it is REALLY better to ask for permission rather than forgiveness? On Jan 30, 2008 10:30 PM, Ben Finney [EMAIL PROTECTED] wrote: MRAB [EMAIL PROTECTED] writes: On Jan 31, 12:57 am, Asun Friere [EMAIL PROTECTED] wrote: Ouch!! If on the other hand 'females' is populated by

Fwd: small problem with re.sub

2008-01-30 Thread Sergio Correia
See this: http://www.regular-expressions.info/python.html (the Search and Replace part) You are referring to the group as (?P=id), when you should be using r\gname. HTH, Sergio On Jan 30, 2008 10:01 PM, Astan Chee [EMAIL PROTECTED] wrote: Hi, I have a html text stored as a string. Now I want

Re: I don't understand what is happening in this threading code

2008-01-18 Thread Sergio Correia
This is what's happening: 1) The chef thread releases the sema 2) While the chef thread is saying Andiamo, decreasing i, and ending the while loop, the waiter thread SERVES the dish and RUNS to reacquire the lock 3) Back in the main loop, chef.join() is run, and then the waiter's variable is

Re: Why this apparent assymetry in set operations?

2008-01-15 Thread Sergio Correia
Both of you are correct. x = set([1,2,3]) y = set([4,5]) x |= y x set([1, 2, 3, 4, 5]) On Jan 15, 2008 11:07 AM, Skip Montanaro [EMAIL PROTECTED] wrote: Why is that? Doesn't the |= operator essentially map to an update() call? No, according to 3.7 Set Types, s | t maps to

Re: Job Offer: Python Ninja or Pirate!

2007-12-10 Thread Sergio Correia
import sys, xml, urllib dummy = [sys.stdout.write(city + ': ' + str(num) + '\n') for city, num in set([[(a, o.count(a)) for a in p] for o, p in [2*tuple([[city for city in ((xml.dom.minidom.parseString(urllib.urlopen(' http://api.etsy.com/feeds/xml_user_details.php?id=' +

Re: Timeout test hangs IDLE

2007-12-05 Thread Sergio Correia
I once made a small app that used threads on IDLE. There was a strange error when using 'print' threads. When what I printed filled the entire screen, instead of moving all the text up, IDLE just hanged. Try running your code from the shell instead, to see if the problem is in IDLE. HTH, Sergio

Re: Escaping the semicolon?

2007-12-04 Thread Sergio Correia
On Dec 4, 2007 10:40 AM, Nick [EMAIL PROTECTED] wrote: Is this expected behavior? s = '123;abc' s.replace(';', '\;') '123\\;abc' Everything is Ok. It's still a single backslash. Try: print s.replace(';', '\;') Or x = s.replace(';', '\;') print x Best, Sergio --

Re: Show this file in explorer

2007-12-01 Thread Sergio Correia
Although I'm a python fan; for that kind of stuff, I use autohotkey ( http://www.autohotkey.com/download/ ) Best, Sergio On Dec 1, 2007 3:30 AM, farsheed [EMAIL PROTECTED] wrote: I have a big problem. I have a list of files that my script find and list them in a little gui. I need this

Re: Code Management

2007-11-26 Thread Sergio Correia
Bluebird: If you are using python 2.5, relative imports are no longer an issue: http://docs.python.org/whatsnew/pep-328.html That problem solved, what you sometimes want is to change the version of your package. I just change the text in the PTH file, to point to another version, and voilá (no

Re: How do I convert escaped HTML into a string?

2007-11-23 Thread Sergio Correia
This may help: http://effbot.org/zone/re-sub.htm#strip-html You should take care that there are several issues about going from html to txt 1) p What should bwe/bdo aboutbr /this?/p You need to strip all tags.. 2) quot;, amp;, lt;, and gt... and I could keep going.. we need to convert all

Re: Function stopping a function

2007-11-22 Thread Sergio Correia
If you are talking about events and all that, I suppose you are using (or should be using) threads. Why don't try running the length_function as a Thread that on every loop checks a semaphore and if the condition is met, exits itself? Kinda like this:

Re: Code Management

2007-11-20 Thread Sergio Correia
Let's see: 1) Should I put my unittests in a subdirectory? Does the subdirectory have to be a package? Sure, to avoid cluttering put the tests in a folder called 'tests' (and any input the tests require, like mock files, output files used to test if the output is correct, etc etc, should be

Fwd: Formatting question.

2007-11-20 Thread Sergio Correia
Hey Mike, Welcome to Python! About your first issue, just change the line outfile.write( '%s', % (LoL[x][y])) With outfile.write( '%s', % (LoL[x][y][:-1])) Why? Because when you do the line.split, you are including the '\n' at the end, so a new line is created. Now, what you are doing is not

Re: Code Management

2007-11-20 Thread Sergio Correia
As a side note, I find much easier to drop a PTH file than messing with pythonpath. If you are not familiar with PTH files, what I do is this 1) Go to C:\Program Files\Python25\Lib\site-packages or whatever is appropiate in your case. 2) Create a text file, name it something like MyProjects.PTH

Fwd: Sorting Countries by Region

2007-11-16 Thread Sergio Correia
Just a few notes: 1) get_countries_list What is the purpose of that function? Besides a few errors (an argument named list, no value returned), it seems you just want to remove duplicates from a list called countries. You can do that transforming the list to a 'set'. new_countries = list(

Re: Fwd: Sorting Countries by Region

2007-11-16 Thread Sergio Correia
About the sort: Check this (also on http://pastebin.com/f12b5b6ca ) def make_regions(): # Values you provided EU = [Austria,Belgium, Cyprus,Czech Republic, Denmark,Estonia, Finland] NA = [Canada, United States] AP = [Australia, China, Hong Kong, India, Indonesia, Japan]

Re: Simple threading example freezes IDLE?

2007-09-26 Thread Sergio Correia
I think the -print- command, as used in IDLE, is not thread-safe. I was bitten by an issue like that today, and the problem ended up being the -print- command I used. On the cmd line, it works per-fect-ly.. but IDLE seems to be the culprit. A possible answer seems to be to write a wrapper for

Re: Simple threading example freezes IDLE?

2007-09-26 Thread Sergio Correia
) for symbol in sorted(symbols): qSymbols.put_nowait(symbol) Worker(qSymbols) # Start thread qSymbols.join() print The End... On 9/26/07, Sergio Correia [EMAIL PROTECTED] wrote: I think the -print- command, as used in IDLE, is not thread-safe. I was bitten by an issue like that today

[issue1176] str.split() takes no keyword arguments (Should this be expected?)

2007-09-20 Thread Sergio Correia
Sergio Correia added the comment: Thanks for the update, Sergio __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1176 __ ___ Python-bugs-list mailing list Unsubscribe: http

[issue1176] str.split() takes no keyword arguments (Should this be expected?)

2007-09-18 Thread Sergio Correia
New submission from Sergio Correia: str.split() does not accept maxsplits as a keyword argument. If i want to split a string, and, say, get its first word, I do this: 'SPAM eggs eggs spam spam ham'.split(None, 1)[0] 'SPAM' However, as documented on help(str.split), the separator is optional

[issue1176] str.split() takes no keyword arguments (Should this be expected?)

2007-09-18 Thread Sergio Correia
Sergio Correia added the comment: As a side note, this is slightly related with: http://mail.python.org/pipermail/python-dev/2000-October/009694.html http://bugs.python.org/issue1123 (but check the date of the first link!) __ Tracker [EMAIL PROTECTED] http

Re: Why 'class spam(object)' instead of class spam(Object)' ?

2007-09-08 Thread Sergio Correia
Thanks for the replies, very instructive! On 9/7/07, Steve Holden [EMAIL PROTECTED] wrote: Carl Banks wrote: On Fri, 07 Sep 2007 01:30:00 -0500, Sergio Correia wrote: Hi, I'm kinda new to Python (that means, I'm a total noob here), but have one doubt which is more about consistency

Why 'class spam(object)' instead of class spam(Object)' ?

2007-09-07 Thread Sergio Correia
Hi, I'm kinda new to Python (that means, I'm a total noob here), but have one doubt which is more about consistency that anything else. Why if PEP 8 says that Almost without exception, class names use the CapWords convention, does the most basic class, object, is lowercase? I found a thread

Re: PYTHONPATH not working on Windows XP (?)

2007-09-03 Thread Sergio Correia
Thanks! It worked straightforward, and it's easier than messing with the enviromental variables or the registry. BTW, I'm still wondering how did Autohotkey got included in sys.path (there are no other .pht files on my PC) Regards, Sergio On 9/3/07, olivier [EMAIL PROTECTED] wrote: Hi, Any

Can you use -getattr- to get a function in the current module?

2007-09-03 Thread Sergio Correia
This works: # Module spam.py import eggs print getattr(eggs, 'omelet')(100) That is, I just call the function omelet inside the module eggs and evaulate it with the argument 100. But what if the function 'omelet' is in the module where I do the getattr (that is, in spam.py). If I do any of

Re: Can you use -getattr- to get a function in the current module?

2007-09-03 Thread Sergio Correia
Alex, Gabriel, Thanks for the reply. Works great! On 9/3/07, Gabriel Genellina [EMAIL PROTECTED] wrote: En Mon, 03 Sep 2007 20:13:43 -0300, Sergio Correia [EMAIL PROTECTED] escribi�: # Module spam.py import eggs print getattr(eggs, 'omelet')(100) That is, I just call

PYTHONPATH not working on Windows XP (?)

2007-09-02 Thread Sergio Correia
Hi, I'm trying to add a personal folder to the path used by python in searching for packages and modules. This folder, C:\docs\utils , has some packages not yet ready for site-packages. First, I tried sys.path.append(C:\docs\utils) BUT this only lasts for the current python session. Then, I

Re: How to open a txt file from the same folder as my module (w/out changing the working dir)

2007-04-05 Thread Sergio Correia
Larry, Gabriel Thanks for the replies. Both ways work great. Sergio On 4/4/07, Gabriel Genellina [EMAIL PROTECTED] wrote: En Wed, 04 Apr 2007 20:14:37 -0300, Larry Bates [EMAIL PROTECTED] escribió: Sergio Correia wrote: I have a program in 'C:\Python25\Lib\site-packages\spam\spam.py

How to open a txt file from the same folder as my module (w/out changing the working dir)

2007-04-04 Thread Sergio Correia
I have a program in 'C:\Python25\Lib\site-packages\spam\spam.py' Importing and everything works fine: from spam import spam But the program calls a file located on the same folder (that is: C:\Python25\Lib\site-packages\spam\). How do i do that? spam.eggs() Traceback (most recent call

Best place for a function?

2007-03-07 Thread Sergio Correia
I'm writing a class, where one of the methods is kinda complex. The method uses a function which I know for certain will not be used anywhere else. This function does not require anything from self, only the args passed by the method. Where should I put the function? a) Inside the module but

Re: Best place for a function?

2007-03-07 Thread Sergio Correia
I also found out I can't use `unittest` with nested functions :-( Thank you all for the responses, Best, Sergio On 7 Mar 2007 14:57:54 -0800, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Diez B. Roggisch: If it really has no other use as in this class, put it as an instancemethod in there.

Flatten a two-level list -- one liner?

2007-03-07 Thread Sergio Correia
Hi, I'm looking for an easy way to flatten a two level list like this spam = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]] Into something like eggs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] There are *no* special cases (no empty sub-lists). I have found two ways: 1) Accumulator eggs = []

Re: Flatten a two-level list -- one liner?

2007-03-07 Thread Sergio Correia
! Sergio On 3/7/07, Gabriel Genellina [EMAIL PROTECTED] wrote: En Wed, 07 Mar 2007 21:14:43 -0300, Sergio Correia [EMAIL PROTECTED] escribió: I'm looking for an easy way to flatten a two level list like this Try google. PS: Why does `sum` works only with numbers? Try google

Re: Flatten a two-level list -- one liner?

2007-03-07 Thread Sergio Correia
O_o List comprehensions never cease to amaze me. Thanks, On 3/7/07, Gabriel Genellina [EMAIL PROTECTED] wrote: En Wed, 07 Mar 2007 21:41:16 -0300, Sergio Correia [EMAIL PROTECTED] escribió: I forgot to say: I've already checked the discussions about recursive/iterative/etc flatten

Re: Getting external IP address

2007-03-06 Thread Sergio Correia
The above suggestions seem nice, but I find this one easier: import urllib2 ext_ip = urllib2.urlopen('http://whatismyip.org/').read() print ext_ip The nice thing about the above code is that http://whatismyip.org/ only contains exactly what you want (the ip, nothing more, nothing less), so no