Re: list comprehension problem

2009-11-02 Thread Paul Rudin
Falcolas writes: > [s.strip() for s in hosts if s.strip()] There's something in me that rebels against seeing the same call twice. I'd probably write: filter(None, (s.strip() for s in hosts)) -- http://mail.python.org/mailman/listinfo/python-list

Re: Sqlite3. Substitution of names in query.

2009-11-02 Thread Lawrence D'Oliveiro
In message , Dennis Lee Bieber wrote: > On Tue, 03 Nov 2009 09:41:10 +1300, Lawrence D'Oliveiro > declaimed the following in > gmane.comp.python.general: > >> There is no such parsing overhead. I speak from experience. >> > > >> Look at the BulkInserter class here >>

Re: substituting list comprehensions for map()

2009-11-02 Thread Sean DiZazzo
On Nov 2, 9:01 pm, Ben Finney wrote: > Anh Hai Trinh writes: > > > > Yes, just about any ‘map()’ operation has a corresponding list > > > comprehension. (Does anyone know of a counter-example, a ‘map()’ > > > operation that doesn't have a correspondingly simple list > > > comprehension?) > > > Tr

Re: substituting list comprehensions for map()

2009-11-02 Thread Steven D'Aprano
On Mon, 02 Nov 2009 20:06:51 -0800, Anh Hai Trinh wrote: >> Yes, just about any ‘map()’ operation has a corresponding list >> comprehension. (Does anyone know of a counter-example, a ‘map()’ >> operation that doesn't have a correspondingly simple list >> comprehension?) > > Try turning this into

Re: chr / ord

2009-11-02 Thread Steven D'Aprano
On Mon, 02 Nov 2009 20:30:00 -0800, Sean McIlroy wrote: > hello > > how do i say "chr" and "ord" in the new python? "chr" and "ord". > the functions below (which work in 2.6.6) Can I borrow your time machine, there's some lottery numbers I want to get. There is no Python 2.6.6. The lates

Re: About one class/function per module

2009-11-02 Thread Steven D'Aprano
On Mon, 02 Nov 2009 07:24:59 -0600, Peng Yu wrote: > Suppose I have class A and class B in a file, I can not easily figure > out which class depends on which class by a simple script. How about looking at the classes? >>> class A: ... pass ... >>> class B(A): ... pass ... >>> >>> B.__ba

Re: chr / ord

2009-11-02 Thread Ben Finney
Sean McIlroy writes: > how do i say "chr" and "ord" in the new python? By “the new python”, what do you mean? * Python 2.6.4, the newest released version. * Python 2.7, a currently in-development version. * Python 3.1, another new release (but not the latest). * Python 3.2, a currently in-devel

Re: chr / ord

2009-11-02 Thread Benjamin Kaplan
On Mon, Nov 2, 2009 at 11:30 PM, Sean McIlroy wrote: > hello > > how do i say "chr" and "ord" in the new python? the functions below > (which work in 2.6.6) show what i'm trying to do. thanks if you can > help. > > def readbytes(filepath): >    return [ord(x) for x in open(filepath,'rb').read()] >

Re: substituting list comprehensions for map()

2009-11-02 Thread Ben Finney
Anh Hai Trinh writes: > > Yes, just about any ‘map()’ operation has a corresponding list > > comprehension. (Does anyone know of a counter-example, a ‘map()’ > > operation that doesn't have a correspondingly simple list > > comprehension?) > > Try turning this into a list comprehension: > > vec

Re: substituting list comprehensions for map()

2009-11-02 Thread Ben Finney
Steven D'Aprano writes: > On Mon, 02 Nov 2009 19:19:41 +1100, Ben Finney wrote: > > > "Jon P." writes: > > > >> I'd like to do: > >> > >> resultlist = operandlist1 + operandlist2 > > > > That's an unfortunate way of expressing it; it's valid Python syntax > > that doesn't do what you're descri

Re: self.__dict__ tricks

2009-11-02 Thread Aahz
In article <02fd0c85$0$1326$c3e8...@news.astraweb.com>, Steven D'Aprano wrote: >On Sat, 31 Oct 2009 11:15:48 -0500, Tim Johnson wrote: >> >> Many programmers I know stay away from 'lists' such as this, because >> they are afraid to show their ignorance. Me, I'm fearless, and I have >> learned a l

Re: substituting list comprehensions for map()

2009-11-02 Thread Anh Hai Trinh
> Try turning this into a list comprehension: > >   vectorsum = lambda *args: map(sum, zip(*args)) > >   vectorsum([1,2], [3,4], [5,6]) > ->[9, 12] >   vectorsum([1,2], [3,4], [5,6], [7,8]) > ->[16, 20] Nvm, it's actually easy: vectorsum = lambda *args: [sum(i) for i in zip(*args)] -- http://ma

chr / ord

2009-11-02 Thread Sean McIlroy
hello how do i say "chr" and "ord" in the new python? the functions below (which work in 2.6.6) show what i'm trying to do. thanks if you can help. def readbytes(filepath): return [ord(x) for x in open(filepath,'rb').read()] def writebytes(numbers,filepath): open(filepath,'wb').write(''.

Re: substituting list comprehensions for map()

2009-11-02 Thread Anh Hai Trinh
> On the other hand, list comps using an if clause can't be written as pure > maps. You can do this: > > [func(x) for x in seq if cond(x)] > > filter(cond, map(func, seq)) > > but the second version may use much more temporary memory if seq is huge > and cond very rarely true. You could use ifilte

Re: About one class/function per module

2009-11-02 Thread Gabriel Genellina
En Tue, 03 Nov 2009 00:50:56 -0300, Peng Yu escribió: On Mon, Nov 2, 2009 at 9:39 PM, alex23 wrote: Peng Yu wrote: A simple solution might be to associate a unique identifier to each file, so that even the filename has been changed, the new version and the old version can still be identifi

Re: substituting list comprehensions for map()

2009-11-02 Thread Steven D'Aprano
On Mon, 02 Nov 2009 19:19:41 +1100, Ben Finney wrote: > "Jon P." writes: > >> I'd like to do: >> >> resultlist = operandlist1 + operandlist2 > > That's an unfortunate way of expressing it; it's valid Python syntax > that doesn't do what you're describing (in this case, it will bind > ‘resultlis

Re: About one class/function per module

2009-11-02 Thread Peng Yu
On Mon, Nov 2, 2009 at 9:39 PM, alex23 wrote: > Peng Yu wrote: >> I don't think that this is a problem that can not be overcome. A >> simple solution might be to associate a unique identifier to each >> file, so that even the filename has been changed, the new version and >> the old version can s

Re: About one class/function per module

2009-11-02 Thread alex23
Peng Yu wrote: > I don't think that this is a problem that can not be overcome. A > simple solution might be to associate a unique identifier to each > file, so that even the filename has been changed, the new version and > the old version can still be identified as actually the same file. Or, ag

Re: substituting list comprehensions for map()

2009-11-02 Thread Steven D'Aprano
On Tue, 03 Nov 2009 09:14:05 +1100, Ben Finney wrote: > J Kenneth King writes: > >> Steven D'Aprano writes: >> >> > from operator import add >> > map(add, operandlist1, operandlist2) >> >> This is the best solution so far. > > Strange to say it's a solution, when it doesn't solve the stated >

Re: About one class/function per module

2009-11-02 Thread Peng Yu
On Mon, Nov 2, 2009 at 7:41 PM, Lee wrote: > On Nov 2, 7:06 pm, Peng Yu wrote: >> On Mon, Nov 2, 2009 at 9:02 AM, Jean-Michel Pichavant >> >> >> >> >> >> wrote: >> > Diez B. Roggisch wrote: >> >> >> Peng Yu wrote: >> >> >>>  I can navigate to the definition of >> >>> class and function by vim +

Re: Sqlite3. Substitution of names in query.

2009-11-02 Thread Carsten Haese
Lawrence D'Oliveiro wrote: > There is no such parsing overhead. I speak from experience. > > Look at the BulkInserter class here > . I have successfully > used that to insert tens of thousands of records in just a few seconds. Yet > it makes n

Re: read Zipfile

2009-11-02 Thread Tim Chase
Looks like you'd have to use the more primitive .read() method: http://docs.python.org/library/zipfile.html#zipfile.ZipFile.read Unfortunately, the ZipFile.read() reads the entire content. One of the main reasons to zip things is that they're big -- possibly too big to fit conveniently in mem

Re: read Zipfile

2009-11-02 Thread Tim Chase
I would like to know how does python 2.4 work for my case w/o the new added feature in 2.6? Do you guys know? You can just grab the zipfile.py file from within the 2.6 distribution[1] and dump it in your project folder. Python should find it before it finds the 2.4 version in the $PYTHONPATH

Re: __eq__() inconvenience when subclassing set

2009-11-02 Thread Gabriel Genellina
En Mon, 02 Nov 2009 22:05:42 -0300, Jess Austin escribió: On Nov 1, 1:13 am, "Gabriel Genellina" wrote: Looks like in 3.1 this can be done with bytes+str and viceversa, even if bytes and str don't have a common ancestor (other than object; basestring doesn't exist in 3.x): The same examp

Re: Sqlite3. Substitution of names in query.

2009-11-02 Thread Lawrence D'Oliveiro
In message , Robert Kern wrote: > On 2009-11-02 14:47 PM, Lawrence D'Oliveiro wrote: > >> For instance, I'm not aware of any database API that lets me do this: >> >> sql.cursor.execute \ >>( >> "update numbers set flags = flags | %(setflags)u where >> project

Re: read Zipfile

2009-11-02 Thread Chris Rebert
> On Mon, Nov 2, 2009 at 5:02 PM, Tim Chase > wrote: I would like to open the csv file with folowwing command, file=archive.open("CHAVI_MACS_SC_A__AUG_25_08_FinalReport_090812.csv","r") But it turned out error, Traceback (most recent call last):  File "", line 1,

Re: read Zipfile

2009-11-02 Thread sityee kong
Hi all, yes, im using python 2.4. I would like to know how does python 2.4 work for my case w/o the new added feature in 2.6? Do you guys know? thanks! On Mon, Nov 2, 2009 at 5:02 PM, Tim Chase wrote: > I would like to open the csv file with folowwing command, >>> >>> file=archive.open("CHAVI_

Re: read Zipfile

2009-11-02 Thread Gabriel Genellina
En Mon, 02 Nov 2009 20:39:07 -0300, sityee kong escribió: However for the ZIP file, let says the ZIP file contains only one member, archive.namelist() ['CHAVI_MACS_SC_A__AUG_25_08_FinalReport_090812.csv'] I would like to open the csv file with folowwing command, file=archive.open("CHAVI_MA

Re: __eq__() inconvenience when subclassing set

2009-11-02 Thread Jess Austin
On Nov 1, 1:13 am, "Gabriel Genellina" wrote: > Looks like in 3.1 this can be done with bytes+str and viceversa, even if   > bytes and str don't have a common ancestor (other than object; basestring   > doesn't exist in 3.x): > > p3> Base = bytes > p3> Other = str > p3> > p3> class Derived(Base):

Re: About one class/function per module

2009-11-02 Thread Peng Yu
On Mon, Nov 2, 2009 at 9:02 AM, Jean-Michel Pichavant wrote: > Diez B. Roggisch wrote: >> >> Peng Yu wrote: >> >>> >>>  I can navigate to the definition of >>> class and function by vim + ctags, >>> >> >> Start learning a decent editor (emacs is mine) which allows you to deal >> with all of your p

Re: read Zipfile

2009-11-02 Thread Tim Chase
I would like to open the csv file with folowwing command, file=archive.open("CHAVI_MACS_SC_A__AUG_25_08_FinalReport_090812.csv","r") But it turned out error, Traceback (most recent call last): File "", line 1, in ? AttributeError: ZipFile instance has no attribute 'open' ZipFile.open(name[, m

Re: import bug

2009-11-02 Thread Carl Banks
On Oct 31, 7:12 am, kj wrote: > I'm running into an ugly bug, which, IMHO, is really a bug in the > design of Python's module import scheme.  Consider the following > directory structure: > > ham > |-- __init__.py > |-- re.py > `-- spam.py > > ...with the following very simple files: > > % head ha

Re: Feedback wanted on programming introduction (Python in Windows)

2009-11-02 Thread Alf P. Steinbach
* Rhodri James: On Mon, 02 Nov 2009 00:49:50 -, Alf P. Steinbach wrote: * Rhodri James: On Sun, 01 Nov 2009 21:20:20 -, Alf P. Steinbach wrote: * Rhodri James: This is a weird attribution style, by the way. I don't think it helps. That's a pretty weird thing to comment on.

Re: Feedback wanted on programming introduction (Python in Windows)

2009-11-02 Thread Rhodri James
On Mon, 02 Nov 2009 00:49:50 -, Alf P. Steinbach wrote: * Rhodri James: On Sun, 01 Nov 2009 21:20:20 -, Alf P. Steinbach wrote: * Rhodri James: This is a weird attribution style, by the way. I don't think it helps. That's a pretty weird thing to comment on. And as far as I

Re: Tkinter callback arguments

2009-11-02 Thread Alf P. Steinbach
* Peter Otten: * Alf P. Steinbach wrote: * Peter Otten: Every time someone has to read the code he will read, hesitate, read again, and then hopefully come to the conclusion that the code does nothing, consider not using it, or if it is not tied into a larger project removing it. I don't under

Re: Pyfora, a place for python

2009-11-02 Thread Diez B. Roggisch
Daniel Fetchinson schrieb: If you have any suggestions, let me know -- this is a community effort! Suggestion: Please don't make efforts to fragment the community. When a community grows and consequently its needs also grow, how do you differentiate "natural growth" from "fragmenting the commun

Re: About one class/function per module

2009-11-02 Thread Rhodri James
On Mon, 02 Nov 2009 13:24:59 -, Peng Yu wrote: Another advantage one of class/function per file is that the syntax clearly tell the dependence relation between classes and functions. Um, no. Grepping for "import" now tells you that there is a dependency between the file contents, but it

Re: read Zipfile

2009-11-02 Thread Chris Rebert
On Mon, Nov 2, 2009 at 4:39 PM, sityee kong wrote: > However for the ZIP file, let says the ZIP file contains only one member, archive.namelist() > ['CHAVI_MACS_SC_A__AUG_25_08_FinalReport_090812.csv'] > > I would like to open the csv file with folowwing command, > file=archive.open("CHAVI_M

read Zipfile

2009-11-02 Thread sityee kong
Hi all, I'm writing a program to manipulate data in 3 different kind of format, there are GZIP, cvs/txt, or ZIP file. Here is part of my program to open these 3 kind formats of file, if (option==1): file=gzip.GzipFile(sys.argv[1],"r") elif (option==2): file=open(sys.argv[1],"r")

Re: conditional __init__

2009-11-02 Thread Carl Banks
On Nov 2, 11:40 am, King wrote: > class A(object): >     def __init__(self): >         pass >     def printme(self): >         print "I am A" > > class B(object): >     def __init__(self): >         pass >     def printme(self): >         print "I am B" > > class K(A, B): >     def __init__(self,

Re: list comprehension problem

2009-11-02 Thread Krister Svanlund
On Mon, Nov 2, 2009 at 10:11 PM, Aahz wrote: > In article > <7589e0a1-98b2-4df4-bc76-5d4c10194...@f20g2000prn.googlegroups.com>, > Falcolas   wrote: >> >>I'd also recommend trying the following filter, since it is identical >>to what you're trying to do, and will probably catch some additional >>

Re: Tkinter callback arguments

2009-11-02 Thread Diez B. Roggisch
Alf P. Steinbach schrieb: * Diez B. Roggisch: Your comment about "computed" makes it more clear what that's all about. Also Bertrand Meyer (Eiffel language creator) had idea like that, he called it "referential transparency". But I think when Python has this nice property mechanism, why do peopl

Re: graceful degradation : is it degrading?

2009-11-02 Thread Terry Reedy
Aaron Watters wrote: people noted that they sometimes didn't work properly with javascript off. I could fix this in some cases, but the fix would involve changing a "POST" to a "GET" and that would cause MSIE to suddenly fail when the GET parameters get too big (and probably other browsers too)

Re: substituting list comprehensions for map()

2009-11-02 Thread Ben Finney
J Kenneth King writes: > Steven D'Aprano writes: > > > from operator import add > > map(add, operandlist1, operandlist2) > > This is the best solution so far. Strange to say it's a solution, when it doesn't solve the stated problem: to replace use of ‘map()’ with a list comprehension. > I unde

Re: Sqlite3. Substitution of names in query.

2009-11-02 Thread Robert Kern
On 2009-11-02 14:47 PM, Lawrence D'Oliveiro wrote: In message, Dennis Lee Bieber wrote: On Sun, 01 Nov 2009 19:08 +1300, Lawrence D'Oliveiro declaimed the following in gmane.comp.python.general: On the grounds that Python has more general and powerful string parameter- substitution mechani

Re: Recommended number of threads? (in CPython)

2009-11-02 Thread Aahz
In article , mk wrote: > >I wrote run-of-the-mill program for concurrent execution of ssh command >over a large number of hosts. (someone may ask why reinvent the wheel >when there's pssh and shmux around -- I'm not happy with working details >and lack of some options in either program) > >The

Re: list comprehension problem

2009-11-02 Thread Aahz
In article <7589e0a1-98b2-4df4-bc76-5d4c10194...@f20g2000prn.googlegroups.com>, Falcolas wrote: > >I'd also recommend trying the following filter, since it is identical >to what you're trying to do, and will probably catch some additional >edge cases without any additional effort from you. > >[s.

Re: Sqlite3. Substitution of names in query.

2009-11-02 Thread Lawrence D'Oliveiro
In message , Dennis Lee Bieber wrote: > On Sun, 01 Nov 2009 19:08 +1300, Lawrence D'Oliveiro > declaimed the following in > gmane.comp.python.general: > >> On the grounds that Python has more general and powerful string >> parameter- substitution mechanisms than anything built into any database

Re: Hi help me in installing pcapy extension module

2009-11-02 Thread Diez B. Roggisch
pranesh schrieb: dear friends, I have python 2.6.4 i my Windows XP machine. I am trying to install pcapy - python extension module ( I am using http://oss.coresecurity.com/projects/pcapy.html for reference ) I decided to implement the libpcap library... Since I have only windows xp machine.

Re: Sqlite3. Substitution of names in query.

2009-11-02 Thread Lawrence D'Oliveiro
In message , Carsten Haese wrote: > Lawrence D'Oliveiro wrote: > >> Says someone who hasn't realized where the real inefficiencies are. >> Remember what Tony Hoare told us: "premature optimization is the root of >> all evil". These are databases we're talking about. Real-world databases >> are la

RE: How do I install libxml2 and libxslt?

2009-11-02 Thread Kevin Ar18
Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 > According to the lxml installation instructions you linked=2C > the windows lxml binary is statically linked and you do not > need to install the libraries separately. The install ins

Hi help me in installing pcapy extension module

2009-11-02 Thread pranesh
dear friends, I have python 2.6.4 i my Windows XP machine. I am trying to install pcapy - python extension module ( I am using http://oss.coresecurity.com/projects/pcapy.html for reference ) I decided to implement the libpcap library... Since I have only windows xp machine.. I installed WinPc

Re: conditional __init__

2009-11-02 Thread OKB (not okblacke)
King wrote: > class A(object): > def __init__(self): > pass > def printme(self): > print "I am A" > > class B(object): > def __init__(self): > pass > def printme(self): > print "I am B" > > class K(A, B): > def __init__(self, value=0): >

Re: conditional __init__

2009-11-02 Thread Chris Rebert
On Mon, Nov 2, 2009 at 12:40 PM, King wrote: > class A(object): >    def __init__(self): >        pass >    def printme(self): >        print "I am A" > > class B(object): >    def __init__(self): >        pass >    def printme(self): >        print "I am B" > > class K(A, B): >    def __init__(se

conditional __init__

2009-11-02 Thread King
class A(object): def __init__(self): pass def printme(self): print "I am A" class B(object): def __init__(self): pass def printme(self): print "I am B" class K(A, B): def __init__(self, value=0): if value == 0: A.__init__(sel

Re: Command parsing... best module to use?

2009-11-02 Thread Mark Tolonen
"Collin D" wrote in message news:94dbc92b-0682-4995-b358-0c615c95a...@x6g2000prc.googlegroups.com... Hey everyone. I am writing a game in python, and it includes a text console somewhat like the one in WoW and Runescape. I want to be able to include "/" commands, like IRC, and was wondering w

Re: How do I install libxml2 and libxslt?

2009-11-02 Thread Nat Williams
On Mon, Nov 2, 2009 at 9:41 AM, Kevin Ar18 wrote: > I want to use the lxml library, but can't get it to work on Windows. > > The following will not work: > * import libxml2 > * import libxslt > * from lxml import etree > > Here's the instructions: > http://codespeak.net/lxml/installation.html >

Re: Pyfora, a place for python

2009-11-02 Thread Paul Rubin
Kee Nethery writes: > I just noticed the tag line "a place for Python". Looked it up online > (http://pyfora.org/ ) and it will be interesting to see if it can fill > the void that I experience (no centralized place to post and view > user submitted sample code) in the existing Python community.

Re: Tkinter callback arguments

2009-11-02 Thread Peter Otten
Alf P. Steinbach wrote: > * Peter Otten: >> Alf P. Steinbach wrote: >> >>> * Peter Otten: Alf P. Steinbach wrote: >> for x in range(0,3): >> Button(.., command=lambda x=x: function(x)) > An alternative reusable alternative is to create a button-with-id >

Re: graceful degradation : is it degrading?

2009-11-02 Thread Chris Withers
Aaron Watters wrote: These days javascript is so pervasive that graceful degradation is becoming increasingly difficult and absolutely no fun for web designers and programmers. This sounds like something I'd ask about on #web on irc.freenode.net... Those guys are pretty knowledgeable, would be

Re: C api and exception handling

2009-11-02 Thread Carl Banks
On Nov 2, 7:16 am, "lallous" wrote: > Hello, > > Is there is a way, using the Python C api, to install an exception handler > that: > - will be triggered when an exception occurs > - analyze the reason of the exception > - correct the situation and try again (something like exception handling on >

graceful degradation : is it degrading?

2009-11-02 Thread Aaron Watters
Graceful degradation is what I hope to display as I continue to age... But in the context of web programming it also refers to the supposedly desirable behaviour of web sites to "do something reasonable" as resources are denied them by client browsers such as cookies, applets, javascript, etcetera

Re: Migrating from R to Python

2009-11-02 Thread Ishwor Gurung
Hi, 2009/11/3 Ryan : > I am a long time user of "R" for statistical analysis and find it an [...] > My question is to people who have used zoo and xts in R, what has > their experience been with Python? Would you recommend using native > Python to do time series analysis, or rPy to link back to R

Re: Accessing a method from within its own code

2009-11-02 Thread Dave Angel
Paddy O'Loughlin wrote: I suspect that the "inspection" module has your answer, but that it'll be bulkier, and much slower than just doing what you're doing already. Hmm. Yeah, it does appear to be bulky. I don't think it's really any more use than what I'm doing already. Why not use the

Migrating from R to Python

2009-11-02 Thread Ryan
I am a long time user of "R" for statistical analysis and find it an extremely useful environment for data exploration. That said I may be adding and/or moving to Python for more of my work and wanted to know if people had any recommendations. My work is primarily financial time series analysis. I

Re: Command parsing... best module to use?

2009-11-02 Thread TerryP
On Nov 2, 2:27 pm, Collin D wrote: > Hey everyone. > > I am writing a game in python, and it includes a text console somewhat > like the one in WoW and Runescape. I want to be able to include "/" > commands, like IRC, and was wondering what the best module would be to > parse these. > > Thanks a l

Re: Pyfora, a place for python

2009-11-02 Thread Duncan Booth
"Diez B. Roggisch" wrote: > Kee Nethery wrote: >> My personal preference would be a link in each sub-paragraph in the >> official documentation to a wiki page devoted to that specific aspect >> of the Python language. A place were users could augment the >> documentation by providing sample code

Re: Tkinter callback arguments

2009-11-02 Thread Mel
Alf P. Steinbach wrote: > Your comment about "computed" makes it more clear what that's all about. > Also Bertrand Meyer (Eiffel language creator) had idea like that, he > called it "referential transparency". But I think when Python has this > nice property mechanism, why do people change direct d

Re: Accessing a method from within its own code

2009-11-02 Thread Paddy O'Loughlin
> > I suspect that the "inspection" module has your answer, but that it'll be > bulkier, and much slower than just doing what you're doing already. > Hmm. Yeah, it does appear to be bulky. I don't think it's really any more use than what I'm doing already. Why not use the default arguments gimmic

Re: Tkinter callback arguments

2009-11-02 Thread Alf P. Steinbach
* Diez B. Roggisch: Your comment about "computed" makes it more clear what that's all about. Also Bertrand Meyer (Eiffel language creator) had idea like that, he called it "referential transparency". But I think when Python has this nice property mechanism, why do people change direct data attrib

Re: Tkinter callback arguments

2009-11-02 Thread Mel
Alf P. Steinbach wrote: > * Peter Otten: >> Alf P. Steinbach wrote: >>> * Peter Otten: unidiomatic None-checks >>> What's the idiomatic Python way for an optional thing? >> >> if some_value is None: ... > > Thanks! > > But why is this preferred? I guess because `some_value == None` restric

How do I install libxml2 and libxslt?

2009-11-02 Thread Kevin Ar18
I want to use the lxml library, but can't get it to work on Windows. The following will not work: * import libxml2 * import libxslt * from lxml import etree Here's the instructions: http://codespeak.net/lxml/installation.html * So, I run "easy_install lxml" -- that works! * Now, it says I need

Re: Pyfora, a place for python

2009-11-02 Thread Daniel Fetchinson
If you have any suggestions, let me know -- this is a community effort! >>> >>> Suggestion: Please don't make efforts to fragment the community. >> >> When a community grows and consequently its needs also grow, how do >> you differentiate "natural growth" from "fragmenting the community"

Re: Pyfora, a place for python

2009-11-02 Thread Diez B. Roggisch
Kee Nethery wrote: > I just noticed the tag line "a place for Python". Looked it up online > (http://pyfora.org/ ) and it will be interesting to see if it can fill the > void that I experience (no centralized place to post and view user > submitted sample code) in the existing Python community. A

Re: Accessing a method from within its own code

2009-11-02 Thread Gerard Flanagan
Paddy O'Loughlin wrote: Hi, I was wondering if there was a shorthand way to get a reference to a method object from within that method's code. Take this code snippet as an example: import re class MyClass(object): def find_line(self, lines): if not hasattr(MyClass.do_work, "matche

Re: Pyfora, a place for python

2009-11-02 Thread Kee Nethery
I just noticed the tag line "a place for Python". Looked it up online (http://pyfora.org/ ) and it will be interesting to see if it can fill the void that I experience (no centralized place to post and view user submitted sample code) in the existing Python community. As for user community f

Re: Accessing a method from within its own code

2009-11-02 Thread Dave Angel
Paddy O'Loughlin wrote: Hi, I was wondering if there was a shorthand way to get a reference to a method object from within that method's code. Take this code snippet as an example: import re class MyClass(object): def find_line(self, lines): if not hasattr(MyClass.do_work, "matcher"

C api and exception handling

2009-11-02 Thread lallous
Hello, Is there is a way, using the Python C api, to install an exception handler that: - will be triggered when an exception occurs - analyze the reason of the exception - correct the situation and try again (something like exception handling on windows where the exception handler can retriev

Re: About one class/function per module

2009-11-02 Thread Jean-Michel Pichavant
Diez B. Roggisch wrote: Peng Yu wrote: I can navigate to the definition of class and function by vim + ctags, Start learning a decent editor (emacs is mine) which allows you to deal with all of your perceived "problems" Diez This is a declaration of war against the vi communit

Re: exec-function in Python 3.+

2009-11-02 Thread Dave Angel
Hans Larsen wrote: Help! I'm begginer in Python 3.+! If i wih to update a module after an import and chages, How could I do: By "from imp import reload" and then reload(mymodule) or how to use "exec(?)", it is mentoined in docs. In Python ver. <3 reload(module) writes some

Re: Pyfora, a place for python

2009-11-02 Thread Diez B. Roggisch
Daniel Fetchinson wrote: >>> If you have any suggestions, let me know -- this is a community >>> effort! >> >> Suggestion: Please don't make efforts to fragment the community. > > When a community grows and consequently its needs also grow, how do > you differentiate "natural growth" from "fragme

Re: Help with SOAPpy and WSDL.

2009-11-02 Thread Simon Brunning
2009/11/2 Henrik Aagaard Sørensen : > I'll try to explain it here then: > > A small example on SOAPpy and WSDL. My code: > from SOAPpy import WSDL > wsdlFile = 'http://www.webservicex.net/country.asmx?wsdl' > server = WSDL.Proxy(wsdlFile) > server.GetCurrencyByCountry('Zimbabwe') > > returns: > Sy

Re: Pyfora, a place for python

2009-11-02 Thread Daniel Fetchinson
>> If you have any suggestions, let me know -- this is a community >> effort! > > Suggestion: Please don't make efforts to fragment the community. When a community grows and consequently its needs also grow, how do you differentiate "natural growth" from "fragmenting the community"? Same question

Command parsing... best module to use?

2009-11-02 Thread Collin D
Hey everyone. I am writing a game in python, and it includes a text console somewhat like the one in WoW and Runescape. I want to be able to include "/" commands, like IRC, and was wondering what the best module would be to parse these. Thanks a lot, Collin D -- http://mail.python.org/mailman/li

Re: have opensource crawler written by python?

2009-11-02 Thread Daniel Fetchinson
> Is there a crawler written by python? anybody can give me more information? http://www.google.com/search?q=python+web+crawlers HTH, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown -- http://mail.python.org/mailman/listinfo/python-list

Re: Help with SOAPpy and WSDL.

2009-11-02 Thread Henrik Aagaard Sørensen
I'll try to explain it here then: A small example on SOAPpy and WSDL. My code: from SOAPpy import WSDL wsdlFile = 'http://www.webservicex.net/country.asmx?wsdl' server = WSDL.Proxy(wsdlFile) server.GetCurrencyByCountry('Zimbabwe') returns: Traceback (most recent call last): File "pythonwsdl.py"

Re: Tkinter callback arguments

2009-11-02 Thread Alf P. Steinbach
* Diez B. Roggisch: Alf P. Steinbach wrote: * Peter Otten: Alf P. Steinbach wrote: for x in range(0,3): Button(.., command=lambda x=x: function(x)) An alternative reusable alternative is to create a button-with-id class. This is my very first Python class so I'm guessing th

Re: Tkinter callback arguments

2009-11-02 Thread Alf P. Steinbach
* Peter Otten: Alf P. Steinbach wrote: * Peter Otten: Alf P. Steinbach wrote: for x in range(0,3): Button(.., command=lambda x=x: function(x)) An alternative reusable alternative is to create a button-with-id class. This is my very first Python class so I'm guessing that th

Re: substituting list comprehensions for map()

2009-11-02 Thread J Kenneth King
Steven D'Aprano writes: > On Sun, 01 Nov 2009 23:54:16 -0800, Jon P. wrote: > >> I'd like to do: >> >> resultlist = operandlist1 + operandlist2 >> >> where for example >> >> operandlist1=[1,2,3,4,5] >> operandlist2=[5,4,3,2,1] >> >> and resultlist will become [6,6,6,6,6]. Using map(), I can

have opensource crawler written by python?

2009-11-02 Thread Junjun Shao
hi, Is there a crawler written by python? anybody can give me more information? thanks a lot! -- http://mail.python.org/mailman/listinfo/python-list

Re: About one class/function per module

2009-11-02 Thread Diez B. Roggisch
Peng Yu wrote: > On Mon, Nov 2, 2009 at 3:03 AM, Bruno Desthuilliers > wrote: >> Peng Yu a écrit : >> (snip) >>> >>> I prefer organized my code one class/function per file (i.e per module >>> in python). I know the majority of programmers don't use this >>> approach. Therefore, I'm wondering what

Accessing a method from within its own code

2009-11-02 Thread Paddy O'Loughlin
Hi, I was wondering if there was a shorthand way to get a reference to a method object from within that method's code. Take this code snippet as an example: import re class MyClass(object): def find_line(self, lines): if not hasattr(MyClass.do_work, "matcher"): MyClass.do_

Re: About one class/function per module

2009-11-02 Thread Peng Yu
On Mon, Nov 2, 2009 at 7:11 AM, Peng Yu wrote: > On Mon, Nov 2, 2009 at 3:03 AM, Bruno Desthuilliers > wrote: >> Peng Yu a écrit : >> (snip) >>> >>> I prefer organized my code one class/function per file (i.e per module >>> in python). I know the majority of programmers don't use this >>> approac

Re: About one class/function per module

2009-11-02 Thread Peng Yu
On Mon, Nov 2, 2009 at 3:03 AM, Bruno Desthuilliers wrote: > Peng Yu a écrit : > (snip) >> >> I prefer organized my code one class/function per file (i.e per module >> in python). I know the majority of programmers don't use this >> approach. Therefore, I'm wondering what its disadvantage is. > >

Re: Tkinter callback arguments

2009-11-02 Thread Diez B. Roggisch
Alf P. Steinbach wrote: > * Peter Otten: >> Alf P. Steinbach wrote: >> for x in range(0,3): Button(.., command=lambda x=x: function(x)) >>> An alternative reusable alternative is to create a button-with-id class. >>> >>> This is my very first Python class so I'm guessing

Re: Help with SOAPpy and WSDL.

2009-11-02 Thread Simon Brunning
2009/11/2 Henrik Aagaard Sørensen : > I have a problem with SOAPpy and WSDL. It is explained here: > http://www.python-forum.org/pythonforum/viewtopic.php?f=3&t=15532 Why not explain it here? In any case, I imagine the advice is going to be to try Suds - . -- Che

Help with SOAPpy and WSDL.

2009-11-02 Thread Henrik Aagaard Sørensen
I have a problem with SOAPpy and WSDL. It is explained here: http://www.python-forum.org/pythonforum/viewtopic.php?f=3&t=15532 Many regards, Henrik -- http://mail.python.org/mailman/listinfo/python-list

Re: Tkinter callback arguments

2009-11-02 Thread Peter Otten
Alf P. Steinbach wrote: > * Peter Otten: >> Alf P. Steinbach wrote: >> for x in range(0,3): Button(.., command=lambda x=x: function(x)) >>> An alternative reusable alternative is to create a button-with-id class. >>> >>> This is my very first Python class so I'm guessing

Re: exec-function in Python 3.+

2009-11-02 Thread Jon Clements
On 2 Nov, 10:49, "Hans Larsen" wrote: > Help! >     I'm begginer in Python 3.+! >     If i wih to update a module after an import and chages, >     How could I do: >     By "from imp import reload" and then reload(mymodule) >     or how to use "exec(?)", it is mentoined in docs. >     In Python ve

Re: substituting list comprehensions for map()

2009-11-02 Thread Bruno Desthuilliers
Ben Finney a écrit : Bruno Desthuilliers writes: Ben Finney a écrit : (Does anyone know of a counter-example, a ‘map()’ operation that doesn't have a correspondingly simple list comprehension?) ... depends on your definition of "simple". There are things I'd rather not write as a list compre

  1   2   >