> def chunkify(s, chunksize):
> "Yield sequence s in chunks of size chunksize."
> for i in range(0, len(s), chunksize):
> yield s[i:i+chunksize]
>
> I wrote this because I need to take a string of a really, really long
> length and process 4000 bytes at a time.
>
> Is there a bett
Matthew Wilson wrote:
> I wrote a function that I suspect may already exist as a python builtin,
> but I can't find it:
>
> def chunkify(s, chunksize):
> "Yield sequence s in chunks of size chunksize."
> for i in range(0, len(s), chunksize):
> yield s[i:i+chunksize]
>
> I wrote t
Larry Hastings wrote:
>> Nice idea, though. You might also see how it does on tasks like
>>
>> s = ""
>> for i in range(10):
>> s += "a"
>
> Sure. Here are the results, but with range (1000):
ten million? what hardware are you running this on?
> Python 2.5 release: 31.0s
>
Matthew Wilson wrote:
> I wrote a function that I suspect may already exist as a python builtin,
> but I can't find it:
>
> def chunkify(s, chunksize):
> "Yield sequence s in chunks of size chunksize."
> for i in range(0, len(s), chunksize):
> yield s[i:i+chunksize]
>
> I wrote thi
Matthew Warren wrote:
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On
> Behalf Of paw
> Sent: 29 September 2006 11:01
> To: python-list@python.org
> Subject: Re: Problems with Python 2.5 installer.
>
>
> John Machin wrote:
> > paw wrote:
> > > I have ran the M
So every now and then I like to mess around with hobby projects - I
often end up trying to write an OpenGL video game. My last attempt
aborted due to the difficulty of automating game elements and creating
a good level editor - I basically needed a scripting language to
control the C modules of th
Interesting post by voidspace.
Ruby and Python are doing well, according to the latest TIOBE index.
Java, C and C++ and 1, 2 and 3 on the list
http://jugad.livejournal.com/2006/09/29/
Vasudev Ram
http://www.dancingbison.com
P.S. Dunno why "hot new" though - not too many of them are new. More
On 29/09/06, Matthew Warren <[EMAIL PROTECTED]> wrote:
> I have
> found that in real usage of other programs within the company that use
> lockfiles, it sometimes causes a bit of troubleshooting time when it stops
> working due to a stale lockfile.. This especially happens when the program
> is ki
Thank for your response :-)
I have tried (it's my first try ..) :
./TestOfficiel TestPythonFoo multiply 3 2
and i get :
[EMAIL PROTECTED] swigCallPython]$ ./TestOfficiel TestPythonFoo
multiply 3 2
ImportError: No module named TestPythonFoo
Failed to load "TestPythonFoo"
Then i tried what y
[EMAIL PROTECTED] wrote:
> But I'm suffering from serious scoping bugs. I hope someone here
> can help me with them.
>
> First of all, if I type in something like;
>
> def f(x):
> if x==1:
> return x
> else:
> return x * f(x-1)
>
> and then go
> print f(5)
>
Tim Williams wrote:
> def check_lock():
> import os, sys
> try:
> os.remove({filename})
> except:
> if "Permission denied" in sys.exc_info()[1]:
> print 'This program is already running'
> sys.exit()
> f_lock = open({filename},'w')
have you
Fredrik Lundh wrote:
> > Sure. Here are the results, but with range (1000):
> ten million? what hardware are you running this on?
Athlon 64 x2 4400+ (aka 2.2GHz), 3GB of RAM, Windows XP.
> what's in "s" when that loop is done?
It's equivalent to " 'a' * 1000 ". (I shan't post it here
On 29/09/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> Tim Williams wrote:
>
> > def check_lock():
> > import os, sys
> > try:
> > os.remove({filename})
> > except:
> > if "Permission denied" in sys.exc_info()[1]:
> > print 'This program is already running'
On Friday 29 September 2006 08:34, Larry Hastings wrote:
> It would still blow up if you ran
> s = ""
> for i in range(1000):
> s = "a" + s
This is a pretty small change but I would suggest xrange instead of range.
That way you don't allocate that large list just to throw all the ite
Hi,
I hope I don't upset anybody by comparing Python to Ruby (again). Is
there something like Ruby's retry keyword in Python? I couldn't find any
thing...
Regards,
antoine
--
http://mail.python.org/mailman/listinfo/python-list
Larry Hastings wrote:
>> what's in "s" when that loop is done?
>
> It's equivalent to " 'a' * 1000 ". (I shan't post it here.)
but what *is* it ? an ordinary PyString object with a flattened buffer,
or something else ?
--
http://mail.python.org/mailman/listinfo/python-list
Roy Smith wrote:
> I'm working on a product which for a long time has had a Perl binding for
> our remote access API. A while ago, I wrote a Python binding on my own,
> chatted it up a bit internally, and recently had a (large) customer enquire
> about getting access to it.
>
> I asked for per
William Heymann wrote:
> This is a pretty small change but I would suggest xrange instead of range.
Good point! Since I was calling range() during the benchmark, it was
timed too. Switching to xrange() will mean less overhead.
I re-ran this benchmark (again):
s = ""
for i in range(10):
Fredrik Lundh wrote:
> [EMAIL PROTECTED] wrote:
>
> > But I'm suffering from serious scoping bugs. I hope someone here
> > can help me with them.
> >
> > First of all, if I type in something like;
> >
> > def f(x):
> > if x==1:
> > return x
> > else:
> > return
Fredrik Lundh wrote:
> >> what's in "s" when that loop is done?
> > It's equivalent to " 'a' * 1000 ". (I shan't post it here.)
> but what *is* it ? an ordinary PyString object with a flattened buffer,
> or something else ?
At the exact moment that the loop is done, it's a
PyStringConcatenat
Hi,
Bruno Desthuilliers a écrit :
> I've never met a programmer that "loved" Windev.
I have met some here (I'm the guy with a mustache-just kidding but
actually I was there).
http://www.pcsoft.fr/pcsoft/tdftech/2006/images/Paris/07-IMG_5853.jpg
WinDev is widely used in France and that's a thing
Larry Hastings wrote:
>
> At the exact moment that the loop is done, it's a
> PyStringConcatenationObject * which points to a deep one-sided tree of
> more PyStringConcatenationObject * objects. Its ob_sval is NULL, which
> means that the first time someone asks for its value (via the macro
> PyS
Antoine De Groote enlightened us with:
> I hope I don't upset anybody by comparing Python to Ruby (again). Is
> there something like Ruby's retry keyword in Python?
Please don't assume that everybody knows Ruby through and through...
Sybren
--
Sybren Stüvel
Stüvel IT - http://www.stuvel.eu/
-
Tim Williams enlightened us with:
> def check_lock():
> import os, sys
> try:
> os.remove({filename})
> except:
> if "Permission denied" in sys.exc_info()[1]:
> print 'This program is already running'
> sys.exit()
> f_lock = open({filename},'w
Why are they all look so gloomy? I don't see a single smile on their
faces.
:=)
[EMAIL PROTECTED] wrote:
> Hi,
>
> Bruno Desthuilliers a écrit :
> > I've never met a programmer that "loved" Windev.
>
> I have met some here (I'm the guy with a mustache-just kidding but
> actually I was there).
>
On 29/09/06, Sybren Stuvel <[EMAIL PROTECTED]> wrote:
> Checking for a lock, and later acquiring the lock, seems non-atomic to
> me. It's easier to simply create a lock directory. If it fails, the
> dir already exists and someone else holds the lock. If it succeeds,
> the lock is immediately yours,
Craig W wrote:
>
> I need to take a screen shot of the computer screen.
>
> I am trying to use PIL and I saw there is ImageGrab...however it only
> works on Windows. Is there a platform-independent ability to work
> around this?
>
> thanks
>
> --
> http://mail.python.org/mailman/listinfo/p
Oh, good, just what we needed--sort of a Nobel Prize for whackos. AP should
be a shoo-in.
Eric Lucas
<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
Copy and paste from the site on 911 http://reopen911.org/
$1 Million Challenge Details
This is void where prohibited by law: inclu
"Tim Williams" <[EMAIL PROTECTED]> writes:
> My reply was in response to a post that mentioned a known problem with
> this, what happens when the previously running program doesn't exit
> gracefully, and leaves the directory in place ??
Don't use the presence or absence of a file as a lock. Have
titan516 wrote:
>> I am trying to use PIL and I saw there is ImageGrab...however it only
>> works on Windows. Is there a platform-independent ability to work
>> around this?
> Maybe you can try http://www.acasystems.com ACA capture PRO , it , i
> think,can fix your problem well..
"System re
On 29 Sep 2006 09:47:12 -0700, Paul Rubin
<"http://phr.cx"@nospam.invalid> wrote:
> "Tim Williams" <[EMAIL PROTECTED]> writes:
> > My reply was in response to a post that mentioned a known problem with
> > this, what happens when the previously running program doesn't exit
> > gracefully, and leav
[EMAIL PROTECTED] wrote:
> Steve makes a good point. Fredrik is one of the most important
> contributors of Python code, tools, etc and as far as I am concerned,
> that is so important that it gives him the right to be cranky from tiem
> to time.
Since February last year I've had the opportunity t
"Tim Williams" <[EMAIL PROTECTED]> writes:
> That's the same kind of principle as my posted snippet, it doesn't
> rely on the file's presence or absence as such. It only cares when
> the file exists *and* is held open by another process.When the
> process exits, the lock ends without needing
Paul Rubin wrote:
> Don't use the presence or absence of a file as a lock. Have the file
> there all the time, and have the app open it and use fcntl to get an
> exclusive kernel lock on the file descriptor.
doesn't work on all file systems, though...
--
http://mail.python.org/mailman/listin
Tim Williams wrote:
> So that I know my mistake, which bit fails (the text from
> sys.exc_info()[1]?? ) , or is it all complete rubbish - and not
> do-able - on a *nix system ?
opening a file for writing doesn't lock it on Unix. if you want
locking, you need other mechanisms, and I'm not sure
Patrick Smith wrote:
> > Well, the problem is that you can't simply kill a thread--it shares
> > memory with other threads that it could be leaving in an inconsistent
> > state. Imagine that it was, say, holding a lock when it was forceably
> > killed. Now any other thread that tries to acquire t
On 29 Sep 2006 10:04:15 -0700, Paul Rubin
<"http://phr.cx"@nospam.invalid> wrote:
> "Tim Williams" <[EMAIL PROTECTED]> writes:
> > That's the same kind of principle as my posted snippet, it doesn't
> > rely on the file's presence or absence as such. It only cares when
> > the file exists *and* is
Paul Rubin wrote:
>> That's the same kind of principle as my posted snippet, it doesn't
>> rely on the file's presence or absence as such. It only cares when
>> the file exists *and* is held open by another process.When the
>> process exits, the lock ends without needing to clean up.
>>
>>
On 29/09/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> Tim Williams wrote:
>
> > So that I know my mistake, which bit fails (the text from
> > sys.exc_info()[1]?? ) , or is it all complete rubbish - and not
> > do-able - on a *nix system ?
>
> opening a file for writing doesn't lock it on Unix.
[EMAIL PROTECTED] wrote:
> Hi,
>
> Bruno Desthuilliers a écrit :
>> I've never met a programmer that "loved" Windev.
>
> I have met some here (I'm the guy with a mustache-just kidding but
> actually I was there).
>
> http://www.pcsoft.fr/pcsoft/tdftech/2006/images/Paris/07-IMG_5853.jpg
>
> WinD
Fredrik Lundh <[EMAIL PROTECTED]> writes:
> opening a file for writing doesn't lock it on Unix. if you want
> locking, you need other mechanisms, and I'm not sure any of them
> work properly on all configurations, under all circumstances.
Hmm. What about trying to listen on a PF_UNIX socket asso
Fredrik Lundh wrote:
> so what does the benchmark look like if you actually do this ?
Okay, timing this:
x = ""
for i in range(10):
x += "a"
t = x[1] # forces the concat object to render
The result:
Python 2.5 release: 30.0s
Python 2.5 locally built: 30.2s
Python 2.5 concat: 4
is there anyway I can, in a setup.py file, set and internal equivalent
to the '--install-scripts' commandline option?
script installation directory but I don't want on the command line where
things can go horribly wrong if the user forgets. I would like to
create a new default setting for th
Ok, this is completely unnecessary so I don't intend to get into stuff
that's beyond my skill, but I'm wondering how simple it would be to use
Python to create a server that runs on my computer so I can test my
webpages (because otherwise I have to keep sending them to our IT person
so he can u
Magnus Lycka wrote:
> In other words, Python has to a significant taken over the role Perl
> had.
This seems relevant to that thought (although it's not working right
now): http://suttree.com/2006/09/02/php-is-the-new-classic/
--
http://mail.python.org/mailman/listinfo/python-list
New to Python ... this should be an easy question to answer.
INPUT
import sys
print 'The command line arguments are:'
for i in sys.argv:
print i
print '\nThe PYTHONPATH is', sys.path
OUTPUT
The command line arguments are:
C:\Python25\using_sys.py
The PYTHONPATH is ['C:\\Python25\\Lib\\idl
> It works fine when I 'Run Module'...but when I type in interactive mode
> in the Python Shell
python using_sys.py test1 test2 test3
>
> I get the following error:
> SyntaxError: invalid syntax
By using proper syntax... :*)
To pass parameters, you do it when *starting* python[*]. Thus,
Python author and trainer Mark Lutz will be interviewed
on the radio show Tech Talk this Sunday, October 1st,
at 6PM Eastern time. He'll be answering questions about
Python, his books, and his Python training services.
For more details about the show, see Tech Talk's website
at http://techtalk.im
Ben Sizer wrote:
> [EMAIL PROTECTED] wrote:
> > I'm a compiler newbie and was curious if Python's language/grammar
> > can be handled by a recursive descent parser.
>
> I believe a recursive descent parser can handle any grammar; it just
> depends on how pure you want it to be.
>
> --
> Ben Size
metaperl wrote:
> Actually right after posting this I came up with a great usage. I use
> meld3 for my Python based dynamic HTML generation. Whenever I plan to
> loop over a tree section I use a for loop, but if there is no data to
> iterate over, then I simply remove that section from the tree or
I'm writing a function that accepts a function as an argument, and I
want to know to all the parameters that this function expects. How can
I find this out in my program, not by reading the source?
For example, I would want to know for the function below that I have to
pass in two things:
def f(
Sybren Stuvel wrote:
> Antoine De Groote enlightened us with:
> > I hope I don't upset anybody by comparing Python to Ruby (again). Is
> > there something like Ruby's retry keyword in Python?
>
> Please don't assume that everybody knows Ruby through and through...
In ruby, the equivalent to try...
Hey, I have the following code that has to send every command it
receives to a list of backends. Instead of:
class MultiBackend(object):
"""Renders to multiple backends"""
def __init__(self, backends):
self.backends = backends
def flush(self):
for b in self.backends:
John Salerno wrote:
> Ok, this is completely unnecessary so I don't intend to get into stuff
> that's beyond my skill, but I'm wondering how simple it would be to use
> Python to create a server that runs on my computer so I can test my
> webpages (because otherwise I have to keep sending them t
metaperl wrote:
> I was shocked to see the personal insults hurled in this thread:
> http://groups.google.com/group/comp.lang.python/browse_thread/thread/d0758cb9545cad4b
Ahhh, no need to overreact, that's just the usual Friday night steel
cage match:
Fredrik vs "Poster Who is Convinced That The
Eric S. Johansson wrote:
> is there anyway I can, in a setup.py file, set and internal equivalent
> to the '--install-scripts' commandline option?
Please don't. Hard-coding that interferes with the user's decision of where
things should go. Only the user should be making that decision, not the
Larry Hastings wrote:
[snip]
> The core concept: adding two strings together no longer returns a pure
> "string" object. Instead, it returns a "string concatenation" object
> which holds references to the two strings but does not actually
> concatenate
> them... yet. The strings are concatenated
Paul Rubin wrote:
> http://web.cecs.pdx.edu/~mpj/timbot/index.html
How said it's another one? Maybe our timbot grew a body.
--
http://mail.python.org/mailman/listinfo/python-list
If your using python 2.4.3 or essentially any of the 2.3, 2.4 series,
i'd test out PyScripter as an IDE, it's one of the best that I've used.
Unfortunately, they have yet to fully accomedate 2.5 code (you can
still write 2.5 code with almost no problems, but you won't be able to
use a 2.5 interact
If your using python 2.4.3 or essentially any of the 2.3, 2.4 series,
i'd test out PyScripter as an IDE, it's one of the best that I've used.
Unfortunately, they have yet to fully accomedate 2.5 code (you can
still write 2.5 code with almost no problems, but you won't be able to
use a 2.5 interact
MonkeeSage schrieb:
> Sybren Stuvel wrote:
>> Antoine De Groote enlightened us with:
>>> I hope I don't upset anybody by comparing Python to Ruby (again). Is
>>> there something like Ruby's retry keyword in Python?
>> Please don't assume that everybody knows Ruby through and through...
>
> In ruby
On 2006-09-28, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> I'm a compiler newbie and was curious if Python's language/grammar
> can be handled by a recursive descent parser.
IIUC the python grammer is LL(1) and the development team is commited
to keeping it LL(1).
LL(1) languages can be handle
Matt,
In [26]: inspect.getargspec(f)
Out[26]: (['x1', 'x2'], None, None, None)
For more see the inspect module.
-Nick Vatamaniuc
Matthew Wilson wrote:
> I'm writing a function that accepts a function as an argument, and I
> want to know to all the parameters that this function expects. How c
It's been observed a couple times recently ... distributing and compiling
extensions is a pain, especially on windows, when the main supported
compilers are not freely availble .. nor even commercially availble anymore.
What we need is a way to break out of this dependency. A way for python
ext
Irmen de Jong wrote:
> John Salerno wrote:
>> Ok, this is completely unnecessary so I don't intend to get into stuff
>> that's beyond my skill, but I'm wondering how simple it would be to
>> use Python to create a server that runs on my computer so I can test
>> my webpages (because otherwise I
MonkeeSage wrote:
> I don't think python has any equivalent (could be wrong).
a trivial combination of while and try/except/else does the trick:
n = 0
while 1:
try:
# do something
print n
n = n + 1
# make sure it fails a couple of times
if n < 10:
> In ruby, the equivalent to try...except is begin...rescue. In the
> rescue section you can ask it to retry the begin section. So, for
> example:
>
> b=0
> begin
> puts 1/b
> rescue
> b=1
> retry # <- this little guy
> end
Well, it's all a matter of how you look at it. I personally
pref
Matthew Wilson wrote:
> I'm writing a function that accepts a function as an argument, and I
> want to know to all the parameters that this function expects. How can
> I find this out in my program, not by reading the source?
>
> For example, I would want to know for the function below that I hav
Reciently i wrote a simple client (in twisted) using Reconnecting
Factory.
That client logins to my socket server.. and that`s it.
Interesting thing is that it is seems that twisted client,
sends some ping on a TCP level without sending any data to the
socket directl
>> Why do you need to use Python for the server?
>
> Well, perhaps I don't know what I'm talking about. I'm on an XP machine
> and I just needed a way to test my web pages, and I thought Python could
> be used to create a server to do this. But I know nothing about network
> programming...
Wel
Everyone wrote:
> [cool stuff]
Ps. I've only used retry a handful of times in about 3 or 4 years of
using ruby; I wasn't advocating it or criticizing python, just trying
to explain the OPs request.
Regards,
Jordan
--
http://mail.python.org/mailman/listinfo/python-list
Robert Kern wrote:
> Eric S. Johansson wrote:
>> is there anyway I can, in a setup.py file, set and internal equivalent
>> to the '--install-scripts' commandline option?
>
> Please don't. Hard-coding that interferes with the user's decision of where
> things should go. Only the user should be m
Thus spoke John Salerno (on 2006-09-29 21:13):
> Irmen de Jong wrote:
>> John Salerno wrote:
>>> Ok, this is completely unnecessary so I don't intend to get into stuff
>>> that's beyond my skill, but I'm wondering how simple it would be to
>>> use Python to create a server that runs on my compute
Eric S. Johansson wrote:
> Robert Kern wrote:
>> Eric S. Johansson wrote:
>>> is there anyway I can, in a setup.py file, set and internal equivalent
>>> to the '--install-scripts' commandline option?
>> Please don't. Hard-coding that interferes with the user's decision of where
>> things should
Robert Kern wrote:
>
> Okay, if it's just for internal use, then I certainly have no objection. Use
> a
> setup.cfg file:
>
>http://docs.python.org/inst/config-syntax.html
>
> Specifically, use something like the following section:
>
> [install]
> install_scripts=/path/to/scripts/director
If I want to have a list like this:
[(first_name, 'First Name:'), (last_name, 'Last Name:').]
where the first part of each tuple is a variable name and the second
part is a label for the user to see, such as a form like this:
First Name:
Last Name:
(the variables would s
Bruno Desthuilliers wrote:
> [EMAIL PROTECTED] wrote:
> > Hi,
> >
> > Bruno Desthuilliers a écrit :
> >> I've never met a programmer that "loved" Windev.
> >
> > I have met some here (I'm the guy with a mustache-just kidding but
> > actually I was there).
> >
> > http://www.pcsoft.fr/pcsoft/tdftec
Thus spoke Mirco Wahab (on 2006-09-29 21:32):
> Thus spoke John Salerno (on 2006-09-29 21:13):
>> Irmen de Jong wrote:
>>> John Salerno wrote:
Ok, this is completely unnecessary so I don't intend to get into stuff
>>> Why do you need to use Python for the server?
>> Well, perhaps I don't know
Eric S. Johansson wrote:
> Now I get to puzzle out how to install the CGI plus images plus
> stylesheets plus plus plus mess. Probably a bit outside of the scope of
> distutils even if the CGI programs are Python. ;-)
I recommend installing the data inside the package itself. In 2.4, use the
[EMAIL PROTECTED] schrieb:
>> I've started a wiki page where I already added an entry about the above
>> question.
>> Do you think the entry would have answered your question?
>> http://starship.python.net/crew/theller/moin.cgi/CodeSnippets
>
> As concise as I now can imagine, yes thank you.
>
>
Hi John
John Salerno wrote:
> how would I go about putting these variable names in a list? I know I
> can't leave them as above, but if I put them in as a string, then how do
> I later "transform" them into an actual variable for assign, such as:
>
> first_name = widget.get_text()
>
> Is there
John Salerno wrote:
> If I want to have a list like this:
>
> [(first_name, 'First Name:'), (last_name, 'Last Name:').]
>
> where the first part of each tuple is a variable name and the second
> part is a label for the user to see, such as a form like this:
>
> First Name:
> Last Name
Neal Becker wrote:
> Any suggestions for transforming the sequence:
>
> [1, 2, 3, 4...]
> Where 1,2,3.. are it the ith item in an arbitrary sequence
>
> into a succession of tuples:
>
> [(1, 2), (3, 4)...]
>
> In other words, given a seq and an integer that specifies the size of tuple
> to retu
Robert Kern wrote:
> Eric S. Johansson wrote:
>
>> Now I get to puzzle out how to install the CGI plus images plus
>> stylesheets plus plus plus mess. Probably a bit outside of the scope of
>> distutils even if the CGI programs are Python. ;-)
>
> I recommend installing the data inside the pa
Mark Lutz wrote:
> Python author and trainer Mark Lutz will be interviewed
> on the radio show Tech Talk this Sunday, October 1st,
> at 6PM Eastern time. He'll be answering questions about
> Python, his books, and his Python training services.
>
Does he always talk in the third person ? ;-)
Fuz
Eric S. Johansson wrote:
> So what I have seen so far says that to be able to take data from a
> series of directories scatter it to other directories may be out of
> scope. It's okay. If I have to write a wrapper, it won't be the first
> time.
do'h.
http://docs.python.org/dist/node13.html
John Salerno wrote:
> If I want to have a list like this:
>
> [(first_name, 'First Name:'), (last_name, 'Last Name:').]
>
> where the first part of each tuple is a variable name and the second
...
> can't leave them as above, but if I put them in as a string, then how do
> I later "transform"
[EMAIL PROTECTED] wrote:
> Hey, I have the following code that has to send every command it
> receives to a list of backends. Instead of:
>
> class MultiBackend(object):
> """Renders to multiple backends"""
>
> def __init__(self, backends):
> self.backends = backends
>
> def
John Salerno wrote:
> If I want to have a list like this:
>
> [(first_name, 'First Name:'), (last_name, 'Last Name:').]
Do you need the data to be ordered? If not, just use a dictionary:
d = {'First Name:': '', 'Last Name:': ''}
d['First Name:'] = 'Bob'
d['Last Name:'] = 'Smith'
print "Hi, I
Dennis is absolutely right. The reason you won't find a method in the
standard libraries for doing this task specifically is because python
aims to by cross-platform. If it were to support a method that worked
in the way you describe specifically for Windows, that would
essentially break python's
On 29 Sep 2006 11:26:10 -0700, Klaas <[EMAIL PROTECTED]> wrote:
else: does not trigger when there is no data on which to iterate, butwhen the loop terminated normally (ie., wasn't break-ed out). It is
meaningless without break.
The else clause *is* executed when there is no data on which to itera
Klaas wrote:
> else: does not trigger when there is no data on which to iterate, but
> when the loop terminated normally (ie., wasn't break-ed out). It is
> meaningless without break.
Sorry, this was worded confusingly. "else: triggers when the loop
terminates normally, not simply in the case t
On 9/29/06, Johan Steyn <[EMAIL PROTECTED]> wrote:
> On 29 Sep 2006 11:26:10 -0700, Klaas <[EMAIL PROTECTED]> wrote:
>
> > else: does not trigger when there is no data on which to iterate, but
> > when the loop terminated normally (ie., wasn't break-ed out). It is
> > meaningless without break.
>
On 9/29/06, Johan Steyn <[EMAIL PROTECTED]> wrote:
> I agree that it is meaningless without a break statement, but I still find
> it useful when I want to determine whether I looped over the whole list or
> not. For example, if I want to see whether or not a list contains an odd
> number:
>
> for
[EMAIL PROTECTED] wrote:
> Hey, I want to send commands to a list of backends:
How about something like:
class Forwards(object):
to_forward = set(['flush', 'read', 'write', 'close'])
def __init__(self, backends):
self.backends = backends
def forwarder(self, methodname)
Scott David Daniels wrote:
>
> class Forwards(object):
>
> to_forward = set(['flush', 'read', 'write', 'close'])
>
> def __init__(self, backends):
> self.backends = backends
>
> def forwarder(self, methodname):
> def method(*args, **kwargs):
> for b in se
"John Salerno" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
> Irmen de Jong wrote:
>> John Salerno wrote:
>>> Ok, this is completely unnecessary so I don't intend to get into stuff
>>> that's beyond my skill, but I'm wondering how simple
>>> it would be to use Python to create a se
[EMAIL PROTECTED] wrote:
> Hey, I have the following code that has to send every command it
> receives to a list of backends.
> I would like to write each method like:
>
> flush = multimethod()
Here's one way, using a metaclass:
class multimethod(object):
def transform(self, attr):
Tim Chase wrote:
>
> Well, you could investigate WebStack:
[...]
> The documentation is a bit terse, and lacking in some areas, but
> a little debugging output goes a long way toward diagnosing
> problems with your code.
Suggestions for improvement are very welcome! And I do value the
expertise
[EMAIL PROTECTED] wrote:
> And so on. For every use of the for/else clause there exists a better
> alternative. Which sums up my opinion about the construct -- if you
> are using it, there's something wrong with your code.
How do you transform this?
height = 0
for block in stack:
if block.is_
101 - 200 of 229 matches
Mail list logo