Re: expression in an if statement

2010-08-19 Thread John Nagle
On 8/18/2010 3:12 PM, Thomas Jollans wrote: On Wednesday 18 August 2010, it occurred to John Nagle to exclaim: On 8/18/2010 11:24 AM, ernest wrote: Hi, In this code: if set(a).union(b) == set(a): pass Does Python compute set(a) twice? CPython does. Shed Skin might optimize. Don't kn

Re: String substitution VS proper mysql escaping

2010-08-19 Thread Nik Gr
Στις 20/8/2010 8:22 πμ, ο/η Cameron Simpson έγραψε: [...snip...] | Why does the page variable which is actually a string needs to be a | tuple or a list and not just as a string which is what it actually | is? With regard to the "%" operator, it considers the string on the left to be a format s

Re: String substitution VS proper mysql escaping

2010-08-19 Thread Cameron Simpson
On 19Aug2010 21:50, Nik Gr wrote: | Στις 19/8/2010 6:58 μμ, ο/η Tim Chase έγραψε: | >It can be written as a non-3-quote string, you just have to escape | >the inner quotes (single & double) and the backslash to be seen: | > | > name = 'My name is "Nikos" and I\'m from Thessaloniki\\Greece' | >

Assert statements in python 3.1

2010-08-19 Thread genxtech
This is more of a curiosity question then anything else... I was just wondering why in version 3 of python assertions weren't converted to use parenthesis, since print was. I am just asking because it seems the following line of code would seem more readable as a function: assert 2 + 2 == 5, "

Re: Iterative vs. Recursive coding

2010-08-19 Thread John Nagle
On 8/19/2010 2:41 PM, Thomas Jollans wrote: On Thursday 19 August 2010, it occurred to Baba to exclaim: This is not recursive. In fact, it's exactly the same approach as the first one, plus a bit of an if statement. Right. The original poster seems to be getting their ideas from "http:/

Re: 79 chars or more?

2010-08-19 Thread Steven D'Aprano
On Fri, 20 Aug 2010 15:09:39 +1200, Lawrence D'Oliveiro wrote: > In message , Terry > Reedy wrote: > >> A reason not mentioned much is that some people have trouble following >> packed lines that are too much longer. Wide-page textbooks routinely >> put text in two columns for easier reading. >

Problem with tarfile module to open *.tar.gz files - unreliable ?

2010-08-19 Thread m_ahlenius
Hi, I am relatively new to doing serious work in python. I am using it to access a large number of log files. Some of the logs get corrupted and I need to detect that when processing them. This code seems to work for quite a few of the logs (all same structure) It also correctly identifies som

Re: Using String Methods In Jump Tables

2010-08-19 Thread Tim Daneliuk
On 8/19/2010 6:41 PM, Chris Rebert wrote: > >> >> How do you get a reference to a method found in one object instance, but >> actually apply it to another instance of the same class? I'm guessing >> this may >> involve fiddling with some of the internal __ variables, but I'm not >> qu

Re: Using String Methods In Jump Tables

2010-08-19 Thread Tim Daneliuk
On 8/19/2010 7:23 PM, Steven D'Aprano wrote: > On Thu, 19 Aug 2010 18:27:11 -0500, Tim Daneliuk wrote: > >> Problem: >> >> Given tuples in the form (key, string), use 'key' to determine what >> string method to apply to the string: > table = {'l': str.lower, 'u': str.upper} table['u

Re: Iterative vs. Recursive coding

2010-08-19 Thread Steven D'Aprano
On Thu, 19 Aug 2010 22:00:16 +, Martin Gregorie wrote: > Recursion can be quite a trick to get your mind round at first Really? Do people actually find the *concept* of recursion to be tricky? If I remember correctly, my puzzlement about recursion lasted about 15 seconds. I remember thinkin

Re: Using String Methods In Jump Tables

2010-08-19 Thread Steven D'Aprano
On Thu, 19 Aug 2010 18:27:11 -0500, Tim Daneliuk wrote: > Problem: > > Given tuples in the form (key, string), use 'key' to determine what > string method to apply to the string: >>> table = {'l': str.lower, 'u': str.upper} >>> table['u']('hello world') 'HELLO WORLD' [...] > As I said, I k

Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-19 Thread Richard Harter
On Thu, 19 Aug 2010 04:14:42 -0700 (PDT), spinoza wrote: >On Aug 18, 1:44=A0am, James Kanze wrote: >> On Aug 17, 6:21 pm, Standish P wrote: >> >> > > Garbage collection doesn't use a stack. It uses a "heap", >> > > which is in the abstract a collection of memory blocks of >> > > different l

Re: extra rows in a CSV module output when viewed in excel 2007

2010-08-19 Thread JonathanB
On Aug 20, 9:10 am, MRAB wrote: > JonathanB wrote: > > On Aug 13, 3:52 pm, alex23 wrote: > >> On Aug 13, 4:22 pm, JonathanB wrote: > > >>>         writer = csv.writer(open(output, 'w'), dialect='excel') > >> I think - not able to test atm - that if you open the file in 'wb' > >> mode instead it

Re: extra rows in a CSV module output when viewed in excel 2007

2010-08-19 Thread MRAB
JonathanB wrote: On Aug 13, 3:52 pm, alex23 wrote: On Aug 13, 4:22 pm, JonathanB wrote: writer = csv.writer(open(output, 'w'), dialect='excel') I think - not able to test atm - that if you open the file in 'wb' mode instead it should be fine. changed that to writer = csv.writer(op

Re: extra rows in a CSV module output when viewed in excel 2007

2010-08-19 Thread JonathanB
On Aug 13, 3:52 pm, alex23 wrote: > On Aug 13, 4:22 pm, JonathanB wrote: > > >         writer = csv.writer(open(output, 'w'), dialect='excel') > > I think - not able to test atm - that if you open the file in 'wb' > mode instead it should be fine. changed that to writer = csv.writer(open(output,

Re: Using String Methods In Jump Tables

2010-08-19 Thread Chris Rebert
On Thu, Aug 19, 2010 at 4:27 PM, Tim Daneliuk wrote: > Problem: > >  Given tuples in the form (key, string), use 'key' to determine >  what string method to apply to the string: > >    key           operation >    --- > >     l            lower() >     u            upper() >  

Re: expression in an if statement

2010-08-19 Thread ernest
On 19 Ago, 08:40, Frederic Rentsch wrote: > On Thu, 2010-08-19 at 00:12 +0200, Thomas Jollans wrote: > > On Wednesday 18 August 2010, it occurred to John Nagle to exclaim: > > > On 8/18/2010 11:24 AM, ernest wrote: > > > > Hi, > > > > > In this code: > > > > > if set(a).union(b) == set(a): pass >

Using String Methods In Jump Tables

2010-08-19 Thread Tim Daneliuk
Problem: Given tuples in the form (key, string), use 'key' to determine what string method to apply to the string: key operation --- llower() uupper() ttitle() ... Commentary: Easy, right? Wel

Re: Reading the access attributes of directories in Windows

2010-08-19 Thread Nobody
On Fri, 20 Aug 2010 00:04:29 +0200, Thomas Jollans wrote: > This brings up an interesting, but probably quite complicated question: is it > reasonable to try to express Windows permissions using full POSIX ACLs > Do Windows NT permissions do anything more? Or, apart from the > "executable" bit,

Re: Iterative vs. Recursive coding

2010-08-19 Thread MRAB
Thomas Jollans wrote: [snip] "iterate": use a loop. and again. and again. and again. and again. and aga "recurse": consider. recurse. This is another good one: http://mytechquest.com/blog/wp-content/uploads/2010/05/From-a-Programming-Book.jpg The definition for recursion looks a lot li

Re: path to data files

2010-08-19 Thread Nobody
On Thu, 19 Aug 2010 14:30:34 +0200, Alain Ketterlin wrote: >> If a python module requires a data file to run how would I reference >> this data file in the source in a way that does not depend on whether >> the module is installed system-wide, installed in $HOME/.local or is >> just placed in a di

Re: Iterative vs. Recursive coding

2010-08-19 Thread Dave Angel
Baba wrote: Level: Beginner exercise source: http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-00-introduction-to-computer-science-and-programming-fall-2008/assignments/pset3.pdf I am looking at the first problem in the above assignment. The assignemnt deals, amongst oth

Re: Reading the access attributes of directories in Windows

2010-08-19 Thread Thomas Jollans
On Thursday 19 August 2010, it occurred to Tim Golden to exclaim: > On 19/08/2010 4:55 PM, vsoler wrote: > > I've been looking in the "os" library, and found the "os.chmod" method > > but I am not sure that it is going to give me what I need. Should I > > also used library "stat"? > > No. Both of

Re: Iterative vs. Recursive coding

2010-08-19 Thread Martin Gregorie
On Thu, 19 Aug 2010 14:12:44 -0700, Baba wrote: > Level: Beginner > > exercise source: > http://ocw.mit.edu/courses/electrical-engineering-and-computer- science/6-00-introduction-to-computer-science-and-programming-fall-2008/ assignments/pset3.pdf > > I am looking at the first problem in the abo

Re: Creating a PYD file

2010-08-19 Thread Martin v. Loewis
> (Pseudo code) > > result = arg1 + arg2 > return result For this code, the manually-written version will most likely be faster than the Pyrex-generated one. This is, most likely, because the manually-written version will assume a specific data type for the arguments (e.g. int), which Pyrex will

Re: Iterative vs. Recursive coding

2010-08-19 Thread Daniel Kluev
On Fri, Aug 20, 2010 at 8:12 AM, Baba wrote: > Level: Beginner > > exercise source: > > http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-00-introduction-to-computer-science-and-programming-fall-2008/assignments/pset3.pdf > > I am looking at the first problem in the above a

Re: Iterative vs. Recursive coding

2010-08-19 Thread MRAB
Baba wrote: Level: Beginner exercise source: http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-00-introduction-to-computer-science-and-programming-fall-2008/assignments/pset3.pdf I am looking at the first problem in the above assignment. The assignemnt deals, amongst othe

Re: Iterative vs. Recursive coding

2010-08-19 Thread Thomas Jollans
On Thursday 19 August 2010, it occurred to Baba to exclaim: > def countSubStringMatchRecursive(target,key): > counter=0 > fsi=0 #fsi=find string index > if len(key)==len(target): #base case > if key==target: >counter+=1 > elif len(key) while fsi

Re: bug? context managers vs ImportErrors

2010-08-19 Thread Benjamin Peterson
Chris Withers simplistix.co.uk> writes: > When was it introduced? It depends on how the exception was raised. -- http://mail.python.org/mailman/listinfo/python-list

Re: Reading the access attributes of directories in Windows

2010-08-19 Thread Emile van Sebille
On 8/19/2010 2:17 PM vsoler said... On Aug 19, 10:59 pm, Tim Golden wrote: I have a subversion branch for Python 3. If you have subversion access, try: http://winsys.googlecode.com/svn/branches/py3k and do the python setup.py install dance. If you can't get that working, let me know an

Re: bug? context managers vs ImportErrors

2010-08-19 Thread Chris Withers
Christian Heimes wrote: Why is 'e' ending up as a string rather than the ImportError object? This is with Python 2.6.5 if that makes a difference... It's a known bug in Python 2.6 and earlier. See http://docs.python.org/whatsnew/2.7.html#porting-to-python-2-7 When was it introduced? I've be

Re: Reading the access attributes of directories in Windows

2010-08-19 Thread vsoler
On Aug 19, 10:59 pm, Tim Golden wrote: > On 19/08/2010 9:17 PM, vsoler wrote: > > > > > On Aug 19, 8:55 pm, Tim Golden  wrote: > >> On 19/08/2010 4:55 PM, vsoler wrote: > > >>> I need to read, for each of the directories in a shared file server > >>> unit, who has access to the directories and wha

Iterative vs. Recursive coding

2010-08-19 Thread Baba
Level: Beginner exercise source: http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-00-introduction-to-computer-science-and-programming-fall-2008/assignments/pset3.pdf I am looking at the first problem in the above assignment. The assignemnt deals, amongst others, with the i

Re: Reading the access attributes of directories in Windows

2010-08-19 Thread Tim Golden
On 19/08/2010 9:17 PM, vsoler wrote: On Aug 19, 8:55 pm, Tim Golden wrote: On 19/08/2010 4:55 PM, vsoler wrote: I need to read, for each of the directories in a shared file server unit, who has access to the directories and what type of access privileges. This is something that I can easil

Re: Creating a PYD file

2010-08-19 Thread Terry Reedy
On 8/19/2010 3:41 PM, Rony wrote: is a PYD file created from C faster then a PYD file from Pyrex ? Since a .pyd file from Pyrex is also from C, the question is ill-posed. It is equivalent to "Does the C code generated by Pyrex compile to faster or slower machine code than the C code generated

Re: String substitution VS proper mysql escaping

2010-08-19 Thread John Nagle
On 8/18/2010 2:50 AM, Cameron Simpson wrote: On 18Aug2010 12:07, Nik Gr wrote: | Στις 18/8/2010 7:31 πμ, ο/η Cameron Simpson έγραψε: |>On 17Aug2010 20:15, Νίκος wrote: |>| === |>| cursor.execute( ''' SELECT host, hits, date FROM visitors WHERE page = |>| '%s' ORDER

Re: Django 1.2.1 - stuck with CSRF verification

2010-08-19 Thread Dodo
Le 19/08/2010 20:40, Thomas Jollans a écrit : On Thursday 19 August 2010, it occurred to Dodo to exclaim: Hi all, I followed the tutorial but at page 4 I can't get rid of CSRF errors, even though I followed everything in this page : http://docs.djangoproject.com/en/dev/ref/contrib/csrf/ what

Re: Reading the access attributes of directories in Windows

2010-08-19 Thread vsoler
On Aug 19, 8:55 pm, Tim Golden wrote: > On 19/08/2010 4:55 PM, vsoler wrote: > > > I need to read, for each of the directories in a shared file server > > unit, who has access to the directories and what type of access > > privileges. > > > This is something that I can easily do interactively in m

Re: Python "why" questions

2010-08-19 Thread geremy condra
On Thu, Aug 19, 2010 at 12:32 PM, Steven D'Aprano wrote: > On Thu, 19 Aug 2010 11:57:53 -0700, Russ P. wrote: > >> I don't >> know where zero-based indexing started, but I know that C used it very >> early, probably for some minuscule performance advantage. > > In C, zero based indexing was used b

tkinter

2010-08-19 Thread Eric J. Van der Velden
Hello, I have python2.7 .I have compiled tcl en tk and installed them in my home directory, say /home/eric/tcl and /home/eric/tk . I have edited $ vi Modules/Setup ... _tkinter _tkinter.c tkappinit.c -DWITH_APPINIT \ -L/home/eric/tcl/lib \ -L/home/eric/tk/lib \ -I/home/eric/tcl/include \ -I/home/

Re: Python "why" questions

2010-08-19 Thread MRAB
Russ P. wrote: Yes, apparently Basic uses one-based indexing too. For arrays, yes and no. Traditionally, DIM A(10) has 11 elements, starting at 0, although it might depend on the version of Basic. For strings, yes. As for Ada, apparently, the programmer needs to explicitly define the index r

Wing IDE 3.2.10 released

2010-08-19 Thread Wingware
Hi, Wingware has released version 3.2.10 of Wing IDE, an integrated development environment designed specifically for the Python programming language. This release includes the following improvements: * Several vi mode fixes and other key binding enhancements * Copy from selected text in Except

Re: bug? context managers vs ImportErrors

2010-08-19 Thread Christian Heimes
> Why is 'e' ending up as a string rather than the ImportError object? > > This is with Python 2.6.5 if that makes a difference... It's a known bug in Python 2.6 and earlier. See http://docs.python.org/whatsnew/2.7.html#porting-to-python-2-7 Due to a bug in Python 2.6, the exc_value parameter to

Re: String substitution VS proper mysql escaping

2010-08-19 Thread MRAB
Nik Gr wrote: [snip] Why does the page variable which is actually a string needs to be a tuple or a list and not just as a string which is what it actually is? I have a strong desire to use it like this: cursor.execute( '''SELECT hits FROM counters WHERE page = %s''' , page ) opposed to tuple.

Re: Creating a PYD file

2010-08-19 Thread Rony
Sorry that was a typo... The question actually is, is a PYD file created from C faster then a PYD file from Pyrex ? I know it will depend on how it is written, but let's imagine a tiny example, like (Pseudo code) result = arg1 + arg2 return result Tia Rony On 19 août, 20:47, Thomas Jollans

Re: Python "why" questions

2010-08-19 Thread MRAB
Russ P. wrote: On Aug 19, 11:42 am, Steven D'Aprano wrote: On Thu, 19 Aug 2010 11:03:53 -0700, Russ P. wrote: For those who insist that zero-based indexing is a good idea, why you suppose mathematical vector/matrix notation has never used that convention? I have studied and used linear algebra

Re: Python "why" questions

2010-08-19 Thread Steven D'Aprano
On Thu, 19 Aug 2010 11:57:53 -0700, Russ P. wrote: > I don't > know where zero-based indexing started, but I know that C used it very > early, probably for some minuscule performance advantage. In C, zero based indexing was used because it made pointer arithmetic elegant and reduced bugs. > Wh

Re: Python "why" questions

2010-08-19 Thread Russ P.
On Aug 19, 12:13 pm, Steven D'Aprano While businesses are conservative in which languages they choose, > language designers are not conservative in the design features they come > up with. That there has been a gradual (although as yet incomplete) > convergence towards zero-based indexing in langu

Re: Contains/equals

2010-08-19 Thread Christian Heimes
Am 19.08.2010 20:53, schrieb Tim Chase: > On 08/19/10 12:42, Steven D'Aprano wrote: >> On Thu, 19 Aug 2010 11:00:03 -0400, Alex Hall wrote: >> >>> def __eq__(self, obj): >>>if self.a==obj.a and self.b==obj.b: return True >>>return False >> >> That would be the same as: >> >> def __eq_

Re: Python "why" questions

2010-08-19 Thread AK
On 08/19/2010 02:04 PM, Steven D'Aprano wrote: On Tue, 17 Aug 2010 19:15:54 -0700, Russ P. wrote: The convention of starting with zero may have had some slight performance advantage in the early days of computing, but the huge potential for error that it introduced made it a poor choice in the

Re: Python "why" questions

2010-08-19 Thread Russ P.
Yes, apparently Basic uses one-based indexing too. As for Ada, apparently, the programmer needs to explicitly define the index range for every array. Weird. But I get the impression that one- based indexing is used much more than zero-based indexing. -- http://mail.python.org/mailman/listinfo/pyt

Re: Python "why" questions

2010-08-19 Thread Steven D'Aprano
On Thu, 19 Aug 2010 11:27:18 -0700, Russ P. wrote: [...] >> Zero-based counting doesn't entirely eliminate off-by-one errors, but >> the combination of that plus half-open on the right intervals reduces >> them as much as possible. >> >> The intuitive one-based closed interval notation used in man

Re: Python "why" questions

2010-08-19 Thread Russ P.
On Aug 19, 11:42 am, Steven D'Aprano wrote: > On Thu, 19 Aug 2010 11:03:53 -0700, Russ P. wrote: > > For those who insist that zero-based indexing is a good idea, why you > > suppose mathematical vector/matrix notation has never used that > > convention? I have studied and used linear algebra exte

Re: Reading the access attributes of directories in Windows

2010-08-19 Thread Tim Golden
On 19/08/2010 4:55 PM, vsoler wrote: I need to read, for each of the directories in a shared file server unit, who has access to the directories and what type of access privileges. This is something that I can easily do interactively in my Windows Document Explorer by right clicking a single dir

Re: Contains/equals

2010-08-19 Thread Tim Chase
On 08/19/10 12:42, Steven D'Aprano wrote: On Thu, 19 Aug 2010 11:00:03 -0400, Alex Hall wrote: def __eq__(self, obj): if self.a==obj.a and self.b==obj.b: return True return False That would be the same as: def __eq__(self, obj): return self.a==obj.a and self.b==obj.b Or,

Re: String substitution VS proper mysql escaping

2010-08-19 Thread Nik Gr
Στις 19/8/2010 6:58 μμ, ο/η Tim Chase έγραψε: It can be written as a non-3-quote string, you just have to escape the inner quotes (single & double) and the backslash to be seen: name = 'My name is "Nikos" and I\'m from Thessaloniki\\Greece' name = "My name is \"Nikos\" and I'm from Thessal

Re: Python "why" questions

2010-08-19 Thread Steven D'Aprano
On Thu, 19 Aug 2010 11:39:05 -0700, Russ P. wrote: > I just checked, and Mathematica uses one-based indexing. Apparently they > want their notation to look mathematical. Well duh. It's called MATHematica, not PROGematica. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Creating a PYD file

2010-08-19 Thread Thomas Jollans
On Thursday 19 August 2010, it occurred to Rony to exclaim: > Is a PYD file created from Pyrex faster in execution then a PYD file > created from python source ? How do you plan to create an extension module (*.so, *.pyd on Windows) from Python source then? -- http://mail.python.org/mailman/list

Re: Python "why" questions

2010-08-19 Thread Steven D'Aprano
On Thu, 19 Aug 2010 11:03:53 -0700, Russ P. wrote: > For those who insist that zero-based indexing is a good idea, why you > suppose mathematical vector/matrix notation has never used that > convention? I have studied and used linear algebra extensively, and I > have yet to see a single case of ve

Re: Django 1.2.1 - stuck with CSRF verification

2010-08-19 Thread Thomas Jollans
On Thursday 19 August 2010, it occurred to Dodo to exclaim: > Hi all, > I followed the tutorial but at page 4 I can't get rid of CSRF errors, > even though I followed everything in this page : > http://docs.djangoproject.com/en/dev/ref/contrib/csrf/ > what kind of errors? Any exception tracebacks

Re: Python "why" questions

2010-08-19 Thread Russ P.
I just checked, and Mathematica uses one-based indexing. Apparently they want their notation to look mathematical. -- http://mail.python.org/mailman/listinfo/python-list

Re: bug? context managers vs ImportErrors

2010-08-19 Thread Ethan Furman
Peter Otten wrote: Ethan Furman wrote: As an aside, does anyone know why the 2.x versions are printing the [0] as the first line? 3.1 does not. If reading the error messages carefully doesn't help scroll down for a hint;) . > . > . Look into foo.py AH hahahahahahah. That's what I get f

Re: Python "why" questions

2010-08-19 Thread Russ P.
On Aug 19, 11:04 am, Steven D'Aprano wrote: > On Tue, 17 Aug 2010 19:15:54 -0700, Russ P. wrote: > > The convention of starting with zero may have had some slight > > performance advantage in the early days of computing, but the huge > > potential for error that it introduced made it a poor choice

Django 1.2.1 - stuck with CSRF verification

2010-08-19 Thread Dodo
Hi all, I followed the tutorial but at page 4 I can't get rid of CSRF errors, even though I followed everything in this page : http://docs.djangoproject.com/en/dev/ref/contrib/csrf/ Any idea? Dorian -- http://mail.python.org/mailman/listinfo/python-list

Re: bug? context managers vs ImportErrors

2010-08-19 Thread Peter Otten
Ethan Furman wrote: > Chris Withers wrote: >> Hi All, >> >> Am I right in thinking this is a bug: >> >> class MyContextManager: >> >> def __enter__(self): >> pass >> >> def __exit__(self,t,e,tb): >> print type(t),t >> print type(e),e >> >> >> with MyContextMan

Re: Python "why" questions

2010-08-19 Thread Steven D'Aprano
On Tue, 17 Aug 2010 19:15:54 -0700, Russ P. wrote: > The convention of starting with zero may have had some slight > performance advantage in the early days of computing, but the huge > potential for error that it introduced made it a poor choice in the long > run, at least for high-level language

Re: Python "why" questions

2010-08-19 Thread Russ P.
On Aug 19, 9:07 am, "J.B. Brown" wrote: > 2010/8/9 MRAB : > > > Default User wrote: > > >> Not to prolong a good "food fight", but IIRC, many years ago in QBasic, > >> one could choose > > >> OPTION BASE 0 > > >> or > > >> OPTION BASE 1 > > When I wrote my own C++ 2-D matrix class, I wrote a membe

Re: bug? context managers vs ImportErrors

2010-08-19 Thread Ethan Furman
Chris Withers wrote: Hi All, Am I right in thinking this is a bug: class MyContextManager: def __enter__(self): pass def __exit__(self,t,e,tb): print type(t),t print type(e),e with MyContextManager(): import foo.bar.baz ...when executed, gives me: No

Re: Contains/equals

2010-08-19 Thread Steven D'Aprano
On Thu, 19 Aug 2010 11:00:03 -0400, Alex Hall wrote: > def __eq__(self, obj): > if self.a==obj.a and self.b==obj.b: return True > return False That would be the same as: def __eq__(self, obj): return self.a==obj.a and self.b==obj.b -- Steven -- http://mail.python.org/mailman/l

Re: bug? context managers vs ImportErrors

2010-08-19 Thread Steven D'Aprano
On Thu, 19 Aug 2010 16:58:30 +0100, Chris Withers wrote: > Hi All, > > Am I right in thinking this is a bug: > > class MyContextManager: > > def __enter__(self): > pass > > def __exit__(self,t,e,tb): > print type(t),t > print type(e),e > > > with MyContex

Re: Python "why" questions

2010-08-19 Thread Neil Cerutti
On 2010-08-19, J.B. Brown wrote: > When I wrote my own C++ 2-D matrix class, I wrote a member > function which did exactly this - allow you to specify the > initial index value. Then users of my class (mainly my research > lab coworkers) could specify whichever behavior they wanted. I did somethi

Python module Code returns empty list any ideas how to fix

2010-08-19 Thread Andrew Evans
Hello I am trying to modify Python xgoogle module to use yahoo I have hit a road block where I receive no error messages the code I use to test just returns an empty list. and I don't know how to trouble shoot it the module code is here http://pastebin.com/iTibRs1R and the code I am using to t

Re: Python "why" questions

2010-08-19 Thread J.B. Brown
2010/8/9 MRAB : > Default User wrote: >> >> Not to prolong a good "food fight", but IIRC, many years ago in QBasic, >> one could choose >> >> OPTION BASE 0 >> >> or >> >> OPTION BASE 1 >> When I wrote my own C++ 2-D matrix class, I wrote a member function which did exactly this - allow you to spec

ANN: eGenix mxODBC - Python ODBC Database Interface 3.1.0

2010-08-19 Thread eGenix Team: M.-A. Lemburg
ANNOUNCING eGenix.com mxODBC - Python ODBC Database Interface Version 3.1.0 mxODBC is our commercially supported Python extension providing ODBC database connectivity to Py

Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-19 Thread Keith Thompson
Standish P writes: > On Aug 18, 5:38 pm, Keith Thompson wrote: [...] >> Show me how this is relevant to comp.lang.c, comp.lang.c++, comp.theory, >> or comp.lang.python.  Please trim the Newsgroups line. > > provide a rigorous proof that people are more interested in the > nauseating nude pictures

Reading the access attributes of directories in Windows

2010-08-19 Thread vsoler
Hello everyone! I need to read, for each of the directories in a shared file server unit, who has access to the directories and what type of access privileges. This is something that I can easily do interactively in my Windows Document Explorer by right clicking a single directory, clicking on Pr

bug? context managers vs ImportErrors

2010-08-19 Thread Chris Withers
Hi All, Am I right in thinking this is a bug: class MyContextManager: def __enter__(self): pass def __exit__(self,t,e,tb): print type(t),t print type(e),e with MyContextManager(): import foo.bar.baz ...when executed, gives me: No module named foo.bar.b

Re: String substitution VS proper mysql escaping

2010-08-19 Thread Tim Chase
On 08/19/10 10:42, Nik Gr wrote: You can also prefix any of them with "r" such as file_path = r"c:\path\to\file.txt" file_path = r'c:\path\to\file.txt file_path = r"""c:\path\to\file.txt""" file_path = r'''c:\path\to\file.txt''' 'r' is to avoid escaping backslashes only or other sp

Re: How to see intermediate fail results from unittest as tests are running?

2010-08-19 Thread Margie Roginski
On Aug 19, 12:41 am, Peter Otten <__pete...@web.de> wrote: > Margie Roginski wrote: > > I am using unittest in a fairly basic way, where I have a single file > > that simply defines a class that inherits from unittest.TestCase and > > then within that class I have a bunch of methods that start with

Re: String substitution VS proper mysql escaping

2010-08-19 Thread Nik Gr
Στις 19/8/2010 2:32 μμ, ο/η Tim Chase έγραψε: (1,) + (2,) to return "(1,2)" This is actually joining two single element tuples (1,) and (2, ) to a new bigger tuple of two elements, correct? -- http://mail.python.org/mailman/listinfo/python-list

Re: String substitution VS proper mysql escaping

2010-08-19 Thread Nik Gr
Στις 19/8/2010 2:32 μμ, ο/η Tim Chase έγραψε: So Python needs a way to express that you *explicitly* mean "this is one of those rare one-element tuples, not an order of operations prioritization": (1,) + (2,) to return "(1,2)" Yes i can see the difference now!! I just had to look at the big

Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-19 Thread Richard Harter
On Wed, 18 Aug 2010 01:39:09 -0700 (PDT), Nick Keighley wrote: >On 17 Aug, 18:34, Standish P wrote: >> How are these heaps being implemented ? Is there some illustrative >> code or a book showing how to implement these heaps in C for example ? > >any book of algorithms I'd have thought > >http:

Re: Contains/equals

2010-08-19 Thread Christian Heimes
Am 19.08.2010 17:00, schrieb Alex Hall: > In Python, as I understand it, you can define this behavior. > > class c(object): > def __init__(self, a=1, b=2): > self.a=a; self.b=b > > def __eq__(self, obj): > if self.a==obj.a and self.b==obj.b: return True > return False Yes, but you have t

Re: Contains/equals

2010-08-19 Thread Alex Hall
On 8/19/10, Peter Otten <__pete...@web.de> wrote: > Karsten Wutzke wrote: > >> I have an object which has a list of other complex objects. How do I >> best achieve a complex "contains" comparison based on the object's >> class? In Java terms, I'm looking for an equivalent to equals(Object) >> in Py

Re: Contains/equals

2010-08-19 Thread Karsten Wutzke
On Aug 19, 4:47 pm, Peter Otten <__pete...@web.de> wrote: > Karsten Wutzke wrote: > > I have an object which has a list of other complex objects. How do I > > best achieve a complex "contains" comparison based on the object's > > class? In Java terms, I'm looking for an equivalent to equals(Object)

Re: Contains/equals

2010-08-19 Thread Peter Otten
Karsten Wutzke wrote: > I have an object which has a list of other complex objects. How do I > best achieve a complex "contains" comparison based on the object's > class? In Java terms, I'm looking for an equivalent to equals(Object) > in Python. Does a similar thing exist? Directions appreciated.

Re: Python "why" questions

2010-08-19 Thread Grant Edwards
On 2010-08-19, Russ P. wrote: > And I'd still like to know if the "1st" element of aList is aList[0] > or aList[1]. aList[0] -- Grant Edwards grant.b.edwardsYow! I'm definitely not at in Omaha!

Re: 79 chars or more?

2010-08-19 Thread Roald de Vries
Dear Jean-Michel, On Aug 18, 2010, at 10:57 AM, Jean-Michel Pichavant wrote: At least, if you still want to stick with 79 chars, do something like text = find(response, 'MPNExpirationDate', ).text self.expiration_date = translate_date(text,'%Y-%m-%d', '%m%d%Y') I don't necessarily like this e

Creating a PYD file

2010-08-19 Thread Rony
Is a PYD file created from Pyrex faster in execution then a PYD file created from python source ? Tia Rony -- http://mail.python.org/mailman/listinfo/python-list

Contains/equals

2010-08-19 Thread Karsten Wutzke
Hello, I have an object which has a list of other complex objects. How do I best achieve a complex "contains" comparison based on the object's class? In Java terms, I'm looking for an equivalent to equals(Object) in Python. Does a similar thing exist? Directions appreciated. Karsten -- http://ma

Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-19 Thread Anton Ertl
John Nagle writes: >In the superscalar era, there's not much of an advantage to avoiding >stack accesses. Apart from 4stack, I am not aware of a superscalar stack machine (and 4stack is more of an LIW than a superscalar). OTOH, if by stack accesses you mean memory accesses through the stack

Re: How do I make python test.py work without a syntax error msg?

2010-08-19 Thread Sergey Smirnov
I see. Your script begins with a string: $ python test.py It's not a valid python code. Maybe you just copied this text to your script accidentally. Try to delete the first string. Can you send a few first strings of your script? On Thu, Aug 19, 2010 at 17:05, Agida Kerimova wrote: > this is

Re: How do I make python test.py work without a syntax error msg?

2010-08-19 Thread Benjamin Kaplan
On Thu, Aug 19, 2010 at 8:22 AM, Agida Kerimova wrote: > I am new to programming/python and have been having some difficulties > getting started. I can't seem to run scripts without a syntax error msg. > When I drag the file to the IDLE launcher or run the module it works, but > when I actually ty

Re: How do I make python test.py work without a syntax error msg?

2010-08-19 Thread Sergey Smirnov
*when I actually * *type it I get an error msg* Did you type python commands in a bash console? In case you did, you should run python interactive console instead. Just type python in terminal window and than you'll be able interactively run statements. If you have your script saved in a file, f

Re: [Python] Unsupported Format Character '&' (0x26)

2010-08-19 Thread Chris Gonnerman
On 08/18/2010 06:35 PM, Andrew Evans wrote: I get an error message "Unsupported Format Character '&' (0x26)" I narrowed it down to these two variables any idea how to fix it? SEARCH_URL_0 = "http://search.yahoo.com/search;_ylt=A0oGdEf1XGxMJRoAUdml87UF;_ylc=X1MDMjE0MjQ3ODk0OARfcgMyBGZyA3NmcA

Re: path to data files

2010-08-19 Thread Alain Ketterlin
Daniel Fetchinson writes: > If a python module requires a data file to run how would I reference > this data file in the source in a way that does not depend on whether > the module is installed system-wide, installed in $HOME/.local or is > just placed in a directory from where the interpreter i

How do I make python test.py work without a syntax error msg?

2010-08-19 Thread Agida Kerimova
I am new to programming/python and have been having some difficulties getting started. I can't seem to run scripts without a syntax error msg. When I drag the file to the IDLE launcher or run the module it works, but when I actually type it I get an error msg. I've been told that the path to pytho

Re: String substitution VS proper mysql escaping

2010-08-19 Thread Stefan Schwarzer
Hi Νίκος, On 2010-08-19 09:10, Νίκος wrote: > On 18 Αύγ, 12:50, Cameron Simpson wrote: >> >> ("nikos",) is a single element tuple. >> ["nikos"] is a single element list. >> ["nikos",] is also a single element list, just written like the tuple. > > It makes more sense if i: > > "nikos" is just a

Re: Unsupported Format Character '&' (0x26)

2010-08-19 Thread Peter Otten
Andrew Evans wrote: > On Wed, Aug 18, 2010 at 4:35 PM, Andrew Evans wrote: > >> I get an error message "Unsupported Format Character '&' (0x26)" I >> narrowed it down to these two variables >> >> any idea how to fix it? >> >> SEARCH_URL_0 = "http://search.yahoo.com/search...?p=%(query)..." >

Re: String substitution VS proper mysql escaping

2010-08-19 Thread Tim Chase
On 08/19/10 02:10, Νίκος wrote: ("nikos",) is a single element tuple. ["nikos"] is a single element list. ["nikos",] is also a single element list, just written like the tuple. It makes more sense if i: "nikos" is just a string ("nikos") is a single element tuple ["nikos"] is also a single ele

  1   2   >