Re: subclass constructor problem

2010-10-06 Thread bruno.desthuilli...@gmail.com
On 5 oct, 17:52, de...@web.de (Diez B. Roggisch) wrote: > Btw, you are a bit on the overprotective side. The convention for > marking attributes (methods or objects alike) "private" s/private/implementation/ I find that thinking in terms of "interface / implementation" instead of "public / privat

Re: meta-class review

2010-10-06 Thread Carl Banks
On Oct 5, 4:17 pm, Ethan Furman wrote: > On one the many mini-reports we use, we have a bunch of counts that are > frequently zero; because the other counts can also be low, it becomes > easy to miss the non-zero counts.  For example: > > Code  Description > >        Conv Errors              :    

Re: unable to mkvirtualenv

2010-10-06 Thread Julian
On 5 Okt., 10:17, Julian wrote: > Hi, > > when creating a virtualenv withmkvirtualenv, I receive an error: > > http://pastebin.com/1N8yRZUv > > I've updated the relating packages (virtualenv, virtualenvwrapper, > distutils, distribute, pip) and couldn't solve my problem via google. jannis leidel

Re: if the else short form

2010-10-06 Thread Lawrence D'Oliveiro
In message , Antoon Pardon wrote: > A lot of times someone comes with code like the following: > > if len(lst) != 0: > ... > > > and than gets the advise to write it as follows: > > if lst: > ... > > Do you mean that this second piece of code is incorrectly written ... Yes. --

Expression problem.

2010-10-06 Thread Nethirlon .
Hi, I am having trouble with an expression. I have the following line of code: self.failUnless(c.as == 65215) What happens when you compile this is that you get a syntax error. This is because as has been made a keyword. failUnless is from the module unittest. Now my problem is this. the ".as"

Re: Expression problem.

2010-10-06 Thread Chris Rebert
On Wed, Oct 6, 2010 at 1:32 AM, Nethirlon . wrote: > Hi, > > I am having trouble with an expression. > > I have the following line of code: > > self.failUnless(c.as == 65215) > > What happens when you compile this is that you get a syntax error. > This is because as has been made a keyword. failUn

Re: if the else short form

2010-10-06 Thread James Harris
On 5 Oct, 06:52, Lawrence D'Oliveiro wrote: > In message > , James > > Harris wrote: > > On 29 Sep, 18:20, Seebs wrote: > > >> On 2010-09-29, Tracubik wrote: > > >>> button = gtk.Button(("False,", "True,")[fill==True]) > > >> Oh, what a nasty idiom. > > > I'm surprised you don't like this constr

Re: Expression problem.

2010-10-06 Thread Sebastiaan de Haan
Thank you Chris, I'll try and find the attribute in the code. That was my conclusion aswell... The original author must have defined it somewhere... Thanks. On Wed, Oct 6, 2010 at 10:59 AM, Chris Rebert wrote: > On Wed, Oct 6, 2010 at 1:32 AM, Nethirlon . wrote: >> Hi, >> >> I am having troubl

Re: help!!!

2010-10-06 Thread Chris Withers
On 06/10/2010 05:28, Dennis Lee Bieber wrote: On Tue, 05 Oct 2010 23:54:00 -0400, declaimed the following in gmane.comp.python.general: plz can u convert this cpp file into python i need that badly as soon as possible... I am new to python. I just wanna learn it Step one... DON'T

Re: if the else short form

2010-10-06 Thread Antoon Pardon
On Wed, Oct 06, 2010 at 09:31:48PM +1300, Lawrence D'Oliveiro wrote: > In message , Antoon > Pardon wrote: > > > A lot of times someone comes with code like the following: > > > > if len(lst) != 0: > > ... > > > > > > and than gets the advise to write it as follows: > > > > if lst: >

Re: Expression problem.

2010-10-06 Thread Peter Otten
Sebastiaan de Haan wrote: > Thank you Chris, > > I'll try and find the attribute in the code. That was my conclusion > aswell... The original author must have defined it somewhere... Don't forget to check whether the object's class (or any of its bases) has a __getattr__() or __getattribute__()

C++ vs. Python Was: Re: help!!!

2010-10-06 Thread Hans-Peter Jansen
On Wednesday 06 October 2010, 06:28:51 Dennis Lee Bieber wrote: > On Tue, 05 Oct 2010 23:54:00 -0400, > > declaimed the following in gmane.comp.python.general: > > plz can u convert this cpp file into python i need that badly as soon > > as possible... I am new to python. I just wanna learn it

Re: [Python-ideas] [Python-Dev] Inclusive Range

2010-10-06 Thread Antoon Pardon
On Tue, Oct 05, 2010 at 01:52:39PM -0700, Chris Rebert wrote: > On Tue, Oct 5, 2010 at 1:31 PM, Wolfgang Rohdewald > wrote: > > On Dienstag 05 Oktober 2010, MRAB wrote: > >> > About notation, even if loved right-hand-half-open > >> > intervals, I would wonder about [a,b] noting it. I guess > >> >

Re: meta-class review

2010-10-06 Thread Jorgen Grahn
On Wed, 2010-10-06, Ethan Furman wrote: > MRAB wrote: >> On 06/10/2010 00:17, Ethan Furman wrote: >> > [snip] >> > Any comments appreciated, especially ideas on how to better handle >> > class- and staticmethods >> > >> I think that's a bit of overkill. The problem lies in the printing >> part,

Re: Expression problem.

2010-10-06 Thread Nethirlon .
On 6 okt, 11:53, Peter Otten <__pete...@web.de> wrote: > Sebastiaan de Haan wrote: > > Thank you Chris, > > > I'll try and find the attribute in the code. That was my conclusion > > aswell... The original author must have defined it somewhere... > > Don't forget to check whether the object's class

Re: [C-API] Weird sys.exc_info reference segfault

2010-10-06 Thread Antoine Pitrou
On Tue, 05 Oct 2010 16:17:57 +0200 "Jonas H." wrote: > > Right now I have this minimal struct: > > static PyTypeObject StartResponse_Type = { > PyObject_HEAD_INIT(&PyType_Type) > 0, /* ob_size */ > "start_response", /* tp_name */ > sizeof(St

Re: sequence multiplied by -1

2010-10-06 Thread Albert van der Horst
In article <4ca6bd15$0$2$c3e8...@news.astraweb.com>, Steven D'Aprano wrote: >On Fri, 01 Oct 2010 14:56:52 +0200, Antoon Pardon wrote: > >> Think about the following possibility. >> >> Someone provides you with a library of functions that act on sequences. >> They rely on the fact that '+' con

Re: resource module returns just zeros

2010-10-06 Thread Adam Tauno Williams
On Tue, 2010-10-05 at 09:49 +1100, Cameron Simpson wrote: > On 04Oct2010 09:02, Adam Tauno Williams wrote: > | I'm using a call to the resource module's getrusage method. On openSUSE > | this works, on CentOS [python26-2.6.5-3.el5] it 'works' but just returns > | zeros for the memory utilization

Re: [C-API] Weird sys.exc_info reference segfault

2010-10-06 Thread Jonas H.
On 10/06/2010 02:01 PM, Antoine Pitrou wrote: It shouldn't. Are you sure you're calling PyType_Ready in the module initialization routine? Yeah. The problem was that the type struct was declared 'static' in another module so the changes `PyType_Ready` made to the struct weren't applied correc

Re: Expression problem.

2010-10-06 Thread Peter Otten
Nethirlon . wrote: > On 6 okt, 11:53, Peter Otten <__pete...@web.de> wrote: >> Sebastiaan de Haan wrote: >> > Thank you Chris, >> >> > I'll try and find the attribute in the code. That was my conclusion >> > aswell... The original author must have defined it somewhere... >> >> Don't forget to chec

Re: Expression problem.

2010-10-06 Thread Nethirlon .
On 6 okt, 15:25, Peter Otten <__pete...@web.de> wrote: > Nethirlon . wrote: > > On 6 okt, 11:53, Peter Otten <__pete...@web.de> wrote: > >> Sebastiaan de Haan wrote: > >> > Thank you Chris, > > >> > I'll try and find the attribute in the code. That was my conclusion > >> > aswell... The original au

Re: Re: Re: How to save a binary file?

2010-10-06 Thread hidura
When you put the 'wb' extension you have to pass a Encode the string Python does not accept a string on a wb file, Python3 On Oct 6, 2010 1:01am, Chris Rebert wrote: > On Oct 5, 2010 8:03pm, MRAB pyt...@mrabarnett.plus.com> wrote: >> On 05/10/2010 23:50, hid...@gmail.com wrote: >> I did

Re: Module loading trickery

2010-10-06 Thread Thomas Jollans
On Wednesday 06 October 2010, it occurred to Dave Angel to exclaim: > On 2:59 PM, Thomas Jollans wrote: > > > > % cat a.py > > foo = 'Meh.' > > import b > > > > % cat b.py > > from a import foo > > > > print(foo) > > > > % python a.py > > Meh. > > % > > But there are now two modules containing

Re: if the else short form

2010-10-06 Thread BartC
"James Harris" wrote in message news:e8b46ea8-8d1e-4db9-91ba-501fd1a44...@g18g2000yqk.googlegroups.com... On 29 Sep, 18:20, Seebs wrote: On 2010-09-29, Tracubik wrote: > Hi all, > I'm studying PyGTK tutorial and i've found this strange form: > button = gtk.Button(("False,", "True,")[fill==T

SAML2 support in Python

2010-10-06 Thread Roland Hedberg
Hi! For those that are interested in making there web applications work in a SAML2 federated environment I have two things to offer: 1) PySAML2 - a not complete but working implementation of SAML2 in Python. Started with implementing the SP part and are now slowly doing the IdP part to

Re: Re: Re: Re: How to save a binary file?

2010-10-06 Thread hidura
How i get the code what MRAB says theres any manual or example?, because i was trying in Python2.x to do it and give me the same mistake, when i try to use repr that give me more backslash On Oct 6, 2010 10:25am, hid...@gmail.com wrote: When you put the 'wb' extension you have to pass a Encod

Python shelve with a file handle

2010-10-06 Thread Adam Tauno Williams
shelve has open({filename}). Is there anyway to open a shelve 'database' using a file handle? Specifically I'd like to create a shelve database via a file handle acquired from a call to SpooledTemporaryFile. -- http://mail.python.org/mailman/listinfo/python-list

suggestions please "what should i watch for/guard against' in a file upload situation?"

2010-10-06 Thread geekbuntu
in general, what are things i would want to 'watch for/guard against' in a file upload situation? i have my file upload working (in the self-made framework @ work without any concession for multipart form uploads), but was told to make sure it's cleansed and cannot do any harm inside the system.

Re: direct print to log file

2010-10-06 Thread Sion Arrowsmith
Dave Angel wrote: >If you want to be able to go back to the original, then first bind >another symbol to it. Or restore from sys.__stdout__, as long as you're sure that nothing else has rebound sys.stdout first (or don't mind clobbering it). -- \S under construction -- http://mail.pytho

Re: meta-class review

2010-10-06 Thread Ethan Furman
Carl Banks wrote: On Oct 5, 4:17 pm, Ethan Furman wrote: class DashInt(int): __metaclass__ = Perpetuate def __str__(x): if x == 0: return '-' return int.__str__(x) Well, it's definitely overkill for printing a dash instead of a zero, but a lot of peopl

Re: suggestions please "what should i watch for/guard against' in a file upload situation?"

2010-10-06 Thread Seebs
On 2010-10-06, geekbuntu wrote: > in general, what are things i would want to 'watch for/guard against' > in a file upload situation? This question has virtually nothing to do with Python, which means you may not get very good answers. > my checklist so far is basically to check the extension -

Re: How to save a binary file?

2010-10-06 Thread MRAB
On 06/10/2010 15:25, hid...@gmail.com wrote: When you put the 'wb' extension you have to pass a Encode the string Python does not accept a string on a wb file, Python3 [snip] You are using Python 3 and type(str) returns ""? Binary data in Python 3 should be an instance of the 'bytes' class, no

Re: "Strong typing vs. strong testing"

2010-10-06 Thread Keith H Duggar
On Sep 29, 9:01 pm, RG wrote: > That the problem is "elsewhere in the program" ought to be small > comfort.  But very well, try this instead: > > [...@mighty:~]$ cat foo.c > #include > > int maximum(int a, int b) { return a > b ? a : b; } > > int main() { >   long x = 8589934592; >   printf("Max

Re: toy list processing problem: collect similar terms

2010-10-06 Thread sln
On Sat, 25 Sep 2010 21:05:13 -0700 (PDT), Xah Lee wrote: >here's a interesting toy list processing problem. > >I have a list of lists, where each sublist is labelled by >a number. I need to collect together the contents of all sublists >sharing >the same label. So if I have the list > >((0 a b) (

SysLogHandler message formatting

2010-10-06 Thread Dustin C. Hatch
I have a daemon that uses the built-in SysLogHandler logging handler class to log messages to the host's syslog. Unfortunately, I am having trouble getting it to work with Metalog[1]. At first, I thought the problem was Metalog's fault because everything works as expected with syslog-ng. Upon furt

hashkey/digest for a complex object

2010-10-06 Thread kj
The short version of this question is: where can I find the algorithm used by the tuple class's __hash__ method? Now, for the long version of this question, I'm working with some complext Python objects that I want to be able to compare for equality easily. These objects are non-mutable once th

Re: C++ vs. Python Was: Re: help!!!

2010-10-06 Thread Krister Svanlund
On Wed, Oct 6, 2010 at 12:16 PM, Hans-Peter Jansen wrote: > On Wednesday 06 October 2010, 06:28:51 Dennis Lee Bieber wrote: >> On Tue, 05 Oct 2010 23:54:00 -0400, >> >> declaimed the following in gmane.comp.python.general: >> > plz can u convert this cpp file into python i need that badly as soon

Re: suggestions please "what should i watch for/guard against' in a file upload situation?"

2010-10-06 Thread Tim Chase
On 10/06/10 12:14, Seebs wrote: not sure what else i could do to guard against anything bad happening. maybe the file name itself could cause greif? Obvious things: * File name causes files to get created outside some particular upload directory ("../foo") * File name has spaces * Crazy st

python-2.6.6 coredump running newspipe

2010-10-06 Thread Thomas Klausner
Hi! I'm running newspipe-1.1.9, an RSS reader (http://newspipe.sourceforge.net/), on NetBSD-5.99.11/amd64 using Python-2.6.6. Sometimes, it core dumps with particular feeds in the configuration (I guess depending on the feed, because when I comment out the offending feed in the opml file, it runs

Re: help!!!

2010-10-06 Thread Diez B. Roggisch
writes: > plz can u convert this cpp file into python i need that badly as soon as > possible... I am new to python. I just wanna learn it For such an aspiring student of the art of computer programming, I have the strange feeling of lack-of-effort-showing here. Do I have to lose my faith i

Re: Re: How to save a binary file?

2010-10-06 Thread hidura
Ppl thanyou, for all your help finally i did it! thanks, another thing to i have to send a propouse code, i can fixed the litle problem of the wsig.input in Python 3 i will tested in the next months but i want to share the code with the comunnity, how i can do that? On Oct 6, 2010 1:45p

Re: hashkey/digest for a complex object

2010-10-06 Thread Duncan Booth
kj wrote: > The short version of this question is: where can I find the algorithm > used by the tuple class's __hash__ method? > http://svn.python.org/view/python/trunk/Objects/tupleobject.c?revision=81029&view=markup static long tuplehash(PyTupleObject *v) { register long x, y; regist

Re: Re: Re: How to save a binary file?

2010-10-06 Thread hidura
Ppl thanyou, for all your help finally i did it! thanks, another thing to who i can send a propose code, i fixed the little problem of the wsig.input in Python 3 i will tested in the next months but i want to share the code with the community, how i can do that? On Oct 6, 2010 3:13pm, h

Re: suggestions please "what should i watch for/guard against' in a file upload situation?"

2010-10-06 Thread Diez B. Roggisch
Seebs writes: > On 2010-10-06, geekbuntu wrote: >> in general, what are things i would want to 'watch for/guard against' >> in a file upload situation? > > This question has virtually nothing to do with Python, which means you > may not get very good answers. In contrast to "comp.super.web.expe

list parameter of a recursive function

2010-10-06 Thread TP
Hi, I have a function f that calls itself recursively. It has a list as second argument, with default argument equal to None (and not [], as indicated at: http://www.ferg.org/projects/python_gotchas.html#contents_item_6 ) This is the outline of my function: def f ( argument, some_list = None ):

Re: hashkey/digest for a complex object

2010-10-06 Thread geremy condra
On Wed, Oct 6, 2010 at 11:58 AM, kj wrote: > > > The short version of this question is: where can I find the algorithm > used by the tuple class's __hash__ method? >From Objects/tuple.c, line 315 in Python3.2: static long tuplehash(PyTupleObject *v) { register long x, y; register Py_ssiz

Re: hashkey/digest for a complex object

2010-10-06 Thread Diez B. Roggisch
kj writes: > The short version of this question is: where can I find the algorithm > used by the tuple class's __hash__ method? Surprisingly, in the source: http://google.com/codesearch/p?hl=de#-2BKs-LW4I0/trunk/python/src/Objects/tupleobject.c&q=python%20tuplehash&sa=N&cd=1&ct=rc > Now, for t

Re: hashkey/digest for a complex object

2010-10-06 Thread Robert Kern
On 10/6/10 1:58 PM, kj wrote: The short version of this question is: where can I find the algorithm used by the tuple class's __hash__ method? The function tuplehash() in Objects/tupleobject.c, predictably enough. Now, for the long version of this question, I'm working with some complext Pyt

Re: suggestions please "what should i watch for/guard against' in a file upload situation?"

2010-10-06 Thread Martin Gregorie
On Wed, 06 Oct 2010 09:02:21 -0700, geekbuntu wrote: > in general, what are things i would want to 'watch for/guard against' in > a file upload situation? > > i have my file upload working (in the self-made framework @ work without > any concession for multipart form uploads), but was told to mak

Re: list parameter of a recursive function

2010-10-06 Thread Chris Torek
In article TP wrote: >I have a function f that calls itself recursively. It has a list as second >argument, with default argument equal to None (and not [], as indicated at: >http://www.ferg.org/projects/python_gotchas.html#contents_item_6 ) > >This is the outline of my function: > >def f ( arg

Re: "Strong typing vs. strong testing"

2010-10-06 Thread RG
In article <1a172248-8aab-42f0-a8a2-3f00168f9...@u13g2000vbo.googlegroups.com>, Keith H Duggar wrote: > On Sep 29, 9:01 pm, RG wrote: > > That the problem is "elsewhere in the program" ought to be small > > comfort.  But very well, try this instead: > > > > [...@mighty:~]$ cat foo.c > > #inclu

Re: list parameter of a recursive function

2010-10-06 Thread TP
Chris Torek wrote: >>import copy from copy > > [from copy import copy, rather] Yes, sorry. > Note that if f() is *supposed* to be able to modify its second > parameter under some conditions, you would want to make the copy > not at the top of f() but rather further in, and in this case, > that

Re: help!!!

2010-10-06 Thread Seebs
On 2010-10-06, Diez B. Roggisch wrote: > writes: >> plz can u convert this cpp file into python i need that badly as soon as >> possible... I am new to python. I just wanna learn it > For such an aspiring student of the art of computer programming, I have > the strange feeling of lack-of-eff

Re: suggestions please "what should i watch for/guard against' in a file upload situation?"

2010-10-06 Thread Seebs
On 2010-10-06, Diez B. Roggisch wrote: > Seebs writes: >> On 2010-10-06, geekbuntu wrote: >>> in general, what are things i would want to 'watch for/guard against' >>> in a file upload situation? >> This question has virtually nothing to do with Python, which means you >> may not get very good

Re: help!!!

2010-10-06 Thread Steven D'Aprano
On Tue, 05 Oct 2010 23:54:00 -0400, fkrafi wrote: > plz can u convert this cpp file into python i need that badly as soon as > possible... I am new to python. I just wanna learn it Good grief. It's bad enough to expect us to do your coding for you, without making even the *tiniest* effort to

Re: list parameter of a recursive function

2010-10-06 Thread Diez B. Roggisch
TP writes: > Hi, > > I have a function f that calls itself recursively. It has a list as second > argument, with default argument equal to None (and not [], as indicated at: > http://www.ferg.org/projects/python_gotchas.html#contents_item_6 ) > > This is the outline of my function: > > def f ( a

Re: suggestions please "what should i watch for/guard against' in a file upload situation?"

2010-10-06 Thread Steven D'Aprano
On Wed, 06 Oct 2010 09:02:21 -0700, geekbuntu wrote: > in general, what are things i would want to 'watch for/guard against' in > a file upload situation? > > i have my file upload working (in the self-made framework @ work without > any concession for multipart form uploads), but was told to mak

Re: list parameter of a recursive function

2010-10-06 Thread Steven D'Aprano
On Wed, 06 Oct 2010 23:00:10 +0200, TP wrote: > I think I prefer doing an explicit copy.copy, because it allows to > remind the reader that it is very important to take care of that. I think a comment is better for that. It's better to explicitly say something is important than to assume the re

Re: suggestions please "what should i watch for/guard against' in a file upload situation?"

2010-10-06 Thread Diez B. Roggisch
Seebs writes: > On 2010-10-06, Diez B. Roggisch wrote: >> Seebs writes: >>> On 2010-10-06, geekbuntu wrote: in general, what are things i would want to 'watch for/guard against' in a file upload situation? > >>> This question has virtually nothing to do with Python, which means you >

mantissa and exponent in base 10

2010-10-06 Thread Steven D'Aprano
I want the mantissa and decimal exponent of a float, in base 10: mantissa and exponent of 1.2345e7 => (1.2345, 7) (0.12345, 8) would also be acceptable. The math module has a frexp() function, but it produces a base-2 exponent: >>> math.frexp(1.2345e7) (0.73581933975219727, 24) Have I missed

Re: suggestions please "what should i watch for/guard against' in a file upload situation?"

2010-10-06 Thread Diez B. Roggisch
Martin Gregorie writes: > On Wed, 06 Oct 2010 09:02:21 -0700, geekbuntu wrote: > >> in general, what are things i would want to 'watch for/guard against' in >> a file upload situation? >> >> i have my file upload working (in the self-made framework @ work without >> any concession for multipart

Re: help!!!

2010-10-06 Thread Diez B. Roggisch
Seebs writes: > On 2010-10-06, Diez B. Roggisch wrote: >> writes: >>> plz can u convert this cpp file into python i need that badly as soon as >>> possible... I am new to python. I just wanna learn it > >> For such an aspiring student of the art of computer programming, I have >> the strang

Re: if the else short form

2010-10-06 Thread Lawrence D'Oliveiro
In message , BartC wrote: > I use this syntax where there are two possibilities chosen according to > condition 'a': > > (a | b | c) Algol 68! > x = ("One","Two","Three") [i-1] > > While this works for i = 1,2,3, it goes funny for i=0,-1,-2, and generates > an error for the rest ... x = {1 :

Re: [Python-ideas] [Python-Dev] Inclusive Range

2010-10-06 Thread Lawrence D'Oliveiro
In message , Antoon Pardon wrote: > Or what if the keys were floats or tuples and I wanted an > inclusive upper boundary? If you’re expecting computer floats to behave as mathematically exact quantities, you’re asking for trouble. -- http://mail.python.org/mailman/listinfo/python-list

Re: help!!!

2010-10-06 Thread Seebs
On 2010-10-06, Diez B. Roggisch wrote: > With an impressive amount of technological experience under his belt. So > I'm a bit aghast to see him struggle with this rather simple > problem. Thus my question... It does seem a bit odd. I mean, if I had a short time line to get something converted to

Re: help!!!

2010-10-06 Thread Diez B. Roggisch
Seebs writes: > On 2010-10-06, Diez B. Roggisch wrote: >> With an impressive amount of technological experience under his belt. So >> I'm a bit aghast to see him struggle with this rather simple >> problem. Thus my question... > > It does seem a bit odd. > > I mean, if I had a short time line to

Re: help!!!

2010-10-06 Thread Seebs
On 2010-10-06, Diez B. Roggisch wrote: > From the look of it... he's just trying to get a freebie on a homework > assignment. It certainly is no commercial/useful piece of code > whatsoever... just CS-101 "read data from stdin and do stuff". Ooh, I should go help, then. I *love* to help people o

Re: help!!!

2010-10-06 Thread Grant Edwards
On 2010-10-06, Steven D'Aprano wrote: > On Tue, 05 Oct 2010 23:54:00 -0400, fkrafi wrote: > >> plz can u convert this cpp file into python i need that badly as soon as >> possible... I am new to python. I just wanna learn it > > Good grief. It's bad enough to expect us to do your coding for yo

Re: if the else short form

2010-10-06 Thread BartC
"Lawrence D'Oliveiro" wrote in message news:i8j0dg$lh...@lust.ihug.co.nz... In message , BartC wrote: x = ("One","Two","Three") [i-1] While this works for i = 1,2,3, it goes funny for i=0,-1,-2, and generates an error for the rest ... x = {1 : "One", 2 : "Two", 3 : "Three"}.get(i, "No

Re: if the else short form

2010-10-06 Thread Mel
BartC wrote: > > > "Lawrence D'Oliveiro" wrote in message > news:i8j0dg$lh...@lust.ihug.co.nz... >> In message , BartC wrote: > >>> x = ("One","Two","Three") [i-1] >>> >>> While this works for i = 1,2,3, it goes funny for i=0,-1,-2, and >>> generates >>> an error for the rest ... >> >> x = {1

Re: if the else short form

2010-10-06 Thread Steven D'Aprano
On Thu, 07 Oct 2010 01:36:33 +0100, BartC wrote: > However, as I mentioned, one problem here is having to evaluate all the > items in the list before selecting one: > > def fna(): > print "FNA CALLED" > return "One" > def fnb(): > print "FNB CALLED" > return "Two

Re: "Strong typing vs. strong testing"

2010-10-06 Thread Pascal J. Bourguignon
Keith H Duggar writes: > On Sep 29, 9:01 pm, RG wrote: >> That the problem is "elsewhere in the program" ought to be small >> comfort.  But very well, try this instead: >> >> [...@mighty:~]$ cat foo.c >> #include >> >> int maximum(int a, int b) { return a > b ? a : b; } >> >> int main() { >>  

Re: help!!!

2010-10-06 Thread Seebs
On 2010-10-06, wrote: > plz can u convert this cpp file into python i need that badly as soon as > possible... I am new to python. I just wanna learn it Having come to realize that this is a homework problem, I would of course be glad to. The original program: #include int

Re: help!!!

2010-10-06 Thread John Nagle
On 10/6/2010 8:02 PM, Seebs wrote: On 2010-10-06,wrote: plz can u convert this cpp file into python i need that badly as soon as possible... I am new to python. I just wanna learn it Having come to realize that this is a homework problem, I would of course be glad to. The original pro

Re: help!!!

2010-10-06 Thread Seebs
On 2010-10-07, John Nagle wrote: > First, "scanf" was deprecated over five years ago. It was? I mean, people have been telling me not to use it since the 80s, but I wasn't aware that it had been deprecated, except in the sense of being derided and dismissed as of no value. -s -- Copyright

Re: list parameter of a recursive function

2010-10-06 Thread TP
Diez B. Roggisch wrote: > Back to your example: your solution is perfectly fine, although a bit > costly and more error-prone if you happen to forget to create a copy. > A safer alternative for these cases is using tuples, because they are > immutable. Thanks Diez for your explanation. The proble

Re: list parameter of a recursive function

2010-10-06 Thread TP
Steven D'Aprano wrote: >> I think I prefer doing an explicit copy.copy, because it allows to >> remind the reader that it is very important to take care of that. > > I think a comment is better for that. It's better to explicitly say > something is important than to assume the reader will guess.

Re: suggestions please "what should i watch for/guard against' in a file upload situation?"

2010-10-06 Thread Lawrence D'Oliveiro
In message <2ce3860b-ae21-48ae-9abc-cb169a6f1...@e20g2000vbn.googlegroups.com>, geekbuntu wrote: > in general, what are things i would want to 'watch for/guard against' > in a file upload situation? If you stored the file contents as a blob in a database field, you wouldn’t have to worry about

Re: Help with sets

2010-10-06 Thread Lawrence D'Oliveiro
In message <87bp79qdhk@rudin.co.uk>, Paul Rudin wrote: > Certainly you can model a set as a dictionary, but that's likely to be > less efficient than using a set, and quite possibly you'll need to roll > your own operations on your sets, whereas they're provided for the built > in implementati

Re: Simple database explorer

2010-10-06 Thread Lawrence D'Oliveiro
In message <21c99273-ed58-4f93-b98a-d9292de5d...@k10g2000yqa.googlegroups.com>, dusans wrote: > - all the others having ODBC drivers... ODBC seems to be something you use when you can’t use a proper database driver. -- http://mail.python.org/mailman/listinfo/python-list

Re: list parameter of a recursive function

2010-10-06 Thread Seebs
On 2010-10-07, TP wrote: > Diez B. Roggisch wrote: >> A safer alternative for these cases is using tuples, because they are >> immutable. > The problem with tuples is that it is not easy to modify them: This is probably the best post-and-response I've seen in the last couple of months. -s -- C

Re: mantissa and exponent in base 10

2010-10-06 Thread Ulrich Eckhardt
Steven D'Aprano wrote: > I want the mantissa and decimal exponent of a float, in base 10: > > mantissa and exponent of 1.2345e7 > => (1.2345, 7) > > (0.12345, 8) would also be acceptable. [...] > Have I missed a built-in or math function somewhere? The integral, decimal exponent is just the floo