Re: Why do Pythoneers reinvent the wheel?

2005-09-09 Thread Stefano Masini
On 10 Sep 2005 02:10:59 EDT, Tim Daneliuk <[EMAIL PROTECTED]> wrote: > As someone who implemented their own configuration mini-language > with validation, blah, blah, blah > (http://www.tundraware.com/Software/tconfpy/) Well, a configuration mini language with validation and blahs is not exactly

Re: nested tuples

2005-09-09 Thread Tim Roberts
"Luis P. Mendes" <[EMAIL PROTECTED]> wrote: > >I'm trying to solve this problem: > >suppose I'm reading a csv file and want to create a tuple of all those >rows and values, like ((row1value1, row1value2, row1value3),(row2value1, >row2value2, row2value3),..., (rowNvalue1, rowNvalue2, rowNvalue3)) >

Re: Python compiled?

2005-09-09 Thread Tim Roberts
"billiejoex" <[EMAIL PROTECTED]> wrote: > >Hi all. I'm sorry for a noob question like this but I'll try to ask it >anyway. >One of the greatest problem that may discourage a new user to choose Python >language is it's interpreted nature. I doubt it. C#, VB.NET, VBscript, Javascript and Perl hav

Re: Why do Pythoneers reinvent the wheel?

2005-09-09 Thread Tim Daneliuk
Stefano Masini wrote: > I wonder how many people (including myself) have implemented their own > versions of such modules, at least once in their pythonic life. I > indeed have my own odict (even same name! :). My own pathutils > (different name, but same stuff). My own validate... and so forth.

Re: Why do Pythoneers reinvent the wheel?

2005-09-09 Thread Stefano Masini
On 9/9/05, Dave Brueck <[EMAIL PROTECTED]> wrote: > shot). The cost of developing _exactly_ what you need often is (or at least > *appears* to be) the same as or lower than bending to use what somebody else > has > already built. That's right. But as you say, this is _often_ the case, not always.

Re: Yielding a chain of values

2005-09-09 Thread [EMAIL PROTECTED]
I'm not really worry that much over O(n^2) performace (especially having optimized some O(n^3) SQL operations :-o !) The things is this really should be an O(n) operation. Having a yield all statement or expression is useful in its own right and also potentially a way to optimized away the O(n^2)

Re: python object model diagram

2005-09-09 Thread Peter Hansen
gene tani wrote: > I think he's looking for tidy pictures of how metaclasses and > descriptors interact with your classes and instances at compile- & > runtime, something like that (which I haven't seen) > > There's pictures of the class hierarchy for C and j-python: > > http://www.brpreiss.com/b

Re: OOP Newb

2005-09-09 Thread James Stroud
Work through the appropriate chapters of this free book: http://www.ibiblio.org/obp/thinkCSpy/ "How to Think Like a Computer Scientist" James On Friday 09 September 2005 18:47, MilkmanDan wrote: > I've been learning python for a while. It's awesome. My problem is > that I don't know anything a

Re: Python Design Principles

2005-09-09 Thread Neal Norwitz
[EMAIL PROTECTED] wrote: > > But I am still puzzled by the argument that has been given for why > methods that operate on mutable types should return None, namely, that > the designers of python didn't want the users to shoot themselves in > the foot by thinking a method simply returned a result an

[OT] Re: "grep" database

2005-09-09 Thread Ara . T . Howard
On Fri, 9 Sep 2005, Hilbert wrote: > Hello, > > I've heard of a software on linux that creates a recursive database of > text files and then provides an interface for grep-like queries. I'd > like to use it to find procedures/variables in a large code base. > > Any suggestions appreciated. > > Th

Re: Create new instance of Python class in C

2005-09-09 Thread phil hunt
On Fri, 9 Sep 2005 18:50:26 +0200, Sybren Stuvel <[EMAIL PROTECTED]> wrote: >djw enlightened us with: >> Personally, I would try Psyco first, and consider Pyrex next. > >Ok, I'll take a look at those. > >> Are you sure your algorithm can't be optimized first, before you >> start trying to write thi

Re: Create new instance of Python class in C

2005-09-09 Thread phil hunt
On Fri, 9 Sep 2005 17:19:21 +0200, Sybren Stuvel <[EMAIL PROTECTED]> wrote: >Hi people, > >I'm creating a program that can solve and create Sudoku puzzles. My >creation function needs to make a lot of copies of a puzzle. Why do you need to maske lots of copies? And when you say "lots of" what numb

Re: Redundant code in multiple methods

2005-09-09 Thread Sam Pointon
How about using a class, with __call__, as a wrapper instead of the function itself? class FunctionWrapper(object): def __init__(self, cls, function): self._function = function self._cls = cls def __call__(self, *args, **kwargs): REQUEST = self.REQUEST SE

Re: Python linear algebra module -- requesting comments on interface

2005-09-09 Thread Bengt Richter
On Fri, 9 Sep 2005 04:58:43 -0700 (PDT), "C. Barnes" <[EMAIL PROTECTED]> wrote: > >Hi, I'm in the process of writing a Python linear >algebra module. > >The current targeted interface is: > > http://oregonstate.edu/~barnesc/temp/linalg/ > >The interface was originally based on Raymond >Hettinger'

Re: where is sys.path initialized?

2005-09-09 Thread Steve M
The PYTHONPATH environment variable is good for that. For general customizing beyond the path, you can make a file called: C:\Python24\Lib\site-packages\sitecustomze.py and it will be executed every time python runs. It might look like this: import sys sys.path.insert(0, r'C:\Python24\mypython')

OOP Newb

2005-09-09 Thread MilkmanDan
I've been learning python for a while. It's awesome. My problem is that I don't know anything about object oriented programming. I can't seem to find any tutorials either, everything kind of assumes a basic knowledge of the subject. I have managed to figure out a few things, like what a class an

Re: "grep" database

2005-09-09 Thread gene tani
maybe look Gonzui, LXR, some of the other tools listed here http://www.gnu.org/software/global/links.html Hilbert wrote: > Hello, > > I've heard of a software on linux that creates a recursive database of > text files and then provides an interface for grep-like queries. I'd > like to use it to

Re: python and ARCView GIS desktop

2005-09-09 Thread Andrew MacIntyre
GISDude wrote: > hi all. I am a newbie, so be kind. > I am using ARCView GIS 9.1 and python win. I am trying to develop a > module using the GZIP module in my ARCView map session. What I am > attempting to do (I think) is use the zip mod to zip up all the files > in a .mxd document into one neat li

Re: python object model diagram

2005-09-09 Thread Ara . T . Howard
On Fri, 9 Sep 2005, gene tani wrote: > I think he's looking for tidy pictures of how metaclasses and > descriptors interact with your classes and instances at compile- & > runtime, something like that (which I haven't seen) > > There's pictures of the class hierarchy for C and j-python: > > http:/

Re: python object model diagram

2005-09-09 Thread Mike
I think he's looking for diagrams of the batteries-included modules and classes. My guess is that he thinks there's a set of "framework" classes that is a lot deeper and class-ier than it is, similar to what you'd find in C++, C#, Java, etc. So, OP - who won the guessing game :) m "gene tani

Re: python object model diagram

2005-09-09 Thread gene tani
I think he's looking for tidy pictures of how metaclasses and descriptors interact with your classes and instances at compile- & runtime, something like that (which I haven't seen) There's pictures of the class hierarchy for C and j-python: http://www.brpreiss.com/books/opus7/html/page114.html ht

Re: global variables shared across modules

2005-09-09 Thread Patrick Maupin
MackS wrote: > print "inside fun(): " + global_var ... > How can I get the changed value to "persist" in such a way that it > isn't reset when control leaves fun()? Why is it even reset in the > first place? After all, the module has already been imported (and the > initialization of global_va

Re: where is sys.path initialized?

2005-09-09 Thread Peter Hansen
Alex wrote: > No one is answering this question. Why, is it a bit unclear or what? No, but if you really expected a response in only four hours you need a reality check. Many people don't receive Usenet articles for a day or two, possibly longer, and in any case many people don't *check* their

global variables shared across modules

2005-09-09 Thread MackS
Hello everyone Consider the following two simple files. The first is my "program", the other a file holding some global variable definitions and code shared by this program and a "twin" program (not shown here): program1.py: from shared import * fun() print "at top level: " + glo

Re: Re: error processing variables

2005-09-09 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, el chupacabra wrote: >>Your problem is that the def statement reassignes the name "toHPU" to a >>function instead of a string. So when the code runs, you're passing a >>function object to s.copy2. > > So...how do fix it? Don't give two different objects the same name!?

Re: Possible improvement to slice opperations.

2005-09-09 Thread Ron Adam
Michael Hudson wrote: > Ron Adam <[EMAIL PROTECTED]> writes: >>With current slicing and a negative step... >> >>[ 1 2 3 4 5 6 7 8 9 ] >> -9 -8 -7 -6 -5 -4 -3 -2 -1 -0 >> >>r[-3:] -> [7, 8, 9]# as expected >>r[-3::-1] -> [7, 6, 5, 4, 3, 2, 1, 0] # surprise >> >

Re: Re: error processing variables

2005-09-09 Thread el chupacabra
>Your problem is that the def statement reassignes the name "toHPU" to a >function instead of a string. So when the code runs, you're passing a >function object to s.copy2. So...how do fix it? >> import shutil >> >> #variables >> s = shutil >> >> toHPU = "/etc/sysconfig/network/toHPU.wifi" >

Re: using % operator to print possibly unitialized data attributes

2005-09-09 Thread François Pinard
[Adam Monsen] > The following code uses the % operator to print possibly unitialized > data attributes: > 8< > class J: > name = '' > value = '' > def __str__(self): > vals = self.__class__.__dict__ > vals.update(self.__di

Re: where is sys.path initialized?

2005-09-09 Thread Robert Kern
Alex wrote: > No one is answering this question. Why, is it a bit unclear or what? Have patience. No one's getting paid to answer your questions. http://docs.python.org/tut/node8.html#SECTION00811 -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass grows hig

Re: py2app and Bittornado

2005-09-09 Thread kooto (sent by Nabble.com)
bsharitt wrote: You wouldn't happen to know a nice way to interact with the PythonMac-SIG group without subscribing and subjecting my inbox to rape by a bunch of useless messages would you? Check out Nabble - for python-list@python.org - there is a searchable bi-directional archive/forum http:/

Re: where is sys.path initialized?

2005-09-09 Thread Alex
No one is answering this question. Why, is it a bit unclear or what? All I wanted to do was to add the path C:\Python24\mypython to the sys.path so that I could put all my stuff there instead of mixing it with the stuff that comes with the installation. And I wanted to do it permanently som that I

Re: List of integers & L.I.S. (SPOILER)

2005-09-09 Thread Bryan Olson
n00m wrote: > It also timed out:( Could be. Yet you did write: > It's incredibly fast! I never intended to submit this program for competition. The contest ranks in speed order, and there is no way Python can compete with truly-compiled languages on such low-level code. I'd bet money that t

Re: OpenSource documentation problems

2005-09-09 Thread Mike Meyer
Florian Diesch <[EMAIL PROTECTED]> writes: > A.M. Kuchling <[EMAIL PROTECTED]> wrote: > Another problem with Wikis is that you have to be online to use them and > can't use your favourite editor to write. You need a better browser. Mine - at least on Unix - have an option to dump textareas into te

Re: error processing variables

2005-09-09 Thread infidel
> import shutil > > #variables > s = shutil > > toHPU = "/etc/sysconfig/network/toHPU.wifi" > wlan = "/etc/sysconfig/network/ifcfg-wlan-id-00:0e:38:88:ba:6d" > toAnyWifi = "/etc/sysconfig/network/toAny.wifi" > wired = "/etc/sysconfig/network/ifcfg-eth-id-00:0b:db:1b:e3:88" > > > def toHPU(): > > >

Re: python object model diagram

2005-09-09 Thread Peter Hansen
Ara.T.Howard wrote: > > anyone out there know where i might find a python object model diagram? Python is a programming language; they don't have object model diagrams. Or maybe you're referring to the Python *source* code? That's in C, which isn't object oriented and wouldn't have an object m

Re: simple problem with os.rename() parameters - path with spaces

2005-09-09 Thread Peter Hansen
Tom wrote: > I'm having a problem using a path with spaces as a parameter to > os.rename() in a program on WinXP. > > This works fine at the command line (where the folder "c:\aa bb" exists) > > > os.rename( "c\aa bb", "c:\cc dd" ); > > > > But, I can't get it to work in my program, eg. > >

Re: Question about consistency in python language

2005-09-09 Thread Kay Schluehr
Terry Reedy wrote: > "Kay Schluehr" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > On the other hand there exists no sorted() method for tuples or lists > > like join() for strings but it is implemented as a function in Python24 > > that returns a new sorted container. I consider

Re: Yielding a chain of values

2005-09-09 Thread Terry Reedy
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >>>unless you are going many levels deep > (and that's usually a design smell of some kind) > > No, its not a bug. its a feature! See the discussion in the recursive > generator thread below: http://groups.google.com/group/comp.lang.pyth

Re: "grep" database

2005-09-09 Thread Mike Meyer
"Hilbert" <[EMAIL PROTECTED]> writes: > I've heard of a software on linux that creates a recursive database of > text files and then provides an interface for grep-like queries. I'd > like to use it to find procedures/variables in a large code base. > > Any suggestions appreciated. The great gran

python object model diagram

2005-09-09 Thread Ara.T.Howard
anyone out there know where i might find a python object model diagram? cheers. -a -- === | email :: ara [dot] t [dot] howard [at] noaa [dot] gov | phone :: 303.497.6469 | Your life dwells amoung the causes of death | L

Re: Question about consistency in python language

2005-09-09 Thread Kay Schluehr
Mike Meyer wrote: > Yes, but the function "sorted" is more useful than a list method > "sorted" in a duck typing language. I don't see what this has to do with "duck typing"? sorted() is simply a generic function accepting different types. I'm not aware that sorted() requires a specific interface

error processing variables

2005-09-09 Thread Unknown
PROBLEM: for some reason, the variables won't work outside the function. I tried fix it by converting the variables to str and unicode and still no joy. The only way it works is by typing each source and destination file by hand on the shutil.copy2() method. Or by specify

Re: Question about consistency in python language

2005-09-09 Thread Terry Reedy
"Kay Schluehr" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On the other hand there exists no sorted() method for tuples or lists > like join() for strings but it is implemented as a function in Python24 > that returns a new sorted container. I consider this as an > inconsistency

Re: encryption with python

2005-09-09 Thread Mike Meyer
Steven D'Aprano <[EMAIL PROTECTED]> writes: > On Wed, 07 Sep 2005 14:31:03 -0700, jlocc wrote: >> Basically I will like to combine a social security number (9 digits) >> and a birth date (8 digits, could be padded to be 9) and obtain a new >> 'student number'. It would be better if the original num

Re: "grep" database

2005-09-09 Thread Hilbert
thanks! -- http://mail.python.org/mailman/listinfo/python-list

Re: disabling TCP connections, just for one script

2005-09-09 Thread Adam Monsen
Another solution is using a deliberately misconfigured proxy: import socket socket.setdefaulttimeout(1) import urllib proxies = {'http': 'http://www.example.com:3128'} url = 'http://www.google.com/' opener = urllib.FancyURLopener(proxies) f = opener.open(url) print f.read() >From this code I get

Re: Python linear algebra module -- requesting comments on interface

2005-09-09 Thread Terry Reedy
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > The module will be public domain. Various lawyers have suggested that either you cannot do that (is US) or that you should not do that. (You know the joke -- ask two lawyers and you get three opinions -- but all depends on your cou

Re: How to upgrade to 2.4.1 on Mac OS X tiger

2005-09-09 Thread Trent Mick
[Mike Meyer wrote] > stri ker <[EMAIL PROTECTED]> writes: > > Has anyone here upgraded from 2.3 to 2.4 on Tiger? > > If so how'd ya do it? > > You don't. You install 2.4 in parallel with 2.3. You can do pretty > much whatever you want with /usr/bin/python, /usr/local/bin/python, > etc. - Tiger doe

Re: How to upgrade to 2.4.1 on Mac OS X tiger

2005-09-09 Thread Mike Meyer
stri ker <[EMAIL PROTECTED]> writes: > Has anyone here upgraded from 2.3 to 2.4 on Tiger? > If so how'd ya do it? You don't. You install 2.4 in parallel with 2.3. You can do pretty much whatever you want with /usr/bin/python, /usr/local/bin/python, etc. - Tiger doesn't seem to use those. I don't r

Re: how to get the return value of a thread?

2005-09-09 Thread Benjamin Niemann
Leo Jay wrote: > Dear all, > > i would like to get the return value of all threads > > e.g. > def foo(num): > if num>10: > return 1 > elif num>50: > return 2 > else > return 0 > > > after i invoked > t = thread.start_new_thread(foo,(12,)) > how to get the re

Re: disabling TCP connections, just for one script

2005-09-09 Thread Adam Monsen
Nice!! Since that works, this also works (any socket operations appear to raise an IOError): import socket socket.setdefaulttimeout(0) Thanks! -Adam -- Adam Monsen http://adammonsen.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Question about consistency in python language

2005-09-09 Thread Mike Meyer
"Kay Schluehr" <[EMAIL PROTECTED]> writes: > If you define > sep = "" sep.join(["d","o","g"]) > "dog" sep > '' > > sep is preserved and a new "dog" string is generated. Since sep is > immutable there is no way to manipulate it inplace. > > On the other hand there exists no sorted() m

Re: using % operator to print possibly unitialized data attributes

2005-09-09 Thread Adam Monsen
Leif K-Brooks wrote: > This will update the class's attributes with instance attributes > when str() is called, which probably isn't what you want. [...] Yikes, you're right! Well, I figured out a modification to my original __str__ code that works for old and new-style classes which doesn't overw

Re: Question about consistency in python language

2005-09-09 Thread Mike Meyer
Dave Benjamin <[EMAIL PROTECTED]> writes: > Mike Meyer wrote: >> Dave Benjamin <[EMAIL PROTECTED]> writes: >>>Python is actually quite consistent in this regard: methods that >>>modify an object in-place return None; >> Um, no. list.pop comes to mind as an immediate counterexample. It may >> be the

Re: using % operator to print possibly unitialized data attributes

2005-09-09 Thread Leif K-Brooks
Adam Monsen wrote: > class J: > name = '' > value = '' > def __str__(self): > vals = self.__class__.__dict__ > vals.update(self.__dict__) > return 'name="%(name)s" value="%(value)s' % vals This will update the class's attributes with instance attributes when str

Expected Value

2005-09-09 Thread George
I have never done any programming with python in my life so I will most definetly need help understanding how I can accomplish this part of my program. The function expectP(z) computes E(X) for the random variable representing a sample over the probability generated by "pf" for the set of discrete

Re: What's the difference between VAR and _VAR_?

2005-09-09 Thread Erik Max Francis
S. D. Rose wrote: > I can't get the value of the variable (out of the class function) if it has > two leading underscores. Sure you can if you want it hard enough; it's just mangled. >>> class C: __x = 1 ... >>> dir(C) ['_C__x', '__doc__', '__module__'] >>> c = C() >>> dir(c) ['_C__x', '__do

Re: disabling TCP connections, just for one script

2005-09-09 Thread cakebread
How about this: import timeoutsocket timeoutsocket.setDefaultSocketTimeout(0) This will make all sockets in your Python app fail. https://svn.plone.org/svn/collective/CMFSquidTool/trunk/timeoutsocket.py -- http://mail.python.org/mailman/listinfo/python-list

Re: nested tuples

2005-09-09 Thread Larry Bates
The first question is why do you need tuples? But this works: import csv filename=r'C:\test.txt' fp=open(filename,'r') reader=csv.reader(fp) tlines=tuple([tuple(x) for x in reader]) fp.close() Larry Bates Luis P. Mendes wrote: > Hi, > > I'm trying to solve this problem: > > suppose I'm readin

Re: looping over arrays in numarray/numeric

2005-09-09 Thread Robert Kern
proof wrote: > a = range(100) > b = [a] * 3 > > b[1] = [k + i for k, i in zip(b[1], b[2])] > > This is rather slow in python and I thought that kind of things should > be written using numeric or numarray. I tried to read trough manuals > but it didn't help me. So how is this done using numer

Re: nested tuples

2005-09-09 Thread Max Erickson
"Luis P. Mendes" <[EMAIL PROTECTED]> wrote in > suppose I'm reading a csv file and want to create a tuple of all > those rows and values, like ((row1value1, row1value2, > row1value3),(row2value1, row2value2, row2value3),..., > (rowNvalue1, rowNvalue2, rowNvalue3)) > > I haven't found the way to d

Re: How to upgrade to 2.4.1 on Mac OS X tiger

2005-09-09 Thread Robert Kern
stri ker wrote: > Has anyone here upgraded from 2.3 to 2.4 on Tiger? > If so how'd ya do it? You just run the official installer. http://python.org/ftp/python/2.4.1/MacPython-OSX-2.4.1-1.dmg Note that this does *not* replace 2.3 which was installed by Apple. That's a good thing. Instead, the exe

Re: Code for generating validation codes (in images)

2005-09-09 Thread jepler
On Sun, Sep 04, 2005 at 11:10:07AM +0200, Giuseppe di Sabato (aka deelan) wrote: > take a look at the "pycaptcha" package: > The links on the freshmeat.net page don't work for me --- the downloads are 404'd, and the demo doesn't work. Jeff pgpkRlXiyKES

Redundant code in multiple methods

2005-09-09 Thread Rob Conner
No you don't need to know Zope to help me. The whole reason I'd even want to do this is because of Zope though. I made a Zope product, and now want to perfect it. some simple example code... class User: def View(self): # play with data here myHtmlDoc = "pretend this is a upe

Re: List of integers & L.I.S. (SPOILER)

2005-09-09 Thread n00m
PS: ALL problems in problems.PDF file (weekly updated): http://spoj.sphere.pl/problems.pdf The friendliest online contester I've ever seen! JUST A NON-SUCH. -- http://mail.python.org/mailman/listinfo/python-list

Re: circular import problem

2005-09-09 Thread Terry Reedy
"Learning Python" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > An example in the book I didn't understood well > two modules files recursively import/from each other There are past postings available in the archives (via Google) at least, that lucided discuss circular imports.

Re: subprocess solved all my problems

2005-09-09 Thread Do Re Mi chel La Si Do
Hi ! Thank you for this interesting message. @-salutations Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list

Python Design Principles

2005-09-09 Thread lechequier
In a previous post, I asked about the inconsistency in usage patterns in operating on mutable and immutable types. Thanks Dave and everyone else for answering my question so thoughtfully and helping me to understand the reasoning about why the different usage patterns are not deemed to be inconsist

nested tuples

2005-09-09 Thread Luis P. Mendes
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, I'm trying to solve this problem: suppose I'm reading a csv file and want to create a tuple of all those rows and values, like ((row1value1, row1value2, row1value3),(row2value1, row2value2, row2value3),..., (rowNvalue1, rowNvalue2, rowNvalue3))

Re: List of integers & L.I.S. (SPOILER)

2005-09-09 Thread n00m
It also timed out:( 241056 2005-09-09 20:11:19 ZZZ time limit exceeded - 7064 PYTH Btw, have a look at this nicest problem: http://spoj.sphere.pl/problems/COINS/ My py solution takes #64 place among its best solutions: http://spoj.sphere.pl/ranks/COINS/start=60 -- http://mail.python.org/m

Re: Timezone and ISO8601 struggles with datetime and xml.utils.iso8601.parse

2005-09-09 Thread Samuel
> Take a look at the utcoffset method of datetime objects. This returns 0. However, meanwhile I figured out a way to do this: Every datetime object by default does not handle timezones at all, and as such "isoformat" does not return an offset in the ISO8601 string. The only way around this appear

working with multiple frame instances

2005-09-09 Thread fchef
I am looking for some advice on working with Multiple frame instances. Essentially I need to be able to refer to specific control values in a frame and be able to hide/show a specific frame. In VB you can reference a particular frame with something like Controls.Form("My form").DoSomething. Is ther

using % operator to print possibly unitialized data attributes

2005-09-09 Thread Adam Monsen
The following code uses the % operator to print possibly unitialized data attributes: 8< class J: name = '' value = '' def __str__(self): vals = self.__class__.__dict__ vals.update(self.__dict__) return 'name="%(nam

Re: sys.stdout

2005-09-09 Thread Sébastien Boisgérault
Jorgen Grahn a écrit : > On 9 Sep 2005 03:40:58 -0700, Sébastien Boisgérault <[EMAIL PROTECTED]> wrote: > > > > Fredrik Lundh wrote: > >> Sébastien Boisgérault wrote: > >> > >> > Thanks for your answer. The execution of your example leads to a > >> > 'aaa' display during 2 secs, before it is era

where is sys.path initialized?

2005-09-09 Thread Alex
Rossum's tutorial states "Actually, modules are searched in the list of directories given by the variable sys.path which is initialized from the directory containing the input script (or the current directory)" I'm running Python standard installation (ver 2.4) on Windows XP. Where can I find the

Re: disabling TCP connections, just for one script

2005-09-09 Thread Adam Monsen
I know very little about socket programming and even less about sockey.py... any idea what behavior would have to be modified? Further complicating matters (for me), it appears some of the socket programming code is in C, and my C skills are lacking. -- Adam Monsen http://adammonsen.com/ -- ht

Re: "grep" database

2005-09-09 Thread Adam Monsen
ctags indexes procedures/variables in source code, perhaps it would help: http://ctags.sf.net/ -- Adam Monsen http://adammonsen.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: simple problem with os.rename() parameters - path with spaces

2005-09-09 Thread Larry Bates
Are you sure the source directory exists and you have rights to rename it? Because the rename works for me. But you may want to look at shutil.move and/or use forward slashes (they work under Windows) -Larry Bates Tom wrote: > I'm having a problem using a path with spaces as a parameter to > o

circular import problem

2005-09-09 Thread Learning Python
An example in the book I didn't understood well two modules files recursively import/from each other in recur1.py,we have: x=1 import recur2 y=1 in recur2.py, we have from recur1 import x from recur1 import y If we run interactively at python command line, >>> import recur1 it has errors li

Re: Timezone and ISO8601 struggles with datetime and xml.utils.iso8601.parse

2005-09-09 Thread skip
Samuel> mydatetime = datetime.datetime(year, month, day, hour, minute) Samuel> strtime= mydatetime.isoformat() Take a look at the utcoffset method of datetime objects. Samuel> The second problem has to do with the ISO8601 parser, which Samuel> raises the following error:

Re: disabling TCP connections, just for one script

2005-09-09 Thread Diez B. Roggisch
Adam Monsen wrote: > It would be helpful to be able to temporarily disable AF_INET socket > connections (I don't care about IPv6 for now). Maybe put an socket.py with mockup funktions in your path before the real socket.py. Then you can alter teh behaviour of all necessary functions. Diez -- ht

"grep" database

2005-09-09 Thread Hilbert
Hello, I've heard of a software on linux that creates a recursive database of text files and then provides an interface for grep-like queries. I'd like to use it to find procedures/variables in a large code base. Any suggestions appreciated. Thanks, Hilbert -- http://mail.python.org/mailman/l

Re: Grouping lists

2005-09-09 Thread [EMAIL PROTECTED]
I wasn't sure of what itertools.groupby() is good for. But it serves your purpose. >>> lst = [1,1,1,1,3,5,1,1,1,1,7,7,7] >>> >>> import itertools >>> i = 0 >>> groups = [] >>> for k, g in itertools.groupby(lst): ... l = len(list(g)) ... if l == 1: ... groups.append(i) ... else:

Re: List of integers & L.I.S. (SPOILER)

2005-09-09 Thread Bryan Olson
n00m wrote: > Oh! > Seems you misunderstand me! > See how the last block in your code should look: > > for tc in range(10): > _ = stdin.readline() > sequence = [int(ch) for ch in stdin.readline().split()] > supers = supernumbers(sequence) > print len(supers) > for i in

simple problem with os.rename() parameters - path with spaces

2005-09-09 Thread Tom
I'm having a problem using a path with spaces as a parameter to os.rename() in a program on WinXP. This works fine at the command line (where the folder "c:\aa bb" exists) > os.rename( "c\aa bb", "c:\cc dd" ); > But, I can't get it to work in my program, eg. print SrcDir print NewDir os.rena

Re: Grouping lists

2005-09-09 Thread Benji York
PyPK wrote: > lst = [1,1,1,1,3,5,1,1,1,1,7,7,7] > I want to group the list so that it returns groups such as > [(0,3),4,5,(6,9),(10,12)]. which defines the regions which are similar. You'll probably want to use "groupby" from the itertools module. See http://docs.python.org/lib/itertools-functio

Re: Why do Pythoneers reinvent the wheel?

2005-09-09 Thread Stefano Masini
On 9/9/05, djw <[EMAIL PROTECTED]> wrote: > I think, for me, this most important reason is that the stdlib version > of a module doesn't always completely fill the requirements of the > project being worked on. That's certainly why I wrote my own, much > simpler, logging module. In this case, its o

Re: Python linear algebra module -- requesting comments on interface

2005-09-09 Thread Colin J. Williams
Connelly, Apologies, my first message was sent in error. I like your general setup. You appear to permit matrix operations, which the folk at Numeric and, later, numarray did not. My own package, PyMatrix, has similar aims to yours but it may be slower as it is based on numarray. My package

Grouping lists

2005-09-09 Thread PyPK
If I have a list say lst = [1,1,1,1,3,5,1,1,1,1,7,7,7] I want to group the list so that it returns groups such as [(0,3),4,5,(6,9),(10,12)]. which defines the regions which are similar. Thanks, -- http://mail.python.org/mailman/listinfo/python-list

Re: Why do Pythoneers reinvent the wheel?

2005-09-09 Thread Stefano Masini
On 9/9/05, Michael Amrhein <[EMAIL PROTECTED]> wrote: > Did you take a look at pyPI (http://www.python.org/pypi) ? > At least you'd find another odict ... Oh, yeah. And another filesystem abstraction layer... and another xml serialization methodology... :) PyPI is actually pretty cool. If I had to

Re: Yielding a chain of values

2005-09-09 Thread [EMAIL PROTECTED]
>>unless you are going many levels deep (and that's usually a design smell of some kind) No, its not a bug. its a feature! See the discussion in the recursive generator thread below: http://groups.google.com/group/comp.lang.python/browse_frm/thread/4c749ec4fc5447fb/36f2b915eba66eac?q=recursive+ge

Re: Create new instance of Python class in C

2005-09-09 Thread Sybren Stuvel
djw enlightened us with: > Personally, I would try Psyco first, and consider Pyrex next. Ok, I'll take a look at those. > Are you sure your algorithm can't be optimized first, before you > start trying to write this in C? I'm sure there will be optimizations, but profiling showed that the copyin

Re: re module help

2005-09-09 Thread Daniel Dittmar
[EMAIL PROTECTED] wrote: > if I start replacing regex by re I get stuck at replacement of >regex.symcomp() and regex.pattern() Groups identified by names are part of the standard regular expression syntax: regex.symcomp ('\([a-z][a-z0-9]*\)') becomes re.compile ('(?Pid[a-z][a-z0-9]*)') I get

Re: distutils question

2005-09-09 Thread Fredrik Lundh
Joachim Dahl wrote: > E.g., say I want to compile a project as: > > gcc -Ddef1 -c foo.c -o foo_def1.o > gcc -Ddef2 -c foo.c -o foo_def2.o > gcc foo_def1.o foo_def2.o -o myext_module.o > > How would I do that using distutils? It doesn't seem to be possible with > the normal core.setup method, and d

Re: Why do Pythoneers reinvent the wheel?

2005-09-09 Thread Dave Brueck
Stefano Masini wrote: > I wonder how many people (including myself) have implemented their own > versions of such modules, at least once in their pythonic life. I > indeed have my own odict (even same name! :). My own pathutils > (different name, but same stuff). My own validate... and so forth. >

disabling TCP connections, just for one script

2005-09-09 Thread Adam Monsen
It would be helpful to be able to temporarily disable AF_INET socket connections (I don't care about IPv6 for now). What I'd like to do is create an environment for a Python script that appears like the network interface is down, so any remote socket stuff should fail (like an HTTP GET request to

looping over arrays in numarray/numeric

2005-09-09 Thread proof
a = range(100) b = [a] * 3 b[1] = [k + i for k, i in zip(b[1], b[2])] This is rather slow in python and I thought that kind of things should be written using numeric or numarray. I tried to read trough manuals but it didn't help me. So how is this done using numeric or numarray? -- http://m

Re: Why do Pythoneers reinvent the wheel?

2005-09-09 Thread djw
Stefano Masini wrote: > I don't know what's the ultimate problem, but I think there are 3 main > reasons: > 1) poor communication inside the community (mhm... arguable) > 2) lack of a rich standard library (I heard this more than once) > 3) python is such an easy language that the "I'll do it mys

Re: Create new instance of Python class in C

2005-09-09 Thread djw
Sybren Stuvel wrote: > Hi people, > > I'm creating a program that can solve and create Sudoku puzzles. My > creation function needs to make a lot of copies of a puzzle. Until > now, I used copy.deepcopy(), but that's too slow. I want to implement > such a copying function in C and use that instead

Re: Why do Pythoneers reinvent the wheel?

2005-09-09 Thread Michael Amrhein
Stefano Masini schrieb: > On 8 Sep 2005 08:24:50 -0700, Fuzzyman <[EMAIL PROTECTED]> wrote: > >>What is pythonutils ? >>= >>ConfigObj - simple config file handling >>validate - validation and type conversion system >>listquote - string to list conversion >>StandOut - simple log

  1   2   >