Re: newbie: working iwth list of tuples

2006-01-29 Thread Raymond Hettinger
[Raymond Hettinger] > Parameterized filter, extract, and reduce functions can be handled in a > like manner. Just for grins, here is a more worked-out example: def pfunc(inputfields, operation): "Parameterized computation of a new field" # For example, append a field that is the sum of fi

Re: newbie: working iwth list of tuples

2006-01-29 Thread John Bauman
"Paul Rubin" wrote in message news:[EMAIL PROTECTED] > "falcon" <[EMAIL PROTECTED]> writes: >> I forgot to add that I passing a tuple of functions to the reduce >> function but apparently that is not allowed. My guess was that a tuple >> made up of individual (simple)

Re: Decoupling the version of the file from the name of the module.

2006-01-29 Thread Raymond Hettinger
[EMAIL PROTECTED] > I'm a newbie experimenting with Python. I want to incrementally develop > a module called 'circle'. . . . > Basically I want to decouple the version of my file from the name of > the module. > > Is there a *simple* way out of this dilemma. In the client code, use an import/as

Re: Data Crunching and Charting....

2006-01-29 Thread Mr BigSmoke
Great!! I kept looking enthought site everyday for 2/3 months about one year ago... but it always had old chaco versions, no news... Then i posted questions about it here at comp.lang.python and some people said the project had been abbandoned... Great to know that it's not true!! TNX VERY MUCH!!

Re: Python loading library containing embedded python...

2006-01-29 Thread Martin v. Löwis
Brennus wrote: > I have a dll/so which embeds python. I can verify it works by > compiling it as an executable and adding an appropriate main. Please explain in more detail how you did the embedding. Did you statically link the Python interpreter into your dll/so, or did you use a shared one? > H

Re: newbie: working iwth list of tuples

2006-01-29 Thread Raymond Hettinger
[Raymond Hettinger] > > Parameterized filter, extract, and reduce functions can be handled in a > > like manner. > > Just for grins, here is a more worked-out example: See the ASPN Cookbook recipe for a version with doctests and a couple bug-fixes: http://aspn.activestate.com/ASPN/Cookbook/Pyt

Re: Using bytecode, not code objects

2006-01-29 Thread Fredrik Lundh
Fabiano Sidler wrote: > I'm looking for a way to compile python source to bytecode instead of > code-objects. Is there a possibility to do that? The reason is: I want > to store pure bytecode with no additional data. use marshal. > The second question is, therefore: How can I get the correct val

Re: writing large files quickly

2006-01-29 Thread Fredrik Lundh
Bengt Richter wrote: > >> How the heck does that make a 400 MB file that fast? It literally takes > >> a second or two while every other solution takes at least 2 - 5 minutes. > >> Awesome... thanks for the tip!!! > > > >Because it isn't really writing the zeros. You can make these > >files all

adding current date to a file name in a python script

2006-01-29 Thread markryde
Hello, I am trying to add the current date to a file name in python script like thus: import os import sys import rpm import time import datetime today = datetime.date.today() print "The date is", today myFile = '/work/output1' myFile = myFile.join(today) myFile = myFile.join(".txt") print "myF

Re: Decoupling the version of the file from the name of the module.

2006-01-29 Thread Steven D'Aprano
On Sun, 29 Jan 2006 00:07:29 -0800, Raymond Hettinger wrote: > [EMAIL PROTECTED] >> I'm a newbie experimenting with Python. I want to incrementally develop >> a module called 'circle'. > . . . >> Basically I want to decouple the version of my file from the name of >> the module. >> >> Is there a

Re: adding current date to a file name in a python script

2006-01-29 Thread Sybren Stuvel
[EMAIL PROTECTED] enlightened us with: > myFile = '/work/output1' > myFile = myFile.join(today) > myFile = myFile.join(".txt") join does something completely different. You want: myFile = '/work/output1/%s.txt' % today Sybren -- The problem with the world is stupidity. Not saying there should b

Re: Python vs C for a mail server

2006-01-29 Thread Sybren Stuvel
Dan Lowe enlightened us with: > I'm on my second major mail system deployment built around Exim, and > would recommend it to anybody needing a robust, flexible mail > server. Same here. I used Sendmail, QMail, Exim 3 and Exim 4, and out of those, Exim 4 came out winner. Sybren -- The problem wit

Re: adding current date to a file name in a python script

2006-01-29 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > I am trying to add the current date to a file name in python script > like thus: > > import os > import sys > import rpm > import time > import datetime > > today = datetime.date.today() > print "The date is", today > myFile = '/work/output1' > myFile = myFile.join(today

Re: generating method names 'dynamically'

2006-01-29 Thread Max
Magnus Lycka wrote: > Daniel Nogradi wrote: > >> Well, I would normally do what you suggest, using parameters, but in >> the example at hand I have to have the method names as variables and >> the reason is that the whole thing will be run by apache using >> mod_python and the publisher handler. T

Re: generating method names 'dynamically'

2006-01-29 Thread Fredrik Lundh
"Unknown" wrote: > >> Well, I would normally do what you suggest, using parameters, but in > >> the example at hand I have to have the method names as variables and > >> the reason is that the whole thing will be run by apache using > >> mod_python and the publisher handler. There a URL > >> http:

Re: Builder Pattern

2006-01-29 Thread Paddy
> What the following discussion says is that the C++ -> Python > transliteration is totally trivial and obvious and berates the original > requestor for making me waste 10 minutes to provide it. Thanks for the giggle :-) -- http://mail.python.org/mailman/listinfo/python-list

Re: SLUT distibution mangled?

2006-01-29 Thread Ido Yehieli
ok, Thanks Paul! -- http://mail.python.org/mailman/listinfo/python-list

Re: SLUT distibution mangled?

2006-01-29 Thread Rob Wolfe
Actually when you remember the ancient history of Windows and MS/DOS you will see why. That filename, and a lot of others (as noted by Fredrik) are legacies of that time. They were special filenames (think "/dev/null") that related to specific devices. Gives us a good example of one of the little

Re: writing large files quickly

2006-01-29 Thread Thomas Bellman
Grant Edwards <[EMAIL PROTECTED]> writes: > $ dd if=/dev/zero of=zeros bs=64k count=1024 > 1024+0 records in > 1024+0 records out > $ ls -l zeros > -rw-r--r-- 1 grante users 67108864 Jan 28 14:49 zeros > $ du -h zeros > 65M zeros > In my book that's 64MB not 65MB, but that's an argument for

Re: newbie: working iwth list of tuples

2006-01-29 Thread Kent Johnson
falcon wrote: > Hi All, > I am fairly new to Python (less than a week). My goal is to write a > small prototype of a database. Rather than build it using the typical > method where one provides selection, projection, aggregation, union, > intersection, etc. functions, I would like to do it in a m

Re: "Dynamic" website content

2006-01-29 Thread sophie_newbie
To be honest that doesn't seem to work. Also it seems that only Mozilla based browsers support server push. Maybe it is something to do with how Apache is configured? Or is Python buffering the output? Is there a line of code to make python unbeffered? -- http://mail.python.org/mailman/listinfo

Re: "Dynamic" website content

2006-01-29 Thread sophie_newbie
I am running apache on windows by the way. I think there may be issues with unbuffered output on windows... -- http://mail.python.org/mailman/listinfo/python-list

Tk.quit() now working!

2006-01-29 Thread al pacino
i have a weired problem with button widget in Tkinter the callback function(Tk.quit()) for button widget is not working! when i 'press' the button the GUI hangs. code for displaying a 'button objec': ### import Tkinter top=Tkinter.Tk() button=Tkinter.Button(top,text='press me',comm

Re: Python vs C for a mail server

2006-01-29 Thread Jens Theisen
Nicolas wrote: > http://nicolas.lehuen.com/ > My two latest problems with coding in C++ are due to the environments : > libraries using different string types and the whole problem with the > building system. I love the language, but I get a much better leverage > through Python and Java due to t

Re: Python vs C for a mail server

2006-01-29 Thread Jens Theisen
Alex wrote: > > > Since Robert Martin and Bruce Eckel (the authors of the two documents > linked above) are both acknowledged gurus of statically typechecked > languages such as C++, the convergence

Re: Fast generation of permutations

2006-01-29 Thread Anton Vredegoor
Paul Rubin wrote: > Cool, I'd still like to know why (13**5)-13 = C(52,5) other than > by just doing the arithmetic and comparing the results. Maybe your > tkinter script can show that. That seems to be very hard :-) Unless I'm missing something. Anton def noverk(n,k): return reduce(lambda

Re: Tk.quit() now working!

2006-01-29 Thread Fredrik Lundh
"al pacino" wrote: > i have a weired problem with button widget in Tkinter > the callback function(Tk.quit()) for button widget is not working! when > i 'press' the button > the GUI hangs. > code for displaying a 'button objec': > ### > import Tkinter > top=Tkinter.Tk() > button=T

Re: Fast generation of permutations

2006-01-29 Thread Anton Vredegoor
Anton Vredegoor wrote: > Paul Rubin wrote: > > > Cool, I'd still like to know why (13**5)-13 = C(52,5) other than > > by just doing the arithmetic and comparing the results. Maybe your > > tkinter script can show that. > > That seems to be very hard :-) Unless I'm missing something. Like a facto

Re: Printing HTML

2006-01-29 Thread Steve Holden
Unknown wrote: > Rene Pijlman wrote: > >>Max <[EMAIL PROTECTED]>: >> >> >>>How can I print (as in laser printer, not the python print statement) >>>HTML from Python >> >> >>Is the printer attached to your server, or are you printing over the >>internet? >> > > > I'm not sure if the printer is

Re: "Intro to Pyparsing" Article at ONLamp

2006-01-29 Thread Anton Vredegoor
Paul McGuire wrote: > There are two types of parsers: design-driven and data-driven. With > design-driven parsing, you start with a BNF that defines your language or > data format, and then construct the corresponding grammar parser. As the > design evolves and expands (new features, keywords, a

Re: equivalent to c++ "reference" or "pointers"

2006-01-29 Thread Steve Holden
Collin Jones wrote: > Hello, > > Is there a Python equivalent to creating "reference" or "pointer"-type > variables as in C++?? I'm trying to create a couple classes that have > something like a container-and-iterator relationship; one class acts as > a data resource (container-like) and can b

Re: Python vs C for a mail server

2006-01-29 Thread Jay Parlar
> Indeed, especially Eckels article shed some light about testing as an > alternative to static typing. I still can't quite understand why you > can't > do both. Clearly unit tests should be part of any software, not only > Python software. > You can do both, but why? *Especially* in a language li

Re: Python vs C for a mail server

2006-01-29 Thread Peter Hansen
Jens Theisen wrote: > Test failures, however, don't tell you anything about the current usage of > your program - just about the inteded usage at the point where the test > was writte. Clearly you can't test _anything_? And clearly you can never > be sure that all you collegues did so as well

Tkinter PhotoImage won't show ;-(

2006-01-29 Thread vm
please help! I can't find anything wrong (except the result ofc ;-) This: picfile = 'logo.gif' pic = tk.PhotoImage(file=picfile, master=root) canpic = cv.create_image(320, 240, image=pic) #cv is is a Tkinter Canvas ofc ...works just fine, but when I put it in the event binding fu

Re: Python vs C for a mail server

2006-01-29 Thread Alex Martelli
Jens Theisen <[EMAIL PROTECTED]> wrote: ... > Indeed, especially Eckels article shed some light about testing as an > alternative to static typing. I still can't quite understand why you can't > do both. Clearly unit tests should be part of any software, not only > Python software. Clearly. Gi

Re: Tkinter PhotoImage won't show ;-(

2006-01-29 Thread Fredrik Lundh
"vm" wrote: > I can't find anything wrong (except the result ofc ;-) > > This: > > picfile = 'logo.gif' > > pic = tk.PhotoImage(file=picfile, master=root) > > canpic = cv.create_image(320, 240, image=pic) #cv is is a Tkinter > Canvas ofc > > ...works just fine, but when I put it in the eve

Server side newbie

2006-01-29 Thread swisscheese
I have a simple python desktop app with several edit controls and a couple of buttons. It just does some math. What's the simplest way to make it a server-side app so visitors to my site can run the app via their browser? -- http://mail.python.org/mailman/listinfo/python-list

stumped by tricky logic

2006-01-29 Thread Dave
So I'm trying to write a CSS preprocessor. I want to add the ability to append a selector onto other selectors. So, given the following code: = #selector { { property: value; property: value; } .other_selector { property:

Re: Server side newbie

2006-01-29 Thread Dave
Check out mod_python for Apache. Basically, you would write your python app as a server-side script and the end user would interact with your code via a webpage. It's likely that you won't need any GUI code you wrote, as HTML form elements will be your choices in the browser. Check out PSP: it ena

Re: Server side newbie

2006-01-29 Thread Peter Hansen
swisscheese wrote: > I have a simple python desktop app with several edit controls and a > couple of buttons. It just does some math. What's the simplest way to > make it a server-side app so visitors to my site can run the app via > their browser? There will probably be a dozen answers, any of wh

OT: Re: Using non-ascii symbols

2006-01-29 Thread Magnus Lycka
Runsun Pan wrote: > The simplified chinese exists due to the call for modernization of > language decades ago. That involved the 'upside-down' of almost > entire culture This is in some ways quite the opposite compared to Nynorsk in Norway, which was an attempt to revive the old and pure Norwegian

Re: Decoupling the version of the file from the name of the module.

2006-01-29 Thread Xavier Morel
[EMAIL PROTECTED] wrote: > Now suppose I have make a new version with __version__ = 1.1. What > shall I call this file and (I don't want to overwrite the old file if I > need to go back to it) how do I import it from the shell. Your advice > sounds nice, but I would appreciate if you could give me

Re: Python vs C for a mail server

2006-01-29 Thread Alex Martelli
Jay Parlar <[EMAIL PROTECTED]> wrote: ... > Because in all of my own industry experience, it's been MUCH easier to > jump into someone else's Python code than someone else's C++ code (and > at my last job, I had to do a lot of both). I find Python to be much > more self-documenting, because the

Re: Strange behavior of int()

2006-01-29 Thread Rob E
> Why is int(r/k), where r = 0.5 and k = 0.5 = 0? Shouldn't it be 1? > And why is the last one = 4 and not 5? I dont' know why the differences in your exact case. However, please realise that Regardless of the programming language good programming practice is to never rely on the int of a float

Re: Tkinter PhotoImage won't show ***SOLVED***

2006-01-29 Thread vm
I was missing "global pic" line at the begining of putpic function. doh! "vm" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > please help! > > I can't find anything wrong (except the result ofc ;-) > > This: > > > > picfile = 'logo.gif' > > pic = tk.PhotoImage(file=picfile, master=r

Re: Decoupling the version of the file from the name of the module.

2006-01-29 Thread Robert Kern
Steven D'Aprano wrote: > I distribute two apps, Parrot and Shrubbery. Both rely on a common module, > Spam. Parrot uses version 1 of Spam and Shrubbery uses version 2. For the > sake of the argument, Spam is completely backwards compatible, so I > have no problems with somebody installing Parrot p

Re: stumped by tricky logic

2006-01-29 Thread Max
Dave wrote: > So I'm trying to write a CSS preprocessor. > > I want to add the ability to append a selector onto other selectors. > So, given the following code: > = > #selector { > > { property: value; property: value; } >

Re: stumped by tricky logic

2006-01-29 Thread Roy Smith
"Dave" <[EMAIL PROTECTED]> wrote: > So I'm trying to write a CSS preprocessor. What you're trying to do is write a parser. I don't know CSS, so I can't comment on the details, but basically, you're trying to parse a non-trivial language. It is usually hopeless to try and write a parser using j

Find directory name of file?

2006-01-29 Thread veracon
I'm pretty new at Python, so I have no idea how to do this: How do I find the name of the directory that contains the application currently being executed (e.g. if the file is /home/user/file.py, I want to get the /home/user part)? Thanks! -- http://mail.python.org/mailman/listinfo/python-list

Re: Find directory name of file?

2006-01-29 Thread jmdeschamps
veracon wrote: > I'm pretty new at Python, so I have no idea how to do this: How do I > find the name of the directory that contains the application currently > being executed (e.g. if the file is /home/user/file.py, I want to get > the /home/user part)? > > Thanks! look into os.path module for

Re: VB to Python migration

2006-01-29 Thread Magnus Lycka
Josh wrote: > We currently use a MS Access back end and need to migrate to a proper > SQL server. We need to leave options open for SQL Server (for customers > who want to use existing infrastructure) and something like MySQL or > PostgreSQL. But in the mean time, we need to be able to access an

Re: VB to Python migration

2006-01-29 Thread Magnus Lycka
Ravi Teja wrote: > 230 UI screens is a lot. An app of that nature is not something people > commonly do in Python (although I would be happy to see people show me > wrong). Maybe not, but I don't doubt that it's reasonable to replace a VB app with 230 UI screens with Python code. A code of that s

Hostname

2006-01-29 Thread [EMAIL PROTECTED]
Hi Iam new in Python. I want to know for my first Project in Python how i can get the Hostname from a URL? Thanks for Help -- http://mail.python.org/mailman/listinfo/python-list

Re: Find directory name of file?

2006-01-29 Thread jmdeschamps
also the function os.cwd() ;-) -- http://mail.python.org/mailman/listinfo/python-list

Re: newbie: working iwth list of tuples

2006-01-29 Thread falcon
Wow, great answers here. Thank you all for the links and examples, I'm going through them all now. -- http://mail.python.org/mailman/listinfo/python-list

Re: Hostname

2006-01-29 Thread Alex Martelli
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Hi > Iam new in Python. > I want to know for my first Project in Python how i can get the > Hostname from a URL? >>> import urlparse >>> urlparse.urlsplit('http://foo.bar.com/zapzap') ('http', 'foo.bar.com', '/zapzap', '', '') >>> As you may notice

Re: Hostname

2006-01-29 Thread [EMAIL PROTECTED]
Wow! This was a fast answer and it works. -- http://mail.python.org/mailman/listinfo/python-list

Re: Returning a value from code string

2006-01-29 Thread Fried Egg
>From above: I hope the contents of the database are trusted, because if the code is coming from an untrusted source, well, U R pwn3d. Seems like you are jumping through a lot of hoops for very little benefit. What am I missing? Why does anyone care about "why" people do things when they ask a

ANN: (slightly) extended Python debugger 0.11

2006-01-29 Thread R. Bernstein
The second public release of the extended Python debugger is now available from sourceforge: http://sourceforge.net/project/showfiles.php?group_id=61395&package_id=175827 For this release documentation has been added. That is also available online at: http://bashdb.sourceforge.net/pydb/pydb/lib/i

Re: Python vs C for a mail server

2006-01-29 Thread Jim Segrave
In article <[EMAIL PROTECTED]>, abhinav <[EMAIL PROTECTED]> wrote: >ya its supposed to be some stupid 6 month project which my friend has >to do.I am just helping him out.he may not be implementing a full >fledged rfc compliance mail server but may support some of the major >functionalities.so basi

Print dict in sorted order

2006-01-29 Thread Kamilche
I have a code snippet here that prints a dict in an arbitrary order. (Certain keys first, with rest appearing in sorted order). I didn't want to subclass dict, that's error-prone, and overkill for my needs. I just need something that returns a value like dict.__str__, with a key ordering I specify.

Re: Python vs C for a mail server

2006-01-29 Thread Jim Segrave
In article <[EMAIL PROTECTED]>, Dan Lowe <[EMAIL PROTECTED]> wrote: > >On Jan 28, 2006, at 8:39 PM, Dennis Lee Bieber wrote: > >> On Sat, 28 Jan 2006 18:03:56 +1100, Steven D'Aprano said: >>> >>> Google is your friend. The first four mail servers listed are, in >>> order: >>> >>> sendmail >>> po

Authenticating to Kerberos

2006-01-29 Thread David
Hi, I've had a quick look but cannot find a module that will let me authenticate against Kerberos. There appears to be a krb5 module that hasn't been updated for a long time and I can't find much on it except the pages at starship.python.net. I don't need to do anything except authenticate and g

Re: Print dict in sorted order

2006-01-29 Thread Paul Rubin
"Kamilche" <[EMAIL PROTECTED]> writes: > I have a code snippet here that prints a dict in an arbitrary order. > (Certain keys first, with rest appearing in sorted order). I didn't > want to subclass dict, that's error-prone, and overkill for my needs. I > just need something that returns a value l

Re: VB to Python migration

2006-01-29 Thread Ravi Teja
Magnus Lycka wrote: > Ravi Teja wrote: > > 230 UI screens is a lot. An app of that nature is not something people > > commonly do in Python (although I would be happy to see people show me > > wrong). > > Maybe not, but I don't doubt that it's reasonable to replace a > VB app with 230 UI screens wi

RE: OpenGL

2006-01-29 Thread Delaney, Timothy (Tim)
Mike C. Fletcher wrote: > ctypes re-re-implementation of the same Python API to OpenGL. My > intention is that the ctypes implementation will become the 3.0.0 > release when it is finished and optimised. You should be aware then that it's likely that ctypes will be included in Python 2.5. Tim D

Re: Hostname

2006-01-29 Thread Alex Martelli
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Wow! This was a fast answer and it works. That's why we used to joke about Guido's time machine: somebody would express a need (sometimes phrased as a suggestion for an enhancement), and Guido would zip back in time and implement the needed functiona

Re: Server side newbie

2006-01-29 Thread Pierre Quentel
swisscheese a écrit : > I have a simple python desktop app with several edit controls and a > couple of buttons. It just does some math. What's the simplest way to > make it a server-side app so visitors to my site can run the app via > their browser? > Among the many web frameworks for Python, Ka

StringIO proposal: add __iadd__

2006-01-29 Thread Paul Rubin
I've always found the string-building idiom temp_list = [] for x in various_pieces_of_output(): v = go_figure_out_some_string() temp_list.append(v) final_string = ''.join(temp_list) completely repulsive. As an alternative I suggest temp_buf = StringIO() for x in various_

Re: StringIO proposal: add __iadd__

2006-01-29 Thread Alex Martelli
Paul Rubin wrote: ... >temp_buf = StringIO() >for x in various_pieces_of_output(): > v = go_figure_out_some_string() > temp_buf += v >final_string = temp_buf.getvalue() > > here, "temp_buf += v" is supposed to be the same as "temp_buf.write(v)

Re: StringIO proposal: add __iadd__

2006-01-29 Thread Paul Rubin
[EMAIL PROTECTED] (Alex Martelli) writes: > What's the added value of spelling x.write(v) as x += v? Is it worth > the utter strangeness of having a class which allows += and not + (the > only one in the std library, I think it would be)...? Sure, + can also be supported. Adding two StringIO's,

Re: Strange behavior of int()

2006-01-29 Thread Dan Bishop
Brian wrote: > Hello, > > Can someone tell me what I am doing wrong in this code. > > If I create a file change.py with the following contents: > > def intTest(M, c): > r = M > for k in c: > print 'int(r/k) = ', int(r/k), 'r =', r, 'k =', k, 'r/k > =', r/k >

Re: Returning a value from code string

2006-01-29 Thread Alex Martelli
Fried Egg <[EMAIL PROTECTED]> wrote: ... > Why does anyone care about "why" people do things when they ask a > specific technical question on a newsgroup? Maybe op is risking his Because experienced techies have learned that people (including other techies) often ask the wrong "specific techni

Re: Returning a value from code string

2006-01-29 Thread Peter Hansen
Fried Egg wrote: >>From above: > Seems like you are jumping through a lot of hoops for very little > benefit. > What am I missing? > > > Why does anyone care about "why" people do things when they ask a > specific technical question on a newsgroup? Maybe op is risking his > server (who cares) or

Re: StringIO proposal: add __iadd__

2006-01-29 Thread Alex Martelli
Paul Rubin wrote: ... > > In StringIO's case, it's nice to be able to use the above idiom to > > concatenate Unicode strings just as easily as plain ones, for > > example -- cStringIO (like file objects) wants plain bytestrings. > > I wasn't aware of that limitation--

Re: obtain client ip address from SimpleXMLRPCServer ?

2006-01-29 Thread stuff
Thanks again Peter. I found 2 potential solutions for obtaining the ip address of the incoming connection. The first was to subclass SimpleXMLRPCRequestHandler class and pass it to the SimpleXMLRPCServer constructor. In doing so, I could directly access the client_address via self.client_address

Re: Python vs C for a mail server

2006-01-29 Thread Paul Boddie
Jay Parlar wrote: > I don't think I've ever seen anyone advocating calling a function like > getattr(obj "foo" + "bar")(). >From Lib/compiler/visitor.py: meth = getattr(self.visitor, 'visit' + className, 0) Later on: meth(node, *args) Of course, you can drop the "visit" prefix and make the mec

Re: StringIO proposal: add __iadd__

2006-01-29 Thread Paul Rubin
[EMAIL PROTECTED] (Alex Martelli) writes: > But why can't I have perfectly polymorphic "append a bunch of strings > together", just like I can now (with ''.join of a list of strings, or > StringIO), without caring whether the strings are Unicode or > bytestrings? I see that 'a' + u'b' = u'ab', whi

Re: Find directory name of file?

2006-01-29 Thread Peter Hansen
[EMAIL PROTECTED] wrote: > also the function os.cwd() > ;-) I'm not sure how os.cwd() helps, but generally the solution to this starts with pointing out that sys.argv[0] usually contains the path to the main script, which is often the answer needed. Recipes have been posted in the past which c

Re: StringIO proposal: add __iadd__

2006-01-29 Thread Erik Max Francis
Paul Rubin wrote: > I've always found the string-building idiom > > temp_list = [] > for x in various_pieces_of_output(): > v = go_figure_out_some_string() > temp_list.append(v) > final_string = ''.join(temp_list) > > completely repulsive. As an alternative I suggest > >t

Re: Python vs C for a mail server

2006-01-29 Thread Fredrik Lundh
Paul Boddie wrote: > > I don't think I've ever seen anyone advocating calling a function like > > getattr(obj "foo" + "bar")(). > > >From Lib/compiler/visitor.py: > > meth = getattr(self.visitor, 'visit' + className, 0) > > Later on: > > meth(node, *args) > > Of course, you can drop the "visit" pr

Re: Find directory name of file?

2006-01-29 Thread Grant Edwards
On 2006-01-29, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > also the function os.cwd() Neither os.path nor os.cwd are going to tell you the location of the python program being executed. Looking at the value of sys.argv[0] is probably the best bet. If it's a relative path, then you can use os

Re: Print dict in sorted order

2006-01-29 Thread Fuzzyman
You can always use OrderedDict : htttp://www.voidspace.org.uk/python/odict.html from odict import OrderedDict my_dict = OrderedDict(some_dict.keys()) keys = my_dict.keys() keys.sort() my_dict.setkeys(keys) print my_dict Of course if your ordering requirement was *that* trivial, you could do

Re: StringIO proposal: add __iadd__

2006-01-29 Thread Scott David Daniels
Alex Martelli wrote: > It would be nice (in Py3k, when backwards compatibility can be broken) > to make the plain-named, "default" modules those coded in C, since > they're used more often, and find another convention to indicate pure > Python equivalents -- e.g., pickle/pypickle and StringIO/pyStr

Re: Python vs C for a mail server

2006-01-29 Thread Volker Grabsch
Jens Theisen wrote: > What do you do when you want to no if a certain method or function is > actually used from somewhere, say "foobar", it a language which allows > (and even encourages) that it could be called by: > > getattr(obj, "foo" + "bar")() No. The recommended way to do it is:

Re: Using bytecode, not code objects

2006-01-29 Thread Michael Spencer
Fredrik Lundh wrote: > Fabiano Sidler wrote: > >> I'm looking for a way to compile python source to bytecode instead of >> code-objects. Is there a possibility to do that? The reason is: I want >> to store pure bytecode with no additional data. > > use marshal. > >> The second question is, there

Re: StringIO proposal: add __iadd__

2006-01-29 Thread Alex Martelli
Paul Rubin wrote: > [EMAIL PROTECTED] (Alex Martelli) writes: > > But why can't I have perfectly polymorphic "append a bunch of strings > > together", just like I can now (with ''.join of a list of strings, or > > StringIO), without caring whether the strings are Unicode

Storing lines from a text file

2006-01-29 Thread bradfordh
Hello everyone. I am not sure how hard of a question is, but I do know that I need some help if you can give it. What I want to do is read the lines in a text file and store each line into a variable. I believe that I can use readlines() to read the individual lines, but how would I store each lin

Storing lines from a text file

2006-01-29 Thread bradfordh
Hello everyone. I am not sure how hard of a question is, but I do know that I need some help if you can give it. What I want to do is read the lines in a text file and store each line into a variable. I believe that I can use readlines() to read the individual lines, but how would I store each lin

Re: StringIO proposal: add __iadd__

2006-01-29 Thread Alex Martelli
Scott David Daniels <[EMAIL PROTECTED]> wrote: > Alex Martelli wrote: > > It would be nice (in Py3k, when backwards compatibility can be broken) > > to make the plain-named, "default" modules those coded in C, since > > they're used more often, and find another convention to indicate pure > > Pyth

Re: Storing lines from a text file

2006-01-29 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > I am not sure how hard of a question is, but I do know that I need some > help if you can give it. What I want to do is read the lines in a text > file and store each line into a variable. I believe that I can use > readlines() to read the individual lines, but how would

Re: Returning a value from code string

2006-01-29 Thread Kirk McDonald
Peter Hansen wrote: > In the specific case in question, Kirk's first post gave little or no > hint about how much he knew about security issues and, by asking "why?", > with a single word Steven hoped to learn enough to say things like "oh, > there's a package designed to do that which you can j

Re: Storing lines from a text file

2006-01-29 Thread bradfordh
so this: a, b, c, d, e =f.readlines() ..this will put the first line in a, second in b, etc? How do I accomplish this when I'm not sure how many lines there are going to be every time? Thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python vs C for a mail server

2006-01-29 Thread Jay Parlar
> Paul Boddie wrote: > >> I don't think I've ever seen anyone advocating calling a function like >> getattr(obj "foo" + "bar")(). > >> From Lib/compiler/visitor.py: > > meth = getattr(self.visitor, 'visit' + className, 0) > > Later on: > > meth(node, *args) > > Of course, you can drop the "visit" p

Re: Storing lines from a text file

2006-01-29 Thread Kirk McDonald
[EMAIL PROTECTED] wrote: > so this: > a, b, c, d, e =f.readlines() > > ..this will put the first line in a, second in b, etc? How do I > accomplish this when I'm not sure how many lines there are going to be > every time? Thanks. > With a list: http://python.org/doc/2.4.2/tut/node5.html#SECT

instance references?

2006-01-29 Thread bytecolor
I'm working on a simple graphics package. I've got a function show() that the user needs to call at the end of the script to actually display the points, lines and circles that have been defined in the script. p1 = point(0, 0) l1 = line(1, 3, -4, 5) c1 = circle(-2, 3, 1) show() In each __init__()

Language Semantics: @ symbol??

2006-01-29 Thread Enigma Curry
Sorry, for the noob question, but I haven't been able to find documentation on this matter. I've been looking for documentation that describes what the @function() syntax is all about. I've seen this on a few pages, for instance: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/307871 an

Re: Python loading library containing embedded python...

2006-01-29 Thread Brennus
Martin v. Löwis wrote: >Brennus wrote: >> I have a dll/so which embeds python. I can verify it works by >> compiling it as an executable and adding an appropriate main. > >Please explain in more detail how you did the embedding. Did you >statically link the Python interpreter into your dll/so, or

Re: Storing lines from a text file

2006-01-29 Thread bradfordh
With what kind of list? I don't see how I can do it with a list unless I create one indefinate list and use the objects in the indefinate list for the names of the lists to hold the lines of text. Is that how you are suggesting that I do it? -- http://mail.python.org/mailman/listinfo/python-list

Re: Language Semantics: @ symbol??

2006-01-29 Thread Jay Parlar
Enigma Curry wrote: > > > Sorry, for the noob question, but I haven't been able to find > documentation on this matter. > > I've been looking for documentation that describes what the @function() > syntax is all about. > > I've seen this on a few pages, for instance: > > http://aspn.activestate.co

  1   2   >