Re: [Tutor] regular expressions - backslashes

2006-04-06 Thread Kent Johnson
Justin Ezequiel wrote: > will try to convince my colleague to use string formatting > if he insists on regexp then he can do > re.sub(r'(?i)', apppath.replace('\\', ''), template) > > re.escape does not quite work for my example > re.sub(r'(?i)', re.escape(apppath), template) > 'C\\:\\n

Re: [Tutor] mysql store directory information

2006-04-06 Thread Tiago Saboga
Em Qui 06 Abr 2006 23:10, R. Alan Monroe escreveu: > > Em Qui 06 Abr 2006 15:41, Danny Yoo escreveu: > > > > model for that. But I want also to able to find these files, which are on > > removable media (cds and dvds). As I'll have to store where's the file, I > > thought I could as well store some

Re: [Tutor] mysql store directory information

2006-04-06 Thread R. Alan Monroe
> Em Qui 06 Abr 2006 15:41, Danny Yoo escreveu: > model for that. But I want also to able to find these files, which are on > removable media (cds and dvds). As I'll have to store where's the file, I > thought I could as well store some other basic infos, at least the size (I > really don't know

Re: [Tutor] mysql store directory information

2006-04-06 Thread Tiago Saboga
Em Qui 06 Abr 2006 15:41, Danny Yoo escreveu: > On Thu, 6 Apr 2006, Tiago Saboga wrote: > > As a first part of a project, I need to store a directory tree in a > > mysql db. I'm wondering if there is a canonical way of doing that. I > > don't know if it's an appropriate question for this list, but

Re: [Tutor] regular expressions - backslashes

2006-04-06 Thread Justin Ezequiel
Kent wrote: """The problem is that the re engine itself is interpreting the backslashes in the replacement pattern. With a single slash you get a newline even though the slash is a literal in the replacement string: So if you want a literal \ in your replacement text you have to escape the \, ev

Re: [Tutor] request for sugestions on fragement of code for generating truth-tables

2006-04-06 Thread Brian van den Broek
Danny Yoo said unto the world upon 06/04/06 04:38 PM: > Yes, I agree that the readability of the code is primary. Understandng > the recursive approach depends on the reader's comfort with recursive > functions, and the non-recursive code depends on the reader's comfort with > arithmetic operat

Re: [Tutor] Logical Operaor

2006-04-06 Thread Brian van den Broek
Kaushal Shriyan said unto the world upon 06/04/06 08:06 AM: > Hi > > I am referring to http://www.ibiblio.org/obp/thinkCSpy/chap04.htm > about Logical operators > > I didnot understood > > x = 5 x and 1 > > 1 > y = 0 y and 1 > > 0 > > How 5 and 1 means 1 and 0 and 1 mean

Re: [Tutor] Tutor Digest, Vol 25, Issue 83

2006-04-06 Thread Janesh Ramakrishnan
Hi Kent: Thanks for your response. The Grep function does a really good job of searching across .py files in a directory or subdirectories for the specific keyword/string. In the PythonWin interpreter 2.1, Go to File -> New -> Grep and the search string can be entered. It is useful in searchi

Re: [Tutor] request for sugestions on fragement of code for generating truth-tables

2006-04-06 Thread Danny Yoo
> One way to get rid of the 'recursed' flag is to refactor slightly, and > break out the sorting in another helper function, like this: > > ## > def tva_dict_maker(atoms): > tvas = tiva_helper(atoms) ^^^ >

Re: [Tutor] request for sugestions on fragement of code for generating truth-tables

2006-04-06 Thread Danny Yoo
> Your post got me to take another bash and I obtained a recursive > solution. But, subject to the caveat that my recursive solution might > well be non-optimal, the non-recursive approach seems a bit better to > me. Opinions welcome :-) > > My recursive solution: > > def recursive_tva_dict_maker(a

Re: [Tutor] request for sugestions on fragement of code for generating truth-tables

2006-04-06 Thread Brian van den Broek
Orri Ganel said unto the world upon 01/04/06 03:04 PM: > Brian van den Broek wrote: >> Then, the output is like so: >> >> >>> atoms = ["a","b","c"] >> >>> tvas = tva_dict_maker(atoms) >> >>> display_tvas(tvas) >> a:Trueb:Truec:True >> a:Trueb:Truec:False >> a:Trueb:Fals

Re: [Tutor] request for sugestions on fragement of code for generating truth-tables

2006-04-06 Thread Brian van den Broek
Danny Yoo said unto the world upon 31/03/06 08:27 PM: > >>Then, the output is like so: >> >> >>> atoms = ["a","b","c"] >> >>> tvas = tva_dict_maker(atoms) >> >>> display_tvas(tvas) >>a:Trueb:True c:True >>a:Trueb:True c:False >>a:Trueb:False c:True >>a:Trueb:False

Re: [Tutor] mysql store directory information

2006-04-06 Thread Danny Yoo
On Thu, 6 Apr 2006, Tiago Saboga wrote: > As a first part of a project, I need to store a directory tree in a > mysql db. I'm wondering if there is a canonical way of doing that. I > don't know if it's an appropriate question for this list, but I think > it's not only a choice of db design, but

[Tutor] mysql store directory information

2006-04-06 Thread Tiago Saboga
Hi! As a first part of a project, I need to store a directory tree in a mysql db. I'm wondering if there is a canonical way of doing that. I don't know if it's an appropriate question for this list, but I think it's not only a choice of db design, but also a choice of appropriate python tools.

Re: [Tutor] Logical Operators

2006-04-06 Thread Carroll, Barry
Greetings, Kaushal: There are two topics to understand here: 1. what "TRUE" and "FALSE" mean in Python, and 2. how Python evaluates "X and Y". The tutorial "Instant Python" by Magnus Lie Hetland has good, short descriptions of these two topics, so I'll borrow from it. You can find the doc

Re: [Tutor] Logical Operators

2006-04-06 Thread Alan Gauld
> I am referring to http://www.ibiblio.org/obp/thinkCSpy/chap04.htm > about Logical operators > You might find the functional programming topic in my tutorial interesting for a comparison. Look at the subsection "Short Circuit Evaluation" for some relevant examples. > I did not understood >>>

Re: [Tutor] preliminary app design question

2006-04-06 Thread Ron Phillips
You might also consider JSON (http://www.json.org), which is generally lighter weight than XML, fairly human-readable, and useful in several languages (most, anymore) . Python, Javascript, and ECMAScript use it natively through Eval(), if you don't have security concerns; or through a wrapper if se

Re: [Tutor] Logical Operaor

2006-04-06 Thread Jason Keen
In python, any nonzero number is considered to mean "True". Zero is considered to be "False". The "and" logical operation evaluates to "True" only if both terms are true. On 4/6/06, Kaushal Shriyan <[EMAIL PROTECTED]> wrote: > Hi > > I am referring to http://www.ibiblio.org/obp/thinkCSpy/chap04.

[Tutor] Logical Operaor

2006-04-06 Thread Kaushal Shriyan
Hi I am referring to http://www.ibiblio.org/obp/thinkCSpy/chap04.htm about Logical operators I didnot understood >>> x = 5 >>> x and 1 1 >>> y = 0 >>> y and 1 0 How 5 and 1 means 1 and 0 and 1 means 0 Thanks Regards Kaushal ___ Tutor maillist

Re: [Tutor] preliminary app design question

2006-04-06 Thread Kent Johnson
Richard Querin wrote: > > On 4/5/06, *Alan Gauld* <[EMAIL PROTECTED] > > wrote: > > Sounds like creating each app as a class which can be instantiated on > demand by the master application would be a possible design option. > > I guess writing the master progr

Re: [Tutor] OR operator?

2006-04-06 Thread Alan Gauld
> I'm trying with this operator, could it possible? > > fruit1 = 'apple' > fruit2 = 'orange' > > fruits = fruit1 or fruit2 > > is 'orange' = fruits ? Why not just try it at the python prompt?! And you would find that no, fruits = 'apple' (The order is because fruits is a name which references

Re: [Tutor] preliminary app design question

2006-04-06 Thread Alan Gauld
>> The class approach coupled to a config XML file would do this. > > Define a file that looks something like >> >> >> >> My Foo App >> >> >>MyName >> >So for the master program this makes sense. However, what about the >

Re: [Tutor] preliminary app design question

2006-04-06 Thread Richard Querin
On 4/5/06, Hugo González Monteverde <[EMAIL PROTECTED]> wrote: Now seriously. Are there file formats meant to be used and understood byother programs in principle (we know it is a nice feature, but is itnecessary?)?There will be input data and output results from program A that may be utilized by p

Re: [Tutor] preliminary app design question

2006-04-06 Thread Richard Querin
On 4/5/06, Alan Gauld <[EMAIL PROTECTED]> wrote: Sounds like creating each app as a class which can be instantiated ondemand by the master application would be a possible design option.I guess writing the master program (or some simplified version of it) would be required from the start in order to

[Tutor] Logical Operators

2006-04-06 Thread Kaushal Shriyan
Hi I am referring to http://www.ibiblio.org/obp/thinkCSpy/chap04.htm about Logical operators I didnot understood >>> x = 5 >>> x and 1 1 >>> y = 0 >>> y and 1 0 How 5 and 1 means 1 and 0 and 1 means 0 Thanks Regards Kaushal ___ Tutor maillist

Re: [Tutor] testing u=unicode(str, 'utf-8') and u = str.decode('utf-8')

2006-04-06 Thread Kent Johnson
Keo Sophon wrote: > Hi, > > Today i tested u=unicode(str,'utf-8') and u=str.decode('utf-8'). Then in both > case I used: > > if isinstance(u,str): >print "just string" > else: > print "unicode" > > the result of both case are "unicode". So it seems u=unicode(str,'utf-8') and > u=str.deco

Re: [Tutor] regular expressions - backslashes

2006-04-06 Thread Kent Johnson
Justin Ezequiel wrote: > a colleague demonstrated a problem he had with regular expressions > apppath = os.path.abspath(os.curdir) apppath > 'C:\\napp_and_author_query\\napp_and_author_query\\a b c d' template = r'\files' template > '\\files' re.sub(r'(?i)', apppath, templ

Re: [Tutor] Urgent question about program debugging

2006-04-06 Thread Alan Gauld
> father_son = {"Kirk Douglas" : "Michael Douglas", > "James Brolin" : "Josh Brolin", > "Bob Dylan" : "Jakob Dylan"} > >elif choice == "2": >print "LIST OF ALL FATHERS\n" >for father_son in father_son: >print father_son You are replacing

Re: [Tutor] What's the invalid syntax?

2006-04-06 Thread Alan Gauld
> What's the invalid syntax in the following code? I tried figuring it out > by > myself, and I couldn't. > > # Inspired by Programming and Problem Solving with Java, 1st ed., question > def date(): >int year >year = int(raw_input("Year please: ")) > The editor highlights the word year in