comp.lang.python - 26 new messages in 11 topics - digest
comp.lang.python
http://groups.google.com/group/comp.lang.python?hl=en
comp.lang.python@googlegroups.com
Today's topics:
* Open Question - I'm a complete novice in programming so please bear with me..
.Is python equivalent to C, C++ and java combined? - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/eaf393e9028e2f09?hl=en
* Python example source code - 9 messages, 6 authors
http://groups.google.com/group/comp.lang.python/t/8594472fa123f77e?hl=en
* Dawkins arrested - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/3cf2900ae590dd7f?hl=en
* extracting string.Template substitution placeholders - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/e98ada5213c4b344?hl=en
* Python: 404 Error when trying to login a webpage by using 'urllib' and '
HTTPCookieProcessor' - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/bf0e28e020a02c69?hl=en
* Problem writing some strings (UnicodeEncodeError) - 5 messages, 4 authors
http://groups.google.com/group/comp.lang.python/t/08d2e6a4bc11d1c3?hl=en
* How to get Mac address of ethernet port? - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/0fea9cedbd05df8a?hl=en
* python first project - 3 messages, 3 authors
http://groups.google.com/group/comp.lang.python/t/9e82659cb027cf95?hl=en
* parametized unittest - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/21d911b3dbbdf18e?hl=en
* Data peeping function? - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/c57f6b9cfd4b7ca0?hl=en
* 'Straße' ('Strasse') and Python 2 - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/93ddbbff468ab95d?hl=en
==============================================================================
TOPIC: Open Question - I'm a complete novice in programming so please bear
with me...Is python equivalent to C, C++ and java combined?
http://groups.google.com/group/comp.lang.python/t/eaf393e9028e2f09?hl=en
==============================================================================
== 1 of 2 ==
Date: Sun, Jan 12 2014 6:36 am
From: Rotwang
On 12/01/2014 05:58, Chris Angelico wrote:
> [...]
>
> (BTW, is there no better notation than six nested for/range for doing
> 6d6? I couldn't think of one off-hand, but it didn't really much
> matter anyway.)
If you're willing to do an import, then how about this:
>>> from itertools import product
>>> len([x for x in product(range(1, 7), repeat = 6) if sum(x) < 14])/6**6
0.03587962962962963
== 2 of 2 ==
Date: Sun, Jan 12 2014 6:44 am
From: Chris Angelico
On Mon, Jan 13, 2014 at 1:36 AM, Rotwang <sg552@hotmail.co.uk> wrote:
> On 12/01/2014 05:58, Chris Angelico wrote:
>>
>> (BTW, is there no better notation than six nested for/range for doing
>> 6d6? I couldn't think of one off-hand, but it didn't really much
>> matter anyway.)
>
>
> If you're willing to do an import, then how about this:
>
>>>> from itertools import product
>>>> len([x for x in product(range(1, 7), repeat = 6) if sum(x) < 14])/6**6
> 0.03587962962962963
Should have known itertools would have something. That's a little more
complicated to try to explain, but it's a lot shorter.
ChrisA
==============================================================================
TOPIC: Python example source code
http://groups.google.com/group/comp.lang.python/t/8594472fa123f77e?hl=en
==============================================================================
== 1 of 9 ==
Date: Sun, Jan 12 2014 6:37 am
From: ngangsia akumbo
where can i find example source code by topic?
Any help please
== 2 of 9 ==
Date: Sun, Jan 12 2014 6:53 am
From: bob gailer
On 1/12/2014 9:37 AM, ngangsia akumbo wrote:
> where can i find example source code by topic?
There are several Python tutorials on the internet. They have good code
examples.
Most modules also have module-specific examples.
There are also some web sites that may address your needs. I will leave
it to others to list these.
What do you mean by topic? Give us some examples of topics and maybe we
can help more.
== 3 of 9 ==
Date: Sun, Jan 12 2014 7:06 am
From: Dave Angel
ngangsia akumbo <ngangsia@gmail.com> Wrote in message:
> where can i find example source code by topic?
> Any help please
>
http://code.activestate.com/recipes/langs/python/
http://code.activestate.com/recipes/sets/2-python-cookbook-edition-2/
http://shop.oreilly.com/product/mobile/0636920027072.do
http://www.mindviewinc.com/Books/Python3Patterns/Index.php
https://pypi.python.org/pypi
--
DaveA
----Android NewsGroup Reader----
http://www.piaohong.tk/newsgroup
== 4 of 9 ==
Date: Sun, Jan 12 2014 7:13 am
From: ngangsia akumbo
On Sunday, January 12, 2014 4:06:13 PM UTC+1, Dave Angel wrote:
> ngangsia akumbo <ngangsia@gmail.com> Wrote in message:
>
Thanks bro
== 5 of 9 ==
Date: Sun, Jan 12 2014 8:38 am
From: Joel Goldstick
On Sun, Jan 12, 2014 at 10:13 AM, ngangsia akumbo <ngangsia@gmail.com> wrote:
>
> On Sunday, January 12, 2014 4:06:13 PM UTC+1, Dave Angel wrote:
> > ngangsia akumbo <ngangsia@gmail.com> Wrote in message:
> >
>
>
> Thanks bro
>
> --
> https://mail.python.org/mailman/listinfo/python-list
Don't forget Python Module of the Week pymotw.com/
--
Joel Goldstick
http://joelgoldstick.com
== 6 of 9 ==
Date: Sun, Jan 12 2014 8:52 am
From: Emile van Sebille
On 01/12/2014 06:37 AM, ngangsia akumbo wrote:
> where can i find example source code by topic?
I'd recommend http://effbot.org/librarybook/ even though it's v2
specific and somewhat dated.
Emile
== 7 of 9 ==
Date: Sun, Jan 12 2014 8:59 am
From: ngangsia akumbo
On Sunday, January 12, 2014 5:38:03 PM UTC+1, Joel Goldstick wrote:
> On Sun, Jan 12, 2014 at 10:13 AM, ngangsia akumbo <ngangsia@gmail.com> wrote:
>
> Don't forget Python Module of the Week pymotw.com/
Thanks
== 8 of 9 ==
Date: Sun, Jan 12 2014 9:06 am
From: ngangsia akumbo
On Sunday, January 12, 2014 5:52:19 PM UTC+1, Emile van Sebille wrote:
> On 01/12/2014 06:37 AM, ngangsia akumbo wrote:
>
> I'd recommend http://effbot.org/librarybook/ even though it's v2
specific and somewhat dated.
Thank very much , it is very nice
== 9 of 9 ==
Date: Sun, Jan 12 2014 9:47 am
From: memilanuk
On 01/12/2014 06:37 AM, ngangsia akumbo wrote:
> where can i find example source code by topic?
> Any help please
>
nullege.com is usually helpful...
==============================================================================
TOPIC: Dawkins arrested
http://groups.google.com/group/comp.lang.python/t/3cf2900ae590dd7f?hl=en
==============================================================================
== 1 of 1 ==
Date: Sun, Jan 12 2014 7:06 am
From: Thrinassodon
================
>BREAKING NEWS!
================
>
THRINAXODON SPEARHEADED THE ASSAULT ON RICHARD DAWKINS, KNOWN FOR
SUPPRESSION OF VALID RESEARCH OF HUMAN ORIGINS FOR YEARS, JUST TO GET A
BUCK OUT OF BRAINWASHING CHILDREN'S LIVES INTO THE SCAM OF EVOLUTION.
>
Dawkins was charged with OVER 9000! complaints of mind-control, torture,
and pyramid schemes where he got millions of dollars out of the American
populace over the scam of evolution.
>
This is what Dawkins said when he faced the charges, "SHIT! How am I
going to get money now!" Later, his charges were reduced to probation.
He is now broke.
>
According to Thrinaxodon, PHD, an expert on human origins, "The loss of
Dawkins is a great blow to the evolutionist establishment, with no
figurehead the scientific establishement that has been dominating
American politics for 150 years is now falling down under it's own
weight. How are people like AronRa or James Watson going to get money
now? No-one knows."
>
When Dawkins was asked how the scientific establishement was going to
rebuild, he said "I don't know. Maybe, just maybe, we'll have to move on
to another scam. Like the Big Bang."
>
===================================
>
MAN AS OLD AS FROGS!
https://groups.google.com/forum/#!topic/sci.bio.paleontology/buAVigqX9Ts
>
TO FIND OUT HOW MAN IS AS OLD AS FROGS, VISIT:
http://thrinaxodon.wordpress.com/faq
--
Thrinaxodon, The Ultimate Defender of USENET
==============================================================================
TOPIC: extracting string.Template substitution placeholders
http://groups.google.com/group/comp.lang.python/t/e98ada5213c4b344?hl=en
==============================================================================
== 1 of 1 ==
Date: Sun, Jan 12 2014 7:08 am
From: "Eric S. Johansson"
As part of speech recognition accessibility tools that I'm building, I'm
using string.Template. In order to construct on-the-fly grammar, I need
to know all of the identifiers before the template is filled in. what is
the best way to do this?
can string.Template handle recursive expansion i.e. an identifier
contains a template.
Thanks
--- eric
==============================================================================
TOPIC: Python: 404 Error when trying to login a webpage by using 'urllib' and
'HTTPCookieProcessor'
http://groups.google.com/group/comp.lang.python/t/bf0e28e020a02c69?hl=en
==============================================================================
== 1 of 1 ==
Date: Sun, Jan 12 2014 7:17 am
From: xDog Walker
On Sunday 2014 January 12 04:42, Chris Angelico wrote:
> As a last resort, try firing up Wireshark or something and watch
> exactly what gets sent and received. I went looking through the docs
> for a "verbose" mode or a "debug" setting but can't find one - that'd
> be ideal if it exists, though.
I think you can set debug on httplib before using urllib to get the header
traffic printed. I don't recall exactly how to do it though.
--
Yonder nor sorghum stenches shut ladle gulls stopper torque wet
strainers.
==============================================================================
TOPIC: Problem writing some strings (UnicodeEncodeError)
http://groups.google.com/group/comp.lang.python/t/08d2e6a4bc11d1c3?hl=en
==============================================================================
== 1 of 5 ==
Date: Sun, Jan 12 2014 7:36 am
From: Paulo da Silva
Hi!
I am using a python3 script to produce a bash script from lots of
filenames got using os.walk.
I have a template string for each bash command in which I replace a
special string with the filename and then write the command to the bash
script file.
Something like this:
shf=open(bashfilename,'w')
filenames=getfilenames() # uses os.walk
for fn in filenames:
...
cmd=templ.replace("<fn>",fn)
shf.write(cmd)
For certain filenames I got a UnicodeEncodeError exception at
shf.write(cmd)!
I use utf-8 and have # -*- coding: utf-8 -*- in the source .py.
How can I fix this?
Thanks for any help/comments.
== 2 of 5 ==
Date: Sun, Jan 12 2014 8:19 am
From: Albert-Jan Roskam
--------------------------------------------
On Sun, 1/12/14, Paulo da Silva <p_s_d_a_s_i_l_v_a@netcabo.pt> wrote:
Subject: Problem writing some strings (UnicodeEncodeError)
To: python-list@python.org
Date: Sunday, January 12, 2014, 4:36 PM
Hi!
I am using a python3 script to produce a bash script from
lots of
filenames got using os.walk.
I have a template string for each bash command in which I
replace a
special string with the filename and then write the command
to the bash
script file.
Something like this:
shf=open(bashfilename,'w')
filenames=getfilenames() # uses os.walk
for fn in filenames:
...
cmd=templ.replace("<fn>",fn)
shf.write(cmd)
For certain filenames I got a UnicodeEncodeError exception
at
shf.write(cmd)!
I use utf-8 and have # -*- coding: utf-8 -*- in the source
.py.
How can I fix this?
Thanks for any help/comments.
======> what is the output of locale.getpreferredencoding(False)? That is the default value of the "encoding" parameter of the open function.
shf=open(bashfilename,'w', encoding='utf-8') might work, though on my Linux macine locale.getpreferredencoding(False) returns utf-8.
help(open)
...
In text mode, if encoding is not specified the encoding used is platform
dependent: locale.getpreferredencoding(False) is called to get the
current locale encoding. (For reading and writing raw bytes use binary
mode and leave encoding unspecified.)
...
== 3 of 5 ==
Date: Sun, Jan 12 2014 8:23 am
From: Peter Otten <__peter__@web.de>
Paulo da Silva wrote:
> I am using a python3 script to produce a bash script from lots of
> filenames got using os.walk.
>
> I have a template string for each bash command in which I replace a
> special string with the filename and then write the command to the bash
> script file.
>
> Something like this:
>
> shf=open(bashfilename,'w')
> filenames=getfilenames() # uses os.walk
> for fn in filenames:
> ...
> cmd=templ.replace("<fn>",fn)
> shf.write(cmd)
>
> For certain filenames I got a UnicodeEncodeError exception at
> shf.write(cmd)!
> I use utf-8 and have # -*- coding: utf-8 -*- in the source .py.
>
> How can I fix this?
>
> Thanks for any help/comments.
You make it harder to debug your problem by not giving the complete
traceback. If the error message contains 'surrogates not allowed' like in
the demo below
>>> with open("tmp.txt", "w") as f:
... f.write("\udcef")
...
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
UnicodeEncodeError: 'utf-8' codec can't encode character '\udcef' in
position 0: surrogates not allowed
you have filenames that are not valid UTF-8 on your harddisk.
A possible fix would be to use bytes instead of str. For that you need to
open `bashfilename` in binary mode ("wb") and pass bytes to the os.walk()
call.
Or you just go and fix the offending names.
== 4 of 5 ==
Date: Sun, Jan 12 2014 8:55 am
From: Emile van Sebille
On 01/12/2014 07:36 AM, Paulo da Silva wrote:
> Hi!
>
> I am using a python3 script to produce a bash script from lots of
> filenames got using os.walk.
>
> I have a template string for each bash command in which I replace a
> special string with the filename and then write the command to the bash
> script file.
>
> Something like this:
>
> shf=open(bashfilename,'w')
> filenames=getfilenames() # uses os.walk
> for fn in filenames:
> ...
> cmd=templ.replace("<fn>",fn)
> shf.write(cmd)
>
> For certain filenames I got a UnicodeEncodeError exception at
> shf.write(cmd)!
> I use utf-8 and have # -*- coding: utf-8 -*- in the source .py.
>
> How can I fix this?
Not sure exactly, but I'd try
shf=open(bashfilename,'wb')
as a start.
HTH,
Emile
== 5 of 5 ==
Date: Sun, Jan 12 2014 9:51 am
From: Paulo da Silva
Em 12-01-2014 16:23, Peter Otten escreveu:
> Paulo da Silva wrote:
>
>> I am using a python3 script to produce a bash script from lots of
>> filenames got using os.walk.
>>
>> I have a template string for each bash command in which I replace a
>> special string with the filename and then write the command to the bash
>> script file.
>>
>> Something like this:
>>
>> shf=open(bashfilename,'w')
>> filenames=getfilenames() # uses os.walk
>> for fn in filenames:
>> ...
>> cmd=templ.replace("<fn>",fn)
>> shf.write(cmd)
>>
>> For certain filenames I got a UnicodeEncodeError exception at
>> shf.write(cmd)!
>> I use utf-8 and have # -*- coding: utf-8 -*- in the source .py.
>>
>> How can I fix this?
>>
>> Thanks for any help/comments.
>
> You make it harder to debug your problem by not giving the complete
> traceback. If the error message contains 'surrogates not allowed' like in
> the demo below
>
>>>> with open("tmp.txt", "w") as f:
> ... f.write("\udcef")
> ...
> Traceback (most recent call last):
> File "<stdin>", line 2, in <module>
> UnicodeEncodeError: 'utf-8' codec can't encode character '\udcef' in
> position 0: surrogates not allowed
That is the situation. I just lost it and it would take a few houres to
repeat the situation. Sorry.
>
> you have filenames that are not valid UTF-8 on your harddisk.
>
> A possible fix would be to use bytes instead of str. For that you need to
> open `bashfilename` in binary mode ("wb") and pass bytes to the os.walk()
> call.
This is my 1st time with python3, so I am confused!
As much I could understand it seems that os.walk is returning the
filenames exactly as they are on disk. Just bytes like in C.
My template is a string. What is the result of the replace command? Is
there any change in the filename from os.walk contents?
Now, if the result of the replace has the replaced filename unchanged
how do I "convert" it to bytes type, without changing its contents, so
that I can write to the bashfile opened with "wb"?
>
> Or you just go and fix the offending names.
This is impossible in my case.
I need a bash script with the names as they are on disk.
==============================================================================
TOPIC: How to get Mac address of ethernet port?
http://groups.google.com/group/comp.lang.python/t/0fea9cedbd05df8a?hl=en
==============================================================================
== 1 of 1 ==
Date: Sun, Jan 12 2014 8:22 am
From: Dennis Lee Bieber
On Sat, 11 Jan 2014 16:55:53 -0500, Roy Smith <roy@panix.com> declaimed the
following:
>In article <mailman.5336.1389476410.18130.python-list@python.org>,
> Chris Angelico <rosuav@gmail.com> wrote:
>
>> We had a connection set up a few years
>> ago where the ISP tech recorded the source MAC into the far end, and
>> only that MAC would work - so when I stuck in a different router, I
>> needed to switch it to the old MAC before it could establish a
>> connection. Stupid? Yes. Unusual? I hope so
>
>Actually, I think it's pretty common.
>
In my situation, the first thing I did with the router was "MAC address
clone" of my desktop computer... Why? My ISP wanted [still does, I think]
to charge $10/month for the privilege of a LAN vs direct single connection
(worse, for the same router I already had owned).
This way, if I did encounter problems, I would be able to bypass the
router without appearing as a different NIC to the DSL adapter (granted, I
might have had a different problem, as the adapter was in bridge mode and I
never installed the PPPoE software on my desktop; my router handled that).
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
==============================================================================
TOPIC: python first project
http://groups.google.com/group/comp.lang.python/t/9e82659cb027cf95?hl=en
==============================================================================
== 1 of 3 ==
Date: Sun, Jan 12 2014 8:37 am
From: Emile van Sebille
On 01/11/2014 09:14 PM, ngangsia akumbo wrote:
> From all indication it is a very huge project.
Yep -- I built such a system in the late 70's with a team of seven over
two-three years. Then modifications and improvements continued over the
next 20 years keeping about 2-4 programmers busy full time.
> How much do you thing all this will cost if we were to put the system all complete.
A lot. In today's dollars a million or two to do it right at a
minimalist level. Going for the gold will be much more.
IMHO you'd be better off researching the existing software market for an
application suite the 'best fits' their needs and allows for
customization to fine tune things.
I'm now working with OpenERP which is python based and is OSS with a
subscription model to ensure an upgrade path. It already has most of
what you're looking for built in or available as third party addons and
is of a quality that you couldn't hope to attain in years of effort.
Which reflects the millions they've invested.
see http://www.openerp.com for more.
For an example of a commercially available entry level alternative costs
check out:
http://www.erpsoftwareblog.com/2012/10/microsoft-dynamics-gp-2013-pricing-and-costs/
Overall a much better choice than starting from scratch.
That said, it wouldn't surprise me that the CEO hasn't already looked
into alternatives and been put off by the costs involved. (S)he is
trying to cheap their way through things by deluding themselves into a
its-not-that-big-a-problem way of thinking that I wouldn't involve
myself in that train wreck.
Call me a sceptic -- it's true. :)
HTH,
Emile
== 2 of 3 ==
Date: Sun, Jan 12 2014 8:47 am
From: ngangsia akumbo
On Sunday, January 12, 2014 5:37:41 PM UTC+1, Emile van Sebille wrote:
> On 01/11/2014 09:14 PM, ngangsia akumbo wrote:
> For an example of a commercially available entry level alternative costs
check out:
> That said, it wouldn't surprise me that the CEO hasn't already looked
into alternatives and been put off by the costs involved. (S)he is
trying to cheap their way through things by deluding themselves into a
its-not-that-big-a-problem way of thinking that I wouldn't involve
myself in that train wreck.
Call me a sceptic -- it's true. :)
HAHAHAHAH, LOL THAT IS TRUE YOU SPOKE LIKE A MAGICIAN.
WHEN I START PUTTING THE CODE UP FOR STOCK/BOOKKEEPING
I WILL NEED YOUR ASSISTANCE.
THANKS
== 3 of 3 ==
Date: Sun, Jan 12 2014 10:50 am
From: MRAB
On 2014-01-12 06:04, Chris Angelico wrote:
> On Sun, Jan 12, 2014 at 4:14 PM, ngangsia akumbo <ngangsia@gmail.com>
> wrote:
>> What options do you think i can give the Ceo. Because from what you
>> have outline, i think i will like to follow your advice.
>>
>> If it is just some recording data stuff then some spreadsheet can
>> do the work.
>>
>> From all indication it is a very huge project.
>>
>> How much do you thing all this will cost if we were to put the
>> system all complete.
>
> If you currently do all your bills and things on paper, then this
> job is going to be extremely daunting. Even if you don't write a
> single line of code (ie you buy a ready-made system), you're going to
> have to convert everybody to doing things the new way. In that case,
> I would recommend getting some people together to discuss exactly
> what you need to do, and then purchase an accounting, warehousing, or
> inventory management system, based on what you actually need it to
> do.
>
> On the other hand, if it's already being done electronically, your
> job is IMMENSELY easier. Easier, but more complex to describe,
> because what you're really asking for is a program that will get
> certain data out of your accounting/inventory management system and
> display it. The difficulty of that job depends entirely on what
> you're using for that data entry.
>
You should also consider whether you need to do it all at once or could
do it incrementally. Look at what functionality you might want and where
you might get the greatest benefit and start there. Doing it that way
will reduce the chances of you committing a lot of resources (time and
money) building a system, only to find at the end that you either left
something out or added something that you didn't really need after all.
==============================================================================
TOPIC: parametized unittest
http://groups.google.com/group/comp.lang.python/t/21d911b3dbbdf18e?hl=en
==============================================================================
== 1 of 1 ==
Date: Sun, Jan 12 2014 8:57 am
From: CraftyTech
On Saturday, January 11, 2014 11:34:30 PM UTC-5, Roy Smith wrote:
> In article <mailman.5355.1389500996.18130.python-list@python.org>,
>
> "W. Trevor King" <wking@tremily.us> wrote:
>
>
>
> > On Sat, Jan 11, 2014 at 08:00:05PM -0800, CraftyTech wrote:
>
> > > I'm finding it hard to use unittest in a for loop. Perhaps something like:
>
> > >
>
> > > for val in range(25):
>
> > > self.assertEqual(val,5,"not equal)
>
> > >
>
> > > The loop will break after the first failure. Anyone have a good
>
> > > approach for this? please advise.
>
> >
>
> > If Python 3.4 is an option, you can stick to the standard library and
>
> > use subtests [1].
>
>
>
> Or, as yet another alternative, if you use nose, you can write test
>
> generators.
>
>
>
> https://nose.readthedocs.org/en/latest/writing_tests.html#test-generators
Thank you all for the feedback. I now have what I need. Cheers
On Saturday, January 11, 2014 11:34:30 PM UTC-5, Roy Smith wrote:
> In article <mailman.5355.1389500996.18130.python-list@python.org>,
>
> "W. Trevor King" <wking@tremily.us> wrote:
>
>
>
> > On Sat, Jan 11, 2014 at 08:00:05PM -0800, CraftyTech wrote:
>
> > > I'm finding it hard to use unittest in a for loop. Perhaps something like:
>
> > >
>
> > > for val in range(25):
>
> > > self.assertEqual(val,5,"not equal)
>
> > >
>
> > > The loop will break after the first failure. Anyone have a good
>
> > > approach for this? please advise.
>
> >
>
> > If Python 3.4 is an option, you can stick to the standard library and
>
> > use subtests [1].
>
>
>
> Or, as yet another alternative, if you use nose, you can write test
>
> generators.
>
>
>
> https://nose.readthedocs.org/en/latest/writing_tests.html#test-generators
==============================================================================
TOPIC: Data peeping function?
http://groups.google.com/group/comp.lang.python/t/c57f6b9cfd4b7ca0?hl=en
==============================================================================
== 1 of 1 ==
Date: Sun, Jan 12 2014 9:36 am
From: Thor Whalen
The first thing I do once I import new data (as a pandas dataframe) is to .head() it, .describe() it, and then kick around a few specific stats according to what I see.
But I'm not satisfied with .describe(). Amongst others, non-numerical columns are ignored, and off-the-shelf stats will be computed for any numerical column.
I've been shopping around for a "data peeping" function that would:
(1) Have a hands-off mode where simply typing
diagnose_this(data)
the function would figure things out on its own, and notify me when in doubt. For example, would assume that any string data with not too many unique values should be considered categorical and appropriate statistics erected.
(2) Perform standard diagnoses and print them out. For example, (a) missing values? (b) heterogeneously formatted data? (c) columns with only one unique value? etc.
(3) Be parametrizable, if I so choose.
Does anyone know of such a function?
==============================================================================
TOPIC: 'Straße' ('Strasse') and Python 2
http://groups.google.com/group/comp.lang.python/t/93ddbbff468ab95d?hl=en
==============================================================================
== 1 of 1 ==
Date: Sun, Jan 12 2014 10:33 am
From: MRAB
On 2014-01-12 08:31, Peter Otten wrote:
> wxjmfauth@gmail.com wrote:
>
>>>>> sys.version
>> 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)]
>>>>> s = 'Straße'
>>>>> assert len(s) == 6
>>>>> assert s[5] == 'e'
>>>>>
>>
>> jmf
>
> Signifying nothing. (Macbeth)
>
> Python 2.7.2+ (default, Jul 20 2012, 22:15:08)
> [GCC 4.6.1] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> s = "Straße"
>>>> assert len(s) == 6
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> AssertionError
>>>> assert s[5] == "e"
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> AssertionError
>
>
The point is that in Python 2 'Straße' is a bytestring and its length
depends on the encoding of the source file. If the source file is UTF-8
then 'Straße' is a string literal with 7 bytes between the single
quotes.
==============================================================================
You received this message because you are subscribed to the Google Groups "comp.lang.python"
group.
To post to this group, visit http://groups.google.com/group/comp.lang.python?hl=en
To unsubscribe from this group, send email to comp.lang.python+unsubscribe@googlegroups.com
To change the way you get mail from this group, visit:
http://groups.google.com/group/comp.lang.python/subscribe?hl=en
To report abuse, send email explaining the problem to abuse@googlegroups.com
==============================================================================
Google Groups: http://groups.google.com/?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home