r0g wrote:
def ip2inet(a):
li = a.split('.')
assert len(li) == 4 or len(li) == 6
return reduce(add,[int(li[e])*(256**((len(li)-1)-e)) for e in
xrange(0,len(li))])
what a mess.
i don't use this extreme a functional style in python (it's not really how
the language is intended to be
r0g aioe@technicalbloke.com writes:
def inet2ip(n):
p = (n/16777216)
q = ((n-(p*16777216))/65536)
r = ((n-((p*16777216)+(q*65536)))/256)
s = ((n-((p*16777216)+(q*65536)+(r*256
return str(p)+.+str(q)+.+str(r)+.+str(s)
from struct import pack
def inet2ip(n):
xs =
Hey .python first time poster here. I'm pretty good with python so
far, but I keep needed a function in my program but not knowing how to
build it. =( Here's the problem:
Imagine a html file full of 100's of these strings all mooshed
together onto many lines;
!--@@MARKER@@; id=ITEM--ITEMbr
Where
J wrote:
Thanks for your answers, especially Chris Rebert and Paul McGuire's. I
have a question:
How far does Python go in the Game Development field? (Using Python
only, no extensions)
Hey J,
Python's all about the libraries (extensions), you won't be able to do
much without them but
Hello all,
The zlib interface does not indicate when you've hit the end of a compressed
stream.
The underlying zlib functionality provides for this.
With python's zlib, you have to read past the compressed data and into
the uncompressed, which gets stored in Decompress.unused_data.
As a
does anyone have any arguments against optparse vs getopt
--
http://mail.python.org/mailman/listinfo/python-list
Hello all,
I am very new to Python and I am using it because I needed an easy
language to control a piece of equipment that connects to my computer
via a serial cable. I am running Python 2.6 with pySerial 2.4 under
Windows. I can get Python to create a serial port on COM1, but when I
try to
On 2009-02-10 15:06, Matthew Sacks wrote:
does anyone have any arguments against optparse vs getopt
As the getopt docs say: A more convenient, flexible, and powerful alternative
is the optparse module.
I have found all three statements to be true.
But I've found argparse to be even better.
For expressiveness, try something like:
def ip2in(dotted_ip_addr):
result = 0
assert dotted_ip_addr.count('.') in (3, 7)
for chunk in dotted_ip_addr.split('.'):
result = (result 8) + int(chunk)
return result
def inet2ip(ip_number):
assert 0 ip_number 1 48
2009/2/10 namire nam...@gmail.com:
Hey .python first time poster here. I'm pretty good with python so
far, but I keep needed a function in my program but not knowing how to
build it. =( Here's the problem:
Imagine a html file full of 100's of these strings all mooshed
together onto many
On Tue, 2009-02-10 at 12:50 -0800, Josh Dukes wrote:
The thing I don't understand is why a generator that has no iterable
values is different from an empty list. Why shouldn't bool ==
has_value?? Technically a list, a tuple, and a string are also objects
but if they lack values they're
Travis wrote:
The zlib interface does not indicate when you've hit the
end of a compressed stream
The underlying zlib functionality provides for this.
With python's zlib, you have to read past the compressed data and into
the uncompressed, which gets stored in Decompress.unused_data.
...
Matthew Sacks wrote:
does anyone have any arguments against optparse vs getopt
I've found that the optparse module beats getopt on *every*
aspect except in the event that you have experience with the C
getopt libraries *and* just want something that behaves like
those libraries. Optparse
Thanks for your suggestions. I've also figured that I can test if
logging.RootLogger.manager.loggerDict has any items in it. Or if it
has a logger for the module that I wish to start. I like basicLogger
idea though as it seems like the cleanest implementation.
On Feb 10, 3:21 pm, Vinay Sajip
it seems as if optparse isn't in my standard library.
is there a way to add a lib like ruby gems?
On Tue, Feb 10, 2009 at 1:38 PM, Tim Chase
python.l...@tim.thechases.com wrote:
Matthew Sacks wrote:
does anyone have any arguments against optparse vs getopt
I've found that the optparse module
Hi List,
I'm trying to get python to parse a CAP file in an ATOM feed from the
National Weather Service. Here's one states ATOM feed.
http://www.weather.gov/alerts-beta/ky.php?x=0. If you view the source
of this file, there is a reference to another web feed. For instance,
On 2009-02-10 15:42, Matthew Sacks wrote:
it seems as if optparse isn't in my standard library.
How did you install your Python? It has been part of the standard library for a
very long time.
is there a way to add a lib like ruby gems?
http://docs.python.org/install/index.html
But
On Feb 11, 5:51 am, r rt8...@gmail.com wrote:
On Feb 10, 1:27 pm, Kalibr space.captain.f...@gmail.com wrote:
[snip]
You should really check out wxPython, there is support for just this
type of thing. of course you could do this with Tkinter, but just
thinking about it makes my head hurt :).
was not able to use open to open a binary file so what I did was use
urlfetch to fetch the image for me and read the content into BlobProperty()
Not sure why it took me so long to figure this out. Hope it helps someone.
thx
def post(self,key):
k=db.get(key)
Travis travis+ml-pyt...@subspacefield.org writes:
However, perhaps this would be a good time to discuss how this library
works; it is somewhat awkward and perhaps there are other changes which
would make it cleaner.
What does the python community think?
It is missing some other features
Here a small benchmark:
def ip2inet01(a): # can't be used with 6
li = a.split('.')
assert len(li) == 4
a = int(li[0])*16777216
b = int(li[1])*65536
c = int(li[2])*256
d = int(li[3])
return a+b+c+d
from itertools import count
def ip2inet02(a):
blocks =
On Tue, 10 Feb 2009 12:50:02 -0800, Josh Dukes wrote:
The thing I don't understand is why a generator that has no iterable
values is different from an empty list.
How do you know it has no iterable values until you call next() on it and
get StopIteration?
By the way, your has_values function
On Tue, 10 Feb 2009 12:43:20 +, Lie Ryan wrote:
Of course multi-core processor can improve single function using
multiprocessing, as long as the function is parallelizable. The
Fibonacci function is not a parallelizable function though.
As I understand it, there's very little benefit to
Aaron Brady wrote:
I guess a generator that counts, but skips K numbers, where K can be
varied. For instance, you initialize it with N, the starting number,
and K, the jump size. Then, you can change either one later on.
This specification is incomplete as to the timing of when changes to N
namire wrote:
Just as a comparison in the Windows OS this seems easy to do when
managing files, say for the file a-blah-b-blah.tmp where blah is an
unknown you can use: del a-*-b-*.tmp to get rid of that file. But for
python and a string in text file I don't have a clue. @_@ could
someone
On Tue, 10 Feb 2009 22:41:25 +1000, Gerhard Weis wrote:
btw. the timeings are not that different for the naive recursion in OP's
version and yours.
fib(500) on my machine:
OP's: 0.00116 (far away from millions of years)
This here: 0.000583
I don't believe those timings are credible.
On Tue, 10 Feb 2009 12:06:06 +, Duncan Booth wrote:
Steven D'Aprano ste...@remove.this.cybersource.com.au wrote:
On Mon, 09 Feb 2009 19:10:28 -0800, Spacebar265 wrote:
How would I do separate lines into words without scanning one
character at a time?
Scan a line at a time, then
On Tue, Feb 10, 2009 at 1:57 PM, Steven D'Aprano
ste...@remove.this.cybersource.com.au wrote:
On Tue, 10 Feb 2009 12:50:02 -0800, Josh Dukes wrote:
The thing I don't understand is why a generator that has no iterable
values is different from an empty list.
How do you know it has no iterable
ahhh any! ok, yeah, I guess that's what I was looking for. Thanks.
On 10 Feb 2009 21:57:56 GMT
Steven D'Aprano ste...@remove.this.cybersource.com.au wrote:
On Tue, 10 Feb 2009 12:50:02 -0800, Josh Dukes wrote:
The thing I don't understand is why a generator that has no iterable
values is
On Feb 10, 9:38 pm, aha aquil.abdul...@gmail.com wrote:
Thanks for your suggestions. I've also figured that I can test
iflogging.RootLogger.manager.loggerDict has any items in it. Or if it
has a logger for the module that I wish to start. I like basicLogger
idea though as it seems like the
So how does this effect the install instructions found on the link:
http://wiki.python.org/moin/MacPython/Leopard
do you trash that when you do an install on OS X? I am so hesitant to
delete anything that resides in /System
--
http://mail.python.org/mailman/listinfo/python-list
Josh Dukes wrote:
I was actually aware of that (thank you, though, for trying to help).
What I was not clear on was if the boolean evaluation is a method of an
object that can be modified via operatior overloading (in the same way
+ is actually .__add__()) or not. Clearly __nonzero__ is the
On Tue, 10 Feb 2009 02:05:35 -0800, Niklas Norrthon wrote:
According to the common definition of fibonacci numbers fib(0) = 0, fib
(1) = 1 and fib(n) = fib(n-1) + fib(n-2) for n 1. So the number above
is fib(501).
So it is. Oops, off by one error!
Or, if you prefer, it's the right algorithm
bearophileh...@lycos.com wrote:
Paul Rubin:
Gideon Smeding of the University of
Utrecht has written a masters' thesis titled An executable
operational semantics for Python.
A significant part of Computer Science is a waste of time and money.
The same can be said for any research. Can you
nnp wrote:
Hey,
I'm currently working with propositional boolean formulae of the type
'A (b - c)' (for example). I was wondering if anybody knows of a
Python library to create parse trees and convert such formulae to
conjunctive, disjunctive and Tseitin normal forms?
You would probably do
Paul Rubin wrote:
Travis travis+ml-pyt...@subspacefield.org writes:
However, perhaps this would be a good time to discuss how [zlib] works...
It is missing some other features too, like the ability to preload
a dictionary. I'd support extending the interface.
The trick to defining a preload
On 2009-02-11 08:01:29 +1000, Steven D'Aprano
ste...@remove.this.cybersource.com.au said:
On Tue, 10 Feb 2009 22:41:25 +1000, Gerhard Weis wrote:
btw. the timeings are not that different for the naive recursion in OP's
version and yours.
fib(500) on my machine:
OP's: 0.00116 (far
bmasch...@gmail.com wrote:
Hello all,
I am very new to Python and I am using it because I needed an easy
language to control a piece of equipment that connects to my computer
via a serial cable. I am running Python 2.6 with pySerial 2.4 under
Windows. I can get Python to create a serial port on
bmasch...@gmail.com schrieb:
Hello all,
I am very new to Python and I am using it because I needed an easy
language to control a piece of equipment that connects to my computer
via a serial cable. I am running Python 2.6 with pySerial 2.4 under
Windows. I can get Python to create a serial port
Or for a slightly less simple minded splitting you could try re.split:
re.split((\w+), The quick brown fox jumps, and falls over.)[1::2]
['The', 'quick', 'brown', 'fox', 'jumps', 'and', 'falls', 'over']
Perhaps I'm missing something, but the above regex does the exact same
thing as
On Tue, 10 Feb 2009 22:02:57 -, Steven D'Aprano
ste...@remove.this.cybersource.com.au wrote:
On Tue, 10 Feb 2009 12:06:06 +, Duncan Booth wrote:
Steven D'Aprano ste...@remove.this.cybersource.com.au wrote:
On Mon, 09 Feb 2009 19:10:28 -0800, Spacebar265 wrote:
How would I do
r0g wrote:
def inet2ip(n):
p = (n/16777216)
q = ((n-(p*16777216))/65536)
r = ((n-((p*16777216)+(q*65536)))/256)
s = ((n-((p*16777216)+(q*65536)+(r*256
return str(p)+.+str(q)+.+str(r)+.+str(s)
Beyond what other wrote:
To future-proof code, use // instead of / for integer
On 10 Feb, 20:45, Jean-Paul Calderone exar...@divmod.com wrote:
It replaces one kind of repetition with another. I think each kind is
about as unpleasant. Has anyone gathered any data on the frequency of
changes of base classes as compared to the frequency of classes being
renamed? I don't
namire wrote:
Hey .python first time poster here. I'm pretty good with python so
far, but I keep needed a function in my program but not knowing how to
build it. =( Here's the problem:
Imagine a html file full of 100's of these strings all mooshed
together onto many lines;
!--@@MARKER@@;
On Tue, Feb 10, 2009 at 01:36:21PM -0800, Scott David Daniels wrote:
A simple way to fix this would be to add a finished attribute to the
Decompress object.
Perhaps you could submit a patch with such a change?
Yes, I will try and get to that this week.
However, perhaps this would be a good
On Tue, 10 Feb 2009 16:46:30 -0600, Tim Chase wrote:
Or for a slightly less simple minded splitting you could try re.split:
re.split((\w+), The quick brown fox jumps, and falls
over.)[1::2]
['The', 'quick', 'brown', 'fox', 'jumps', 'and', 'falls', 'over']
Perhaps I'm missing something,
Steven D'Aprano wrote:
On Tue, 10 Feb 2009 16:46:30 -0600, Tim Chase wrote:
Or for a slightly less simple minded splitting you could try re.split:
re.split((\w+), The quick brown fox jumps, and falls
over.)[1::2]
['The', 'quick', 'brown', 'fox', 'jumps', 'and', 'falls', 'over']
Perhaps
I have embedded Python in a shared library. This works fine in Windows
(dll), but I get the following error is Ubuntu when I try to load modules:
/usr/lib/python2.5/lib-dynload/*time.so*: error: symbol lookup error: *
undefined* symbol: PyExc_ValueError
I found many postings on this issue on
its a debian package. 2.5
importing optparse works with interactive python, but not through the
jython interpreter i an using.
is there some way i can force the import based on the the absolute
path to the module?
On Tue, Feb 10, 2009 at 1:48 PM, Robert Kern robert.k...@gmail.com wrote:
On
On 2009-02-10 17:32, Matthew Sacks wrote:
its a debian package. 2.5
importing optparse works with interactive python, but not through the
jython interpreter i an using.
Ah, yes. The current version of Jython is still based off of Python 2.2 whereas
optparse was introduced in Python 2.3.
bearophileh...@lycos.com wrote:
Here a small benchmark:
def ip2inet01(a): # can't be used with 6
li = a.split('.')
snip
Wow, thanks everybody for all the suggestions, v.interesting esp as I
didn't even ask for any suggestions! This is a fantastically didactic
newsgroup: you start off
Scott David Daniels scott.dani...@acm.org writes:
I suspect that is why such an interface never came up (If
you can clone states, then you can say: compress this, then use the
resultant state to compress/decompress others.
The zlib C interface supports something like that. It is just not
I'm writing a linux remastering script in python where I need to chroot
into a folder, run some system commands and then come out and do some
tidying up, un-mounting proc sys etc.
I got in there with os.chroot() and I tried using that to get back out
but that didn't work so... is my script
On Feb 10, 5:41 pm, Diez B. Roggisch de...@nospam.web.de wrote:
bmasch...@gmail.com schrieb:
Hello all,
I am very new to Python and I am using it because I needed an easy
language to control a piece of equipment that connects to my computer
via a serial cable. I am running Python
In article 4c7158d2-5663-46b9-b950-be81bd799...@z6g2000pre.googlegroups.com,
Emanuele D'Arrigo man...@gmail.com wrote:
I'm having a ball with the power of regular expression but I stumbled
on something I don't quite understand:
Book recommendation: _Mastering Regular Expressions_, Jeffrey Friedl
En Tue, 10 Feb 2009 18:01:53 -0200, Daniel Fetchinson
fetchin...@googlemail.com escribió:
On 2/9/09, Gabriel Genellina gagsl-...@yahoo.com.ar wrote:
En Mon, 09 Feb 2009 23:34:05 -0200, Daniel Fetchinson
fetchin...@googlemail.com escribió:
Consider whether you really need to use super().
Found a couple of references to this in the newsgroup, but no
solutions.
I'm trying to build libsbml-3.3.0 with python 2.5.4 support on RHEL
5.3. This RedHat distro has python 2.4.5, and libsbml builds ok with
that release.
After building 2.5.4 (./configure CFLAGS=-fPIC , as the error message
Suppose I have a python object X, which holds inside it a python object
Y. How can I propagate each function call to X so the same function call
in Y will be called, i.e:
X.doThatFunkyFunk()
Would cause
Y.doThatFunkyFunk()
Thanks, Noam
--
http://mail.python.org/mailman/listinfo/python-list
This is a fantastically didactic newsgroup: you start off just musing about
fill-in-the-blank, you end up learning python has some great feature,
brilliant :-)
+1 !!
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, Feb 10, 2009 at 5:02 PM, Noam Aigerman no...@answers.com wrote:
Suppose I have a python object X, which holds inside it a python object Y.
How can I propagate each function call to X so the same function call in Y
That'd be a method call actually, not a function call.
will be called,
if anyone can have a look at this code and offer suggestions i would
appreciate it.
i am forced to use getopt, so i cant use something good like optparse
passedArgs = sys.argv[1:]
optlist, args = getopt.getopt(str(passedArgs), [connectPassword=,
adminServerURL=, action=, targets=, appDir=])
for
On Wed, Feb 11, 2009 at 11:02 AM, Noam Aigerman no...@answers.com wrote:
Suppose I have a python object X, which holds inside it a python object Y.
How can I propagate each function call to X so the same function call in Y
will be called, i.e:
X.doThatFunkyFunk()
Would cause
On Feb 11, 12:12 pm, Matthew Sacks ntw...@gmail.com wrote:
if anyone can have a look at this code and offer suggestions i would
appreciate it.
i am forced to use getopt, so i cant use something good like optparse
passedArgs = sys.argv[1:]
optlist, args = getopt.getopt(str(passedArgs),
In article 2ba4f763-79fa-423e-b082-f9de829ae...@i20g2000prf.googlegroups.com,
Giampaolo Rodola' gne...@gmail.com wrote:
Just out of curiosity, am I the only one who think that switching to
3.x right now is not a good idea?
Hardly. I certainly wouldn't consider it for production software, but
I sometimes write recursive functions like this simple factorial:
def fact(n):
if n 0: raise ValueError
if n = 0: return 1
return fact(n-1)*n
At the risk of premature optimization, I wonder if there is an idiom for
avoiding the unnecessary test for n = 0 in the subsequent
Consider whether you really need to use super().
http://fuhm.net/super-harmful/
Because throwing around that link carries about the same amount of
information as perl is better than python, my IDE is better than
yours, vim rulez!, emacs is cooler than vim, etc, etc.
Not at all. It contains
On Tue, Feb 10, 2009 at 9:25 PM, Daniel Fetchinson
fetchin...@googlemail.com wrote:
Consider whether you really need to use super().
http://fuhm.net/super-harmful/
Because throwing around that link carries about the same amount of
information as perl is better than python, my IDE is
I like the ability to access elements of a struct such as with ctypes
Structure:
myStruct.elementName1
4
What I like about it is there are no quotes needed.
What I don't like about it is that it's not iterable:
for n in myStruct: == gives error
print n
I don't want to force the end user to
I've done this:
def _fact(n):
if n = 0: return 1
return _fact(n-1)*n
def fact(n):
if n 0: raise ValueError
return _fact(n)
but that's ugly. What else can I do?
Hello, an idea is optional keyword arguments.
def fact(n, check=False):
if not check:
if n 0: raise
On 2009-02-10, bmasch...@gmail.com bmasch...@gmail.com wrote:
Hello all,
I am very new to Python and I am using it because I needed an
easy language to control a piece of equipment that connects to
my computer via a serial cable. I am running Python 2.6 with
pySerial 2.4 under Windows. I can
En Wed, 11 Feb 2009 00:31:06 -0200, Benjamin Kaplan
benjamin.kap...@case.edu escribió:
On Tue, Feb 10, 2009 at 9:25 PM, Daniel Fetchinson
fetchin...@googlemail.com wrote:
Okay, I think we converged to a common denominator. I agree with you
that the documentation needs additions about super
Can someone explain the difference between vars() and locals()?
I'm also trying to figure out what the use case is for vars(),
eg. when does it make sense to use vars() in a program?
Thank you,
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
En Wed, 11 Feb 2009 01:38:49 -0200, pyt...@bdurham.com escribió:
Can someone explain the difference between vars() and locals()?
I'm also trying to figure out what the use case is for vars(),
eg. when does it make sense to use vars() in a program?
Without arguments, vars() returns the current
Thank you Gabriel!
Malcolm
- Original message -
From: Gabriel Genellina gagsl-...@yahoo.com.ar
To: python-list@python.org
Date: Wed, 11 Feb 2009 02:04:47 -0200
Subject: Re: Difference between vars() and locals() and use case for
vars()
En Wed, 11 Feb 2009 01:38:49 -0200,
Hi, guys, my fib(xx) is just an example to show what is a single
function and what is the effect I expect to see when enable
multi-core.
My real purpose is to know whether multi-core can help to improve the
speed of a common function. But I know definitely that the answer is
NO.
--
En Tue, 10 Feb 2009 23:58:07 -0200, Steven D'Aprano
ste...@remove.this.cybersource.com.au escribió:
I sometimes write recursive functions like this simple factorial:
def fact(n):
if n 0: raise ValueError
if n = 0: return 1
return fact(n-1)*n
At the risk of premature
On Feb 11, 1:48 pm, Jervis Whitley jervi...@gmail.com wrote:
Hello, an idea is optional keyword arguments.
def fact(n, check=False):
if not check:
if n 0: raise ValueError
if n == 0: return 1
return fact(n - 1, check=True) * n
essentially hiding an expensive check with a cheap
On Feb 10, 9:19 am, Gabriel Genellina gagsl-...@yahoo.com.ar
wrote:
You really should push them to be included in python.org, even in their
unfinished form. (At least a link in the wiki pages). Their visibility is
almost null now.
It looks like I made an unfortunate choice with the
title
On Wed, Feb 11, 2009 at 2:21 PM, oyster lepto.pyt...@gmail.com wrote:
My real purpose is to know whether multi-core can help to improve the
speed of a common function. But I know definitely that the answer is
NO.
As stated by others, and even myself,
it is not possible to just automagically
On Tue, Feb 10, 2009 at 8:57 PM, James Mills
prolo...@shortcircuit.net.au wrote:
On Wed, Feb 11, 2009 at 2:21 PM, oyster lepto.pyt...@gmail.com wrote:
My real purpose is to know whether multi-core can help to improve the
speed of a common function. But I know definitely that the answer is
NO.
On Tue, 2009-02-10 at 12:50 -0800, Josh Dukes wrote:
The thing I don't understand is why a generator that has no iterable
values is different from an empty list. Why shouldn't bool ==
has_value?? Technically a list, a tuple, and a string are also objects
but if they lack values they're
The documentation leaves lack for want, especially the examples.
On Tue, Feb 10, 2009 at 5:25 PM, John Machin sjmac...@lexicon.net wrote:
On Feb 11, 12:12 pm, Matthew Sacks ntw...@gmail.com wrote:
if anyone can have a look at this code and offer suggestions i would
appreciate it.
i am forced
En Wed, 11 Feb 2009 00:31:26 -0200, mark.sea...@gmail.com escribió:
I like the ability to access elements of a struct such as with ctypes
Structure:
myStruct.elementName1
4
What I like about it is there are no quotes needed.
What I don't like about it is that it's not iterable:
for n in
oyster lepto.pyt...@gmail.com writes:
Hi, guys, my fib(xx) is just an example to show what is a single
function and what is the effect I expect to see when enable
multi-core.
My real purpose is to know whether multi-core can help to improve
the speed of a common function. But I know
On Feb 11, 12:25 pm, John Machin sjmac...@lexicon.net wrote:
On Feb 11, 12:12 pm, Matthew Sacks ntw...@gmail.com wrote:
if anyone can have a look at this code and offer suggestions i would
appreciate it.
i am forced to use getopt, so i cant use something good like optparse
passedArgs =
En Tue, 10 Feb 2009 16:22:36 -0200, Gary Wood python...@sky.com escribió:
Can someone recommend a good tutorial for Python 3, ideally that has
tasks or assignments at the end of each chapter.
I don't know of any specifically targetted to Python 3, except the
official one at
On Feb 11, 4:36 pm, Matthew Sacks ntw...@gmail.com wrote:
The documentation leaves lack for want, especially the examples.
You had two problems:
(1) str(passedArgs): The docs make it plain that args is a list, not
a str instance: args is the argument list to be parsed, without the
leading
Hi ,
I am using TKinter for creating a GUI. As of now i am using
tkFileDialog module for selection of file/directory.But i see that i
can use either of these at one go.Is there a way i can select a file
or a directory through a single dialog box??
--
Hi,
Anybody have suggestions of how network proxy settings can be changed
programmatically on the Mac, Tiger and Leopard. Are there any helpful
python api's that can be used.
Thanks
Sunil
--
http://mail.python.org/mailman/listinfo/python-list
http://wiki.python.org/moin/Python3.0Tutorials
On Wed, Feb 11, 2009 at 3:22 AM, Gary Wood python...@sky.com wrote:
Can someone recommend a good tutorial for Python 3, ideally that has tasks
or assignments at the end of each chapter.
Please,
--
I didn't realize that the no-value arguments, -b, -h, etc are required?
This seems to make things a bit more difficult considering unless I
use the GNU style getopt all arguments are required to be passed?
I could be mistaken.
I will have a look at what you have posted here and report my
Steven D'Aprano wrote:
I sometimes write recursive functions like this simple factorial:
def fact(n):
if n 0: raise ValueError
if n = 0: return 1
return fact(n-1)*n
At the risk of premature optimization, I wonder if there is an idiom for
avoiding the unnecessary test for n = 0 in
Steven D'Aprano ste...@remove.this.cybersource.com.au writes:
def fact(n):
if n 0: raise ValueError
if n = 0: return 1
return fact(n-1)*n
At the risk of premature optimization, I wonder if there is an idiom for
avoiding the unnecessary test for n = 0 in the subsequent
Paul Rubin http://phr...@nospam.invalid writes:
I'd write nested functions:
def fact(n):
if n 0: raise ValueError
def f1(n):
return 1 if n==0 else n*f1(n-1)
return f1(n)
I forgot to add: all these versions except your original one should
add a type
Martin v. Löwis mar...@v.loewis.de added the comment:
The revised patch looks fine to me, please apply.
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue4804
___
New submission from Peter Landgren peter.tal...@telia.com:
If any of the Swedish characters åäöÅÄÖ are input to
unicode.normalize(form, ustr) with form = NFD or NFKD the result
will be aaoAAO. åäöÅÄÖ are normal character and should be the same
after normalize. They are not connected to aaoAAO
Jervis Whitley jervi...@gmail.com added the comment:
Updated NamedTupleReader to give a rename=False keyword argument.
rename is passed directly to the namedtuple factory function to enable
automatic handling of invalid fieldnames.
Two new tests for the rename keyword.
Cheers,
Added file:
New submission from Floris Bruynooghe floris.bruynoo...@gmail.com:
When specifying an RPATH with -rpath or -R you can use the special
tokens `$LIB' and `$ORIGIN' which the runtime linker interprets as
normal search path and relative to current sofile respectively. To
get these correctly to the
New submission from David Jones d...@pobox.com:
When using the wave module to output wave files, the output file cannot
be a Unix pipeline.
Example. The following program outputs a (trivial) wave file on stdout:
#!/usr/bin/env python
import sys
import wave
w = wave.open(sys.stdout, 'w')
Lisandro Dalcin dalc...@gmail.com added the comment:
Mark, here you have a patch. I've only 'make test' on a 32bit Linux box
Just two comments:
- in docs: perhaps the 'versionchanged' stuff should be added.
- in tests: I did not touch Modules/_testcapimodule.c, as it seems the
test is
101 - 200 of 375 matches
Mail list logo