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

2007-07-25 Thread Marc 'BlackJack' Rintsch
On Thu, 26 Jul 2007 00:58:10 +, beginner wrote: > I need nested lists to represent nested records in a script. Since the > structure of the underlying data is nested, I think it is probably > reasonable to represent them as nested lists. For example, if I have > the below structure: > > Big R

Re: Pickled objects over the network

2007-07-25 Thread Paul Rubin
"Hendrik van Rooyen" <[EMAIL PROTECTED]> writes: > 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? > > Or am I th

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

2007-07-25 Thread Hendrik van Rooyen
: <[EMAIL PROTECTED]> 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 line here > > myV

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

2007-07-25 Thread NicolasG
> You need to tell us why you "think" you need this and perhaps we can make a > suggestion. Question: Have you installed ANY applications recently that > consisted of only a single file on your hard drive? Answer: No. Most > applications install many (sometimes hundreds) of files. So what is th

Re: From D

2007-07-25 Thread Ben Finney
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > On Jul 25, 9:04?pm, Steven D'Aprano > <[EMAIL PROTECTED]> wrote: > Why does it make no sense? Have you never had to scrape a web page > or read a CSV file? Again, unrelated to the way the Python compiler syntactically treats the source code. > So

Re: Pickled objects over the network

2007-07-25 Thread Hendrik van Rooyen
"Marco Mariani" wrote: > 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 > > parame

Re: From D

2007-07-25 Thread Ben Finney
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > On Jul 25, 8:54?pm, Steven D'Aprano > <[EMAIL PROTECTED]> wrote: > Any number of whitespace characters? Just spaces or all whitespace > characters? > What about searching source code files? What's the regular > expression for locating a number wit

Re: Keyword argument 'from'; invalid syntax

2007-07-25 Thread Stargaming
On Thu, 26 Jul 2007 12:08:40 +1000, Steven D'Aprano wrote: > On Thu, 26 Jul 2007 03:33:20 +0200, Kai Kuehne wrote: > >> I have tried to prepare a dict and then passing it to the method >> afterwards: > d = {'person': 'user', 'from': vorgestern} > magnolia.bookmarks_find(d) >> : bookmarks_

Re: cls & self

2007-07-25 Thread Stargaming
On Thu, 26 Jul 2007 03:07:56 +, james_027 wrote: > hi, > > is cls & self the same thing? > > I have seen something like > > class A: > def dosomething(cls): >#doing something > > How is cls & self differ? How is it use? > > Thanks > james First, you have to understand that th

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

2007-07-25 Thread Ben Finney
[EMAIL PROTECTED] writes: > Python is a better language, with php support, anyway, but I am fed > up with attitudes of comp.lang.perl.misc. Please, if you must fred the troll, drop comp.lang.python from the discussion (i.e. post trplies only to the newsgroup this message relates to). -- \

Re: From D

2007-07-25 Thread Ben Finney
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > IDLE 1.2c1 > >>> s = '123 456' > >>> s.split() > ['123', '456'] The str.split method has no bearing on this discussion, which is about the Python language syntax, and numeric literal values in particular. -- \"Pinky, are you pondering w

Re: From D

2007-07-25 Thread [EMAIL PROTECTED]
On Jul 25, 9:04?pm, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Wed, 25 Jul 2007 18:17:19 -0700, [EMAIL PROTECTED] wrote: > > On Jul 25, 8:00 pm, Ben Finney <[EMAIL PROTECTED]> > > wrote: > >> "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > >> > On Jul 24, 6:08 pm, Steven D'Aprano > >> > <[EM

Re: From D

2007-07-25 Thread [EMAIL PROTECTED]
On Jul 25, 8:54?pm, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Wed, 25 Jul 2007 10:22:46 -0700, [EMAIL PROTECTED] wrote: > > 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: > >> >> O

Re: Singleton in Python Cookbook

2007-07-25 Thread Steve Holden
Alex Popescu wrote: > Alex Popescu <[EMAIL PROTECTED]> wrote in > news:[EMAIL PROTECTED]: > >> "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 m

Locale-specific string comparasion

2007-07-25 Thread Yuan HOng
Hi, The locale modules privides a strcoll function that can perform locale specific string comparision, and based on this, we can design custom comparision function for the sorting. However, this is quite cumbersome, for we have to derive custom classes from from the string / unicode objects, an

Re: idiom for RE matching

2007-07-25 Thread Gordon Airporte
Ben Finney wrote: > > Not that I want to pick on you; I just don't want something wrong > labelled as "proper" to go unchallenged in the archives :-) Oh gawd :-P I swear I have it right in the actual file! heh. Copy and paste something that's compiled kids, copy and paste. -- http://mail.pytho

Re: Singleton in Python Cookbook

2007-07-25 Thread O.R.Senthil Kumaran
* Alex Popescu <[EMAIL PROTECTED]> [2007-07-25 21:30:14]: > TypeError: type.__new__(SingleSpam): SingleSpam is not a subtype of type That's hardly helpful. All I can think about is, SingleSpam is a class and you have to defined the Class in your program, or it could be something else also. > (I

cls & self

2007-07-25 Thread james_027
hi, is cls & self the same thing? I have seen something like class A: def dosomething(cls): #doing something How is cls & self differ? How is it use? Thanks james -- http://mail.python.org/mailman/listinfo/python-list

Re: idiom for RE matching

2007-07-25 Thread Ben Finney
Gordon Airporte <[EMAIL PROTECTED]> writes: > The actual code uses the proper 'if foo in line or if bar in line:' > form. >>> line = "spam eggs ham" >>> foo = "spam" >>> bar = "sausage" >>> if foo in line or if bar in line: File "", line 1 if foo in line or if bar in

Re: idiom for RE matching

2007-07-25 Thread Wildemar Wildenburger
Gordon Airporte wrote: > Yes, that's pseudo code even though I didn't really mean it that way > when I typed it. The actual code uses the proper 'if foo in line or if > bar in line:' form. > One 'if' too many. /W -- http://mail.python.org/mailman/listinfo/python-list

Re: Unable to abort a FTP command?

2007-07-25 Thread _wdx
Thank you. You are right, retrbinary did not notice I want to abort, so it won't break the recv loop and close data connection. I changed getpart and callback like this, now it works: def getpart_callback(self, received): print "received a packet" if self.cnt <= 0:

Re: Keyword argument 'from'; invalid syntax

2007-07-25 Thread Kai Kuehne
Hi Steven, On 7/26/07, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Thu, 26 Jul 2007 03:33:20 +0200, Kai Kuehne wrote: > Try this: > > magnolia.bookmarks_find(**d) This works perfectly, thank you guys. Kai -- http://mail.python.org/mailman/listinfo/python-list

Re: first, second, etc line of text file

2007-07-25 Thread Gabriel Genellina
En Wed, 25 Jul 2007 19:14:28 -0300, James Stroud <[EMAIL PROTECTED]> escribió: > Daniel Nogradi wrote: >> A very simple question: I currently use a cumbersome-looking way of >> getting the first, second, etc. line of a text file: > > to_get = [0, 3, 7, 11, 13] > got = dict((i,s) for (i,s) in enu

Re: Keyword argument 'from'; invalid syntax

2007-07-25 Thread Steven D'Aprano
On Thu, 26 Jul 2007 03:33:20 +0200, Kai Kuehne wrote: > I have tried to prepare a dict and then passing it to the > method afterwards: d = {'person': 'user', 'from': vorgestern} magnolia.bookmarks_find(d) > : bookmarks_find() takes exactly 1 > argument (2 given) > > I'm out of ideas so

Re: From D

2007-07-25 Thread Steven D'Aprano
On Wed, 25 Jul 2007 18:17:19 -0700, [EMAIL PROTECTED] wrote: > On Jul 25, 8:00 pm, Ben Finney <[EMAIL PROTECTED]> > wrote: >> "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: >> > On Jul 24, 6:08 pm, Steven D'Aprano >> > <[EMAIL PROTECTED]> wrote: >> > > Python already does: >> > > "hello-" "world"

Re: win32com ppt embedded object numbers reverting back to original numbers - SOLVED

2007-07-25 Thread Lance Hoffmeyer
Hey all, I solved this problem. Here is the final version of this def for anyone who someday may be interested: def attributesbyID(row,base,slideID,spreadsheet): sh = wb.Worksheets (spreadsheet) sh.Select() LIST = xlparams(row, base) POWERPOINT SE

Re: Keyword argument 'from'; invalid syntax

2007-07-25 Thread Paul Rubin
"Kai Kuehne" <[EMAIL PROTECTED]> writes: > >>> d = {'person': 'user', 'from': vorgestern} > >>> magnolia.bookmarks_find(d) > : bookmarks_find() takes exactly 1 > argument (2 given) > > I'm out of ideas so help is greatly appreciated! Try magnolia.bookmarks_find(**d) -- http://mail.python.org/

Re: From D

2007-07-25 Thread Steven D'Aprano
On Wed, 25 Jul 2007 10:22:46 -0700, [EMAIL PROTECTED] wrote: > 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 i

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

2007-07-25 Thread chrispwd
On Jul 25, 7:56 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > On Jul 25, 8: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 > >

Keyword argument 'from'; invalid syntax

2007-07-25 Thread Kai Kuehne
Hi list! I'm using pygmalion (magnolia api access lib) and want to use the following method that it is offering: magnolia.bookmarks_find(person='user', from=some_datetime) As you may noticed, from is a keyword argument and so I get the following error message from python: File "", line 1

Re: From D

2007-07-25 Thread [EMAIL PROTECTED]
On Jul 25, 8:00 pm, Ben Finney <[EMAIL PROTECTED]> wrote: > "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > > On Jul 24, 6:08 pm, Steven D'Aprano > > <[EMAIL PROTECTED]> wrote: > > > Python already does: > > > "hello-" "world" => "hello-world" > > > > Propose: > > > 123 456 789 => 123456789 > > >

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

2007-07-25 Thread Jeff
> For example, if I have > the below structure: > > Big Record >Small Record Type A >Many Small Record Type B >Small Record Type C > > It is pretty natural to use lists, although after a while it is > difficult to figure out the meaning of the fields in the lists. If > only there were a

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

2007-07-25 Thread Jeff McNeil
On 7/25/07, Steve Holden <[EMAIL PROTECTED]> wrote: > 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

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

2007-07-25 Thread Steven D'Aprano
On Wed, 25 Jul 2007 09:33:26 -0700, Paul Rubin wrote: > Things > are logically single values or they are logically lists of values Except for strings, and string-like objects. And files. And records/structs, and tuples. And lists. And sets. And bit strings. And tree-like structures. And, we

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

2007-07-25 Thread Steven D'Aprano
On Wed, 25 Jul 2007 15:46:58 +, beginner wrote: > I know the * operator. However, a 'partial unpack' does not seem to > work. > > def g(): > return (1,2) > > def f(a,b,c): > return a+b+c > > f(*g(),10) will return an error. No it doesn't, it _raises_ an exception. This is a function t

Re: From D

2007-07-25 Thread Ben Finney
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > On Jul 24, 6:08 pm, Steven D'Aprano > <[EMAIL PROTECTED]> wrote: > > Python already does: > > "hello-" "world" => "hello-world" > > > > Propose: > > 123 456 789 => 123456789 > > 123.456 789 => 123.456789 > > So, spaces will no longer be delimiters

Re: How do I 'stat' online files?

2007-07-25 Thread Gabriel Genellina
En Wed, 25 Jul 2007 15:11:19 -0300, Carsten Haese <[EMAIL PROTECTED]> escribió: > On Tue, 2007-07-24 at 22:23 -0300, Gabriel Genellina wrote: >> En Tue, 24 Jul 2007 10:47:16 -0300, Carsten Haese <[EMAIL PROTECTED]> >> escribió: >> >> > On Tue, 2007-07-24 at 09:07 -0400, DB Daniel Brown wrote: >>

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

2007-07-25 Thread beginner
> Not the most beautiful solution, but it works. > > Diez- Hide quoted text - > > - Show quoted text - Yeah it works! Thanks. -- http://mail.python.org/mailman/listinfo/python-list

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

2007-07-25 Thread beginner
> Well, there are several ways to solve this. You could either invoke f(*g > () + (10,)). Might be a bit nasty and unreadable, though. Or you could > just change your function f to accept them in reversed order (f(10, *g) > should work) or convert g() to return a dictionary like {'b': 1, 'c': 2} >

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

2007-07-25 Thread beginner
> Also, this has not been suggested: > > py> def g(): > ... return (1,2) > ... > py> def f(a,b,c): > ... return a+b+c > ... > py> f(c=10, *g()) > 13 > > James- Hide quoted text - > > - Show quoted text - Great idea. -- http://mail.python.org/mailman/listinfo/python-list

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

2007-07-25 Thread beginner
On Jul 25, 11:33 am, Paul Rubin wrote: > 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 yo

Re: classmethod & staticmethod

2007-07-25 Thread Steven D'Aprano
On Wed, 25 Jul 2007 00:55:17 +, Alex Popescu 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

Re: code indentation

2007-07-25 Thread Ben Finney
[EMAIL PROTECTED] writes: > On this group I ask for serious help and now we talk about > communication. Yes. You're asking for volunteer help from a group of people who have their own priorities separate from yours. The way to garner help from these people is to respect their time. One excellent

Re: classmethod & staticmethod

2007-07-25 Thread Steven D'Aprano
On Wed, 25 Jul 2007 00:22:18 +, Alex Popescu wrote: > "Steven D'Aprano" <[EMAIL PROTECTED]> wrote in > news:[EMAIL PROTECTED]: > >> On Tue, 24 Jul 2007 21:35:58 +, Alex Popescu wrote: >> >>> Neil Cerutti <[EMAIL PROTECTED]> wrote in >>> news:[EMAIL PROTECTED]: >>> On 2007-07-24,

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

2007-07-25 Thread Jeff
No programming language can fix bad programmers. And if cost is an issue, www.nearlyfreespeech.net has Python, clisp, and OCaml. -- http://mail.python.org/mailman/listinfo/python-list

Re: python-fam documentation.

2007-07-25 Thread Evan Klitzke
On 7/25/07, Evan Klitzke <[EMAIL PROTECTED]> wrote: > On 7/23/07, Shriphani <[EMAIL PROTECTED]> wrote: > > Folks, > > I am trying to create an app which stares at a file and when the file > > is altered, the script joins a channel on freenode and reports that > > the file has been altered. > > I fo

Re: python-fam documentation.

2007-07-25 Thread Evan Klitzke
On 7/23/07, Shriphani <[EMAIL PROTECTED]> wrote: > Folks, > I am trying to create an app which stares at a file and when the file > is altered, the script joins a channel on freenode and reports that > the file has been altered. > I found a module called python-fam, unfortunately i have been unable

Re: Cleaning up a string

2007-07-25 Thread MRAB
On Jul 24, 8:47 pm, James Stroud <[EMAIL PROTECTED]> wrote: > Hello all, > > I dashed off the following function to clean a string in a little > > program I wrote: > > def cleanup(astr, changes): >for f,t in changes: > atr = astr.replace(f, t) >return astr > > where changes would be a

Re: Closures / Blocks in Python

2007-07-25 Thread Gabriel Genellina
En Wed, 25 Jul 2007 11:45:00 -0300, Jeff <[EMAIL PROTECTED]> escribió: > 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 defin

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

2007-07-25 Thread [EMAIL PROTECTED]
On Jul 25, 8: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: first, second, etc line of text file

2007-07-25 Thread Paul Rubin
"Daniel Nogradi" <[EMAIL PROTECTED]> writes: > 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:

Re: Reading a Directory of Emails - Problems

2007-07-25 Thread StatsJunkie
Thanks. I tried that, but absolutely nothing is printed to the screen. This is the code I am trying to use. mbox = mailbox.MHMailbox("stat_inbox.mbox/Messages",email.message_from_file) for msg in mbox: print(msg) #just to see if anything is happening Which mailbox type did you u

Re: first, second, etc line of text file

2007-07-25 Thread Jeff McNeil
Yup, I actually had log files in mind, too. I process Apache logs from an 8-way cluster every 15 minutes. There are 32,000 sites on said cluster; that's a lot of log data! I didn't actually think anyone would go *try* to open("war_and_peace.txt").readlines().. I just meant it as a generalization

Re: Singleton in Python Cookbook

2007-07-25 Thread John J. Lee
Alex Popescu <[EMAIL PROTECTED]> writes: > 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 Haven't look

Re: Singleton in Python Cookbook

2007-07-25 Thread John J. Lee
"Diez B. Roggisch" <[EMAIL PROTECTED]> writes: [...] > AFAIK the cookbook is completely found online at ASPN. So no sweat > publishing it here. [...] No: the book-form cookbook is edited, and has extra text. I believe the recipes are under a BSD-style license, though. John -- http://mail.pytho

Re: Singleton in Python Cookbook

2007-07-25 Thread Alex Popescu
Alex Popescu <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > "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

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

2007-07-25 Thread James Matthews
Wow! They might leave this newsgroup now also! On 7/25/07, Jürgen Exner <[EMAIL PROTECTED]> wrote: [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 eve

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

Re: idiom for RE matching

2007-07-25 Thread Gordon Airporte
Miles wrote: > On 7/24/07, Gordon Airporte <[EMAIL PROTECTED]> wrote: >> 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 > > Be careful: unless this is just pseudocode, this Python doesn't do >

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 walterbyrd
On Jul 25, 3:55 pm, Steve Holden <[EMAIL PROTECTED]> wrote: > 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 >

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: TypeError: 'int' object is not callable for max(2,3)

2007-07-25 Thread Steve Holden
Arash Arfaee wrote: > 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

Re: first, second, etc line of text file

2007-07-25 Thread James Stroud
Daniel Nogradi wrote: > 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

Re: Singleton in Python Cookbook

2007-07-25 Thread Diez B. Roggisch
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.__new__(SingleSpam): SingleSpam is not a subtype of type > > (I haven't presented the o

Re: is_iterable function.

2007-07-25 Thread Steve Holden
Carsten Haese 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 support direct cursor > iteration

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: 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

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: 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: 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

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

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.

Re: first, second, etc line of text file

2007-07-25 Thread Grant Edwards
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 many servers. A decent OS will swap

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: Why PHP is so much more popular for web-development

2007-07-25 Thread walterbyrd
On Jul 25, 2:10 pm, Jeff <[EMAIL PROTECTED]> wrote: > I can tell you exactly why PHP > is so popular: it acts as an extension of HTML and is syntactically > similar to Perl. > Although, that can lead to problems, if you're not careful: Perl: my $x = 5 + 9000 || 1; # $x is 9005 PHP: $x = 5 + 900

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: first, second, etc line of text file

2007-07-25 Thread Grant Edwards
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 don't think that would actually

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: first, second, etc line of text file

2007-07-25 Thread George Sakkis
On Jul 25, 3:44 pm, "Daniel Nogradi" <[EMAIL PROTECTED]> wrote: > 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 >

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 McNeil
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. >>> f = open("/etc/passwd") >>> lines = f.readlines() >>> lines[5] '# lookupd DirectoryServices

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

2007-07-25 Thread Carsten Haese
On Wed, 2007-07-25 at 12:34 -0700, walterbyrd wrote: > On Jul 25, 12:40 pm, Carsten Haese <[EMAIL PROTECTED]> wrote: > > > What exactly could Python learn from PHP? > > Remember, I'm a noob, I'm not trolling. I know. > When I posted "Python" I meant the Python web-developement world. In > parti

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: is_iterable function.

2007-07-25 Thread George Sakkis
On Jul 25, 3:26 pm, 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? # iterate over random numbers from 1 to 10; use 0 as a sentinel to stop the iteration for n in iter(lambda:r

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

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 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

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 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: adding a docstring to an instancemethod

2007-07-25 Thread Gabriel Genellina
En Wed, 25 Jul 2007 08:05:37 -0300, jelle <[EMAIL PROTECTED]> escribió: > 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 Se

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

  1   2   3   >