On Wed, 22 Aug 2012 23:49:17 -0500, Evan Driscoll wrote:
> On 8/22/2012 18:58, Ben Finney wrote:
>> You haven't discovered anything about types; what you have discovered
>> is that Python name bindings are not variables.
>>
>> In fact, Python doesn't have variables – not as C or Java programmers
On Wednesday, August 22, 2012 3:28:18 AM UTC-7, Kamil Kuduk wrote:
> less file.txt | sed -e "s/\b\([a-z]\{4,\}\)/\u\1/g"
Say what?
Yes, you could do a crazy regex at the Linux prompt. But... will you be able
to retain that insane syntax in your head until the NEXT time you need to write
somet
List folk,
I am a newbie trying to get used to Python. I was wondering if anyone knows of
web resources that teach good practices in data cleaning and management for
statistics/analytics/machine learning, particularly using Python.
Ideally, these would be exercises of the form: here is some hor
On 23/08/12 02:19, Walter Hurry wrote:
On Wed, 22 Aug 2012 18:46:43 +0100, lipska the kat wrote:
Well I'm a beginner
Then maybe you should read more and write less.
Really ? I read all the responses to my posts and learn more from them
in less time than I ever have from reading the 'docume
On 20.08.2012 20:34, Christian Heimes wrote:
> Am 19.08.2012 19:35, schrieb Jan Riechers:
>
> Hello Jan,
>
> we decided against ImageMagick and pgmagick for several reasons. For one
> we were already using FreeImage in other projects (Delphi projects and
> through ctypes binding with FreeImagePy)
[ Virgil Stokes wrote on Wed 22.Aug'12 at 16:34:40 +0200 ]
> On 22-Aug-2012 16:04, Steven D'Aprano wrote:
> > On Tue, 21 Aug 2012 18:36:50 -0700, Anonymous Group wrote:
> >
> >> What books do you recomend for learning python? Preferably free and/or
> >> online.
> > Completely by coincidence, I hav
On 23/08/12 05:14, Steven D'Aprano wrote:
On Thu, 23 Aug 2012 01:19:49 +, Walter Hurry wrote:
On Wed, 22 Aug 2012 18:46:43 +0100, lipska the kat wrote:
Well I'm a beginner
Then maybe you should read more and write less.
I think that's uncalled for. Lipska isn't trolling. He's making
o
Hi,
in response to a bug report I got the follow helpful comments from R. David
Murray.
Many thanks to him. (Unfortunately, I don't know his email, so I can write him
directly)
To generate an email (with non-ascii letters)
R. David Murray wrote:
>>> But even better, so will this:
>>> m = Mes
Steven D'Aprano writes:
> On Wed, 22 Aug 2012 23:49:17 -0500, Evan Driscoll wrote:
>
> > On 8/22/2012 18:58, Ben Finney wrote:
> >> You haven't discovered anything about types; what you have
> >> discovered is that Python name bindings are not variables.
> >>
> >> In fact, Python doesn't have var
Suppose I want to define a function "safe", which returns the argument passed
if there is no error, and 42 if there is one. So the setup is something like:
def safe(x):
# WHAT WOULD DEFINE HERE?
print safe(666) # prints 666
print safe(1/0) # prints 42
I don't see how such a function could be
On Thu, Aug 23, 2012 at 7:05 PM, Mark Carter wrote:
> Suppose I want to define a function "safe", which returns the argument passed
> if there is no error, and 42 if there is one. So the setup is something like:
>
> def safe(x):
># WHAT WOULD DEFINE HERE?
>
> print safe(666) # prints 666
> pr
On 22/08/12 22:31, Evan Driscoll wrote:
On 08/22/2012 02:45 PM, lipska the kat wrote:
On 22/08/12 20:03, Evan Driscoll wrote:
Second, this concept isn't *so* unfamiliar to you. If I give you the
following Java code:
void foo(Object o) { ... }
looking at this method declaration I can see
On Thursday, 23 August 2012 10:16:08 UTC+1, Chris Angelico wrote:
> On Thu, Aug 23, 2012 at 7:05 PM, Mark Carter <> wrote:
> > Suppose I want to define a function "safe", which returns the argument
> > passed if there is no error, and 42 if there is one.
> only possible with floating point, not
That can work ONLY if the division of 1/0 doesn't raise an exception.
This is why the concept of NaN exists; I'm not sure if there's a way
to tell Python to return NaN instead of bombing, but it's most likely
only possible with floating point, not integer.
For integers, Python will always raise
On 2012-08-23 11:05, Mark Carter wrote:
Suppose I want to define a function "safe", which returns the argument passed
if there is no error, and 42 if there is one. So the setup is something like:
def safe(x):
# WHAT WOULD DEFINE HERE?
print safe(666) # prints 666
print safe(1/0) # prints 4
On Thu, Aug 23, 2012 at 7:22 PM, Mark Carter wrote:
> OK, so it looks like a solution doesn't exist to the problem as specified. I
> guess it's something that only a language with macros could accommodate.
You're asking for a function to prevent the evaluation of its
arguments from throwing an e
On Thu, Aug 23, 2012 at 7:28 PM, Laszlo Nagy wrote:
>> That can work ONLY if the division of 1/0 doesn't raise an exception.
>> This is why the concept of NaN exists; I'm not sure if there's a way
>> to tell Python to return NaN instead of bombing, but it's most likely
>> only possible with floati
On Thursday, 23 August 2012 10:23:20 UTC+1, Laszlo Nagy wrote:
> On 2012-08-23 11:05, Mark Carter wrote:
> You are very vague. "There is an error" - but what kind of error?
Assume that it doesn't matter.
> In some special cases, this can be a good idea to do.
Those are the cases that I'm inte
Mark Carter wrote:
> Suppose I want to define a function "safe", which returns the argument
> passed if there is no error, and 42 if there is one. So the setup is
> something like:
>
> def safe(x):
># WHAT WOULD DEFINE HERE?
>
> print safe(666) # prints 666
> print safe(1/0) # prints 42
>
>
def safe(deferred, default=42, exception=Exception):
... try:
... return deferred()
... except exception:
... return default
What a beautiful solution! I was wondering if the following would be
possible:
def test(thing, default, *exc_classes):
try:
On 23/08/2012 12:01, Laszlo Nagy wrote:
def safe(deferred, default=42, exception=Exception):
... try:
... return deferred()
... except exception:
... return default
What a beautiful solution! I was wondering if the following would be
possible:
def test(thing
Laszlo Nagy wrote:
> def safe(deferred, default=42, exception=Exception):
>> ... try:
>> ... return deferred()
>> ... except exception:
>> ... return default
>
> What a beautiful solution! I was wondering if the following would be
> possible:
>
>
> def test(t
On 23/08/2012 09:59, Jussi Piitulainen wrote:
Steven D'Aprano writes:
On Wed, 22 Aug 2012 23:49:17 -0500, Evan Driscoll wrote:
> On 8/22/2012 18:58, Ben Finney wrote:
>> You haven't discovered anything about types; what you have
>> discovered is that Python name bindings are not variables.
>>
>
On 23/08/2012 09:30, Helmut Jarausch wrote:
Hi,
in response to a bug report I got the follow helpful comments from R. David
Murray.
Many thanks to him. (Unfortunately, I don't know his email, so I can write him
directly)
To generate an email (with non-ascii letters)
R. David Murray wrote:
Hi.
I need help with an assignment and I hope you guys can guide me in the right
direction.
This is the code:
--
"""
Demostration of setUp and tearDown.
The tests do not actually test anything - this is a demo.
"""
import unittest
import tempfile
import shutil
import glob
import
On 23 August 2012 10:05, Mark Carter wrote:
> Suppose I want to define a function "safe", which returns the argument
> passed if there is no error, and 42 if there is one. So the setup is
> something like:
>
> def safe(x):
># WHAT WOULD DEFINE HERE?
>
> print safe(666) # prints 666
> print sa
In article <6b0299df-bc24-406b-8d69-489e990d8...@googlegroups.com>,
Tigerstyle wrote:
> Hi.
>
> I need help with an assignment and I hope you guys can guide me in the right
> direction.
> [code elided]
> 1. The test_1() method includes code to verify that the test directory
> contains only th
On Thu, 23 Aug 2012 12:36:01 +0100, MRAB wrote:
> From what I've tried, it looks like the date can't be a string:
>
> >>> m['Date'] = datetime.datetime.utcnow()
> >>> m['Date']
> 'Thu, 23 Aug 2012 11:33:20 -'
Many thanks - it's even easier!
Waiting for Python 3.3 to become standard!
Helm
This is neither a complaint nor a question, just a comment.
In the previous discussion related to the flexible
string representation, Roy Smith added this comment:
http://groups.google.com/group/comp.lang.python/browse_thread/thread/2645504f459bab50/eda342573381ff42
Not only I agree with his sen
On 2012-08-22, Dennis Lee Bieber wrote:
> On Wed, 22 Aug 2012 01:43:19 -0700 (PDT), Guillaume Comte
> declaimed the following in
> gmane.comp.python.general:
>
>> I've managed to build the IP header. I've put the source and destination
>> addresses in this header but it doesn't change the real so
lipska the kat writes:
> On 23/08/12 05:14, Steven D'Aprano wrote:
> > I think that's uncalled for.
[…]
> Excellent advice as usual, but I'm more than capable of looking after
> myself thank you.
As is usual, it's not all about you; Steven is demonstrating that we
require civil behaviour here,
wxjmfa...@gmail.com:
Small illustration. Take an a4 page containing 50 lines of 80 ascii
characters, add a single 'EM DASH' or an 'BULLET' (code points> 0x2000),
and you will see all the optimization efforts destroyed.
sys.getsizeof('a' * 80 * 50)
4025
sys.getsizeof('a' * 80 * 50 + '•')
80
On 23/08/2012 10:05, Mark Carter wrote:
Suppose I want to define a function "safe", which returns the argument passed
if there is no error, and 42 if there is one. So the setup is something like:
def safe(x):
# WHAT WOULD DEFINE HERE?
print safe(666) # prints 666
print safe(1/0) # prints 4
On 23/08/2012 13:47, wxjmfa...@gmail.com wrote:
This is neither a complaint nor a question, just a comment.
In the previous discussion related to the flexible
string representation, Roy Smith added this comment:
http://groups.google.com/group/comp.lang.python/browse_thread/thread/2645504f459bab
lipska the kat writes:
> On 23/08/12 14:59, Ben Finney wrote:
> > lipska the kat writes:
> >
> >> On 23/08/12 05:14, Steven D'Aprano wrote:
> >>> I think that's uncalled for.
> > […]
> >
> >> Excellent advice as usual, but I'm more than capable of looking after
> >> myself thank you.
> >
> > As
On 23/08/12 14:59, Ben Finney wrote:
lipska the kat writes:
On 23/08/12 05:14, Steven D'Aprano wrote:
I think that's uncalled for.
[…]
Excellent advice as usual, but I'm more than capable of looking after
myself thank you.
As is usual, it's not all about you; Steven is demonstrating that
On Thu, Aug 23, 2012 at 4:59 AM, Jussi Piitulainen
wrote:
> I don't get it either. To me the python-has-no-variables campaigners
> seem confused. As far as I can see, Python can be seen in terms of
> variables bound to (locations containing) values perfectly well, in a
> way that should be quite f
On 23/08/2012 14:57, Neil Hodgson wrote:
wxjmfa...@gmail.com:
Small illustration. Take an a4 page containing 50 lines of 80 ascii
characters, add a single 'EM DASH' or an 'BULLET' (code points> 0x2000),
and you will see all the optimization efforts destroyed.
sys.getsizeof('a' * 80 * 50)
40
On Thu, Aug 23, 2012 at 9:11 AM, MRAB wrote:
> Perhaps the solution should've been to just switch between 2/4 bytes instead
> of 1/2/4 bytes. :-)
Why? You don't lose any complexity by doing that. I can see
arguments for 1/2/4 or for just 4, but I can't see any advantage of
2/4 over either of th
We got burned yesterday by a scenario which has burned us before. We had
multiple copies of a module in sys.path. One (the one we wanted) was in our
deployed code tree, the other was in /usr/local/lib/python/ or some such. It
was a particularly confusing situation because we *knew* we had uni
On 08/23/2012 04:19 AM, lipska the kat wrote:
> Well we don't want to turn this into a language comparison thread do we,
> that might upset too many people but I can't remember ever writing a
> method that took an Object as argument, you just can't do that much with
> an Object.
In the pre-Java-1.
On Saturday, August 18, 2012 9:28:32 PM UTC-5, Aaron Brady wrote:
> On Saturday, August 18, 2012 5:14:05 PM UTC-5, MRAB wrote:
>
> > On 18/08/2012 21:29, Aaron Brady wrote:
>
> > > On Friday, August 17, 2012 4:57:41 PM UTC-5, Chris Angelico wrote:
>
> > >> On Sat, Aug 18, 2012 at 4:37 AM, Aaron
On Aug 23, 9:34 am, Steven D'Aprano wrote:
> On Wed, 22 Aug 2012 18:46:43 +0100, lipska the kat wrote:
> > We need to separate out the 'view' from the 'implementation' here. Most
> > developers I know, if looking at the code and without the possibly
> > dubious benefit of knowing that in Python 'e
[I have some things to say to a few people so I'm just putting it all in
one rather than clutter up your email box even more.]
On 08/23/2012 12:33 AM, Chris Angelico wrote:
> [Snip discussion on names vs variables]
>
> Does that sort things out, or just make things more confusing?
>
> ChrisA
I...
On 8/23/2012 10:43 AM, Jerry Hill wrote:
Personally, when I was learning python I found the idea of python
having names and values (rather than variables and references) to
clear up a lot of my misconceptions of the python object model. I
think it's done the same for other people too, especiall
On Aug 23, 3:11 pm, Peter Otten <__pete...@web.de> wrote:
> Mark Carter wrote:
> > Suppose I want to define a function "safe", which returns the argument
> > passed if there is no error, and 42 if there is one. So the setup is
> > something like:
>
> > def safe(x):
> > # WHAT WOULD DEFINE HERE?
On 8/23/2012 8:28 AM, Roy Smith wrote:
I think you want to end up with something like:
def test_1(self):
"Verify creation of files is possible"
filenames = ("this.txt", "that.txt", "the_other.txt")
for filename in filenames:
f = open(filename, "w")
On Thu, 23 Aug 2012 12:17:03 -0500, Evan Driscoll wrote:
> I definitely *wouldn't* say "Python
> classes aren't really classes" -- even though (I assert) Python classes
> are *far* further from Simula-style (/Java/C++) classes than Python
> variables are from Java variables.
Well, Python classes
On 23/08/12 17:44, Evan Driscoll wrote:
On 08/23/2012 04:19 AM, lipska the kat wrote:
Well we don't want to turn this into a language comparison thread do we,
that might upset too many people but I can't remember ever writing a
method that took an Object as argument, you just can't do that much
On 8/23/12 06:11 , Steven D'Aprano wrote:
2) Related to the above, you can infinitely nest scopes. There's nothing
wrong with having six variables called 'q'; you always use the innermost
one. Yes, this can hurt readability
Well, there you go. There *is* something wrong with having six variabl
On Thu, 23 Aug 2012 09:49:41 -0700, Aaron Brady wrote:
[...]
> The patch for the above is only 40-60 lines. However it introduces two
> new concepts.
>
> The first is a "linked list", a classic dynamic data structure, first
> developed in 1955, cf. http://en.wikipedia.org/wiki/Linked_list .
> L
On Thu, Aug 23, 2012 at 12:02 PM, Jan Kuiken wrote:
> On 8/23/12 06:11 , Steven D'Aprano wrote:
>
>>> 2) Related to the above, you can infinitely nest scopes. There's nothing
>>> wrong with having six variables called 'q'; you always use the innermost
>>> one. Yes, this can hurt readability
>>
>>
Le jeudi 23 août 2012 15:57:50 UTC+2, Neil Hodgson a écrit :
> wxjmfa...@gmail.com:
>
>
>
> > Small illustration. Take an a4 page containing 50 lines of 80 ascii
>
> > characters, add a single 'EM DASH' or an 'BULLET' (code points> 0x2000),
>
> > and you will see all the optimization efforts
On Thursday, August 23, 2012 1:29:19 PM UTC-4, Terry Reedy wrote:
> One can start with a set rather than tuple of file names.
> filenames = {"this.txt", "that.txt", "the_other.txt"}
Yeah, that's even cleaner. Just be aware, the set notation above is only
available in (IIRC), 2.7 or abo
On 08/23/2012 12:56 PM, Steven D'Aprano wrote:
> On Thu, 23 Aug 2012 12:17:03 -0500, Evan Driscoll wrote:
>
>> I definitely *wouldn't* say "Python
>> classes aren't really classes" -- even though (I assert) Python classes
>> are *far* further from Simula-style (/Java/C++) classes than Python
>> va
On Thu, Aug 23, 2012 at 12:33 PM, wrote:
>> >>> sys.getsizeof('a' * 80 * 50)
>>
>> > 4025
>>
>> sys.getsizeof('a' * 80 * 50 + '•')
>>
>> > 8040
>>
>>
>>
>> This example is still benefiting from shrinking the number of bytes
>>
>> in half over using 32 bits per character as was the case w
On 23/08/2012 19:33, wxjmfa...@gmail.com wrote:
Le jeudi 23 août 2012 15:57:50 UTC+2, Neil Hodgson a écrit :
wxjmfa...@gmail.com:
Small illustration. Take an a4 page containing 50 lines of 80 ascii
characters, add a single 'EM DASH' or an 'BULLET' (code points> 0x2000),
and you will s
On 8/23/12 20:17 , Ian Kelly wrote:
...
Well, there you go. There *is* something wrong with having six variables
called 'q'.
Sometimes you don't want only six variables called 'q' but a hundred
of them :-)
def fac(q):
if q < 1 :
return 1
else:
return q
On Fri, Aug 24, 2012 at 4:49 AM, Dennis Lee Bieber
wrote:
> By the time you wrap the equation with a lambda all, named, terms,
> AND supply the named terms after the lambda, you might as well just wrap
> the equation in a plain try/except block.
But closures spare you that hassle.
>>> a=
On Fri, Aug 24, 2012 at 3:56 AM, Steven D'Aprano
wrote:
> But name bindings are a kind of variable. Named memory locations are a
> *different* kind of variable. The behaviour of C variables and Python
> variables do not follow the Liskov Substitution Principle -- you can't
> rip out the entire "na
On Fri, Aug 24, 2012 at 5:22 AM, Evan Driscoll wrote:
> In Python--, any time you use a name, you have to prefix it with the
> word 'variable':
> variable x = 4
> print(variable x)
That gets really unwieldy. You should shorten it to a single symbol.
And your language could be called Python Hy
Steven D'Aprano writes:
> No offence to Ben Finney, but I think sometimes he's a bit too eager
> to emphasise the subtle differences between Python and other
> languages, rather than the similarities.
No offense taken.
> Again, context is important:
Indeed. Note that my assertion was in respon
On Fri, Aug 24, 2012 at 9:54 AM, Dennis Lee Bieber
wrote:
> On Fri, 24 Aug 2012 08:00:59 +1000, Chris Angelico
> declaimed the following in gmane.comp.python.general:
>
>>
>> But again, that probably doesn't help explain the variables. Unless
>> you've come from (or can at least imagine) an envir
In article ,
Evan Driscoll wrote:
> > In fact, Python doesn't have variables not as C or Java programmers
> > would understand the term. What it has instead are references to objects
> > (with names as one kind of reference).
>
> OK, I've seen this said a few times, and I have to ask: what do
On Fri, Aug 24, 2012 at 10:36 AM, Roy Smith wrote:
> In fact, I can even write it that way and everything works:
>
globals()["a"] = 42
a
> 42
>
> Even id() thinks they're the same thing:
>
id(a)
> 1755402140
id(globals()["a"])
> 1755402140
Ah, no. What you have there is actual
I agree with Madison, think Python is a good choice if you have no
programming experience. It'll teach you Python while also covering
programming fundamentals.
If you have prior programming experience, the Python docs/tutorials should
be enough to get you started.
On Thu, Aug 23, 2012 at 5:56 PM,
On Aug 24, 11:34 am, Chris Angelico wrote:
> On Fri, Aug 24, 2012 at 10:36 AM, Roy Smith wrote:
> > Even id() thinks they're the same thing:
> id(a)
> > 1755402140
> id(globals()["a"])
> > 1755402140
>
> Ah, no. What you have there is actually id(4) and nothing to do with a at all.
Wel
Please, can anyone explain me the meaning of the
"buffering > 1" in the built-in open()?
The doc says: "...and an integer > 1 to indicate the size
of a fixed-size chunk buffer."
So I thought this size was the number of bytes or chars, but
it is not:
>>> f = open('myfile', 'w', buffering=2)
>>> f.
On 08/24/2012 06:35 AM, Marco wrote:
Please, can anyone explain me the meaning of the
"buffering > 1" in the built-in open()?
The doc says: "...and an integer > 1 to indicate the size
of a fixed-size chunk buffer."
Sorry, I get it:
>>> f = open('myfile', 'w', buffering=2)
>>> f._CHUNK_SIZE = 5
Does a wxPython program not run on 64bit Windows?
I saw this “
wxPython is a cross-platform toolkit. This means that the same program
will run on multiple platforms without modification. Currently
supported platforms are 32-bit Microsoft Windows, most Unix or
unix-like systems, and Macintosh OS
On Aug 23, 12:52 pm, Fg Nu wrote:
> List folk,
>
> I am a newbie trying to get used to Python. I was wondering if anyone knows
> of web resources that teach good practices in data cleaning and management
> for statistics/analytics/machine learning, particularly using Python.
>
> Ideally, these w
Thanks. I will try the SciPy list. It was a bit of a hail mary anyway. Pretty
sure elevated Python types don't actually get their hands dirty with data. ;)
- Original Message -
From: rusi
To: python-list@python.org
Cc:
Sent: Thursday, August 23, 2012 11:01 PM
Subject: Re: Data clean
72 matches
Mail list logo