Re: Can I get a technical explanation on the following error

2009-05-24 Thread grocery_stocker
On May 24, 11:47 am, Hans Müller wrote: > Try this: > > print "\\" > > \ is the escape character, it masks the meaning of the next chararcter. > > If you write print "\" python tries to print " (the meaning of " as > the string delimiter is beeing masked) and finds no closing " > This is why you g

Can I get a technical explanation on the following error

2009-05-24 Thread grocery_stocker
How come something like '\' causes an error? Here is what I mean. [cdal...@localhost ~]$ python Python 2.6.2 (r262:71600, May 3 2009, 17:04:44) [GCC 4.1.1 20061011 (Red Hat 4.1.1-30)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> print "test \" File "", l

Re: Thread locking question.

2009-05-09 Thread grocery_stocker
On May 9, 8:36 am, Piet van Oostrum wrote: > >>>>> grocery_stocker (gs) wrote: > >gs> The following code gets data from 5 different websites at the "same > >gs> time". > >gs> #!/usr/bin/python > >gs> import Queue > >gs&g

Thread locking question.

2009-05-09 Thread grocery_stocker
The following code gets data from 5 different websites at the "same time". #!/usr/bin/python import Queue import threading import urllib2 import time hosts = ["http://yahoo.com";, "http://google.com";, "http://amazon.com";, "http://ibm.com";, "http://apple.com";] queue = Queue.Queue()

Re: Is it better to use threads or fork in the following case

2009-05-03 Thread grocery_stocker
On May 3, 1:40 pm, "Diez B. Roggisch" wrote: > grocery_stocker schrieb: > > > > > On May 3, 1:16 pm, "Diez B. Roggisch" wrote: > >> grocery_stocker schrieb: > > >>> Let's say there is a new zip file with updated information every

Re: Is it better to use threads or fork in the following case

2009-05-03 Thread grocery_stocker
On May 3, 1:16 pm, "Diez B. Roggisch" wrote: > grocery_stocker schrieb: > > > Let's say there is a new zip file with updated information every 30 > > minutes on a remote website. Now, I wanna connect to this website > > every 30 minutes, download the

Is it better to use threads or fork in the following case

2009-05-03 Thread grocery_stocker
Let's say there is a new zip file with updated information every 30 minutes on a remote website. Now, I wanna connect to this website every 30 minutes, download the file, extract the information, and then have the program search the file search for certain items. Would it be better to use threads

Re: Question about the wording in the python documents.

2009-05-02 Thread grocery_stocker
On May 2, 4:14 am, Sebastian Wiesner wrote: > > I don't understand your objection. Is it that the > documentation calls it > > Request instead of urllib2.Request? Or that it calls it an object instead > > of an instance? > > I guess the latter ... > > > In either case, I think you're picking a ni

Question about the wording in the python documents.

2009-05-01 Thread grocery_stocker
At the following url... http://docs.python.org/library/urllib2.html They have the following... "urllib2.urlopen(url[, data][, timeout]) Open the URL url, which can be either a string or a Request object" I don't get how urllib2.urlopen() can take a Request object. When I do the following..

Re: CSV performance

2009-04-27 Thread grocery_stocker
On Apr 27, 5:15 am, Peter Otten <__pete...@web.de> wrote: > psaff...@googlemail.com wrote: > > I'm using the CSV library to process a large amount of data - 28 > > files, each of 130MB. Just reading in the data from one file and > > filing it into very simple data structures (numpy arrays and a > >

Re: question about class vs class at

2009-04-26 Thread grocery_stocker
On Apr 26, 2:07 pm, Arnaud Delobelle wrote: > grocery_stocker writes: > > When I do pexpect.spawn in the following example, I see > 'pexpect.spawn'> > > > [cdal...@localhost oakland]$ python > > Python 2.4.3 (#1, Oct 1 2006, 18:00:19) > > [GC

question about class vs class at

2009-04-26 Thread grocery_stocker
When I do pexpect.spawn in the following example, I see [cdal...@localhost oakland]$ python Python 2.4.3 (#1, Oct 1 2006, 18:00:19) [GCC 4.1.1 20060928 (Red Hat 4.1.1-28)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import pexpect >>> pexpect.spawn >>>

repost: http web page fetch question

2009-04-24 Thread grocery_stocker
Given the following... [cdal...@localhost oakland]$ more basic.py #!/usr/bin/python import sched import time scheduler = sched.scheduler(time.time, time.sleep) def print_event(name): print 'EVENT:', time.time(), name print 'START:', time.time() scheduler.enter(2, 1, print_event, ('firs

Re: http web fetch question

2009-04-23 Thread grocery_stocker
On Apr 23, 3:29 pm, Chris Rebert wrote: > On Thu, Apr 23, 2009 at 3:21 PM, grocery_stocker wrote: > > Say I have a script that fetches data from a website every hour. Is > > there a general solution or is the solution operating system specific? > > WRT the periodic operat

http web fetch question

2009-04-23 Thread grocery_stocker
Say I have a script that fetches data from a website every hour. Is there a general solution or is the solution operating system specific? -- http://mail.python.org/mailman/listinfo/python-list

Re: Inputting data into a website question

2009-04-21 Thread grocery_stocker
On Apr 21, 3:39 pm, Benjamin Edwards wrote: > On Apr 21, 11:10 pm, grocery_stocker wrote: > > > Let's say that I have a file with the following words > > shirt > > jeans > > belt > > jacket > > > Now I want to be able to enter these words int

Inputting data into a website question

2009-04-21 Thread grocery_stocker
Let's say that I have a file with the following words shirt jeans belt jacket Now I want to be able to enter these words into the search function at the following website.. http://oldnavy.gap.com/?redirect=true Is there some method in the urllib method that would allow me to do this? I tried goo

I'm sort of mystified by the print hex to char conversion

2009-04-18 Thread grocery_stocker
I'm just really not seeing how something like x63 and/or x61 gets converted by 'print' to the corresponding chars in the following output... [cdal...@localhost oakland]$ python Python 2.4.3 (#1, Oct 1 2006, 18:00:19) [GCC 4.1.1 20060928 (Red Hat 4.1.1-28)] on linux2 Type "help", "copyright", "cre

Re: Queue() question. This post is pretty long.

2009-04-16 Thread grocery_stocker
On Apr 16, 11:46 am, Piet van Oostrum wrote: > >>>>> grocery_stocker (g) wrote: > >g> [cdal...@localhost ~]$ python > >g> Python 2.4.3 (#1, Oct 1 2006, 18:00:19) > >g> [GCC 4.1.1 20060928 (Red Hat 4.1.1-28)] on linux2 > >g> Type "help

Re: get text from rogramms runn by subprocess.Popen immediatetly

2009-04-16 Thread grocery_stocker
On Apr 16, 4:12 am, Rüdiger Ranft <_r...@web.de> wrote: > Hi all, > > I need to call some programms and catch their stdout and stderr streams. > While the Popen class from subprocess handles the call, I get the > results of the programm not until the programm finishes. Since the > output of the pro

Queue() question. This post is pretty long.

2009-04-16 Thread grocery_stocker
I don't get how item = self.__queue.get() gets advanced to if item is None: in the following code. >>> import time >>> from threading import Thread >>> import Queue >>> >>> WORKER = 2 >>> >>> class Worker(Thread): ... def __init__(self, queue): ... Thread.__init__(self) ...

Overriding __init__() questions

2009-04-11 Thread grocery_stocker
What's the difference between doing something calling A.__init__(self) like in the following... [cdal...@localhost ~]$ python Python 2.4.3 (#1, Oct 1 2006, 18:00:19) [GCC 4.1.1 20060928 (Red Hat 4.1.1-28)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> class

Re: I can't get RLock to work (warning, the following code is pretty long)

2009-04-10 Thread grocery_stocker
On Apr 10, 8:39 am, Peter Otten <__pete...@web.de> wrote: > grocery_stocker wrote: > > On Apr 10, 6:48 am, Peter Otten <__pete...@web.de> wrote: > >> grocery_stocker wrote: > >> > When I run the following... > > >> > #!/usr/bin/pytho

Re: I can't get RLock to work (warning, the following code is pretty long)

2009-04-10 Thread grocery_stocker
On Apr 10, 6:48 am, Peter Otten <__pete...@web.de> wrote: > grocery_stocker wrote: > > When I run the following... > > > #!/usr/bin/python > > > import time > > import thread > > import threading > > > def get_first_part(strin

I can't get RLock to work (warning, the following code is pretty long)

2009-04-10 Thread grocery_stocker
When I run the following... #!/usr/bin/python import time import thread import threading def get_first_part(string, lock, sleeptime, *args): global counter lock.acquire() try: counter = counter + 1 data = counter print "%s v

Re: How come I can't get get my background thread to output anything?

2009-04-09 Thread grocery_stocker
On Apr 9, 7:01 pm, grocery_stocker wrote: > On Apr 9, 6:36 pm, grocery_stocker wrote: > > > Given the following > > > #!/usr/local/bin/python > > > import os > > import time > > import thread > > > def domsg(string, sleeptime, *args): >

Re: How come I can't get get my background thread to output anything?

2009-04-09 Thread grocery_stocker
On Apr 9, 6:36 pm, grocery_stocker wrote: > Given the following > > #!/usr/local/bin/python > > import os > import time > import thread > > def domsg(string, sleeptime, *args): > print "%s was here", string > #os.system('tel %s test&

How come I get get my background thread to output anything?

2009-04-09 Thread grocery_stocker
Given the following #!/usr/local/bin/python import os import time import thread def domsg(string, sleeptime, *args): print "%s was here", string #os.system('tel %s test' % person); #time.sleep(sleeptime) def buildlist(): out = 1 persons = [] while(out != 0):

Why doesn't StopIteration get caught in the following code?

2009-04-04 Thread grocery_stocker
Given the following [cdal...@localhost ~]$ python Python 2.4.3 (#1, Oct 1 2006, 18:00:19) [GCC 4.1.1 20060928 (Red Hat 4.1.1-28)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> def counter(): ... mylist = range(3) ... for i in mylist: ... yield i*i .

Re: Iteratoration question

2009-04-02 Thread grocery_stocker
On Apr 2, 6:33 pm, "Rhodri James" wrote: > On Fri, 03 Apr 2009 02:07:38 +0100, grocery_stocker > wrote: > > > Okay, I was thinking more about this. I think this is also what is > > irking me. Say I have the following.. > > >>>> a = [1,2,3,4] >

Re: Iteratoration question

2009-04-02 Thread grocery_stocker
On Apr 2, 4:41 pm, "andrew cooke" wrote: > Robert Kern wrote: > >> replace return with yield and it might work. > > >> i have to go eat, but if it doesn't read the python docs on iterators - > >> for examplehttp://docs.python.org/reference/expressions.html#index-1825 > > > No, .next() needs to be

Re: Iteratoration question

2009-04-02 Thread grocery_stocker
> > in summary: iterator is bound to one instance of "it", while some_func() > returns a new instance each time it is called. > > BUT > > while what you are doing is interesting, it is not the same as Python's > iterators, which use "yield" from a function and don't require storing a > value in a

iterator question

2009-04-02 Thread grocery_stocker
On Apr 2, 3:14 pm, grocery_stocker wrote: > Give the following code.. > > >>> class it: > > ...def __init__(self): > ...self.count = -1 > ...def next(self): > ...self.count +=1 > ...if self.count < 4: > ...

Iteratoration question

2009-04-02 Thread grocery_stocker
Give the following code.. >>> class it: ...def __init__(self): ...self.count = -1 ...def next(self): ...self.count +=1 ...if self.count < 4: ...return self.count ...else: ...raise StopIteration ... >>> def some_func(): ... return

Re: *args question

2009-03-25 Thread grocery_stocker
On Mar 25, 8:28 am, Tim Chase wrote: > grocery_stocker wrote: > > On Mar 25, 7:05 am, grocery_stocker wrote: > >> Given the following code... > > >> #!/usr/bin/env python > > >> import time > >> import thread > > >> def myfunction(

Re: *args question

2009-03-25 Thread grocery_stocker
On Mar 25, 7:05 am, grocery_stocker wrote: > Given the following code... > > #!/usr/bin/env python > > import time > import thread > > def myfunction(string,sleeptime,*args): > while 1: > > print string > time.sleep(sleeptime) #sleep fo

*args question

2009-03-25 Thread grocery_stocker
Given the following code... #!/usr/bin/env python import time import thread def myfunction(string,sleeptime,*args): while 1: print string time.sleep(sleeptime) #sleep for a specified amount of time. if __name__=="__main__": thread.start_new_thread(myfunction,("Thread N

What's the difference between generating a value and returning a value?

2009-03-24 Thread grocery_stocker
Taken from the url http://openbookproject.net/thinkCSpy/ch05.xhtml#index15 "The built-in functions we have used, such as abs, pow, and max, have produced results. Calling each of these functions generates a value, which we usually assign to a variable or use as part of an expression. bigge

Re: Creating Linked Lists in Python

2009-03-21 Thread grocery_stocker
On Mar 21, 10:03 am, Tim Chase wrote: > >>>transitions = { > >>> # values are tuples of (newstate, transition_function) > >>> STATE_A: [ > >>>(STATE_B, lambda x: x > 5), > >>>(STATE_C, lambda x: x > 10), > >>>(STATE_D, lambda x: x > 100), > >>>], > >>>

Re: Creating Linked Lists in Python

2009-03-21 Thread grocery_stocker
On Mar 21, 8:47 am, grocery_stocker wrote: > On Mar 21, 6:38 am, Tim Chase wrote: > > > > > > For example, this means that there can be a start node supposedly. > > > Having a value of 0. It is pointing to node 1 with the value of "a" > > > an

Re: Creating Linked Lists in Python

2009-03-21 Thread grocery_stocker
On Mar 21, 6:38 am, Tim Chase wrote: > > For example, this means that there can be a start node supposedly. > > Having a value of 0. It is pointing to node 1 with the value of "a" > > and to node 2 with the value of "b". Trying to make something like an > > NFA. Where id be changing regular expres

Re: How do I call the double() function?

2009-03-21 Thread grocery_stocker
On Mar 21, 8:21 am, Kushal Kumaran wrote: > On Mar 21, 7:55 pm, grocery_stocker wrote: > > > Given the following > > > def double(val): > > return val.bind(lambda x: val.return_(x*2)) > > > I get "AttributeError: 'int' object has no at

Re: How do I call the double() function?

2009-03-21 Thread grocery_stocker
On Mar 21, 8:11 am, John Machin wrote: > On Mar 22, 1:55 am, grocery_stocker wrote: > > > > > Given the following > > > def double(val): > > return val.bind(lambda x: val.return_(x*2)) > > > I get "AttributeError: 'int' object has

How do I call the double() function?

2009-03-21 Thread grocery_stocker
Given the following def double(val): return val.bind(lambda x: val.return_(x*2)) I get "AttributeError: 'int' object has no attribute 'bind' " when I try to do the following double(2) Below is the output... [cdal...@localhost ~]$ python Python 2.4.3 (#1, Oct 1 2006, 18:00:19) [GCC 4.

Re: get rid of duplicate elements in list without set

2009-03-20 Thread grocery_stocker
On Mar 20, 5:08 pm, grocery_stocker wrote: > On Mar 20, 8:34 am, Paul McGuire wrote: > > > On Mar 20, 9:54 am, "thomasvang...@gmail.com" > > > wrote: > > > You could use: > > > B=list(set(A)).sort() > > > Hope that helps. > > &g

Re: get rid of duplicate elements in list without set

2009-03-20 Thread grocery_stocker
On Mar 20, 8:34 am, Paul McGuire wrote: > On Mar 20, 9:54 am, "thomasvang...@gmail.com" > > wrote: > > You could use: > > B=list(set(A)).sort() > > Hope that helps. > > T > > That may hurt more than help, sort() only works in-place, and does > *not* return the sorted list.  For that you want the

Re: Where's the documentation to support the following behavior...

2009-03-17 Thread grocery_stocker
On Mar 17, 3:22 pm, Emile van Sebille wrote: > grocery_stocker wrote: > > > > > > > It seems like id(list[]) == id(). > > It might seem that way, but test with other than single-character > strings, eg lists like [7],[8],[9] and try again. > I still get t

Where's the documentation to support the following behavior...

2009-03-17 Thread grocery_stocker
Given the following [cdal...@localhost ~]$ python Python 2.4.3 (#1, Oct 1 2006, 18:00:19) [GCC 4.1.1 20060928 (Red Hat 4.1.1-28)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> list = [7,8,9] >>> id(list) -1209401076 >>> id(list[0]) 154303848 >>> id(list[

Re: Is python worth learning as a second language?

2009-03-09 Thread grocery_stocker
On Mar 9, 1:33 pm, Bruno Desthuilliers wrote: > David Cournapeau a écrit : > > > On Mon, Mar 9, 2009 at 11:33 PM, grocery_stocker wrote: > >> On Mar 9, 5:30 am, Nick Craig-Wood wrote: > >>> Go here > > >>>  http://www.diveintopython.org/ >

Re: Is python worth learning as a second language?

2009-03-09 Thread grocery_stocker
On Mar 9, 5:30 am, Nick Craig-Wood wrote: > ZikO wrote: > > I am a C++ programmer and I am thinking of learning something else > > because I know second language might be very helpful somehow. I have > > heard a few positive things about Python but I have never writen any > > single line in p

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

2007-08-04 Thread grocery_stocker
On Jul 25, 12:45 pm, [EMAIL PROTECTED] wrote: > Python is a better language, with php support, anyway, but I am fed up > with attitudes of comp.lang.perl.misc. Assholes in this newsgroup ruin > Perl experience for everyone. Instead of being helpful, snide remarks, > back-biting, scare tactings, and