[Tutor] Unit-testing advice

2010-03-08 Thread mhw
Dear All, Quick UT question. I am working on a CSV processing script. I want to write some tests. The tests will need to read in, manipulate and write out some CSV files. My instinct is to manually construct some small data files, and consider them as part of the test suite. The other option

Re: [Tutor] Unit-testing advice

2010-03-08 Thread C.T. Matsumoto
m...@doctors.net.uk wrote: Dear All, Quick UT question. I am working on a CSV processing script. I want to write some tests. The tests will need to read in, manipulate and write out some CSV files. My instinct is to manually construct some small data files, and consider them as part of the t

Re: [Tutor] Passing nested structures to fcntl.ioctl

2010-03-08 Thread spir
On Mon, 8 Mar 2010 11:57:35 +0530 (IST) "Noufal Ibrahim" wrote: > Hello everyone, > I have some code that's calling fcntl.ioctl. I need to pass a nested > structure as the 3rd argument of the function. Something like this > > typedef struct coordinates{ > int x; > int y; > } coordinates;

[Tutor] Read XML records one by one

2010-03-08 Thread Hichiro
-- Best regards, Vinh NV CNPM K50 DHBKHN Y!: Vinh.dhbk Sky : Vinh.dhbk 84 976 314 988 ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

[Tutor] Read XML records one by one

2010-03-08 Thread Hichiro
Hi all! I'm trying to read one by one record in XML file to find out its tag and attribute for schema matching. But I haven't done yet. So, could you help me?! Thanks so much! :) -- Best regards, Vinh NV CNPM K50 DHBKHN Y!: Vinh.dhbk Sky : Vinh.dhbk 84 976 314 988 __

Re: [Tutor] Printing time without "if" statement

2010-03-08 Thread spir
On Mon, 8 Mar 2010 18:03:12 +1100 Steven D'Aprano wrote: > On Mon, 8 Mar 2010 03:38:49 pm Elisha Rosensweig wrote: > > Hi, > > > > I have an event-based simulator written in Python (of course). It > > takes a while to run, and I want to have messages printed every so > > often to the screen, indi

[Tutor] Communicate between a thread and the main program

2010-03-08 Thread Plato P.B.
Hi all, I have created a script in which i need to implement the communication between the main program and a thread. The thread looks for any newly created files in a particular directory. It will be stored in a variable in the thread function. I want to get that name from the main program. How ca

Re: [Tutor] Read XML records one by one

2010-03-08 Thread Stefan Behnel
Hichiro, 08.03.2010 10:48: I'm trying to read one by one record in XML file to find out its tag and attribute for schema matching. But I haven't done yet. So, could you help me?! You were not very specific about your data, neither did you provide enough information about your use case to under

Re: [Tutor] WSGI / Apache

2010-03-08 Thread Benno Lang
On 5 March 2010 04:37, Giorgio wrote: > Hi, > > as you all probably know i'm using the Google App Engine platform for my > python code. > > As I learn python i try to understand more and more how GAE works. Today > i've noticed that all applications on GAE are running on WSGI. A quick > Google sea

Re: [Tutor] Communicate between a thread and the main program

2010-03-08 Thread Dave Angel
Plato P.B. wrote: Hi all, I have created a script in which i need to implement the communication between the main program and a thread. The thread looks for any newly created files in a particular directory. It will be stored in a variable in the thread function. I want to get that name from the

[Tutor] variable inheritance

2010-03-08 Thread spir
Hello, Say I have a Tree type that may be based on 2 kinds of Node-s. Both conceptually and practically, a tree itself is a node, namely the top/root one. But a tree also has some additional tree-level behaviour, which is independant of the kind of node. Say, the node type performs all the unde

[Tutor] Really learn programming

2010-03-08 Thread Wayne Werner
As I was reading my favorite webcomics, Abstruse Goose had a link to this interesting site about programming in 21 days (or not). http://norvig.com/21-days.html I thought it was rather interesting (and it also recommends Python ;) enjoy, -Wayne -- To be considered

[Tutor] Use ZODB or Durus to store Python-objects?

2010-03-08 Thread Karjer Jdfjdf
I'm using pickle more often in my programs and now I store them as files. I want to store them in ZODB or Durus to prevent losing sight of where I store what pickled object. Which one is the best one to use? I've never worked with either one, so I would like to have some opinions. I want to ac

Re: [Tutor] variable inheritance

2010-03-08 Thread Hugo Arts
On Mon, Mar 8, 2010 at 1:57 PM, spir wrote: > Hello, > > Say I have a Tree type that may be based on 2 kinds of Node-s. Both > conceptually and practically, a tree itself is a node, namely the top/root > one. But a tree also has some additional tree-level behaviour, which is > independant of th

[Tutor] matching words from a text to keys in a dictionary

2010-03-08 Thread Karjer Jdfjdf
I want to compare words in a text to a dictionary with values attached to the words. The dictionary  looks like: { word1: [1,2,3] word2: [2,3,4,a,b ] ... } I'm trying to find a way to achieve this, but I'm having trouble getting corrects results. If I do the def below, nothing is matched. def

[Tutor] Making Regular Expressions readable

2010-03-08 Thread Stephen Nelson-Smith
Hi, I've written this today: #!/usr/bin/env python import re pattern = r'(?P^(-|[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}(, [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})*){1}) (?P(\S*)) (?P(\S*)) (?P(\[[^\]]+\])) (?P(\"([^"\\]*(?:\\.[^"\\]*)*)\")?) (?P(\S*)) (?P(\S*)) (?P(\"([^"\\]*(?:\\

Re: [Tutor] matching words from a text to keys in a dictionary

2010-03-08 Thread Andre Engels
On Mon, Mar 8, 2010 at 5:05 PM, Karjer Jdfjdf wrote: > I want to compare words in a text to a dictionary with values attached to > the words. > > The dictionary looks like: > { word1: [1,2,3] word2: [2,3,4,a,b ] ... } > Please give the actual dictionary, not something that it 'looks like' - an

[Tutor] Fwd: [XML-SIG] Read XML records one by one

2010-03-08 Thread Hichiro
On Mon, Mar 8, 2010 at 5:40 PM, Stefan Behnel wrote: > Hichiro, 08.03.2010 10:44: > >> I'm trying to read one by one record in XML file to find out its tag and >> >> attribute for schema matching. But I haven't done yet. So, could you help >> me?! >> > > Hi, > > since it appears that you cross-po

Re: [Tutor] Read XML records one by one

2010-03-08 Thread Glen Zangirolami
Another alternative to parsing XML is beautiful soup. Website: http://www.crummy.com/software/BeautifulSoup/ Documentation for parsing xml: http://www.crummy.com/software/BeautifulSoup/documentation.html#Parsing%20XML sample code: from BeautifulSoup import BeautifulStoneSoup xml = "Contents 1Con

Re: [Tutor] Communicate between a thread and the main program

2010-03-08 Thread Glen Zangirolami
I think you can use Queue to communicate between threads. "The Queue module implements multi-producer, multi-consumer queues. It is especially useful in threaded programming when information must be exchanged safely between multiple threads" http://docs.python.org/library/queue.html On Mon, Mar

Re: [Tutor] matching words from a text to keys in a dictionary

2010-03-08 Thread spir
On Mon, 8 Mar 2010 08:05:54 -0800 (PST) Karjer Jdfjdf wrote: > I want to compare words in a text to a dictionary with values attached to the > words. > > The dictionary  looks like: > { word1: [1,2,3] word2: [2,3,4,a,b ] ... } And how does your source text look like? (we have half of the data)

Re: [Tutor] matching words from a text to keys in a dictionary

2010-03-08 Thread Karjer Jdfjdf
>>  I want to compare words in a text to a dictionary with values attached to >> the words. >> >> The dictionary  looks like: >> { word1: [1,2,3] word2: [2,3,4,a,b ] ... } >> > >Please give the actual dictionary, not something that it 'looks like' - an >actual dictionary would never 'look like' thi

[Tutor] Resetting the namespace

2010-03-08 Thread Patrick Sabin
I found this piece of code, which completely puzzles me, in the pdb module of the trunk: class Pdb(bdb.Bdb, cmd.Cmd): ... def _runscript(self, filename): # The script has to run in __main__ namespace (or imports from # __main__ will break). # # So we clear

Re: [Tutor] Making Regular Expressions readable

2010-03-08 Thread spir
On Mon, 8 Mar 2010 16:12:35 + Stephen Nelson-Smith wrote: > Hi, > > I've written this today: > > #!/usr/bin/env python > import re > > pattern = > r'(?P^(-|[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}(, > [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})*){1}) > (?P(\S*)) (?P(\S*)) > (?P(

Re: [Tutor] Making Regular Expressions readable

2010-03-08 Thread member thudfoo
On Mon, Mar 8, 2010 at 9:34 AM, spir wrote: > On Mon, 8 Mar 2010 16:12:35 + > Stephen Nelson-Smith wrote: > >> Hi, >> >> I've written this today: >> >> #!/usr/bin/env python >> import re >> >> pattern = >> r'(?P^(-|[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}(, >> [0-9]{1,3}\.[0-9]{1,3}\.[

Re: [Tutor] matching words from a text to keys in a dictionary

2010-03-08 Thread Karjer Jdfjdf
I brew this up. It works, but I think it will be slow with a long text and a big dictionary def searchWord(text, dictionary):     '''search for terms in dictionary(key) and retrieve value(keywords)'''     text = text.split()     w = []     for word in text:     if word in dictionary:

Re: [Tutor] Really learn programming

2010-03-08 Thread Alan Gauld
"Wayne Werner" wrote a link to this interesting site about programming in 21 days (or not). http://norvig.com/21-days.html I thought it was rather interesting Indeed, although I disagree with some of it. (Including some of his "Answers") And it focusses on programming only, which is a b

Re: [Tutor] variable inheritance

2010-03-08 Thread Alan Gauld
"spir" wrote Say I have a Tree type that may be based on 2 kinds of Node-s. Both conceptually and practically, a tree itself is a node, namely the top/root one. Thats one way to do it... But a tree also has some additional tree-level behaviour, which is independant of the kind of node.

Re: [Tutor] Really learn programming

2010-03-08 Thread Albert-Jan Roskam
This very funny cartoon is about learning C++ in 21 days, but it could be about any language: http://high5.net/comic/AG/ars_longa_vita_brevis.PNG Cheers!! Albert-Jan ~~ In the face of ambiguity, refuse the temptation to gue

Re: [Tutor] Really learn programming

2010-03-08 Thread Jeff Johnson
Wayne Werner wrote: As I was reading my favorite webcomics, Abstruse Goose had a link to this interesting site about programming in 21 days (or not). http://norvig.com/21-days.html I thought it was rather interesting (and it also recommends Python ;) enjoy, -Wa

[Tutor] for _ in

2010-03-08 Thread Joson
Hi all, source code as below puzzles me: def make_sparse_labeled_tensor(ndim, labels=None, initial=None, accumulate=None, normalize=False): if labels is None: labels = [OrderedSet() for _ in xrange(ndim)] .. It's a