Query on User Authentication modules

2007-07-25 Thread Bala Subramanyam vemu
Hi ALL I have SLES 10 installed on my machine, i wanted to get all the information about the installed " USER authentication modules" for example :: localauthentication or LDAP or even a radius server how can I get the above information in SUSE, do we have any python scripts for that Thanks in

Re: classmethod & staticmethod

2007-07-25 Thread Gabriel Genellina
En Tue, 24 Jul 2007 21:55:17 -0300, Alex Popescu <[EMAIL PROTECTED]> escribió: > Neil Cerutti <[EMAIL PROTECTED]> wrote in news:eRwpi.36813$G23.28496 > @newsreading01.news.tds.net: >> On 2007-07-25, Alex Popescu <[EMAIL PROTECTED]> wrote: >>> As a matter of style, how do you figure out that clas

Re: class C: vs class C(object):

2007-07-25 Thread Bruno Desthuilliers
Aahz a écrit : (snip) > *YOU* are the one confusing people by your dogmatic insistance that > classic classes should be ignored. Grow up. I did. I still do. With every new Python release. I'm sorry for you that you are still stuck with almost prehistoric Python versions, but I don't accept th

How to create a single executable of a Python program

2007-07-25 Thread NicolasG
Dear fellows, I'm trying to create a executable file using py2exe . Unfortunately along with the python executable file it also creates some other files that are needed in order to the executable be able to run in a system that doesn't have Python installed. Can some one guide me on how can I merg

Re: decorators tutorials

2007-07-25 Thread Josiah Carlson
james_027 wrote: > hi bruno, > > That seems to be hard to read at all, or I am just very new to python? No, it's hard to read. Note that it's not, technically, necessary to use nested functions to get the same results as a particular decorator. For example, earlier you provided... def check

Re: idiom for RE matching

2007-07-25 Thread Ben Finney
Gordon Airporte <[EMAIL PROTECTED]> writes: > I did already find that it speeds things up to pre-test a line like > > if 'bets' or 'calls' or 'raises' in line: > run the appropriate re's > > which isn't very pretty at all Nor does it work the way you might suppose: >>> line = "foo ca

Re: Base class for file-like objects? (a.k.a "Stream" in Java)

2007-07-25 Thread [EMAIL PROTECTED]
On Jul 25, 12:28 pm, Asun Friere <[EMAIL PROTECTED]> wrote: > On Jul 25, 8:51 am, Boris Dušek <[EMAIL PROTECTED]> wrote: > > > In Python, I found that "file" objects exist. While specifying > > argument types in Python is not possible as in Java, it is possible to > > check whether an object is an

Re: classmethod & staticmethod

2007-07-25 Thread Bruno Desthuilliers
Alex Popescu a écrit : > Bruno Desthuilliers <[EMAIL PROTECTED]> wrote > in news:[EMAIL PROTECTED]: > > > >>[snip...] >> >> >>Not necessarily - you can access class attributes from within an >>instance method (but obviously a classmethod cannot access instance >>attributes). >> > > What I a

Re: How to create a single executable of a Python program

2007-07-25 Thread hong2221
On Jul 25, 2:34 am, NicolasG <[EMAIL PROTECTED]> wrote: > Dear fellows, > > I'm trying to create a executable file using py2exe . Unfortunately > along with the python executable file it also creates some other files > that are needed in order to the executable be able to run in a system > that doe

Re: From D

2007-07-25 Thread Jakub Stolarski
On Jul 25, 1:08 am, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > Underscores in numerics are UGLY. Why not take a leaf out of implicit > string concatenation and allow numeric literals to implicitly concatenate? > > Python already does: > "hello-" "world" => "hello-world" > > Propose: > 123 456 789

Unable to abort a FTP command?

2007-07-25 Thread _wdx
Hi, I write the following script to retrieve a part of a large file from a FTP site: import ftplib class ftp_getter(object): def __init__(self): self.handle = ftplib.FTP('ftp_server_address') self.handle.set_debuglevel(2) self.login() def login(self):

Re: how to get next month string?

2007-07-25 Thread Silfheed
Sounds like a job for dateutil (http://labix.org/python-dateutil). It's not a built in module (it's in the cheeseshop at least), but it looks like it pretty much does exactly what you want. If you really dont want to download anything, I suppose you could create something from datetime's timedelta

Interactive remote debugging by redirecting sys.stdin and sys.stdout to a socket or pipe

2007-07-25 Thread [EMAIL PROTECTED]
Hi I want a simple way to interactively remote debug a running python script which has no tty terminal attached to it. The scripts are running standalone (i.e. they are automatically started and have no terminal) and very infrequently come into error conditions which i want to understand and debug

Re: How to create a single executable of a Python program

2007-07-25 Thread branko . petrovic
On Jul 25, 9:10 am, hong2221 <[EMAIL PROTECTED]> wrote: > On Jul 25, 2:34 am, NicolasG <[EMAIL PROTECTED]> wrote: > > > Dear fellows, > > > I'm trying to create a executable file using py2exe . Unfortunately > > along with the python executable file it also creates some other files > > that are nee

Re: code indentation

2007-07-25 Thread vedrandekovic
On 25 srp, 01:07, Ben Finney <[EMAIL PROTECTED]> wrote: > Steve Holden <[EMAIL PROTECTED]> writes: > > [EMAIL PROTECTED] wrote: > > > On 24 srp, 05:20, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > > >> En Mon, 23 Jul 2007 16:53:01 -0300, ...:::JA:::... > > >> <[EMAIL PROTECTED]> escribió: > > >

Re: How to create a single executable of a Python program

2007-07-25 Thread Graeme Glass
On Jul 25, 8:34 am, NicolasG <[EMAIL PROTECTED]> wrote: > Dear fellows, > > I'm trying to create a executable file using py2exe . Unfortunately > along with the python executable file it also creates some other files > that are needed in order to the executable be able to run in a system > that doe

Re: How to create a single executable of a Python program

2007-07-25 Thread Harlin Seritt
On Jul 25, 6:19 am, Graeme Glass <[EMAIL PROTECTED]> wrote: > On Jul 25, 8:34 am, NicolasG <[EMAIL PROTECTED]> wrote: > > > Dear fellows, > > > I'm trying to create a executable file using py2exe . Unfortunately > > along with the python executable file it also creates some other files > > that are

Re: how to get next month string?

2007-07-25 Thread Yinghe Chen
John's method works perfectly, thanks all for your kind help. "John Machin" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Jul 24, 8:31 pm, "Yinghe Chen" <[EMAIL PROTECTED]> wrote: >> Hi, >> Could someone help on how to use python to output the next month string >> like >> this?

Re: Technology solutions for Ruby?

2007-07-25 Thread Bruno Desthuilliers
vasudevram a écrit : > Bruno Desthuilliers wrote: > > >>s/some/great/g >> >>Both Ruby and Python are known for this. > > Thanks for the info. This is not exactly a scoop, you know ?-) >>I'd say that - wrt/ "advanced" programming tricks - *most* of what you > > can do with one can be done wi

adding a docstring to an instancemethod

2007-07-25 Thread jelle
Hi, I'm working on documenting wrapped C++ methods. The thing is that I'd like to add docstrings to a method, but python won't allow me to: TypeError: attribute '__doc__' of 'instancemethod' objects is not writable What would be an easy way to do so? I'd like to overload the .__doc__, rather than

Re: classmethod & staticmethod

2007-07-25 Thread Neil Cerutti
On 2007-07-25, Alex Popescu <[EMAIL PROTECTED]> wrote: > Neil Cerutti <[EMAIL PROTECTED]> wrote in news:eRwpi.36813$G23.28496 > @newsreading01.news.tds.net: > >> On 2007-07-25, Alex Popescu <[EMAIL PROTECTED]> wrote: >>> As a matter of style, how do you figure out that class_list is >>> a class att

Re: How to create a single executable of a Python program

2007-07-25 Thread Ali
On Jul 25, 7:34 am, NicolasG <[EMAIL PROTECTED]> wrote: > Dear fellows, > > I'm trying to create a executable file using py2exe . Unfortunately > along with the python executable file it also creates some other files > that are needed in order to the executable be able to run in a system > that doe

16-bit colour representation

2007-07-25 Thread beertje
This has me a bit stumped... I'm trying to extract pictures from a file. So far I'm successfully retrieved the header and what I think is the colour for each pixel. Here's the description: """ 3) The picture data format: The color information is 15 bit data stored in 16 bit. This means the most s

Re: renaming an open file in nt like unix?

2007-07-25 Thread aaron . watters
On Jul 13, 2:44 pm, Steve Holden <[EMAIL PROTECTED]> wrote: > Thomas Heller wrote: > > [EMAIL PROTECTED] schrieb:= > > >> ...Do the NT file systems support [renaming an open file] (which I think is > >> standard for POSIX systems)? > > > Yes, you can do that. We implemented something like this to

Re: Unable to abort a FTP command?

2007-07-25 Thread billiejoex
On 25 Lug, 09:48, [EMAIL PROTECTED] wrote: > Hi, > I write the following script to retrieve a part of a large file > from a FTP site: > > import ftplib > > class ftp_getter(object): > > def __init__(self): > self.handle = ftplib.FTP('ftp_server_address') > self.handle.set_de

Re: 16-bit colour representation

2007-07-25 Thread John Machin
On Jul 25, 9:53 pm, beertje <[EMAIL PROTECTED]> wrote: > This has me a bit stumped... > > I'm trying to extract pictures from a file. So far I'm successfully > retrieved the header and what I think is the colour for each pixel. > Here's the description: > > """ > 3) The picture data format: > The c

Re: 16-bit colour representation

2007-07-25 Thread Diez B. Roggisch
beertje wrote: > This has me a bit stumped... > > I'm trying to extract pictures from a file. So far I'm successfully > retrieved the header and what I think is the colour for each pixel. > Here's the description: > > """ > 3) The picture data format: > The color information is 15 bit data store

Re: How to create a single executable of a Python program

2007-07-25 Thread kyosohma
On Jul 25, 6:38 am, Ali <[EMAIL PROTECTED]> wrote: > On Jul 25, 7:34 am, NicolasG <[EMAIL PROTECTED]> wrote: > > > Dear fellows, > > > I'm trying to create a executable file using py2exe . Unfortunately > > along with the python executable file it also creates some other files > > that are needed i

Re: Pickled objects over the network

2007-07-25 Thread Marco Mariani
Hendrik van Rooyen ha scritto: > But more seriously - is there any need for a simple serialiser that will > be able to be used to transfer a subset of the built in types over an > open network in a safe manner, for the transfer of things like lists of > parameters? Yes, there seems to be a need f

How to tell when a socket is closed on the other end?

2007-07-25 Thread billiejoex
Hi there. I'm setting up test suite for a project of mine. >From test suite, acting as a client, I'd like to know, in certain situations, if the socket is closed on the other end or not. I noticed that I can "detect" such state if a call to socket.read() returns 0 but it seems a little poor to me.

Re: How to tell when a socket is closed on the other end?

2007-07-25 Thread Roy Smith
In article <[EMAIL PROTECTED]>, billiejoex <[EMAIL PROTECTED]> wrote: > Hi there. > I'm setting up test suite for a project of mine. > >From test suite, acting as a client, I'd like to know, in certain > situations, if the socket is closed on the other end or not. > I noticed that I can "detect"

Re: Closures / Blocks in Python

2007-07-25 Thread Jeff
You can create a lexical closure using a Python generator function, which allows iteration using a block of code while maintaining internal state. A generator is a regular function which uses yield (like Ruby) to define the point at which the function should return an expression to the calling cod

Re: How to tell when a socket is closed on the other end?

2007-07-25 Thread Josiah Carlson
Roy Smith wrote: > In article <[EMAIL PROTECTED]>, > billiejoex <[EMAIL PROTECTED]> wrote: > >> Hi there. >> I'm setting up test suite for a project of mine. >> >From test suite, acting as a client, I'd like to know, in certain >> situations, if the socket is closed on the other end or not. >> I

Python course around Boston

2007-07-25 Thread Bergsbaken, David
Is there such a course? -- http://mail.python.org/mailman/listinfo/python-list

Re: Flatten a list/tuple and Call a function with tuples

2007-07-25 Thread kyosohma
On Jul 25, 9:50 am, beginner <[EMAIL PROTECTED]> wrote: > Hi, > > I am wondering how do I 'flatten' a list or a tuple? For example, I'd > like to transform[1, 2, (3,4)] or [1,2,[3,4]] to [1,2,3,4]. > > Another question is how do I pass a tuple or list of all the > aurgements of a function to the f

Re: How to tell when a socket is closed on the other end?

2007-07-25 Thread billiejoex
On 25 Lug, 16:37, Roy Smith <[EMAIL PROTECTED]> wrote: > This isn't really a Python question, it's a Berkeley Socket API question. > You don't say, but I assume you're talking about a TCP (i.e. SOCKSTREAM) > connection? Yes. > The answer is you can use the select() system call to detect "excep

Flatten a list/tuple and Call a function with tuples

2007-07-25 Thread beginner
Hi, I am wondering how do I 'flatten' a list or a tuple? For example, I'd like to transform[1, 2, (3,4)] or [1,2,[3,4]] to [1,2,3,4]. Another question is how do I pass a tuple or list of all the aurgements of a function to the function. For example, I have all the arguments of a function in a tu

Re: From D

2007-07-25 Thread Wildemar Wildenburger
Steven D'Aprano wrote: > Python already does: > "hello-" "world" => "hello-world" > > Propose: > 123 456 789 => 123456789 > 123.456 789 => 123.456789 > > I second that! /W -- http://mail.python.org/mailman/listinfo/python-list

ANN: python-ldap-2.3.1

2007-07-25 Thread Michael Ströder
Find a new release of python-ldap: http://python-ldap.sourceforge.net/ python-ldap provides an object-oriented API to access LDAP directory servers from Python programs. It mainly wraps the OpenLDAP 2.x libs for that purpose. Additionally it contains modules for other LDAP-related stuff (e.g. p

Re: Closures / Blocks in Python

2007-07-25 Thread Cameron Laird
In article <[EMAIL PROTECTED]>, Jason <[EMAIL PROTECTED]> wrote: . [good detail] . . >If you can't find a way of doing what you want with iterators, >comprehensions, or lambda, consider writing a little functio

Re: Flatten a list/tuple and Call a function with tuples

2007-07-25 Thread Stargaming
On Wed, 25 Jul 2007 14:50:18 +, beginner wrote: > Hi, > > I am wondering how do I 'flatten' a list or a tuple? For example, I'd > like to transform[1, 2, (3,4)] or [1,2,[3,4]] to [1,2,3,4]. A recursive function, always yielding the first element of the list, could do the job. See the ASPN

Reading files, splitting on a delimiter and newlines.

2007-07-25 Thread chrispwd
Hello, I have a situation where I have a file that contains text similar to: myValue1 = contents of value1 myValue2 = contents of value2 but with a new line here myValue3 = contents of value3 My first approach was to open the file, use readlines to split the lines on the

This One is ULTIMATE. (Dont' Miss)

2007-07-25 Thread Sachin
Hi Everyone, http://surkumarm.googlepages.com/home I found a cool Websites which can be a great resource to making easy money for Home Moms, kids, Students and other people who are looking for making some easy Money Online. This website talks about programmes launched by Giant companies like Ama

Re: Flatten a list/tuple and Call a function with tuples

2007-07-25 Thread beginner
On Jul 25, 10:19 am, Stargaming <[EMAIL PROTECTED]> wrote: > On Wed, 25 Jul 2007 14:50:18 +, beginner wrote: > > Hi, > > > I am wondering how do I 'flatten' a list or a tuple? For example, I'd > > like to transform[1, 2, (3,4)] or [1,2,[3,4]] to [1,2,3,4]. > > A recursive function, always yiel

Re: Flatten a list/tuple and Call a function with tuples

2007-07-25 Thread kyosohma
On Jul 25, 10:46 am, beginner <[EMAIL PROTECTED]> wrote: > On Jul 25, 10:19 am, Stargaming <[EMAIL PROTECTED]> wrote: > > > > > On Wed, 25 Jul 2007 14:50:18 +, beginner wrote: > > > Hi, > > > > I am wondering how do I 'flatten' a list or a tuple? For example, I'd > > > like to transform[1, 2, (

Re: Flatten a list/tuple and Call a function with tuples

2007-07-25 Thread beginner
On Jul 25, 11:00 am, [EMAIL PROTECTED] wrote: > On Jul 25, 10:46 am, beginner <[EMAIL PROTECTED]> wrote: > > > > > > > On Jul 25, 10:19 am, Stargaming <[EMAIL PROTECTED]> wrote: > > > > On Wed, 25 Jul 2007 14:50:18 +, beginner wrote: > > > > Hi, > > > > > I am wondering how do I 'flatten' a lis

Re: code indentation

2007-07-25 Thread Wildemar Wildenburger
[EMAIL PROTECTED] wrote: >> And while we're on the topic of communication: The original poster >> would do well to learn that increasing the number of consecutive >> punctuation marks (!!!, ???) is a sure way to turn away many people >> who would otherwise be helpful. Sentences need at most one '!'

Re: 16-bit colour representation

2007-07-25 Thread Steve Holden
Diez B. Roggisch wrote: > beertje wrote: > >> This has me a bit stumped... >> >> I'm trying to extract pictures from a file. So far I'm successfully >> retrieved the header and what I think is the colour for each pixel. >> Here's the description: >> >> """ >> 3) The picture data format: >> The col

Re: Closures / Blocks in Python

2007-07-25 Thread Wildemar Wildenburger
Jeff wrote: > # Generic counter > def counter(min=None, max): > if not min: > min = 0 > for i in xrange(min, max): > yield i > i = i + 1 > Just for the record: >>> # Generic counter ... def counter(min=None, max): ... if not min: ... min = 0 ... for i in xrange(min, max)

Re: Reading files, splitting on a delimiter and newlines.

2007-07-25 Thread kyosohma
On Jul 25, 10:46 am, [EMAIL PROTECTED] wrote: > Hello, > > I have a situation where I have a file that contains text similar to: > > myValue1 = contents of value1 > myValue2 = contents of value2 but > with a new line here > myValue3 = contents of value3 > > My first approach

Re: Flatten a list/tuple and Call a function with tuples

2007-07-25 Thread Diez B. Roggisch
beginner wrote: > On Jul 25, 10:19 am, Stargaming <[EMAIL PROTECTED]> wrote: >> On Wed, 25 Jul 2007 14:50:18 +, beginner wrote: >> > Hi, >> >> > I am wondering how do I 'flatten' a list or a tuple? For example, I'd >> > like to transform[1, 2, (3,4)] or [1,2,[3,4]] to [1,2,3,4]. >> >> A recur

Re: Flatten a list/tuple and Call a function with tuples

2007-07-25 Thread Stargaming
On Wed, 25 Jul 2007 15:46:58 +, beginner wrote: > On Jul 25, 10:19 am, Stargaming <[EMAIL PROTECTED]> wrote: >> On Wed, 25 Jul 2007 14:50:18 +, beginner wrote: [snip] >> >> > Another question is how do I pass a tuple or list of all the >> > aurgements of a function to the function. For exa

wxGlade: Who knows how to drive this application?

2007-07-25 Thread Steve Holden
I've been trying to use wxGlade recently and I am finding it something of a challenge. Is there any user who finds the user interface satisfactory and the operation of the program predictable? If so I would love to hear from you. regards Steve -- Steve Holden+1 571 484 6266 +1 800

Re: Recursive lists

2007-07-25 Thread mizrandir
So if I understood correctly the recursive structure isn't a problem for python because "a" contains a reference to "a", not "a" itself. On the other hand, print works ok because it has a special trap to detect recursive structures. I think I understand it now. Thnks for your replies, miz. -- ht

Re: 16-bit colour representation

2007-07-25 Thread Steve Holden
Diez B. Roggisch wrote: > beertje wrote: > >> This has me a bit stumped... >> >> I'm trying to extract pictures from a file. So far I'm successfully >> retrieved the header and what I think is the colour for each pixel. >> Here's the description: >> >> """ >> 3) The picture data format: >> The col

Re: Flatten a list/tuple and Call a function with tuples

2007-07-25 Thread Paul Rubin
beginner <[EMAIL PROTECTED]> writes: > I know the * operator. However, a 'partial unpack' does not seem to work. A few other posters have mentioned ways around this, but you might ask yourself what coding situation makes you want to do this stuff in the first place. I won't say there's never a re

Re: Flatten a list/tuple and Call a function with tuples

2007-07-25 Thread James Stroud
beginner wrote: > On Jul 25, 10:19 am, Stargaming <[EMAIL PROTECTED]> wrote: >> On Wed, 25 Jul 2007 14:50:18 +, beginner wrote: >>> Hi, >>> I am wondering how do I 'flatten' a list or a tuple? For example, I'd >>> like to transform[1, 2, (3,4)] or [1,2,[3,4]] to [1,2,3,4]. >> A recursive funct

Re: Flatten a list/tuple and Call a function with tuples

2007-07-25 Thread Wildemar Wildenburger
[EMAIL PROTECTED] wrote: > On Jul 25, 9:50 am, beginner <[EMAIL PROTECTED]> wrote: > >> Another question is how do I pass a tuple or list of all the >> aurgements of a function to the function. For example, I have all the >> arguments of a function in a tuple a=(1,2,3). Then I want to pass each

Re: Base class for file-like objects? (a.k.a "Stream" in Java)

2007-07-25 Thread George Sakkis
On Jul 24, 6:51 pm, Boris Dušek <[EMAIL PROTECTED]> wrote: > Hello, > > (sorry to begin with Java in a Python list ;-) > in Java, when I want to pass input to a function, I pass > "InputStream", which is a base class of any input stream. > > In Python, I found that "file" objects exist. While spec

Re: Flatten a list/tuple and Call a function with tuples

2007-07-25 Thread [EMAIL PROTECTED]
On Jul 25, 8:46 am, beginner <[EMAIL PROTECTED]> wrote: > On Jul 25, 10:19 am, Stargaming <[EMAIL PROTECTED]> wrote: > > > > > On Wed, 25 Jul 2007 14:50:18 +, beginner wrote: > > > Hi, > > > > I am wondering how do I 'flatten' a list or a tuple? For example, I'd > > > like to transform[1, 2, (3

Re: Reading files, splitting on a delimiter and newlines.

2007-07-25 Thread Stargaming
On Wed, 25 Jul 2007 09:16:26 -0700, kyosohma wrote: > On Jul 25, 10:46 am, [EMAIL PROTECTED] wrote: >> Hello, >> >> I have a situation where I have a file that contains text similar to: >> >> myValue1 = contents of value1 >> myValue2 = contents of value2 but >> with a new l

Re: How to create a single executable of a Python program

2007-07-25 Thread Larry Bates
NicolasG wrote: > Dear fellows, > > I'm trying to create a executable file using py2exe . Unfortunately > along with the python executable file it also creates some other files > that are needed in order to the executable be able to run in a system > that doesn't have Python installed. Can some on

Re: From D

2007-07-25 Thread [EMAIL PROTECTED]
On Jul 24, 6:08 pm, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Tue, 24 Jul 2007 20:09:00 +0200, Bjoern Schliessmann wrote: > > Stargaming wrote: > >> On Tue, 24 Jul 2007 03:19:53 -0700, bearophileHUGS wrote: > > >>> While in a syntax like: > >>> for i in xrange(1_000_000): > >>> my eyes help m

Re: From D

2007-07-25 Thread star . public
On Jul 25, 1:22 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > > So, spaces will no longer be delimiters? Won't that cause > much wailing and gnashing of teeth? > I can't think of a circumstance in which 48 1906 is valid, so . . . I like it, too :) -- Star Weaver -- http://mail.python.

Re: Closures / Blocks in Python

2007-07-25 Thread Jeff
True, and I should have known better than to not have thoroughly tested code I post to Usenet :). That being said, it was intended as a fast example of how a generator operates for someone coming from Ruby. -- http://mail.python.org/mailman/listinfo/python-list

Re: Flatten a list/tuple and Call a function with tuples

2007-07-25 Thread Neil Cerutti
On 2007-07-25, Jeff <[EMAIL PROTECTED]> wrote: > Here's a quick flatten() function: > > def flatten(obj): > if type(obj) not in (list, tuple, str): > raise TypeError("String, list, or tuple expected in > flatten().") > if len(obj) == 1: > if type(obj[0]) in (tuple, list): >

Re: is_iterable function.

2007-07-25 Thread Carsten Haese
On Wed, 2007-07-25 at 11:58 -0700, [EMAIL PROTECTED] wrote: > You can use the built-in dir() function to determine whether or not > the __iter__ method exists: > > class Iterable(object): > def __iter__(self): > pass > > class NotIterable(object): > pass > > def is_iterable(thing

Re: is_iterable function.

2007-07-25 Thread Marc 'BlackJack' Rintsch
On Wed, 25 Jul 2007 11:58:40 -0700, [EMAIL PROTECTED] wrote: > You can use the built-in dir() function to determine whether or not > the __iter__ method exists: Doesn't work: In [58]: is_iterable('hello') Out[58]: False But strings *are* iterable. And just calling `iter()` doesn't work either:

Re: Flatten a list/tuple and Call a function with tuples

2007-07-25 Thread Jeff
On Jul 25, 3:05 pm, "Eduardo \"EdCrypt\" O. Padoan" <[EMAIL PROTECTED]> wrote: > def flatten(listOfLists): > return list(chain(*listOfLists)) > > >Fromhttp://www.python.org/doc/2.4/lib/itertools-recipes.html > > -- > EduardoOPadoan (eopadoan->altavix::com) > Bookmarks:http://del.icio.us/edcrypt

Re: Why PHP is so much more popular for web-development

2007-07-25 Thread Christoph Haas
On Wed, Jul 25, 2007 at 12:34:08PM -0700, walterbyrd wrote: > When I posted "Python" I meant the Python web-developement world. In > particular, python frameworks, like CherryPy, have requirements that > are not realistic for most shared hosting plans. It's true that the requirements are higher th

Re: is_iterable function.

2007-07-25 Thread Neil Cerutti
On 2007-07-25, Carsten Haese <[EMAIL PROTECTED]> wrote: > On Wed, 2007-07-25 at 19:26 +, Neil Cerutti wrote: >> Speaking of the iter builtin function, is there an example of the >> use of the optional sentinel object somewhere I could see? > > Example 1: If you use a DB-API module that doesn't

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

2007-07-25 Thread Martha_Jones
Python is a better language, with php support, anyway, but I am fed up with attitudes of comp.lang.perl.misc. Assholes in this newsgroup ruin Perl experience for everyone. Instead of being helpful, snide remarks, back-biting, scare tactings, and so on proliferate and self reinforce. All honest peop

Re: is_iterable function.

2007-07-25 Thread Neil Cerutti
On 2007-07-25, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > So there's no reliable way to test for "iterables" other than > actually iterate over the object. A TypeError exception is perhaps too generic for comfort in this use case: def deeply_mapped(func, iterable): for item in iterab

Re: is_iterable function.

2007-07-25 Thread Marc 'BlackJack' Rintsch
On Wed, 25 Jul 2007 15:46:14 -0400, Carsten Haese wrote: > On Wed, 2007-07-25 at 19:11 +, Marc 'BlackJack' Rintsch wrote: >> And just calling `iter()` doesn't work either: >> >> In [72]: class A: >>: def __getitem__(self, key): >>: if key == 42: >>:

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

2007-07-25 Thread James Stroud
[EMAIL PROTECTED] wrote: > Python is a better language, with php support, anyway, but I am fed up > with attitudes of comp.lang.perl.misc. Assholes in this newsgroup ruin > Perl experience for everyone. Instead of being helpful, snide remarks, > back-biting, scare tactings, and so on proliferate an

Re: first, second, etc line of text file

2007-07-25 Thread Bjoern Schliessmann
Grant Edwards wrote: > On 2007-07-25, Jeff McNeil <[EMAIL PROTECTED]> wrote: >> Depending on the size of your file, you can just use >> file.readlines. Note that file.readlines is going to read the >> entire file into memory, so don't use it on your plain-text >> version of War and Peace. > > I

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

2007-07-25 Thread Abigail
_ [EMAIL PROTECTED] ([EMAIL PROTECTED]) wrote on VLXXVI September MCMXCIII in news:[EMAIL PROTECTED]>: }} Python is a better language, with php support, anyway, but I am fed up }} with attitudes of comp.lang.perl.misc. Assholes in this newsgroup

Re: Why PHP is so much more popular for web-development

2007-07-25 Thread walterbyrd
On Jul 25, 2:12 pm, Carsten Haese <[EMAIL PROTECTED]> wrote: > Also, CherryPy's requirements are very > minimal. In terms of memory and CPU, maybe. But I think that *requires* apache 2.x and a very recent version of mod_python. By web-hosting standards, those are very steep requirements. -- h

Re: first, second, etc line of text file

2007-07-25 Thread Jeff
Grant, That might be a memory problem if you are running multiple processes regularly, such as on a webserver. -- http://mail.python.org/mailman/listinfo/python-list

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

2007-07-25 Thread James Matthews
Welcome aboard On 7/25/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: Python is a better language, with php support, anyway, but I am fed up with attitudes of comp.lang.perl.misc. Assholes in this newsgroup ruin Perl experience for everyone. Instead of being helpful, snide remarks, back-bitin

Re: Why PHP is so much more popular for web-development

2007-07-25 Thread Daniel
On Wed, 25 Jul 2007 20:42:54 +0300, walterbyrd <[EMAIL PROTECTED]> wrote: > I'm fairly new to web-development, and I'm trying out different > technologies. Some people wonder why PHP is so popular, when the > language is flawed in so many ways. To me, it's obvious: it's because > it's much easie

Re: Why PHP is so much more popular for web-development

2007-07-25 Thread Carsten Haese
On Wed, 2007-07-25 at 13:55 -0700, walterbyrd wrote: > On Jul 25, 2:12 pm, Carsten Haese <[EMAIL PROTECTED]> wrote: > > > Also, CherryPy's requirements are very > > minimal. > > In terms of memory and CPU, maybe. But I think that *requires* apache > 2.x and a very recent version of mod_python.

Singleton in Python Cookbook

2007-07-25 Thread Alex Popescu
Hi all! I was reading through Python Cookbook the Singleton recipe. At this moment I am a bit puzzled as the example in the book is not working resulting in: TypeError: type.__new__(SingleSpam): SingleSpam is not a subtype of type (I haven't presented the original code as I am not sure about co

Bug in cPickle with packages and 'object' inherited class

2007-07-25 Thread Conrado PLG
Say you have this structure: pna/ __init__.py model.py __init__.py is empty. model.py is: import cPickle as pickle class A(object): pass def serialize(): pickle.dump(A(), open('temp.dat', 'wb')) Now open a python interpreter on the root directory of that structure and type

Re: first, second, etc line of text file

2007-07-25 Thread Daniel Nogradi
Thanks all! I think I will stick to my original method because the files can be quite large and without reading the whole file into memory probably enumerate( open( textfile ) ) is the only way to access an arbitrary Nth line. -- http://mail.python.org/mailman/listinfo/python-list

Re: Why PHP is so much more popular for web-development

2007-07-25 Thread Jeff
I'm an ex-PHP programmer (well, I still have to use some PHP at work, but I don't tell anyone that at parties) who now uses Python or Lisp wherever possible for web development. I can tell you exactly why PHP is so popular: it acts as an extension of HTML and is syntactically similar to Perl. PHP

Re: first, second, etc line of text file

2007-07-25 Thread Jeff
Files should be iterable on their own: filehandle = open('/path/to/foo.txt') for line in filehandle: # do something... But you could also do a generic lines = filehandle.readlines(), which returns a list of all lines in the file, but that's a bit memory hungry. -- http://mail.python.org/mai

Re: Why PHP is so much more popular for web-development

2007-07-25 Thread Paul McNett
Steve Holden wrote: > When someone starts to push the limits of PHP they either continue to > push until they get where they want to be (producing an ugly or > ill-maintained bunch of code along the way) or they choose a more > appropriate tool. > > The latter behavior is typical of programmers

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

2007-07-25 Thread J�rgen Exner
[EMAIL PROTECTED] wrote: > Python is a better language, with php support, anyway, but I am fed up > with attitudes of comp.lang.perl.misc. Assholes in this newsgroup ruin > Perl experience for everyone. Instead of being helpful, snide remarks, > back-biting, scare tactings, and so on proliferate an

Re: is_iterable function.

2007-07-25 Thread Duncan Booth
Neil Cerutti <[EMAIL PROTECTED]> wrote: > Speaking of the iter builtin function, is there an example of the > use of the optional sentinel object somewhere I could see? for line in iter(open('somefile.txt', 'r').readline, ''): print line -- http://mail.python.org/mailman/listinfo/python

Re: Why PHP is so much more popular for web-development

2007-07-25 Thread Steve Holden
Carsten Haese wrote: > On Wed, 2007-07-25 at 10:42 -0700, walterbyrd wrote: >> "Once you start down the Dark path, forever will it dominate your >> desiny. Consume you, it will." >> - Yoda >> >> I'm fairly new to web-development, and I'm trying out different >> technologies. Some people wonder why

Re: is_iterable function.

2007-07-25 Thread Carsten Haese
On Wed, 2007-07-25 at 19:26 +, Neil Cerutti wrote: > Speaking of the iter builtin function, is there an example of the > use of the optional sentinel object somewhere I could see? Example 1: If you use a DB-API module that doesn't support direct cursor iteration with "for row in cursor", you c

first, second, etc line of text file

2007-07-25 Thread Daniel Nogradi
A very simple question: I currently use a cumbersome-looking way of getting the first, second, etc. line of a text file: for i, line in enumerate( open( textfile ) ): if i == 0: print 'First line is: ' + line elif i == 1: print 'Second line is: ' + line ...

Re: Why PHP is so much more popular for web-development

2007-07-25 Thread Steve Holden
walterbyrd wrote: > On Jul 25, 2:12 pm, Carsten Haese <[EMAIL PROTECTED]> wrote: > >> Also, CherryPy's requirements are very >> minimal. > > In terms of memory and CPU, maybe. But I think that *requires* apache > 2.x and a very recent version of mod_python. By web-hosting > standards, those are

Output to csv

2007-07-25 Thread Doran, Harold
I've hacked together a small utility program that I assume can be written much better. The program reads in output from a statistical program and spits out the relevant data needed. The purpose of the program is to reach into the original data file (which is a text file), pull out the relevant info

TypeError: 'int' object is not callable for max(2,3)

2007-07-25 Thread Arash Arfaee
Hi all, I have a problem. if I enter max(2,3) before I run my program in command line it returns 3. However if I start to debug my program, I have this error: [Dbg]>>> max(2,3) Traceback (most recent call last): File "", line 1, in TypeError: 'int' object is not callable Any idea what should b

Re: Reading files, splitting on a delimiter and newlines.

2007-07-25 Thread John Machin
On Jul 26, 3:08 am, Stargaming <[EMAIL PROTECTED]> wrote: > On Wed, 25 Jul 2007 09:16:26 -0700, kyosohma wrote: > > On Jul 25, 10:46 am, [EMAIL PROTECTED] wrote: > >> Hello, > > >> I have a situation where I have a file that contains text similar to: > > >> myValue1 = contents of value1 > >> myValu

Re: first, second, etc line of text file

2007-07-25 Thread Jay Loden
Grant Edwards wrote: > On 2007-07-25, Jeff <[EMAIL PROTECTED]> wrote: > >> That might be a memory problem if you are running multiple processes >> regularly, such as on a webserver. > > I suppose if you did it in parallel 50 processes, you could use > up 250MB of RAM. Still not a big deal on man

Re: Why PHP is so much more popular for web-development

2007-07-25 Thread Steve Holden
Jeff McNeil wrote: > Unfortunately, I also find that PHP programmers are usually more > plentiful than their Python counterparts. When thinking of staffing > an organization, it's common to target a skill set that's cheaper to > employ and easier to replace down the road if need be. > Right, that

Re: Singleton in Python Cookbook

2007-07-25 Thread Alex Popescu
"Diez B. Roggisch" <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > Alex Popescu schrieb: >> Hi all! >> >> I was reading through Python Cookbook the Singleton recipe. At this >> moment I am a bit puzzled as the example in the book is not working >> resulting in: >> >> TypeError: type.__n

  1   2   3   >