How to use logging

2014-02-16 Thread kumar
Hi folks, i'm new to python i understood the logging mechanism but unable to understand how these are applied in real time examples can any body help me out -- https://mail.python.org/mailman/listinfo/python-list

Re: select(sock) indicates not-ready, but sock.recv does not block

2014-02-16 Thread Chris Angelico
On Mon, Feb 17, 2014 at 5:35 PM, Nikolaus Rath wrote: > Hello, > > I have a problem with using select. I can reliably reproduce a situation ... Can you reproduce it with a reasonably short amount of code? If so, please post it. > I'm running Python 3.3.3 under Linux 3.12. Do you mean Linux kern

Re: Explanation of list reference

2014-02-16 Thread Chris Angelico
On Mon, Feb 17, 2014 at 5:21 PM, Steven D'Aprano wrote: > So before you ask: for-loops aren't things (values). Neither are while- > loops, try...except blocks, pass statements, del statements, etc. Nor are > names and other references -- I believe that there is a practice in > certain areas of com

select(sock) indicates not-ready, but sock.recv does not block

2014-02-16 Thread Nikolaus Rath
Hello, I have a problem with using select. I can reliably reproduce a situation where select.select((sock.fileno(),), (), (), 0) returns ((),(),()) (i.e., no data ready for reading), but an immediately following sock.recv() returns data without blocking. I am pretty sure that this is not a race c

Re: Explanation of list reference

2014-02-16 Thread Steven D'Aprano
On Sun, 16 Feb 2014 18:43:15 -0500, Roy Smith wrote: > In article , > Ben Finney wrote: > >> Gregory Ewing writes: >> >> > Chris Angelico wrote: >> > > Because everything in Python is an object, and objects always are >> > > handled by their references. >> > >> > So, we have objects... and w

Re: Explanation of list reference

2014-02-16 Thread Steven D'Aprano
On Mon, 17 Feb 2014 11:54:45 +1300, Gregory Ewing wrote: > Chris Angelico wrote: >> Because everything in Python is an object, and objects always are >> handled by their references. > > So, we have objects... and we have references to > objects... but everything is an object... so does that mean

Python version problem for rpm

2014-02-16 Thread anju tiwari
Hi all, I have two version of python 2.4 and 2.7. By default python version is 2.4 . I want to install need to install some rpm which needs python 2.7 interpreter. how can I enable 2.7 interpreter for only those packages which are requiring python 2.7, I don't want to change my default python ver

Re: Explanation of list reference

2014-02-16 Thread Steven D'Aprano
On Mon, 17 Feb 2014 11:40:57 +1300, Gregory Ewing wrote: > Steven D'Aprano wrote: >> And indeed numpy arrays do share state. Why? No idea. Somebody thought >> that it was a good idea. (Not me though...) > > Probably because they're often large and people don't want to incur the > overhead of copy

Re: Explanation of list reference

2014-02-16 Thread Steven D'Aprano
On Sun, 16 Feb 2014 20:01:46 +0200, Marko Rauhamaa wrote: > As far as "x is None" is concerned, a key piece of information is > presented on http://docs.python.org/3.2/library/constants.html>: > > None > The sole value of the type NoneType. Sole, adj. "being the only one; si

Re: Explanation of list reference

2014-02-16 Thread Rustom Mody
On Monday, February 17, 2014 8:58:23 AM UTC+5:30, Roy Smith wrote: > Chris Angelico wrote: > > > The correct statement is "all values are objects", or "all data is > > > objects". > > > When people mistakenly say "everything is an object", they are implicitly > > > only thinking about data. > >

Re: Explanation of list reference

2014-02-16 Thread Ben Finney
Roy Smith writes: > Chris Angelico wrote: > > Part of the trouble is that some code is (represented by) objects. A > > function is an object, ergo it's data; a module is an object (though > > that's different); a class is an object; but no other block of code > > is. > > Lambda? The ‘lambda’ s

Re: Explanation of list reference

2014-02-16 Thread Roy Smith
In article , Chris Angelico wrote: > On Mon, Feb 17, 2014 at 12:43 PM, Ned Batchelder > wrote: > > The correct statement is "all values are objects", or "all data is > > objects". > > When people mistakenly say "everything is an object", they are implicitly > > only thinking about data. > > >

Re: Possibly better stringobject allocator

2014-02-16 Thread anish198519851985
On Saturday, February 8, 1997 12:00:00 AM UTC-8, Guido van Rossum wrote: > > I installed modified versions of stringobject.c and stropmodule.c on our web > > server. They are accessible via > > > > http://www.automatrix.com/~skip/python/ > > Cool. I read your description and am very pleased

Re: How to answer questions from newbies

2014-02-16 Thread Chris Angelico
On Mon, Feb 17, 2014 at 12:46 PM, Ben Finney wrote: > Rustom Mody writes: > >> On Sunday, February 16, 2014 9:44:00 PM UTC+5:30, Roy Smith wrote: >> > Moi? >> >> See thats the problem with re's -- just 3 letters and completely >> incomprehensible! > > Actually, that's a regexp pattern that matche

Re: Explanation of list reference

2014-02-16 Thread Chris Angelico
On Mon, Feb 17, 2014 at 12:43 PM, Ned Batchelder wrote: > The correct statement is "all values are objects", or "all data is objects". > When people mistakenly say "everything is an object", they are implicitly > only thinking about data. > > That said, "all data is objects" is really mostly usefu

Re: How to answer questions from newbies

2014-02-16 Thread Ben Finney
Rustom Mody writes: > On Sunday, February 16, 2014 9:44:00 PM UTC+5:30, Roy Smith wrote: > > Moi? > > See thats the problem with re's -- just 3 letters and completely > incomprehensible! Actually, that's a regexp pattern that matches two *or* three letters. -- \ “If nature has made an

Re: Explanation of list reference

2014-02-16 Thread Ned Batchelder
On 2/16/14 5:54 PM, Gregory Ewing wrote: Chris Angelico wrote: Because everything in Python is an object, and objects always are handled by their references. So, we have objects... and we have references to objects... but everything is an object... so does that mean references are objects too

Re: How to answer questions from newbies

2014-02-16 Thread Rustom Mody
On Sunday, February 16, 2014 9:44:00 PM UTC+5:30, Roy Smith wrote: > Moi? See thats the problem with re's -- just 3 letters and completely incomprehensible! It even resembles our resident unicode-troll Oui? -- https://mail.python.org/mailman/listinfo/python-list

Re: Explanation of list reference

2014-02-16 Thread Chris Angelico
On Mon, Feb 17, 2014 at 10:46 AM, Roy Smith wrote: >> References aren't themselves objects. Names, attributes, etc, etc, >> etc, all refer to objects. Is it clearer to use the verb "refer" >> rather than the noun "reference"? >> >> ChrisA > > I know functions are objects, but what about statements

Re: Explanation of list reference

2014-02-16 Thread Ben Finney
Roy Smith writes: > In article , > Ben Finney wrote: > > > Gregory Ewing writes: > > > So, we have objects... and we have references > > > to objects... but everything is an object... so does that mean > > > references are objects too? > > > > My response: No, because references are not thi

Re: Explanation of list reference

2014-02-16 Thread Roy Smith
In article , Chris Angelico wrote: > On Mon, Feb 17, 2014 at 9:54 AM, Gregory Ewing > wrote: > > Chris Angelico wrote: > >> > >> Because everything in Python is an object, and objects always are > >> handled by their references. > > > > > > So, we have objects... and we have > > references to

Re: Explanation of list reference

2014-02-16 Thread Roy Smith
In article , Ben Finney wrote: > Gregory Ewing writes: > > > Chris Angelico wrote: > > > Because everything in Python is an object, and objects always are > > > handled by their references. > > > > So, we have objects... and we have > > references to objects... but everything is an object...

Re: Explanation of list reference

2014-02-16 Thread Ben Finney
Gregory Ewing writes: > Chris Angelico wrote: > > Because everything in Python is an object, and objects always are > > handled by their references. > > So, we have objects... and we have > references to objects... but everything is an object... > so does that mean references are objects too? >

Re: Explanation of list reference

2014-02-16 Thread Chris Angelico
On Mon, Feb 17, 2014 at 9:54 AM, Gregory Ewing wrote: > Chris Angelico wrote: >> >> Because everything in Python is an object, and objects always are >> handled by their references. > > > So, we have objects... and we have > references to objects... but everything is an object... > so does that m

Re: Explanation of list reference

2014-02-16 Thread Gregory Ewing
Chris Angelico wrote: Because everything in Python is an object, and objects always are handled by their references. So, we have objects... and we have references to objects... but everything is an object... so does that mean references are objects too? This is the kind of trouble you get in

Re: Explanation of list reference

2014-02-16 Thread Gregory Ewing
Steven D'Aprano wrote: And indeed numpy arrays do share state. Why? No idea. Somebody thought that it was a good idea. (Not me though...) Probably because they're often large and people don't want to incur the overhead of copying them any more than necessary. So slices are defined to return vie

Re: Puzzling PDF

2014-02-16 Thread F.R.
On 02/16/2014 05:29 PM, Emile van Sebille wrote: You On 2/16/2014 6:00 AM, F.R. wrote: Hi all, Struggling to parse bank statements unavailable in sensible data-transfer formats, I use pdftotext, which solves part of the problem. The other day I encountered a strange thing, when one single figur

Re: random.sample with large weighted sample-sets? [SOLVED]

2014-02-16 Thread Tim Chase
On 2014-02-16 14:47, Terry Reedy wrote: > > 2) the data has to be sorted for bisect to work > > cumulative sums are automatically sorted. Ah, that they were *cumulative* was the key that I missed in my understanding. It makes sense now and works like a charm. Thanks to all who offered a hand

Re: random.sample with large weighted sample-sets?

2014-02-16 Thread Terry Reedy
On 2/16/2014 9:22 AM, Tim Chase wrote: On 2014-02-16 04:12, Terry Reedy wrote: On 2/15/2014 11:41 PM, Tim Chase wrote: data = ( ("apple", 20), ("orange", 50), ("grape", 30), ) If you actually start with date in this form, write the few lines needed to produce the

Re: Explanation of list reference

2014-02-16 Thread Alister
On Sat, 15 Feb 2014 10:44:39 +0100, Christian Gollwitzer wrote: > Am 15.02.14 01:57, schrieb Chris Angelico: >> Can you give an example of an ambiguous case? Fundamentally, the 'is' >> operator tells you whether its two operands are exactly the same >> object, nothing more and nothing less, so I a

Re: Puzzling PDF

2014-02-16 Thread Alister
On Sun, 16 Feb 2014 10:33:39 -0500, Roy Smith wrote: > In article , > "F.R." wrote: > >> Hi all, >> >> Struggling to parse bank statements unavailable in sensible >> data-transfer formats, I use pdftotext, which solves part of the >> problem. The other day I encountered a strange thing, when o

Re: Explanation of list reference

2014-02-16 Thread Mark Lawrence
On 16/02/2014 18:01, Marko Rauhamaa wrote: Rustom Mody : But for that Ive to use is And as a teacher Ive to explain is Might as well use C and get on with pointers To me 'is' is a can of worms I'm not against "is," but it must be carefully defined and taught. As far as "x is None" is concer

Re: Explanation of list reference

2014-02-16 Thread Marko Rauhamaa
Rustom Mody : > But for that Ive to use is > And as a teacher Ive to explain is > Might as well use C and get on with pointers > > To me 'is' is a can of worms I'm not against "is," but it must be carefully defined and taught. As far as "x is None" is concerned, a key piece of information is pre

Re: random.sample with large weighted sample-sets?

2014-02-16 Thread duncan smith
On 16/02/14 16:35, Charles Allen wrote: How efficient does this thing need to be? You can always just turn it into a two-dimensional sampling problem by thinking of the data as a function f(x=item), generating a random x=xr in [0,x], then generating a random y in [0,max(f(x))]. The xr is accept

Re: Explanation of list reference

2014-02-16 Thread Rustom Mody
On Sunday, February 16, 2014 9:59:53 PM UTC+5:30, Ned Batchelder wrote: > On 2/16/14 9:00 AM, Rustom Mody wrote: > > On Saturday, February 15, 2014 7:14:39 PM UTC+5:30, Marko Rauhamaa wrote: > >> Mark Lawrence: > >>> I have no interest in understanding object identity, I can write code > >>> quite

Re: random.sample with large weighted sample-sets?

2014-02-16 Thread Charles Allen
How efficient does this thing need to be? You can always just turn it into a two-dimensional sampling problem by thinking of the data as a function f(x=item), generating a random x=xr in [0,x], then generating a random y in [0,max(f(x))]. The xr is accepted if 0 < y <= max(f(xr)), or rejected (an

Re: Explanation of list reference

2014-02-16 Thread Ned Batchelder
On 2/16/14 9:00 AM, Rustom Mody wrote: On Saturday, February 15, 2014 7:14:39 PM UTC+5:30, Marko Rauhamaa wrote: Mark Lawrence: I have no interest in understanding object identity, I can write code quite happily without it. Luckily, what we are now debating is mostly terminology and points

Re: Puzzling PDF

2014-02-16 Thread Emile van Sebille
You On 2/16/2014 6:00 AM, F.R. wrote: Hi all, Struggling to parse bank statements unavailable in sensible data-transfer formats, I use pdftotext, which solves part of the problem. The other day I encountered a strange thing, when one single figure out of many erroneously converted into letters.

Re: Explanation of list reference

2014-02-16 Thread Marko Rauhamaa
Steven D'Aprano : > On Sun, 16 Feb 2014 12:52:58 +0200, Marko Rauhamaa wrote: >> The syntactic awkwardness, then, explains why numbers don't have an >> evolved set of methods (unlike strings). > > But numbers do have an evolved set of methods. > [...] > py> from decimal import Decimal > py> [name

Re: How to answer questions from newbies

2014-02-16 Thread Roy Smith
In article , Rustom Mody wrote: > On Sunday, February 16, 2014 8:53:47 PM UTC+5:30, Roy Smith wrote: > > We get a lot of newbie questions on this list. People are eager to jump > > in and answer them (which is wonderful), but sometimes we get off on > > tangents about trivia and lose sight of

Re: random.sample with large weighted sample-sets?

2014-02-16 Thread Peter Otten
Tim Chase wrote: > On 2014-02-16 04:12, Terry Reedy wrote: >> On 2/15/2014 11:41 PM, Tim Chase wrote: >> >data = ( >> > ("apple", 20), >> > ("orange", 50), >> > ("grape", 30), >> > ) > > To Ben, yes, this was just some sample data; the original gets built > from an externa

Re: random.sample with large weighted sample-sets?

2014-02-16 Thread duncan smith
On 16/02/14 05:08, Ben Finney wrote: Tim Chase writes: I'm not coming up with the right keywords to find what I'm hunting. I'd like to randomly sample a modestly compact list with weighted distributions, so I might have data = ( ("apple", 20), ("orange", 50), ("grape", 30),

Re: How to answer questions from newbies

2014-02-16 Thread Rustom Mody
On Sunday, February 16, 2014 8:53:47 PM UTC+5:30, Roy Smith wrote: > We get a lot of newbie questions on this list. People are eager to jump > in and answer them (which is wonderful), but sometimes we get off on > tangents about trivia and lose sight of the real question, and our > audience. >

Re: How to turn a package into something pip can install

2014-02-16 Thread Mark Lawrence
On 16/02/2014 15:20, MRAB wrote: On 2014-02-16 15:06, Mark Lawrence wrote: On 16/02/2014 14:25, Roy Smith wrote: We tend not to upgrade stuff unless there's a good reason to. You never know what will break (looking furtively in the direction of the Python 3.x mafiosi). Yeah, those really u

Re: Puzzling PDF

2014-02-16 Thread Roy Smith
In article , "F.R." wrote: > Hi all, > > Struggling to parse bank statements unavailable in sensible > data-transfer formats, I use pdftotext, which solves part of the > problem. The other day I encountered a strange thing, when one single > figure out of many erroneously converted into lett

How to answer questions from newbies

2014-02-16 Thread Roy Smith
We get a lot of newbie questions on this list. People are eager to jump in and answer them (which is wonderful), but sometimes we get off on tangents about trivia and lose sight of the real question, and our audience. The particular one that set me off just now (I'm leaving off the names beca

Re: How to turn a package into something pip can install

2014-02-16 Thread MRAB
On 2014-02-16 15:06, Mark Lawrence wrote: On 16/02/2014 14:25, Roy Smith wrote: We tend not to upgrade stuff unless there's a good reason to. You never know what will break (looking furtively in the direction of the Python 3.x mafiosi). Yeah, those really unpleasant, nasty, horrible mafiosi

Re: Can one use Python to learn and even apply Functional Programming?

2014-02-16 Thread Ryan
Python*can* do functional programming, but, for learning, Haskell will work better. Sam wrote: >I would like to learn and try out functional programming (FP). I love >Python and would like to use it to try FP. Some have advised me to use >Haskell instead because Python is not a good language for

Re: How to turn a package into something pip can install

2014-02-16 Thread Mark Lawrence
On 16/02/2014 14:25, Roy Smith wrote: We tend not to upgrade stuff unless there's a good reason to. You never know what will break (looking furtively in the direction of the Python 3.x mafiosi). Yeah, those really unpleasant, nasty, horrible mafiosi who have the audacity to point out that p

Re: Problem importing libraries installed with PIP in Eclipse

2014-02-16 Thread Renato
It's solved now, oh my god I was so stupid! I created a package named "pybrain" for testing PyBrain module, so obviously when I tryed to import something from PyBrain library, Python would import all modules from this personal package I created. The problem was not being reproduced outside Eclip

Re: random.sample with large weighted sample-sets?

2014-02-16 Thread Ned Batchelder
On 2/16/14 9:22 AM, Tim Chase wrote: 3) you meant to write "(10, 'apple')" rather than 0. With my original example code, a 0-probability shouldn't ever show up in the sampling, where it looks like it might when using this sample code. In my particular use case, I can limit/ensure that 0-probabil

Re: How to turn a package into something pip can install

2014-02-16 Thread Roy Smith
In article , Chris Angelico wrote: > On Sun, Feb 16, 2014 at 11:18 PM, Chris “Kwpolska” Warrick > wrote: > > On Sat, Feb 15, 2014 at 11:35 PM, Roy Smith wrote: > >> Maybe this is something which has changed in newer versions of pip? > >> I've got 1.1 (and python 2.7.3). I'm pretty sure bo

Re: random.sample with large weighted sample-sets?

2014-02-16 Thread Tim Chase
On 2014-02-16 04:12, Terry Reedy wrote: > On 2/15/2014 11:41 PM, Tim Chase wrote: > >data = ( > > ("apple", 20), > > ("orange", 50), > > ("grape", 30), > > ) To Ben, yes, this was just some sample data; the original gets built from an external (i.e., client-supplied, thus t

Re: Explanation of list reference

2014-02-16 Thread Rustom Mody
On Saturday, February 15, 2014 7:14:39 PM UTC+5:30, Marko Rauhamaa wrote: > Mark Lawrence: > > I have no interest in understanding object identity, I can write code > > quite happily without it. > Luckily, what we are now debating is mostly terminology and points of > view where the outcomes are

Puzzling PDF

2014-02-16 Thread F.R.
Hi all, Struggling to parse bank statements unavailable in sensible data-transfer formats, I use pdftotext, which solves part of the problem. The other day I encountered a strange thing, when one single figure out of many erroneously converted into letters. Adobe Reader displays the figure 50

Re: Can one use Python to learn and even apply Functional Programming?

2014-02-16 Thread Rustom Mody
On Sunday, February 16, 2014 10:15:58 AM UTC+5:30, Sam wrote: > I would like to learn and try out functional programming (FP). I love Python > and would like to use it to try FP. Some have advised me to use Haskell > instead because Python is not a good language for FP. I am sort of confused > a

Re: Can one use Python to learn and even apply Functional Programming?

2014-02-16 Thread Chris Angelico
On Mon, Feb 17, 2014 at 12:20 AM, Mark Lawrence wrote: > On 16/02/2014 08:00, Pat Johnson wrote: >> >> This made me grin. ;) >> > > What did, using google groups? :) "Well! I've often seen context without a grin," thought Alice; "but a grin without context! It's the most curious thing I ever saw

Re: inheriting a large python code base

2014-02-16 Thread Chris Angelico
On Sun, Feb 16, 2014 at 11:59 PM, Rita wrote: > when I do profiling is it possible to find out if I am spending a lot of > time in type conversion? > it seems I am not. I would guess that you don't. But in Python, type conversion is like any other function call: value = int("12345") So you can

Re: How to turn a package into something pip can install

2014-02-16 Thread Chris Angelico
On Sun, Feb 16, 2014 at 11:18 PM, Chris “Kwpolska” Warrick wrote: > On Sat, Feb 15, 2014 at 11:35 PM, Roy Smith wrote: >> Maybe this is something which has changed in newer versions of pip? >> I've got 1.1 (and python 2.7.3). I'm pretty sure both of these are what >> came with Ubuntu Precise. >

Re: Can one use Python to learn and even apply Functional Programming?

2014-02-16 Thread Mark Lawrence
On 16/02/2014 08:00, Pat Johnson wrote: This made me grin. ;) What did, using google groups? :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus

Re: Problem importing libraries installed with PIP in Eclipse

2014-02-16 Thread Renato
Em sexta-feira, 14 de fevereiro de 2014 01h30min05s UTC-2, Renato escreveu: > Hi guys, I'm using Python 2.7.5 64 bits and I have a problem when importing > libraries that were installed via PIP when importing them inside Eclipse > (version 4.3.1). Outside Eclipse (directly in Python's shell) eve

Re: inheriting a large python code base

2014-02-16 Thread Rita
when I do profiling is it possible to find out if I am spending a lot of time in type conversion? it seems I am not. Also, is it possible to predeclare a type in python? Similar to C: int i=0; On Sat, Feb 15, 2014 at 10:06 PM, Rustom Mody wrote: > On Sunday, February 16, 2014 4:45:04 AM UTC+5

Re: decimal numbers

2014-02-16 Thread wxjmfauth
Without any warranty. >>> def z(r): ... # r: int > 0 ... t = log10(r) ... if t >= 12.0: ... prefix = '' ... prefix2 = '' ... elif t >= 9.0: ... prefix = 'giga' ... prefix2 = 'G' ... r = r / 1.0e9 ... elif t >= 6.0: ... prefix = 'm

Re: How to turn a package into something pip can install

2014-02-16 Thread Chris “Kwpolska” Warrick
On Sat, Feb 15, 2014 at 11:35 PM, Roy Smith wrote: > In article , > Roy Smith wrote: > >> > > $ pip install --no-index --quiet --find-links packages metar==1.4.0 >> > [snip] >> > > ValueError: unknown url type: packages >> > >> > The path to your cache directory is incorrect. I suggest using >>

Re: Explanation of list reference

2014-02-16 Thread Steven D'Aprano
On Sun, 16 Feb 2014 12:52:58 +0200, Marko Rauhamaa wrote: > Ian Kelly : > > (1).__str__() >> '1' > > Fair enough. > > The syntactic awkwardness, then, explains why numbers don't have an > evolved set of methods (unlike strings). But numbers do have an evolved set of methods. py> [name fo

Re: Explanation of list reference

2014-02-16 Thread Chris Angelico
On Sun, Feb 16, 2014 at 9:52 PM, Marko Rauhamaa wrote: > Ian Kelly : > > (1).__str__() >> '1' > > Fair enough. > > The syntactic awkwardness, then, explains why numbers don't have an > evolved set of methods (unlike strings). No; it's more that numbers are more often used with either operator

Re: Explanation of list reference

2014-02-16 Thread Marko Rauhamaa
Steven D'Aprano : > On Sat, 15 Feb 2014 23:01:53 +0200, Marko Rauhamaa wrote: > I demonstrated a situation where your claim: > > id(x) == id(y) implies x is y > > fails. My from-the-hip formulation can obviously be inaccurate, but I was hoping the point was clear. The Python language specifi

Re: Explanation of list reference

2014-02-16 Thread Marko Rauhamaa
Ian Kelly : (1).__str__() > '1' Fair enough. The syntactic awkwardness, then, explains why numbers don't have an evolved set of methods (unlike strings). Marko -- https://mail.python.org/mailman/listinfo/python-list

Re: Explanation of list reference

2014-02-16 Thread Chris Angelico
On Sun, Feb 16, 2014 at 7:40 PM, Steven D'Aprano wrote: > There are three simple ways to get the effect that you want: > > py> x = 1; x.__str__() # don't use a literal > '1' > py> (1).__str__() # parenthesize the literal > '1' > py> 1 .__str__() # offset it from the dot with a space > '1' Four

Re: random.sample with large weighted sample-sets?

2014-02-16 Thread Terry Reedy
On 2/15/2014 11:41 PM, Tim Chase wrote: I'm not coming up with the right keywords to find what I'm hunting. I'd like to randomly sample a modestly compact list with weighted distributions, so I might have data = ( ("apple", 20), ("orange", 50), ("grape", 30), ) If you ac

Re: Explanation of list reference

2014-02-16 Thread Steven D'Aprano
On Sun, 16 Feb 2014 10:08:22 +0200, Marko Rauhamaa wrote: > Case in point, if everything is a reference, how come: > >>>> "hello".__str__() >'hello' >>>> 1.__str__() >SyntaxError: invalid syntax Because it is a syntax error, just like the parser tells you. When the parser sees "

Re: Can one use Python to learn and even apply Functional Programming?

2014-02-16 Thread Terry Reedy
On 2/16/2014 1:38 AM, Devin Jeanpierre wrote: On Sat, Feb 15, 2014 at 8:45 PM, Sam wrote: I would like to learn and try out functional programming (FP). I love Python and would like to use it to try FP. Some have advised me to use Haskell instead because Python is not a good language for FP.

Re: Explanation of list reference

2014-02-16 Thread Alan Bawden
Marko Rauhamaa writes: > Case in point, if everything is a reference, how come: > >>>> "hello".__str__() >'hello' >>>> 1.__str__() >SyntaxError: invalid syntax >>> (1).__str__() '1' >>> 1..__str__() '1.0' -- Alan Bawden -- https://mail.python.org/mailman/listinfo/

Re: Explanation of list reference

2014-02-16 Thread Jussi Piitulainen
Marko Rauhamaa writes: > Marko Rauhamaa : > > > Conceptually, the "everything is a reference" and the "small"/"big" > > distinction are equivalent (produce the same outcomes). The question > > is, which model is easier for a beginner to grasp. > > Case in point, if everything is a reference, ho

Re: Explanation of list reference

2014-02-16 Thread Ian Kelly
On Sun, Feb 16, 2014 at 1:28 AM, Ian Kelly wrote: > > On Feb 16, 2014 1:11 AM, "Marko Rauhamaa" wrote: >> Case in point, if everything is a reference, how come: >> >>>>> "hello".__str__() >>'hello' >>>>> 1.__str__() >>SyntaxError: invalid syntax > > You need parentheses around the

Re: Explanation of list reference

2014-02-16 Thread Ian Kelly
On Feb 16, 2014 1:11 AM, "Marko Rauhamaa" wrote: > > Marko Rauhamaa : > > > Conceptually, the "everything is a reference" and the "small"/"big" > > distinction are equivalent (produce the same outcomes). The question > > is, which model is easier for a beginner to grasp. > > Case in point, if ever

Re: Install python 2 and 3 in the "wrong" order

2014-02-16 Thread Nagy László Zsolt
I should emphasize that this is with the /same/ x.y version... Installing 3.3 when the previous was 3.2 won't overlay. Though I don't see anything in the ActiveState builds (which are all I've ever used) to handle the #! type selection of the desired version. Just got done updat

Re: Explanation of list reference

2014-02-16 Thread Marko Rauhamaa
Marko Rauhamaa : > Conceptually, the "everything is a reference" and the "small"/"big" > distinction are equivalent (produce the same outcomes). The question > is, which model is easier for a beginner to grasp. Case in point, if everything is a reference, how come: >>> "hello".__str__() 'h

Re: Can one use Python to learn and even apply Functional Programming?

2014-02-16 Thread Pat Johnson
This made me grin. ;) -- https://mail.python.org/mailman/listinfo/python-list