Re: Using regular expressions in internet searches

2005-07-03 Thread MyHaz
Python would be good for this, but if you just want a chuck an rumble
solution might be.


bash $wget -r --ignore-robots -l 0 -c -t 3 http://www.cnn.com/
bash $ grep -r "Micheal.*" ./www.cnn.com/*

Or you could do a wget/python mix

like

import sys
import re
sys.os.command("wget -r --ignore-robots -l 0 -c -t 3
http://ww.cnn.com/";)
re_iraq=re.compile("iraq .+?",re.IGNORECASE)

while "file in dirs under ./www.cnn.com/ "
iraqs = re_iraq.findall(file.read())
print iraqs

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Event Handeling Between Two wxPanles in A wxNotebook

2005-03-19 Thread MyHaz
so you run data pool as like a sruct that contains all your global
objects? That sounds like an iteresting way of doing things. i try to
stay away from gloabs as much as possible but this might be a good time
to queue up that particular tool

thanks for your reply

-- 
http://mail.python.org/mailman/listinfo/python-list


The Running Time of +=

2005-03-22 Thread MyHaz
What is the running time of conactination on character strings.

i.e.

>> joe="123"
>> joe+="9"


is it Amortized Constant time? I don't think it would be O((number of
chars)^2) but i really don't know.

Teach me how to fish, where would i find out more about the internal
representations of data types in python (and guarenteed run times, im
think of something like sgi.com 's info on the STL) . I have looked
through the docs but i don't seem to see these types of specifications.


thanks * 100
- Haz

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Regular Expressions

2005-03-23 Thread MyHaz
escape chars are always a pain when making regex's. There is a section
on it the Regex HOWTO

http://www.amk.ca/python/howto/regex/regex.html#SECTION00042

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python to C++ conversion substituting vectors for lists in a recursive function

2005-03-23 Thread MyHaz
I didn't look at the original code but i you should know that passing
vectors directly (i.e by value) to functions is not a good idea
(results in big copy), its better to use `const vector<> &` or
`vector<> &`  (i.e. by reference). In general you should try to reduce
the number of vector coping to a minimum.

As for the error in the code, it would be better to see the example of
the error, be it compiler or other wise.

I have a question about this line

`vector tseq = nseq.at(0);`

as i have never seen the at() member of vector. And its not referenced
on the sgi site  http://www.sgi.com/tech/stl/Vector.html

what version of the STL are you using?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python for a 10-14 years old?

2005-03-24 Thread MyHaz
Well i don't know of any tutorials but i thought of a cool little
"assignment" that might interest someone of that age assuming english
is her first language. Its a neat little trick with english and the way
that we proccess letter combinations (or should i say permuations). But
a program that turned proper english into this, might be neat.

"""
Aoccdrnig to a rscheearch at Cmabrigde Uinervtisy, it deosn't mttaer in
waht oredr the ltteers in a wrod are, the olny iprmoetnt tihng is taht
the frist and lsat ltteer be at the rghit pclae. The rset can be a
toatl mses and you can sitll raed it wouthit porbelm. Tihs is bcuseae
the huamn mnid deos not raed ervey lteter by istlef, but the wrod as a
wlohe.
"""


the algo whold be something like

openfile
for word in file
   tmp=word[0]
   tmp+=permut(tmp[1:-2])
   tmp+=word[-1]
   print word


She could enjoy sending letters like this, neat secrete codes for a
nine year old ;)


Linky http://www.mrc-cbu.cam.ac.uk/personal/matt.davis/Cmabrigde/

G'Luck
- Haz

P.S. I just had my friend read it and his native tongue is chinese, so
might work for other languages too.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: looking for programmer

2005-03-24 Thread MyHaz
Well your welcolme to send me the specs, im always up for making a few
pennys.

As for the yahoo account, i have me a spam catcher account and seems to
work rather well.

Hope To Here From You
- Haz

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python for a 10-14 years old?

2005-03-24 Thread MyHaz
Michele Simionato:
>Actually, one could even make the case that children are much
> better than adults at learning new things.

In the case of natural languge it has been pretty much proven that
children are (much) better/faster at learning then adults. Now it is
left to be shown if this carries over to programing languages.


- Haz

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The Running Time of += on Char Strings ?

2005-03-24 Thread MyHaz
Thanks Guys It Was Great Help and I have began to mark my code for the
''.join() string conatination optimization. Upon regoogling (when you
know the right thing to google it can make a big diffrence, having not
know how to google +=, hehe). I found this commentary and set of tests.
I find it a good conclustion to this question.

http://www.skymind.com/~ocrow/python_string/


''.join(['Thank ','you])

- Haz

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: newbie - threading

2005-03-29 Thread MyHaz
Posting the error message could help. Also you might check out this
example
http://thraxil.org/thread.txt


- Haz

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: reading from a txt file

2005-03-30 Thread MyHaz
you should have that file i/o in some try: except: pairs for starters.
and you should close data_file when you are done. isn't it just
data_file.read() ?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Optimisation Hints (dict processing and strings)

2005-03-30 Thread MyHaz
I posted a question about string concatination just last week. There is
plenty of discussion on it, if you just search the group.

-- 
http://mail.python.org/mailman/listinfo/python-list


oddness in string.find(sub,somestring)

2005-03-30 Thread MyHaz
OK i find this a quark in string.find that i think needs some
consideration.

Normally if a substring is not in the searched_string then string.find
returns -1 (why not len(searched_string) + 1, i don't know but
nevermind that) but what if a searched_string == '' ? Then
string.find(substring,searched_string) == 0 ?

example:

>>> import string
>>> searched_string="abcdefg"
>>> substring="123"
>>> print string.find(substring,searched_string)
-1
>>> searched_string=""
>>> print string.find(substring,searched_string)
0
>>> 


why would this be? And when is someone going to fix it :P


- Haz

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: oddness in string.find(sub,somestring)

2005-03-30 Thread MyHaz
thanks all that clears things up nicely


- Haz

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Formated String in optparse

2005-03-31 Thread MyHaz
If you haven't looked into it, you may like the way class
OptionParser() makes the help text for you.


- Haz

-- 
http://mail.python.org/mailman/listinfo/python-list


Streaming Data Error in .read() (HTTP/ICY) Possible Bug?

2005-06-12 Thread MyHaz
I playing around with streaming shoutcast mp3s.

Here is some sample code:

---
import httplib


# Put together the headers
headers = {"Icy-MetaData":"1"}

con = httplib.HTTPConnection('64.142.8.154', 8000)
con.request("GET", "/")
stream = con.getresponse()
print stream.status,stream.reason
print stream.read()
---

For which i get error:

bash-2.05b$ ./woxy_saver.py
200
Traceback (most recent call last):
  File "./woxy_saver.py", line 21, in ?
print stream.read()
  File "C:\python24\lib\httplib.py", line 463, in read
s = self._safe_read(self.length)
  File "C:\python24\lib\httplib.py", line 545, in _safe_read
chunk = self.fp.read(amt)
  File "C:\python24\lib\httplib.py", line 1273, in read
return s + self._file.read(amt - len(s))
TypeError: unsupported operand type(s) for -: 'str' and 'int'
bash-2.05b$

It seems somehow amt is turning into a str.

Is this a bug in httplib.py or there something wrong with my code?


Cheers
- Haz

-- 
http://mail.python.org/mailman/listinfo/python-list