comp.lang.python - 26 new messages in 12 topics - digest
comp.lang.python
http://groups.google.com/group/comp.lang.python?hl=en
comp.lang.python@googlegroups.com
Today's topics:
* Editor for Python - 5 messages, 5 authors
http://groups.google.com/group/comp.lang.python/t/1d3bfdac73cdb9d2?hl=en
* Suggest an open-source log analyser? - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/a7adef00a9d20d74?hl=en
* Looking for tips for moving dev environment from Windows to Mac - 4 messages,
3 authors
http://groups.google.com/group/comp.lang.python/t/ca1bbe129ce09782?hl=en
* Bytes indexing returns an int - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/906d7333bbd1d189?hl=en
* Trouble with UnicodeEncodeError and email - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/efbcab9b1aa89c9e?hl=en
* argparse action on default values - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/631cf30af1d4ae87?hl=en
* Looking for Django/Python programmer in Jakarta - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/132ba2e0d2a5ef7c?hl=en
* Dictionary - 2 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/5ea015432bda2a31?hl=en
* Blog "about python 3" - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/3cbbaf1ff962e86d?hl=en
* Recover handle to shadowed builtin? - 4 messages, 3 authors
http://groups.google.com/group/comp.lang.python/t/aa3632850b2daaac?hl=en
* Understanding decorator and class methods - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/04ed45036450248b?hl=en
* the Gravity of Python 2 - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/0afb505736567141?hl=en
==============================================================================
TOPIC: Editor for Python
http://groups.google.com/group/comp.lang.python/t/1d3bfdac73cdb9d2?hl=en
==============================================================================
== 1 of 5 ==
Date: Wed, Jan 8 2014 8:40 am
From: Joel Goldstick
On Wed, Jan 8, 2014 at 10:53 AM, Jean-Michel Pichavant <
jeanmichel@sequans.com> wrote:
> > > -- IMPORTANT NOTICE:
> > >
> > > The contents of this email and any attachments are confidential and
> > > may
> > > also be privileged. If you are not the intended recipient, please
> > > notify
> > > the sender immediately and do not disclose the contents to any
> > > other
> > > person, use it for any purpose, or store or copy the information in
> > > any
> > > medium. Thank you.
> >
> > too late you have sent this to a public forum
>
> No pb with that, the python list is the intended recipient :)
>
> I tried to negotiate this with my IT guys, but it looks like it's now
> mandatory, something related to being in the USA stock market.
> I have no way to remove it, it's added by the email server. I apologise
> for the noise.
>
Two thoughts: maybe create a gmail account, and
What is wrong with this world that some over paid lawyer requires a
useless, silly statement to justify his employment. The money that person
is being paid should be given to someone else.
>
> JM
>
>
> -- IMPORTANT NOTICE:
>
> The contents of this email and any attachments are confidential and may
> also be privileged. If you are not the intended recipient, please notify
> the sender immediately and do not disclose the contents to any other
> person, use it for any purpose, or store or copy the information in any
> medium. Thank you.
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
>
--
Joel Goldstick
http://joelgoldstick.com
== 2 of 5 ==
Date: Wed, Jan 8 2014 8:50 am
From: Chris "Kwpolska" Warrick
On Wed, Jan 8, 2014 at 4:53 PM, Jean-Michel Pichavant
<jeanmichel@sequans.com> wrote:
> I tried to negotiate this with my IT guys, but it looks like it's now mandatory, something related to being in the USA stock market.
> I have no way to remove it, it's added by the email server. I apologise for the noise.
But you have a way to hide it for people whose clients do support
that. Simply, instead of signing your letters with "JM" yourself and
having your employer add this spam, simply have your mail client add
the sequence below as your signature. Some clients offer adding the
separator automatically and you only have to type JM in the signature
field.
The "magical" sequence is: -- \nJM
(that is 0x2D 2D 20 0A 4A 4D, with a trailing space)
> JM
>
>
> -- IMPORTANT NOTICE:
>
> The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
--
Chris "Kwpolska" Warrick <http://kwpolska.tk>
PGP: 5EAAEA16
stop html mail | always bottom-post | only UTF-8 makes sense
== 3 of 5 ==
Date: Wed, Jan 8 2014 8:52 am
From: Chris Angelico
On Thu, Jan 9, 2014 at 3:40 AM, Joel Goldstick <joel.goldstick@gmail.com> wrote:
> What is wrong with this world that some over paid lawyer requires a useless,
> silly statement to justify his employment. The money that person is being
> paid should be given to someone else.
Good luck. Guess who would be suing you for wrongful dismissal? :)
I'm not sure those sorts of footers are enforceable or of any value,
but they keep on popping up. Gmail at my end will happily fold it down
as repeated/quoted text, so it doesn't bother me more than once per
thread (usually), so hey, if it keeps the lawyers from hassling
someone, I'm not fussed.
ChrisA
== 4 of 5 ==
Date: Wed, Jan 8 2014 11:50 am
From: David Robinow
On Jan 8, 2014, at 10:53 AM, Jean-Michel Pichavant <jeanmichel@sequans.com> wrote:
>>> -- IMPORTANT NOTICE:
>>>
>>
>> too late you have sent this to a public forum
>
> No pb with that, the python list is the intended recipient :)
>
> I tried to negotiate this with my IT guys, but it looks like it's now mandatory, something related to being in the USA stock market.
Yeah, when in doubt blame the Americans.
> I have no way to remove it, it's added by the email server. I apologise for the noise.
Maybe you should try Google Groups.
== 5 of 5 ==
Date: Wed, Jan 8 2014 12:15 pm
From: Mark Lawrence
On 08/01/2014 19:50, David Robinow wrote:
>
> On Jan 8, 2014, at 10:53 AM, Jean-Michel Pichavant <jeanmichel@sequans.com> wrote:
>
>>>> -- IMPORTANT NOTICE:
>>>>
>>>
>>> too late you have sent this to a public forum
>>
>> No pb with that, the python list is the intended recipient :)
>>
>> I tried to negotiate this with my IT guys, but it looks like it's now mandatory, something related to being in the USA stock market.
> Yeah, when in doubt blame the Americans.
>> I have no way to remove it, it's added by the email server. I apologise for the noise.
> Maybe you should try Google Groups.
>
Why not, it works fine provided people pay a little attention, and
follow the instructions that others have kindly placed on the Python
wiki to help resolve problems, repeated again for anyone who needs them
https://wiki.python.org/moin/GoogleGroupsPython
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
==============================================================================
TOPIC: Suggest an open-source log analyser?
http://groups.google.com/group/comp.lang.python/t/a7adef00a9d20d74?hl=en
==============================================================================
== 1 of 1 ==
Date: Wed, Jan 8 2014 8:46 am
From: Alec Taylor
So yeah, if you know of a good one; please share.
Thanks
On Sun, Jan 5, 2014 at 2:50 PM, Alec Taylor <alec.taylor6@gmail.com> wrote:
> Because I'm thinking that something with a much less expressive query
> interface would serve me better in the long run... e.g.: Redis or
> maybe Hadoop
>
> On Sat, Jan 4, 2014 at 5:35 PM, Walter Hurry <walterhurry@lavabit.com> wrote:
>> On Thu, 02 Jan 2014 16:40:19 +1100, Alec Taylor wrote:
>>
>>> I use the Python logger class; with the example syntax of:
>>> Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
>>>
>>> Can of course easily use e.g.: a JSON syntax here instead.
>>>
>>> Are there any open-source log viewers (e.g.: with a web-interface)
>>> that you'd recommend; for drilling down into my logs?
>>>
>> If you want to do in-depth analysis, why not just stick it into an SQL
>> database; e.g. SQLite or Postgres?
>>
>> --
>> https://mail.python.org/mailman/listinfo/python-list
==============================================================================
TOPIC: Looking for tips for moving dev environment from Windows to Mac
http://groups.google.com/group/comp.lang.python/t/ca1bbe129ce09782?hl=en
==============================================================================
== 1 of 4 ==
Date: Wed, Jan 8 2014 7:45 am
From: William Ray Wing
On Jan 8, 2014, at 9:11 AM, python@bdurham.com wrote:
> Long time Windows developer making the move to Apple platform. My new development environment is a 15" MacBook Pro with 16 Gb RAM and a 512 Gb SSD. I'm totally new to the world of Apple hardware and software and am looking for advice on what apps, utilities and hardware I should consider for my new environment..
Welcome to the world of Macs, OS-X, and Darwin.
>
> Some early questions:
>
> 1. Which distribution of Python to install (Python.org, ActivateState, other?) and do I need to do anything special to avoid overwriting the system copy of Python?
>
The answer to this is going to depend on exactly what you are intending to do. ActiveState (for example) has what may well be the best totally integrated package of libraries (GUI, numpy, mathplotlib, and such), but has a pretty expensive license if you are going to do commercial development. Tell us more if you want a better recommendation.
> 2. Text editor: Textmate, BBEdit, Emacs/VI, or other?
>
At the risk of setting off a religious war; I use BBEdit (have used it for years, and have been very pleased with its speed, power, regular updates, and integration with the OS). There is strong support for other editors on this list, I'm sure you will hear from supporters of vi, Emacs, and Vim.
> 3. Multiple external monitors: Any recommendations on monitor specs/models for 2 external monitors for a MacBook?
I use Apple monitors, but that's strictly personal.
>
> 4. Best visual diff utility for Mac?
BBEdit has a nice built-in diff with side-by-side scrolling windows. When combined with its code-folding, multi-file search, and built-in python support, it makes a nice package.
>
> Any other "gotta have" Mac apps, utilities, or hardware accessories you would recommend?
Two external disks. One dedicated to TimeMachine for continuous backups of code as you write it, and one dedicated to either CarbonCopy Cloner or SuperDuper. Whichever you choose, set it up to do once-a-week clones at say 2:00 AM Sunday. Modern Mac's are just as hard to crash as any other modern UNIX-derived system, and Mac laptops continue to top Consumer Reports list of trouble-free systems, but ANY hardware can develop problems and it pays to be paranoid.
Again, welcome.
-Bill
>
> Thank you!
> Malcolm
> --
> https://mail.python.org/mailman/listinfo/python-list
== 2 of 4 ==
Date: Wed, Jan 8 2014 9:07 am
From: Chris Angelico
On Thu, Jan 9, 2014 at 2:45 AM, William Ray Wing <wrw@mac.com> wrote:
> Two external disks. One dedicated to TimeMachine for continuous backups of code as you write it, and one dedicated to either CarbonCopy Cloner or SuperDuper. Whichever you choose, set it up to do once-a-week clones at say 2:00 AM Sunday. Modern Mac's are just as hard to crash as any other modern UNIX-derived system, and Mac laptops continue to top Consumer Reports list of trouble-free systems, but ANY hardware can develop problems and it pays to be paranoid.
That's one option. I prefer to put anything that's even vaguely
important into a git repository, toss a remote clone of it onto one of
my servers, and commit and push every change. (And if it's important,
I'll clone that on another machine and pull, so I have a minimum of
three copies.) It's a bit more work, a bit more manual, but it gives
me versioning, backups, cryptographic hash checksums, notes ("Why the
bleep did you do that, Past-Me?!?"), and replication, all in one tidy
package. I don't know how much disk space you need for the two backup
systems you describe there, but the size of a full-history repository
isn't going to be huge, unless you're constantly editing big binary
files.
ChrisA
== 3 of 4 ==
Date: Wed, Jan 8 2014 9:26 am
From: Bob Hartwig
"4. Best visual diff utility for Mac?"
opendiff. I think it's part of xcode.
Regarding Python IDEs, I really like PyCharm. It's written in Java, and
sometimes you can tell that by its performance, but it's very featureful
and has a great debugger, and your 16 GB box should support it nicely.
Bob
On Wed, Jan 8, 2014 at 8:11 AM, <python@bdurham.com> wrote:
> Long time Windows developer making the move to Apple platform. My new
> development environment is a 15" MacBook Pro with 16 Gb RAM and a 512 Gb
> SSD. I'm totally new to the world of Apple hardware and software and am
> looking for advice on what apps, utilities and hardware I should consider
> for my new environment..
>
> Some early questions:
>
> 1. Which distribution of Python to install (Python.org, ActivateState,
> other?) and do I need to do anything special to avoid overwriting the
> system copy of Python?
>
> 2. Text editor: Textmate, BBEdit, Emacs/VI, or other?
>
> 3. Multiple external monitors: Any recommendations on monitor specs/models
> for 2 external monitors for a MacBook?
>
> 4. Best visual diff utility for Mac?
>
> Any other "gotta have" Mac apps, utilities, or hardware accessories you
> would recommend?
>
> Thank you!
> Malcolm
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
>
== 4 of 4 ==
Date: Wed, Jan 8 2014 10:32 am
From: William Ray Wing
On Jan 8, 2014, at 12:26 PM, Bob Hartwig <bobjects@gmail.com> wrote:
> "4. Best visual diff utility for Mac?"
>
> opendiff. I think it's part of xcode.
>
> Regarding Python IDEs, I really like PyCharm. It's written in Java, and sometimes you can tell that by its performance, but it's very featureful and has a great debugger, and your 16 GB box should support it nicely.
>
> Bob
>
Malcom - I didn't mention IDE's since you didn't explicitly ask, but I use WingIDE (and no, I have NO relationship with the company), and have been very pleased by the company's responsiveness and help. They have a free trial you can download and versions with three levels of capabilities, sophistication, and price. These range from student (free) through personal and professional.
-Bill
==============================================================================
TOPIC: Bytes indexing returns an int
http://groups.google.com/group/comp.lang.python/t/906d7333bbd1d189?hl=en
==============================================================================
== 1 of 2 ==
Date: Wed, Jan 8 2014 9:19 am
From: Ned Batchelder
On 1/8/14 11:08 AM, wxjmfauth@gmail.com wrote:
> Byte strings (encoded code points) or native unicode is one
> thing.
>
> But on the other side, the problem is elsewhere. These very
> talented ascii narrow minded, unicode illiterate devs only
> succeded to produce this (I, really, do not wish to be rude).
If you don't want to be rude, you are failing. You've been told a
number of times that your obscure micro-benchmarks are meaningless. Now
you've taken to calling the core devs narrow-minded and Unicode
illiterate. They are neither of these things.
Continuing to post these comments with no interest in learning is rude.
Other recent threads have contained details rebuttals of your views,
which you have ignored. This is rude. Please stop.
--Ned.
>
>>>> import unicodedata
>>>> unicodedata.name('ǟ')
> 'LATIN SMALL LETTER A WITH DIAERESIS AND MACRON'
>>>> sys.getsizeof('a')
> 26
>>>> sys.getsizeof('ǟ')
> 40
>>>> timeit.timeit("unicodedata.normalize('NFKD', 'ǟ')", "import unicodedata")
> 0.8040018888575129
>>>> timeit.timeit("unicodedata.normalize('NFKD', 'zzz')", "import unicodedata")
> 0.3073749330963995
>>>> timeit.timeit("unicodedata.normalize('NFKD', 'z')", "import unicodedata")
> 0.2874013282653962
>>>>
>>>> timeit.timeit("len(unicodedata.normalize('NFKD', 'zzz'))", "import unicodedata")
> 0.3803570633857589
>>>> timeit.timeit("len(unicodedata.normalize('NFKD', 'ǟ'))", "import unicodedata")
> 0.9359970320201683
>
> pdf, typography, linguistic, scripts, ... in mind, in other word the real
> *unicode* world.
>
> jmf
>
--
Ned Batchelder, http://nedbatchelder.com
== 2 of 2 ==
Date: Wed, Jan 8 2014 9:25 am
From: Michael Torrie
On 01/08/2014 09:08 AM, wxjmfauth@gmail.com wrote:
> Byte strings (encoded code points) or native unicode is one
> thing.
Byte strings are not necessarily "encoded code points." Most byte
streams I work with are definitely not unicode! They are in fact things
such as BER-encoded ASN.1 data structures. Or PDF data streams. Or
Gzip data streams. This issue in this thread has nothing to do with
unicode.
==============================================================================
TOPIC: Trouble with UnicodeEncodeError and email
http://groups.google.com/group/comp.lang.python/t/efbcab9b1aa89c9e?hl=en
==============================================================================
== 1 of 1 ==
Date: Wed, Jan 8 2014 10:09 am
From: Florian Lindner
Am Donnerstag, 9. Januar 2014, 00:26:15 schrieb Chris Angelico:
> On Thu, Jan 9, 2014 at 12:14 AM, Florian Lindner <mailinglists@xgm.de> wrote:
> > I've written some tiny script using Python 3 and it used to work perfectly. Then I realized it needs to run on my Debian Stable server too, which offers only Python 2. Ok, most backporting was a matter of minutes, but I'm becoming desperate on some Unicode error...
>
> Are you sure it does? The current Debian stable is Wheezy, which comes
> with a package 'python3' in the repository, which will install 3.2.3.
> (The previous Debian stable, Squeeze, has 3.1.3 under the same name.)
> You may need to change your shebang, but that's all you'd need to do.
> Or are you unable to install new packages? If so, I strongly recommend
> getting Python 3 added, as it's going to spare you a lot of Unicode
> headaches.
>
> Mind you, I compile my own Py3 for Wheezy, since I like to be on the
> bleeding edge. But that's not for everyone. :)
Well, I thought I had scanned to repos but obviously... I had to install BeautifulSoup and scikit-learn manually. Now some other Unicode issues have arised, but I need to sort them out first how they are connected to my mail delivery agent.
Thx a lot,
Florian
==============================================================================
TOPIC: argparse action on default values
http://groups.google.com/group/comp.lang.python/t/631cf30af1d4ae87?hl=en
==============================================================================
== 1 of 2 ==
Date: Wed, Jan 8 2014 10:20 am
From: Florian Lindner
Hello,
I use argparse from Python 3.3.3 with a custom action that normalizes path arguments:
http://docs.python.org/3/library/argparse.html#action
def norm_path(*parts):
""" Returns the normalized, absolute, expanded and joined path, assembled of all parts. """
parts = [ str(p) for p in parts ]
return os.path.abspath(os.path.expanduser(os.path.join(*parts)))
# Taken from the docs
class NormPath(argparse.Action):
def __call__(self, parser, namespace, values, option_string=None):
print('%r %r %r' % (namespace, values, option_string))
setattr(namespace, self.dest, norm_path(values))
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument("--config", help="Path to config file.",
default = "~/.foobar/config", action=NormPath)
return parser.parse_args()
This works fine when there is actually a --config=path supplied. But it's not being applied on default arguments. Of course, I could use "default = norm_path('~/.foobar/config')" but I expect that custom actions are applied to default values as well. The store action works alike for default and supplied values.
What do you think?
Florian
== 2 of 2 ==
Date: Wed, Jan 8 2014 10:53 am
From: Peter Otten <__peter__@web.de>
Florian Lindner wrote:
> I use argparse from Python 3.3.3 with a custom action that normalizes path
arguments:
>
> http://docs.python.org/3/library/argparse.html#action
>
> def norm_path(*parts):
> """ Returns the normalized, absolute, expanded and joined path,
assembled of all parts. """
> parts = [ str(p) for p in parts ]
This looks odd.
> return os.path.abspath(os.path.expanduser(os.path.join(*parts)))
>
> # Taken from the docs
> class NormPath(argparse.Action):
> def __call__(self, parser, namespace, values, option_string=None):
> print('%r %r %r' % (namespace, values, option_string))
> setattr(namespace, self.dest, norm_path(values))
>
>
> def parse_args():
> parser = argparse.ArgumentParser()
> parser.add_argument("--config", help="Path to config file.",
> default = "~/.foobar/config", action=NormPath)
>
> return parser.parse_args()
>
>
> This works fine when there is actually a --config=path supplied. But it's
not being applied on default arguments. Of course, I could use "default =
norm_path('~/.foobar/config')" but I expect that custom actions are applied
to default values as well. The store action works alike for default and
supplied values.
>
> What do you think?
Maybe you should specify type rather than action?
$ cat tmp.py
import argparse
p = argparse.ArgumentParser()
p.add_argument("--foo", default="42", type=int)
print(p.parse_args())
$ python3.3 tmp.py --foo=123
Namespace(foo=123)
$ python3.3 tmp.py
Namespace(foo=42)
==============================================================================
TOPIC: Looking for Django/Python programmer in Jakarta
http://groups.google.com/group/comp.lang.python/t/132ba2e0d2a5ef7c?hl=en
==============================================================================
== 1 of 1 ==
Date: Wed, Jan 8 2014 10:23 am
From: carlos@zocko.com
For working in a startup environment.
Immediate incorporation.
Please send your CV to talent@zocko.com
==============================================================================
TOPIC: Dictionary
http://groups.google.com/group/comp.lang.python/t/5ea015432bda2a31?hl=en
==============================================================================
== 1 of 2 ==
Date: Wed, Jan 8 2014 10:51 am
From: Bischoop
Dennis Lee Bieber wrote:
> On Mon, 30 Dec 2013 18:38:20 +0000, Bischoop <martin@jakis.adres.em>
> declaimed the following:
>
>>I have a txt file with some words, and need simply program that will
>>print me words containing provided letters.
>>
>>For example:
>>Type the letters:
>> (I type: g,m,o)
>>open the dictionary.txt
>>check words containing:g,m,o in dictionary.txt
>>if there are words containing: ["g", "m", "o" ]
>>print words with g,m,o
>
> Vague requirement...
>
> Do you need:
> 1 any word containing any single letter
> 2 any word containing all supplied letters (is there a limit on how
many
> letters?)
> 3 any word containing the supplied letters in the entered order,
but not
> necessarily adjacent to each other
> 4 any word containing the supplied letters in adjacent sequence
> 5 any word that begins with the supplied sequence of letters
1.yes
2. Any combination with supplied letters. It would be great if possible that
I could set also the combination for example: show me all words with: l,x
3. the order doesn't matter
4. doesnt matter
5 doesnt matter.
== 2 of 2 ==
Date: Wed, Jan 8 2014 11:00 am
From: Bischoop
Walter Hurry wrote:
> On Mon, 30 Dec 2013 18:38:20 +0000, Bischoop wrote:
>
>> I have a txt file with some words, and need simply program that will
>> print me words containing provided letters.
>>
>> For example:
>> Type the letters:
>> (I type: g,m,o)
>> open the dictionary.txt
>> check words containing:g,m,o in dictionary.txt
>> if there are words containing: ["g", "m", "o" ]
>> print words with g,m,o
>
> Well, what have you tried so far, and what result did you get?
>
> The incredibly helpful people here will provide advice, guidance and
> pointers, but it won't help you at all if they just do your homework for
> you.
Honestly Im newbie in Python, years ago (10 already) I wrote simply program
something like a TEST: Capitals of Countries. You could learn the capitals
of some countries, and then you could try to solve a test. I know it's seems
so simply for you guys but I was quite pride of myself :-)
Now because of free time I took my book which I used years ago about python
and try to learn it again, and as motivation I try to write the program I
described above just to give me a kick :-), however got no idea how to start
it, I meand there is so many moduls (import this, import that), I know how
to open, read file etc. Just stuck with that, got no clue what and how use
this that what I need to seek the words from the files if I need a words
with letters I want.
==============================================================================
TOPIC: Blog "about python 3"
http://groups.google.com/group/comp.lang.python/t/3cbbaf1ff962e86d?hl=en
==============================================================================
== 1 of 2 ==
Date: Wed, Jan 8 2014 11:26 am
From: Terry Reedy
On 1/8/2014 4:59 AM, wxjmfauth@gmail.com wrote:
[responding to me]
> The FSR acts more as an coding scheme selector
That is what PEP 393 describes and what I and many others have said. The
FSR saves memory by selecting from three choices the most compact coding
scheme for each string.
I ask again, have you read PEP 393? If you are going to critique the
FSR, you should read its basic document.
> than as a code point optimizer.
I do not know what you mean by 'code point optimizer'.
> Claiming that it saves memory is some kind of illusion;
Do you really think that the mathematical fact "10026 < 20040 < 40044"
(from your example below) is some kind of illusion? If so, please take
your claim to a metaphysics list. If not, please stop trolling.
> a little bit as saying "Py2.7 uses "relatively" less memory than
> Py3.2 (UCS-2)".
This is inane as 2.7 and 3.2 both use the same two coding schemes.
Saying '1 < 2' is different from saying '2 < 2'.
On 3.3+
>>>> sys.getsizeof('a' * 10000 + 'z')
> 10026
>>>> sys.getsizeof('a' * 10000 + '€')
> 20040
>>>> sys.getsizeof('a' * 10000 + '\U00010000')
> 40044
3.2- wide (UCS-4) builds use about 40050 bytes for all three unicode
strings. One again, you have posted examples that show how FSR saves
memory, thus negating your denial of the saving.
--
Terry Jan Reedy
== 2 of 2 ==
Date: Wed, Jan 8 2014 12:04 pm
From: Mark Lawrence
On 07/01/2014 13:34, wxjmfauth@gmail.com wrote:
> Le dimanche 5 janvier 2014 23:14:07 UTC+1, Terry Reedy a �crit :
>
> Ned : this has already been explained and illustrated.
>
> jmf
>
This has never been explained and illustrated. Roughly 30 minutes ago
Terry Reedy once again completely shot your argument about memory usage
to pieces. You did not bother to respond to the comments from Tim
Delaney made almost one day ago. Please give up.
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
==============================================================================
TOPIC: Recover handle to shadowed builtin?
http://groups.google.com/group/comp.lang.python/t/aa3632850b2daaac?hl=en
==============================================================================
== 1 of 4 ==
Date: Wed, Jan 8 2014 11:52 am
From: Roy Smith
I'm working with ipython's pylab mode, which replaces the builtin sum() with the one from numpy:
In [105]:
sum
Out[105]:
<function numpy.core.fromnumeric.sum>
Is there any way to recover a reference to the builtin sum()?
---
Roy Smith
roy@panix.com
== 2 of 4 ==
Date: Wed, Jan 8 2014 12:11 pm
From: Mark Lawrence
On 08/01/2014 19:52, Roy Smith wrote:
> I'm working with ipython's pylab mode, which replaces the builtin sum() with the one from numpy:
>
> In [105]:
> sum
>
> Out[105]:
> <function numpy.core.fromnumeric.sum>
>
> Is there any way to recover a reference to the builtin sum()?
>
>
> ---
> Roy Smith
> roy@panix.com
>
Grab it from here I suppose.
>>> help(__builtins__.sum)
Help on built-in function sum in module __builtin__:
...
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
== 3 of 4 ==
Date: Wed, Jan 8 2014 12:15 pm
From: roy@panix.com (Roy Smith)
In article <mailman.5194.1389210743.18130.python-list@python.org>,
Roy Smith <roy@panix.com> wrote:
>I'm working with ipython's pylab mode, which replaces the builtin sum() =
>with the one from numpy:
>[...]
>Is there any way to recover a reference to the builtin sum()?
Sigh. I figured this out myself. What you want is __builtins__.sum ...
BUT, not only does pylab overwrite sum(), it overwrites __builtins__
as well! Instead of a module, it's now a dict. You can still get at
the builtin sum, but you need to do __builtins__["sum"]
========================================================
$ ipython
Python 2.7.3 (default, Aug 1 2012, 05:14:39)
Type "copyright", "credits" or "license" for more information.
IPython 0.12.1 -- An enhanced Interactive Python.
[...]
In [1]: type(__builtins__)
Out[1]: module
========================================================
$ ipython --pylab
Python 2.7.3 (default, Aug 1 2012, 05:14:39)
Type "copyright", "credits" or "license" for more information.
IPython 0.12.1 -- An enhanced Interactive Python.
[...]
In [1]: type(__builtins__)
Out[1]: dict
========================================================
I am slowly coming to the conclusion that the best way to deal with
pylab is to not use it. Overwriting sum() with a different sum() I
can accept, as a useful shortcut. Overwriting __builtins__ seems like
wanton vandalism of the namespace.
== 4 of 4 ==
Date: Wed, Jan 8 2014 12:24 pm
From: Peter Otten <__peter__@web.de>
Roy Smith wrote:
> I'm working with ipython's pylab mode, which replaces the builtin sum()
> with the one from numpy:
>
> In [105]:
> sum
>
> Out[105]:
> <function numpy.core.fromnumeric.sum>
>
> Is there any way to recover a reference to the builtin sum()?
>>> from numpy import *
>>> sum
<function sum at 0x7fb99782cc08>
>>> del sum
>>> sum
<built-in function sum>
Doing it more than once does no harm:
>>> del sum
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'sum' is not defined
>>> sum
<built-in function sum>
==============================================================================
TOPIC: Understanding decorator and class methods
http://groups.google.com/group/comp.lang.python/t/04ed45036450248b?hl=en
==============================================================================
== 1 of 1 ==
Date: Wed, Jan 8 2014 11:56 am
From: axis.of.weasel@gmail.com
can someone please explain why the following works, in contrast to the second example?
def decorator(func):
def on_call(*args):
print args
return func(args)
return on_call
class Foo:
@decorator
def bar(self, param1):
print 'inside bar'
f=Foo()
f.bar(4) # from where is the decorator getting the Foo instance?
I understand why the following works/does not work
class decorator2:
def __init__(self, func):
self.func=func
def __call__(self, *args):
self.func(*args)
class Foo2:
@decorator2
def bar2(self, param): pass
f2 = Foo2()
Foo2.bar2(f2, 4) # works, Foo2 instance and param are passed to decorator2 call
f2.bar2(4) # does not work, Foo2 instance is missing, decorator2 cannot invoke method bar
==============================================================================
TOPIC: the Gravity of Python 2
http://groups.google.com/group/comp.lang.python/t/0afb505736567141?hl=en
==============================================================================
== 1 of 1 ==
Date: Wed, Jan 8 2014 12:45 pm
From: Terry Reedy
On 1/8/2014 9:15 AM, Roy Smith wrote:
> As somebody who is still firmly in the 2.x world, I'm worried about the
> idea of a 2.x fork. While I have my doubts that 3.x was a good idea,
> the fact is, it's here. Having the community fractured between the two
> camps is not good. Let's say I'm somebody who wants to contribute some
> OSS. I have three basic choices:
>
> 1) I can make it 3.x only. Now, (nominally) half of the python
> community is unable to realize value from my contribution.
>
> 2) I can make it 2.x only. Same thing in reverse.
>
> 3) I can make it work on both 2.x and 3.x, which means I'm investing
> more effort than I had to if it were single platform.
>
> Any of those alternatives is worse than ideal. Forking 2.x to create an
> unofficial 2.8 release would just prolong the situation. As I've stated
> before, I don't see any urgency in moving to 3.x, and don't imagine
> doing there for another couple of years, but I absolutely can't imagine
> moving to a 2.8 fork.
This question cannot be answered generically.
I think it worth noting that in part this is the same dilemma as 'how
many versions to support' within each of 2.x and 3.x. Limiting code to
3.3+ allows use of the new asyncio module (via Pypy for 3.3) and the new
FSR unicode. Use of asyncio or FSR features* also forces the choice you
give above as neither can be backported to 2.7.
* IE, support of all of unicode on all Python systems with
straightforward code, without contortions.
If I were giving away 'stand-alone' application code whose dependencies
were available on both 2.7 and 3.x+, I would write for 3.x+ on the basis
that everyone could install 3.x, and that new users are increasingly
likely to only have 3.x only. I would have little sympathy for
organizations that prohibit 3.x -- unless they were to pay me to.
For numerical or combinatorial code, adding 'from __future__ import
division' (which I think one should do anyway for 2.x code) might be the
only extra work needed for option 3).
--
Terry Jan Reedy
==============================================================================
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