Re: Logging all uncaught exceptions

2014-07-14 Thread Steven D'Aprano
On Mon, 14 Jul 2014 06:09:32 +, Steven D'Aprano wrote:

> I want to catch all uncaught exceptions in my application, log them,
> then handle as normal. Which, in practice, means a traceback. Is this
> the right way to do it?

I think I've answered my own question, which leads to the next question.

I'm logging with the syslog handler, and I can see all the logged 
messages *except* those generated by my logger's exception method.

Here's my code, consisting of two modules:


# === mylogging.py ===
import logging
import logging.handlers

name = 'Spam'
mylogger = logging.getLogger(name)
handler = logging.handlers.SysLogHandler(address='/dev/log')
mylogger.addHandler(handler)
mylogger.setLevel(logging.DEBUG)
mylogger.info('started logging ' + name)


# === main.py ===
from mylogging import mylogger
mylogger.info('main.py running')
mylogger.debug('I can see debugging messages too')

import sys
def my_error_handler(type, value, tb):
msg = "Uncaught %s: %s" % (type, value)
mylogger.exception(msg)
sys.__excepthook__(type, value, tb)

# Install exception handler.
sys.excepthook = my_error_handler

mylogger.info('testing exception logging...')
raise RuntimeError('a fake error occurred')



I run it from the command line on a Debian squeeze system:

steve@runes:~/test_logging$ python2.6 main.py 
Traceback (most recent call last):
  File "main.py", line 15, in 
raise RuntimeError('a fake error occurred')
RuntimeError: a fake error occurred


The debug and info messages are logged:

root@runes:/var/log# tail -1 debug
Jul 14 19:04:39 runes I can see debugging messages too

root@runes:/var/log# tail -3 messages
Jul 14 19:04:39 runes started logging Spam
Jul 14 19:04:39 runes main.py running
Jul 14 19:04:39 runes testing exception logging...


but the exception info which should have been generated by 
mylogger.exception doesn't appear anywhere I can see.


What am I doing wrong?


-- 
Steven
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Logging all uncaught exceptions

2014-07-14 Thread Chris Angelico
On Mon, Jul 14, 2014 at 7:07 PM, Steven D'Aprano  wrote:
> but the exception info which should have been generated by
> mylogger.exception doesn't appear anywhere I can see.
>
>
> What am I doing wrong?

I'm not specifically familiar with the logging module, but something
I'd look at would be 'ls /var/log -lt|head' to see what files get
updated. (Works well with 'watch' - a file gets changed, it jumps up
to the top of the list.) Maybe the exceptions are going into a
different file (they go at the ERROR level, IIUI). If that doesn't
help: the exception method says "This method should only be called
from an exception handler", so I don't know if it uses magic to get
extra info. What happens if you explicitly use .debug() instead?

But you probably know a lot more about this than I do.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Logging all uncaught exceptions

2014-07-14 Thread Steven D'Aprano
On Mon, 14 Jul 2014 19:21:44 +1000, Chris Angelico wrote:

> On Mon, Jul 14, 2014 at 7:07 PM, Steven D'Aprano 
> wrote:
>> but the exception info which should have been generated by
>> mylogger.exception doesn't appear anywhere I can see.
>>
>>
>> What am I doing wrong?
> 
> I'm not specifically familiar with the logging module, but something I'd
> look at would be 'ls /var/log -lt|head' to see what files get updated.
> (Works well with 'watch' - a file gets changed, it jumps up to the top
> of the list.) Maybe the exceptions are going into a different file (they
> go at the ERROR level, IIUI). 

That's it! Thanks.

Under Debian, ERROR level messages go to /var/log/syslog instead of debug 
or messages.



-- 
Steven
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Multiprocessing question

2014-07-14 Thread Roy Smith
In article <53c34400$0$9505$c3e8da3$54964...@news.astraweb.com>,
 Steven D'Aprano  wrote:

> On Sun, 13 Jul 2014 19:53:09 -0400, Paul LaFollette wrote:
> 
> > I have thrown together a little C/UNIX program that forks a child
> > process, then proceeds to let the child and parent alternate.  Either
> > can run until it pauses itself and wakes the other.
> > 
> > I would like to know if there be a way to create the same behavior in
> > Python 3, preferably in a non-platform dependent fashion.

[...]
> But the best way to solve this in a platform independent way is to use 
> one of the concurrency modules:
> 
> https://docs.python.org/3/library/concurrency.html
> 
> such as multiprocessing. Although these are written for Python 2 rather 
> than 3, you may find them useful:
> 
> http://pymotw.com/2/multiprocessing/index.html#module-multiprocessing
> 
> https://www.ibm.com/developerworks/aix/library/au-multiprocessing/

Let me toss out one other possibility.  If you are going to build some 
kind of message queue between two processes, you might want to look at 
an external queue mechanism such as http://kr.github.io/beanstalkd/ or 
http://www.celeryproject.org/.  The advantage of these over rolling your 
own using the built-in Python modules is they handle a lot of queueing, 
locking, and persistence problems which you might end up having to deal 
with yourself.

They also give you the ability to locate the two processes on different 
machines.  You might not want to do that today, but if your application 
grows, it might be how you want to scale your processing power.  It is 
easy, for example, to have one process pushing tasks onto the queue, and 
a large number of workers pulling them off.  The producer doesn't have 
to know anything about how many workers there are (nor does there need 
to be a fixed number).

They are also language independent.  You might discover at some point in 
the future that you want to rewrite one side of the queue in a different 
language for some reason (perhaps to take advantage of a library that's 
not available in Python).  A queue like Beanstalk or Celery makes that 
easy.  Of course, to do this, you would need to format your messages in 
some language-neutral way (JSON, MessagePack, etc).
-- 
https://mail.python.org/mailman/listinfo/python-list


Do I need to call close on the handle returned by urlopen?

2014-07-14 Thread krzysztof.zelechowski

The tutorial says that I should use "with open" to close the file handle
properly.  The reference documentation for urlopen mentions that the handle
returned is like a file handle but the code samples below do not bother to
close the handle at all.  Isn’t it inconsistent? 


--
https://mail.python.org/mailman/listinfo/python-list


Re: Do I need to call close on the handle returned by urlopen?

2014-07-14 Thread Skip Montanaro
> The tutorial says that I should use "with open" to close the file
> handle properly.  The reference documentation for urlopen mentions
> that the handle returned is like a file handle but the code samples
> below do not bother to close the handle at all.  Isn’t it
> inconsistent?

I think two things might be happening here.

1. Code samples are just that. They often demonstrate usage with the
smallest amount of code possible, so that the key part of what they
are demonstrating isn't lost in a bunch of other clutter. That often
means leaving out error checking and not completely cleaning up after
themselves, especially if those bits might obscure the actual concept
being conveyed.

2. The "with" statement is (relative to many other parts of the
language) still pretty new, so it's not all that surprising that
examples in the documentation haven't all been updated to reflect the
latest recommended practice.

Skip
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Do I need to call close on the handle returned by urlopen?

2014-07-14 Thread krzysztof.zelechowski

http://bugs.python.org/issue12955

Użytkownik  napisał w wiadomości grup 
dyskusyjnych:lq0sar$r6e$1...@mx1.internetia.pl...


The tutorial says that I should use "with open" to close the file handle
properly.  The reference documentation for urlopen mentions that the handle
returned is like a file handle but the code samples below do not bother to
close the handle at all.  Isn’t it inconsistent? 


--
https://mail.python.org/mailman/listinfo/python-list


python-aware wdiff?

2014-07-14 Thread Roy Smith
Does anybody know of a wdiff-like tool (http://www.gnu.org/software/wdiff/) 
which is aware of python syntax and can show token changes instead of word 
changes.  Wdiff is can turn

-if not metar.is_in_temp_range_f(situation.weather.low_temperature, 
situation.weather.high_temperature):
+if not info.is_in_temp_range_f(situation.weather.low_temperature, 
situation.weather.high_temperature):

into

if not [-metar.is_in_temp_range_f(situation.weather.low_temperature,-] 
{+info.is_in_temp_range_f(situation.weather.low_temperature,+} 
situation.weather.high_temperature):

but what I really want is:

if not 
[-metar-]{+info+}.is_in_temp_range_f(situation.weather.low_temperature, 
situation.weather.high_temperature):

which makes it more obvious that the change is just the one token.  Does such a 
tool exist?

---
Roy Smith
r...@panix.com



-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Do I need to call close on the handle returned by urlopen?

2014-07-14 Thread Mark Lawrence

On 14/07/2014 15:59, krzysztof.zelechow...@syncron.com wrote:

The tutorial says that I should use "with open" to close the file handle
properly.  The reference documentation for urlopen mentions that the handle
returned is like a file handle but the code samples below do not bother to
close the handle at all.  Isn’t it inconsistent?


Yes it is.  The latter probably hasn't been updated after the 
introduction of the 'with' keyword and context managers.  Would you like 
to click on the "Report a bug" link on the page in question and suggest 
a change?


--
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 protection 
is active.
http://www.avast.com


--
https://mail.python.org/mailman/listinfo/python-list


Not enough memory.

2014-07-14 Thread 水静流深
>>> import os
>>> help(os.path)
Not enough memory.‍

Why i get it?Not enough memory , not help info?,not-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Not enough memory.

2014-07-14 Thread Mark Lawrence

On 14/07/2014 14:16, 水静流深 wrote:

 >>> import os
 >>> help(os.path)
Not enough memory.‍

Why i get it?Not enough memory , not help info?,not



A known problem see http://bugs.python.org/issue19914

--
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 protection 
is active.
http://www.avast.com


--
https://mail.python.org/mailman/listinfo/python-list


Re: Not enough memory.

2014-07-14 Thread Zachary Ware
On Mon, Jul 14, 2014 at 8:16 AM, 水静流深 <1248283...@qq.com> wrote:
 import os
 help(os.path)
> Not enough memory.‍
>
> Why i get it?Not enough memory , not help info?,not

In future, it's very helpful to tell us what OS is running which
version of Python when you get an error, but in this case I'm betting
on Python 3 on Windows with code page 65001 active:

C:\>chcp 65001
Active code page: 65001

C:\>py -3
Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600
32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> help(help)
Not enough memory.

>>> exit()

C:\>chcp 437
Active code page: 437

C:\>py -3
Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600
32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> help(help)
Help on _Helper in module _sitebuiltins object:
...

The 'Not enough memory.' message is actually coming from the Windows
'more' utility (C:\Windows\System32\more.com), as stated in the bug
linked to in Mark's message.  To work around that, you can either use
a different codepage (anecdotal evidence tells me that cp65001 is
barely supported by anything, even Windows itself), or set the PAGER
environment variable to "type", which will disable paging, but allow
the help text to print.

-- 
Zach
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: NaN comparisons - Call For Anecdotes

2014-07-14 Thread Anders J. Munch

alister wrote:

I don't have time to start this discussion over again on another mailing
list.
Don't anyone on those lists read python-list also?

they possibly do, but prefer to keep discussions to the proper forum


The semantics of the Python programming language is on-topic for python-list. 
This is about float.__eq__, not about numpy or SciPy.

Maybe they just don't like beer?

regards, Anders

--
https://mail.python.org/mailman/listinfo/python-list


Re: Not enough memory.

2014-07-14 Thread Mark Lawrence

On 14/07/2014 17:40, Zachary Ware wrote:

On Mon, Jul 14, 2014 at 8:16 AM, 水静流深 <1248283...@qq.com> wrote:

import os
help(os.path)

Not enough memory.‍

Why i get it?Not enough memory , not help info?,not


In future, it's very helpful to tell us what OS is running which
version of Python when you get an error, but in this case I'm betting
on Python 3 on Windows with code page 65001 active:

C:\>chcp 65001
Active code page: 65001

C:\>py -3
Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600
32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.

help(help)

Not enough memory.


exit()


C:\>chcp 437
Active code page: 437

C:\>py -3
Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600
32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.

help(help)

Help on _Helper in module _sitebuiltins object:
...

The 'Not enough memory.' message is actually coming from the Windows
'more' utility (C:\Windows\System32\more.com), as stated in the bug
linked to in Mark's message.  To work around that, you can either use
a different codepage (anecdotal evidence tells me that cp65001 is
barely supported by anything, even Windows itself), or set the PAGER
environment variable to "type", which will disable paging, but allow
the help text to print.



See also https://bugs.python.org/issue21927, specifically msg222761

--
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 protection 
is active.
http://www.avast.com


--
https://mail.python.org/mailman/listinfo/python-list


Re: NaN comparisons - Call For Anecdotes

2014-07-14 Thread Mark Lawrence

On 14/07/2014 17:44, Anders J. Munch wrote:

alister wrote:

I don't have time to start this discussion over again on another mailing
list.
Don't anyone on those lists read python-list also?

they possibly do, but prefer to keep discussions to the proper forum


The semantics of the Python programming language is on-topic for
python-list. This is about float.__eq__, not about numpy or SciPy.
Maybe they just don't like beer?

regards, Anders



Maybe they recognise the eqivalent of our resident unicode expert.

--
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 protection 
is active.
http://www.avast.com


--
https://mail.python.org/mailman/listinfo/python-list


Re: NaN comparisons - Call For Anecdotes

2014-07-14 Thread Ian Kelly
On Mon, Jul 14, 2014 at 10:44 AM, Anders J. Munch <2...@jmunch.dk> wrote:
> alister wrote:
>>
>> I don't have time to start this discussion over again on another mailing
>> list.
>> Don't anyone on those lists read python-list also?
>>
>> they possibly do, but prefer to keep discussions to the proper forum
>
>
> The semantics of the Python programming language is on-topic for
> python-list. This is about float.__eq__, not about numpy or SciPy.
> Maybe they just don't like beer?

Well, I don't see anybody with numerical expertise chiming in here to
say they agree with you either, so that tells me you've probably got
the wrong audience.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python-aware wdiff?

2014-07-14 Thread Terry Reedy

On 7/14/2014 11:12 AM, Roy Smith wrote:

Does anybody know of a wdiff-like tool
(http://www.gnu.org/software/wdiff/) which is aware of python syntax and
can show token changes instead of word changes.  Wdiff is can turn

-if not metar.is
_in_temp_range_f(situation.weather.low_temperature,
situation.weather.high_temperature):
+if not info.is
_in_temp_range_f(situation.weather.low_temperature,
situation.weather.high_temperature):

into

 if not
[-metar.is_in_temp_range_f(situation.weather.low_temperature,-]
{+info.is_in_temp_range_f(situation.weather.low_temperature,+}
situation.weather.high_temperature):

but what I really want is:

 if not
[-metar-]{+info+}.is_in_temp_range_f(situation.weather.low_temperature,
situation.weather.high_temperature):

which makes it more obvious that the change is just the one token.  Does
such a tool exist?


The under-known difflib.differ shows within line differences.
Your example would look like:

-if not metar.is_in_temp_range_f(...):
?   ^
+if not info.is_in_temp_range_f
?   

Deletions and insertions are indicated with '-' and '+'.
I use this routinely, when backporting patches, in a script that differs 
the 2.7 and 3.4 versions of repository files.


--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


Re: Twitter Client on Terminal by Python

2014-07-14 Thread Terry Reedy

On 7/13/2014 11:51 PM, Chris Angelico wrote:

On Mon, Jul 14, 2014 at 12:18 PM, Orakaro  wrote:

I use README.md for Github and README.rst for PyPi. Is there a way to use only 
one file for both sites ?


Ah. I don't know; check the docs for one or the other and see what they'll do.


I tested my package on Python 2.7 and Python 3.4 But do I have to install all 
Python 2.6, Python 3.* in my system and test in all environment for sure ?


You don't *have* do anything for free. However, if your package works on 
2.7 and 3.4, it *probably* works as is for 3.2 and 3.3. On Windows at 
least, installing multiple versions is trivial (5 minutes for each).


The more important issue, I think, is what system you have tested on. Up 
to 3.2, including all 2.x, Python had 'wide' and 'narrow' unicode 
builds. On narrow builds (Windows, some *nix), astral (non-BMP) chars 
count as 2. Given Twitter's 140 char limitation, this bug (solved in 
3.3) could affect a Twitter client by giving the length of a 140 char 
tweet as more than 140 chars.



You can state that it supports 2.7 and 3.4, without testing on any
other versions. Those are the two current versions - my example was
showing support for more than just the one latest, but that was just
an example, nothing more. When Python 3.5 comes out, you'll probably
want to test on that (and then say "supports 2.7 and 3.4+"), but at
the moment, "2.7 and 3.4" is fine. If people want to use this with,
say, 3.3, then they're welcome to try, but they'll know not to presume
that it'll work.


Even if you test on, say, 2.6, it is up to you whether you want to 
'support' 2.6 with bugfixes, in case a patch for 2.7 does not work on 2.6.


--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


Re: python-aware wdiff?

2014-07-14 Thread Ian Kelly
On Mon, Jul 14, 2014 at 2:01 PM, Terry Reedy  wrote:
> The under-known difflib.differ shows within line differences.
> Your example would look like:
>
> -if not metar.is_in_temp_range_f(...):
> ?   ^
> +if not info.is_in_temp_range_f
> ?   
>
> Deletions and insertions are indicated with '-' and '+'.
> I use this routinely, when backporting patches, in a script that differs the
> 2.7 and 3.4 versions of repository files.

That will produce a minimal diff though, not a syntax-aware diff. If
the latter is important, something could probably be cooked up using
tokenize and difflib. Not sure how much work that would be.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3 is killing Python

2014-07-14 Thread Rick Johnson
On Wednesday, May 28, 2014 3:15:45 PM UTC-5, Chris Angelico wrote:
> On Thu, May 29, 2014 at 5:58 AM, Larry Martell wrote:
> > No company that I work for is using python 3 - they just
> > have too much of an investment in a python 2 code base
> > to switch. I'm just saying.
> And that's not a problem. Every whinging blog author seems
> to forget [...] Or maybe the complaint is that there are
> fancy new features in Python 3.x that aren't in 2.7? Oh
> wait, that directly contradicts the whine. So if Python 3
> has added nothing, what's the rush to move onto it?

What's wrong with people wanting new features WITHOUT
suffering through the headaches of porting code? I think
your missing the point Chris.

You and i both know that most of the features could be added
without breaking Python, but the choice was made to break
Python anyway, and that would have been fine IF the powers
that be would have REALLY made Python better, but they
only "slightly" improved the language!

Look, along the course of ANY learning curve, a designer, or
an artist, or an engineer, is going to realize he made some
catastrophic mistakes -- okay, no problem, we are ALL but
human after all, even the "Anointed One" is not beyond
mistakes, HOWEVER, the choice to fracture a community over
"minor improvements" was a poor choice and i think some
"owning up" is in order!

Also, this "idea" of yours that people should just shut up
and do what the "regime" commands, is just utter nonsense.
Python is a public offering, and as such is equally subject
to both praise and ridicule.

FREEDOM OF SPEECH IS A REAL BEECH!

If the "powers that be" cannot handle the heat, then they
should withdraw Python from the public and then they can
decree any ridiculous fascist rules they please, until then,
what's that old adage about "reaping" and "sewing"...?

QUESTION:
"What's worse than fracturing a community?"

ANSWER:
"Creating a leadership vacuum."

--And nature *abhors* a vacuum!

Besides, "opposing and competing forces" are a fundamental
part of evolution (psst: do you remember that little thing
called "evolution" Chris?) and so we must NEVER forget the
absolute necessity of dissent! Just think of what our world
would be like if every idea was NOT placed under the
microscope for scrutiny.

I SHUTTER TO THINK!

Image, for a moment, a world WITHOUT the great USA! Yes, i
know you little commies love to curse the USA, and yes,
there are many dark sins committed within AND beyond her
borders, but try to tell me you bass-turds, what nation in
modern history has contributed more technological
achievements [1] or engendered a revolution of social
justice around the world, or, propagated the idea that all
men are created equal and endowed by their creator with
unalienable rights? What would have happened if the colonies
just threw their hands and and said:

"WELL, GEORGE KNOWS BEST!"

> Whiners gonna whine.

And brown-nosing little shills gonna shill!

[1]: even IF many of them were "borrowed". HEY, TO THE VICTOR GO THE SPOILS!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3 is killing Python

2014-07-14 Thread Rick Johnson
On Wednesday, May 28, 2014 7:41:53 PM UTC-5, Terry Reedy wrote:
> Claim: "Python 3 languishes in disuse."
> Fact: in 2013, there were around 14 million downloads of
> windows installers for each of 2.7.x and 3.3.x. 3.3 is
> over twice as popular as 3.2 (to be expected).

Terry, you cannot simply take the download numbers as a
"one-to-one" ratio representing the "actual" usage of
anything. 

Consider:

* HOW MANY DOWNLOADED AND NEVER USED?

Might be difficult to believe, but i am one of those people.
Even though i don't "actively" write code for Python3, i
still keep a current version on my machine just in case i
need to test a code snippet for a NOOB -- i don't remember
the last time i even ran Python 3, must have been a year or
more!

* HOW MANY DOWNLOADED, TRIED, CURSED, AND NEVER USED
  AGAIN?

* HOW MANY DOWNLOADED, TRIED, CURSED, AND ONLY USE
  BECAUSE THEY ARE FORCED?
  
* HOW MANY DOWNLOADED, TRIED, WERE "AMUSED", BUT NOT
  ENOUGH TO ACTUALLY WRITE 3.X CODE?

* HOW MANY DOWNLOADED, TRIED, LIKED, AND ARE "ACTIVELY"
  WRITING 3.X CODE?

I would venture to say that at least half the downloads fall
into the first three categories, and the other half are split
between the last two categories -- equally split, WHO KNOWS!

Sheesh! Metrics measured on download statistics are about as
reliable as that ridiculous TIOBE drivel, hey, watching
Python climb the index might give GvR a raging semi, but
only a moron would take it for truth!

PIPING HOT CUP OF WISHFUL THINKING ANYONE?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3 is killing Python

2014-07-14 Thread mm0fmf

On 14/07/2014 23:12, Rick Johnson wrote:

  I SHUTTER TO THINK!


It's "I shudder to think"!

shut·ter  [shuht-er]

noun
1. a solid or louvered movable cover for a window.
2. a movable cover, slide, etc., for an opening.
3. a person or thing that shuts.
4. Photography . a mechanical device for opening and closing the 
aperture of a camera lens to expose film or the like.


verb (used with object)
5. to close or provide with shutters: She shuttered the windows.
6. to close (a store or business operations) for the day or permanently.

shud·der  [shuhd-er]

verb (used without object)
1. to tremble with a sudden convulsive movement, as from horror,fear, or 
cold.

noun
2. a convulsive movement of the body, as from horror, fear, or cold.


--
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3 is killing Python

2014-07-14 Thread MRAB

On 2014-07-14 23:12, Rick Johnson wrote:

On Wednesday, May 28, 2014 3:15:45 PM UTC-5, Chris Angelico wrote:

On Thu, May 29, 2014 at 5:58 AM, Larry Martell wrote:

No company that I work for is using python 3 - they just have too
much of an investment in a python 2 code base to switch. I'm just
saying.

And that's not a problem. Every whinging blog author seems to
forget [...] Or maybe the complaint is that there are fancy new
features in Python 3.x that aren't in 2.7? Oh wait, that directly
contradicts the whine. So if Python 3 has added nothing, what's the
rush to move onto it?


What's wrong with people wanting new features WITHOUT suffering
through the headaches of porting code? I think your missing the point
Chris.

You and i both know that most of the features could be added without
breaking Python, but the choice was made to break Python anyway, and
that would have been fine IF the powers that be would have REALLY
made Python better, but they only "slightly" improved the language!

Look, along the course of ANY learning curve, a designer, or an
artist, or an engineer, is going to realize he made some catastrophic
mistakes -- okay, no problem, we are ALL but human after all, even
the "Anointed One" is not beyond mistakes, HOWEVER, the choice to
fracture a community over "minor improvements" was a poor choice and
i think some "owning up" is in order!

Also, this "idea" of yours that people should just shut up and do
what the "regime" commands, is just utter nonsense. Python is a
public offering, and as such is equally subject to both praise and
ridicule.

FREEDOM OF SPEECH IS A REAL BEECH!

If the "powers that be" cannot handle the heat, then they should
withdraw Python from the public and then they can decree any
ridiculous fascist rules they please, until then, what's that old
adage about "reaping" and "sewing"...?


Why it should "they" withdraw it (whatever that means)?

"They" are entitled to keep it public if they want to.

Those who aren't interested are not obliged to take any notice of it,
and any group or individual who wants to develop Python 2 further can
just fork Python 2.7 and continue from there.


QUESTION: "What's worse than fracturing a community?"

ANSWER: "Creating a leadership vacuum."

--And nature *abhors* a vacuum!

Besides, "opposing and competing forces" are a fundamental part of
evolution (psst: do you remember that little thing called "evolution"
Chris?) and so we must NEVER forget the absolute necessity of
dissent! Just think of what our world would be like if every idea was
NOT placed under the microscope for scrutiny.


Evolution is also about competition, and there's nothing stopping
someone creating a fork of Python 2 to compete with Python 3.


I SHUTTER TO THINK!


[snip]
BTW, that's "SHUDDER", not "SHUTTER".
--
https://mail.python.org/mailman/listinfo/python-list


initializing "parameters" class in Python only once?

2014-07-14 Thread Catherine M Moroney

Hello,

Pardon me for not using the proper Python language terms, but I hope 
that people can still understand the question:


The problem:  I'm writing a large Python program and I have a bunch of
parameters (whose values are static) that I want to make available to
the rest of the code with minimum overhead and duplicate processing.

I think that the simplest way would be to create a file called 
"Params.py" and then simply have statements like a = 1, b = 2, etc.
in there (no classes, no methods, just a bunch of declarations).  But, 
some of these static parameters have to be calculated rather than simply 
hard-coded.


I thought of creating a class called Params and having a bunch of
methods (decorated with @classmethod) that set/calculate the value of
all the parameters.  Easy enough, but then I have to create a Params
object in every source file that uses these parameters, and that seems
wasteful.

The actual scope of the problem is very small, so memory/cpu time is not
an issue.  I'm just looking for the most pythonic/elegant way of doing this.

What is the recommended way of passing a bunch of static (hard-coded and 
calculated) parameters to various parts of the code?


Thank you for any advice,

Catherine
--
https://mail.python.org/mailman/listinfo/python-list


initializing "parameters" class in Python only once?

2014-07-14 Thread Catherine M Moroney

Hello,

Pardon me for not using the proper Python language terms, but I hope 
that people can still understand the question:


The problem:  I'm writing a large Python program and I have a bunch of
parameters (whose values are static) that I want to make available to
the rest of the code with minimum overhead and duplicate processing.

I think that the simplest way would be to create a file called 
"Params.py" and then simply have statements like a = 1, b = 2, etc.
in there (no classes, no methods, just a bunch of declarations).  But, 
some of these static parameters have to be calculated rather than simply 
hard-coded.


I thought of creating a class called Params and having a bunch of
methods (decorated with @classmethod) that set/calculate the value of
all the parameters.  Easy enough, but then I have to create a Params
object in every source file that uses these parameters, and that seems
wasteful.

The actual scope of the problem is very small, so memory/cpu time is not
an issue.  I'm just looking for the most pythonic/elegant way of doing this.

What is the recommended way of passing a bunch of static (hard-coded and 
calculated) parameters to various parts of the code?


Thank you for any advice,

Catherine
--
https://mail.python.org/mailman/listinfo/python-list


Re: initializing "parameters" class in Python only once?

2014-07-14 Thread Rob Gaddi
On Mon, 14 Jul 2014 15:24:26 -0700
Catherine M Moroney  wrote:

> Hello,
> 
> Pardon me for not using the proper Python language terms, but I hope 
> that people can still understand the question:
> 
> The problem:  I'm writing a large Python program and I have a bunch of
> parameters (whose values are static) that I want to make available to
> the rest of the code with minimum overhead and duplicate processing.
> 
> I think that the simplest way would be to create a file called 
> "Params.py" and then simply have statements like a = 1, b = 2, etc.
> in there (no classes, no methods, just a bunch of declarations).  But, 
> some of these static parameters have to be calculated rather than simply 
> hard-coded.
> 
> I thought of creating a class called Params and having a bunch of
> methods (decorated with @classmethod) that set/calculate the value of
> all the parameters.  Easy enough, but then I have to create a Params
> object in every source file that uses these parameters, and that seems
> wasteful.
> 
> The actual scope of the problem is very small, so memory/cpu time is not
> an issue.  I'm just looking for the most pythonic/elegant way of doing this.
> 
> What is the recommended way of passing a bunch of static (hard-coded and 
> calculated) parameters to various parts of the code?
> 
> Thank you for any advice,
> 
> Catherine

You're 90% of the way there.  You can just create params.py, fill it
with statements that are either hard-coded or calculated as necessary,
and import params from all over the rest of the program.  Once the
interpreter has imported it for the first time, everyone else just gets
a link to the same instance of the module rather than running it all
over and over again.

-- 
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
Email address domain is currently out of order.  See above to fix.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: initializing "parameters" class in Python only once?

2014-07-14 Thread Chris Kaynor
On Mon, Jul 14, 2014 at 3:24 PM, Catherine M Moroney <
catherine.m.moro...@jpl.nasa.gov> wrote:

> Hello,
>
> Pardon me for not using the proper Python language terms, but I hope that
> people can still understand the question:
>
> The problem:  I'm writing a large Python program and I have a bunch of
> parameters (whose values are static) that I want to make available to
> the rest of the code with minimum overhead and duplicate processing.
>
> I think that the simplest way would be to create a file called "Params.py"
> and then simply have statements like a = 1, b = 2, etc.
> in there (no classes, no methods, just a bunch of declarations).  But,
> some of these static parameters have to be calculated rather than simply
> hard-coded.
>

Within a module (such as "Params.py"), you can put any statements or code
you want, without needing classes or functions. Depending on the complexity
of the calculations, you may want to put some of the functionality into
functions, which could then be run on import (just put the function call at
the bottom of the module file).

The interpreter will take care to only import one copy, with the exception
of if the Params.py file is accessible from multiple paths in sys.path
(generally not an issue).

For example, the following is a valid module (untested):
# Params.py
a = 1
b = 5
c = a * b + 42
d = c - b
# End Params.Py

You could also go farther and read external configuration files at the root
scope. The main thing to remember is that all intermediate variables will
be visible outside, and thus should be prefixed with an underscore
(Python's standard for private).

I thought of creating a class called Params and having a bunch of
> methods (decorated with @classmethod) that set/calculate the value of
> all the parameters.  Easy enough, but then I have to create a Params
> object in every source file that uses these parameters, and that seems
> wasteful.
>

If all the methods of a class as decorated with @classmethod or
@staticmethod, and all variables are declared on the class, and not inside
of any non-class/static methods (include __init__), you would not need to
create instances of the object.

For example, if you have a class like follows (untested):

class Params():
myVar = 0
@classmethod
def myMethod(cls):
cls.myVar += 1
return cls.myVar

you can access them without an instance, by using Params.myVar or
Params.myMethod().


> The actual scope of the problem is very small, so memory/cpu time is not
> an issue.  I'm just looking for the most pythonic/elegant way of doing
> this.
>

For most configuration, I would recommend using a combination of the above.
Create the module and place some configuration variables inside the module
directly. Use classes (which shouldn't be instantiated) for namespacing. If
you start to get a LOT of parameters, you may also want to consider making
the entire params a package (folder/directory) with multiple modules and
possibly classes, however that is likely overkill.

Note that, in any case, I would recommend treating the parameters as
constants, meaning do not change their values, except during the
initialization of the parameters module. This is mostly to ensure
thread-safety and prevent difficult to track bugs.


>
> What is the recommended way of passing a bunch of static (hard-coded and
> calculated) parameters to various parts of the code?
>
> Thank you for any advice,
>
> Catherine
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3 is killing Python

2014-07-14 Thread Chris Angelico
On Tue, Jul 15, 2014 at 8:12 AM, Rick Johnson
 wrote:
> If the "powers that be" cannot handle the heat, then they
> should withdraw Python from the public and then they can
> decree any ridiculous fascist rules they please, until then,
> what's that old adage about "reaping" and "sewing"...?

You've already been told about "shutter" vs "shudder", but I'd like to
also point out that this would be "sowing", as it's a reference to
this passage from the Bible:

https://www.biblegateway.com/passage/?search=Galatians+6%3A7-8&version=NIV

which is itself a reference to the work of planting (sowing seeds) and
then harvesting (reaping).

> Besides, "opposing and competing forces" are a fundamental
> part of evolution (psst: do you remember that little thing
> called "evolution" Chris?)

Actually, no. I don't remember evolving from anything else. Do you?
Because I've always been the same thing I am now. What am I supposed
to be remembering, exactly?

> Image, for a moment, a world WITHOUT the great USA!

"Imagine". If you were worth the effort, I could easily "image" a
world without the USA, by Photoshopping something out of a world map.
(I'd probably use the Gimp, or Pike's image manipulation libraries,
but everyone knows what Photoshopping is.)

And I know what would happen if the USA weren't here. People in other
countries would have made similar improvements to the world. Oh, and
just for reference, I'm not in the US. I'm an Aussie, and we boast a
fairly impressive per-capita invention rate. Some of them (like the
stump-jump plough) are specific to our peculiar land, but there are
plenty of awesome tools of general interest that have come from here.
Just start poking around in various technical documents (RFCs, ISO and
ANSI standards, etc, etc) and see how many contributors' addresses say
Australia; chances are it'll be a lot more than our ~20M population
would suggest. There are a few European countries that, similarly,
contribute far more than their apparent size would imply.

> what nation in
> modern history has contributed more technological
> achievements [1] or engendered a revolution of social
> justice around the world, or, propagated the idea that all
> men are created equal and endowed by their creator with
> unalienable rights?

Social justice? Do you honestly think the USofA is the example to hold
up and say "Look, we have perfectly solved the problems of social
injustice"? I guess you've eliminated racism since I last heard.

Oh, and I agree that all people are created equal. (I'll leave aside
the argument about whether your statement is proof that English is
sexist, or that the US founding fathers were the sexist ones.) I also
believe that our Creator sees us as equal. But all through history, we
flawed human beings have had a problem with seeing people differently,
for various reasons. The Apostle James wrote about a major problem
with "wealthist" Christians:

https://www.biblegateway.com/passage/?search=James+2%3A1-4&version=NIV

And there've been plenty of other problems creeping in. God treats us
all the same way: flawed, fallible people whom He loves enough to die
for. If you want to believe in true equality, you need to follow His
example.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: initializing "parameters" class in Python only once?

2014-07-14 Thread Chris Angelico
On Tue, Jul 15, 2014 at 8:32 AM, Catherine M Moroney
 wrote:
> The actual scope of the problem is very small, so memory/cpu time is not
> an issue.  I'm just looking for the most pythonic/elegant way of doing this.

Small job? Use the simplest possible technique. Just create
"params.py" with a bunch of assignments in it:

# params.py
a = 1
b = 2
c = a + b

# every other file
import params
print("c is",params.c)
# if you need to change anything:
params.c += 5
# everyone else will see the change, because there can be
# only one instance of the module (Highlander!)

Works nicely for anything even moderately complex. Also serves as a
convenient way to separate configs from code; for instance, I do this
any time I need to have a program with database passwords, or
per-installation setup, or stuff like that. Two examples:

https://github.com/Rosuav/Yosemite/blob/master/config.py
https://github.com/Rosuav/Flask1/blob/master/1.py

In the latter case, config.py doesn't even exist in the repository, as
its main purpose is to store the database connection string - both
private (don't want that published on Github) and per-installation (my
dev and production systems use different connection strings). The
Yosemite config is actually a bit legacy now; I used to have two
distinctly different instances of it, one running on Windows and the
other on Linux, but now I have a large number of identical instances
(all on Linux and all referencing the same disk server - which,
incidentally, is the one that I've weaponized with Alice, Elsa, Anya,
a Vorpal blade, and a Portal turret). Either way, though, config.py
consists generally of simple assignments (and comments), but it's most
welcome to use all the power of Python to calculate values.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3 is killing Python

2014-07-14 Thread Mark Lawrence

On 15/07/2014 00:28, Chris Angelico wrote:

On Tue, Jul 15, 2014 at 8:12 AM, Rick Johnson
 wrote:


Image, for a moment, a world WITHOUT the great USA!


"Imagine". If you were worth the effort, I could easily "image" a
world without the USA, by Photoshopping something out of a world map.
(I'd probably use the Gimp, or Pike's image manipulation libraries,
but everyone knows what Photoshopping is.)



No more World Series in sport.  No more hunting for weapons of mass 
destruction in Iraq.  No more big mouthed Yanks who insist that they won 
WWII despite the fact that as usual they didn't bother turning up at the 
start.  And apart from that...


--
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 protection 
is active.
http://www.avast.com


--
https://mail.python.org/mailman/listinfo/python-list


Re: initializing "parameters" class in Python only once?

2014-07-14 Thread Ben Finney
Catherine M Moroney  writes:

> The problem:  I'm writing a large Python program and I have a bunch of
> parameters (whose values are static) that I want to make available to
> the rest of the code with minimum overhead and duplicate processing.

Better than putting these in executable code, then, is to put them in a
configuration file read as *data*, not code, when your program starts.

Look at the ‘configparser’ module from the Python standard library
https://docs.python.org/3/library/configparser.html> for a robust
way to read run-time configuration parameters from a non-executable file.

The result of reading the config file (or set of them, if your use case
is complex enough) is an object containing the parameters, which can be
interrogated as normal by getting its attributes. See the documentation
for examples.

-- 
 \“[T]he great menace to progress is not ignorance but the |
  `\   illusion of knowledge.” —Daniel J. Boorstin, historian, |
_o__)1914–2004 |
Ben Finney

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: initializing "parameters" class in Python only once?

2014-07-14 Thread Mark Lawrence

On 14/07/2014 23:32, Catherine M Moroney wrote:

Hello,

Pardon me for not using the proper Python language terms, but I hope
that people can still understand the question:

The problem:  I'm writing a large Python program and I have a bunch of
parameters (whose values are static) that I want to make available to
the rest of the code with minimum overhead and duplicate processing.

I think that the simplest way would be to create a file called
"Params.py" and then simply have statements like a = 1, b = 2, etc.
in there (no classes, no methods, just a bunch of declarations).  But,
some of these static parameters have to be calculated rather than simply
hard-coded.

I thought of creating a class called Params and having a bunch of
methods (decorated with @classmethod) that set/calculate the value of
all the parameters.  Easy enough, but then I have to create a Params
object in every source file that uses these parameters, and that seems
wasteful.

The actual scope of the problem is very small, so memory/cpu time is not
an issue.  I'm just looking for the most pythonic/elegant way of doing
this.

What is the recommended way of passing a bunch of static (hard-coded and
calculated) parameters to various parts of the code?

Thank you for any advice,

Catherine


Besides the answers you've already had, you might like to consider using 
the enum module for some of your parameters.  IIRC it's only available 
in 3.4 but there's what I understand to be pretty much the same thing on 
pypi.


--
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 protection 
is active.
http://www.avast.com


--
https://mail.python.org/mailman/listinfo/python-list


Iterating through set

2014-07-14 Thread LJ
Hi All.

I'm coding a Dynamic Programming algorithm to solve a network flow problem. At 
some point in the algorithm I have to iterate through a set of nodes, while 
adding and/or removing elements, until the set is empty. I know a regular set() 
object does not work in a case like this, so I wonder if anyone knows of an 
efficient pythonic way to handle this.

Thanks in advance!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Iterating through set

2014-07-14 Thread Roy Smith
In article ,
 LJ  wrote:

> Hi All.
> 
> I'm coding a Dynamic Programming algorithm to solve a network flow problem. 
> At some point in the algorithm I have to iterate through a set of nodes, 
> while adding and/or removing elements, until the set is empty. I know a 
> regular set() object does not work in a case like this, so I wonder if anyone 
> knows of an efficient pythonic way to handle this.


You've already figured out that you can't alter a set while you're 
iterating over it.  Which means you basically have two choices:

1) Build a new set while you're iterating over the first one, then 
delete the first set.  This might make sense if you expect there will be 
a large number of items (relative to the size of the original set) added 
or deleted.

2) Keep lists, of those items which need adding or deleting, and do them 
in bulk, after the iteration is completed.  Then, delete the lists.  
This makes sense if you expect the number of add/deletes will be small.

Either way is O(n) in the size of the set, so which you pick is a 
second-order optimization.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3 is killing Python

2014-07-14 Thread Rick Johnson
On Monday, July 14, 2014 5:47:14 PM UTC-5, MRAB wrote:
> Why it should "they" withdraw it (whatever that means)?
> "They" are entitled to keep it public if they want to.

I'm not suggesting they *must* withdraw Python, I'm only
suggesting that IF they wish to *prevent* dissent or scrutiny,
then the only remedy they can employ is to "withdraw" the
language from public view. 

I'm merely highlighting the difference between public and
private property. Python is currently public property, and
just as a public park is open to whoever wishes to visit, so
too is the the Python language.

Sure, nobody wants to see the unwashed homeless people
there, feeding the pigeons until they grow so fat they can
only muster sporadic momentary flight, in between Jackson
Pollock inspired park bench repainting sessions via
cementitious bowel ejections... THOSE VERMIN! 

But we must suffer them, because if we believe in freedom,
we must celebrate the "comfortable" whilst suffering the
"uncomfortable".

> Those who aren't interested are not obliged to take any
> notice of it, and any group or individual who wants to
> develop Python 2 further can just fork Python 2.7 and
> continue from there.

Actually, no. You need to understand some ground rules of
free societies:


 When a *public* "entity" is created, an "individual" *may*:


* Ignore the entity altogether. At which point, no
future interaction occurs UNLESS the "individual"
decides to change his relationship with the *public*
 "entity"

* Engage the entity in one or more forms:
1. Participate in debate. Which may include accolades, 
   dissent, or even vile rebukes.
2. Take from the entity any offerings the entity may
   provide.
3. All of the above.

You see, the "entity" merely offers something for the
taking, and the "individual" decides to take the
offering, or not to take the offering; to participate,
or not to participate; -- extrapolations to infinity...!

And not only does the "individual" control the time,
place, and manner of the interaction, he also has the
capacity to insert or remove himself from participation
at any time. THIS, is the manner of free "individuals"
operating in the realm of *public* "entities".

An "individual", a FREE individual that is, has many more
choices than the single choice you provided. What you're
attempting to do is "compel" an "individual" to engage a
*public* entity in a manner that is most pleasing to YOU,
and i will not allow that to happen!

I've seen this "vulgar display of animosity" before,
predominately in short, angry white women driving
"Scandinavian armored personnel carriers" (aka: Volvo), with
closely trimmed eyebrows, and beaming scowls of superiority
down on the "little people" as she transports her "honor
role student" to school at twenty miles below the speed
limit!

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Iterating through set

2014-07-14 Thread Chris Kaynor
On Mon, Jul 14, 2014 at 5:10 PM, LJ  wrote:

> Hi All.
>
> I'm coding a Dynamic Programming algorithm to solve a network flow
> problem. At some point in the algorithm I have to iterate through a set of
> nodes, while adding and/or removing elements, until the set is empty. I
> know a regular set() object does not work in a case like this, so I wonder
> if anyone knows of an efficient pythonic way to handle this.
>

Your description of your need is somewhat vague, but this sounds like a
queue/stack which should be handled with a while loop and poping items.

Something like (untested):
mySet = [] # Typically, this would be a list. If you only want items
processed once per iteration, you'd likely use a separate set, however the
exact structure would vary based on the data and use-case.
# Some code to add initial items.
while mySet:
item = mySet.pop()
# Do something with item, which may call mySet.add(), and possibly
mySet.remove().


> Thanks in advance!
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3 is killing Python

2014-07-14 Thread Chris Angelico
On Tue, Jul 15, 2014 at 11:00 AM, Rick Johnson
 wrote:
> On Monday, July 14, 2014 5:47:14 PM UTC-5, MRAB wrote:
>> Why it should "they" withdraw it (whatever that means)?
>> "They" are entitled to keep it public if they want to.
>
> I'm not suggesting they *must* withdraw Python, I'm only
> suggesting that IF they wish to *prevent* dissent or scrutiny,
> then the only remedy they can employ is to "withdraw" the
> language from public view.

Python 3 stands up just fine to scrutiny, and dissent is a normal part of life.

> I'm merely highlighting the difference between public and
> private property. Python is currently public property, and
> just as a public park is open to whoever wishes to visit, so
> too is the the Python language.

Python is not public property. Whatever gave you that idea?

> I've seen this "vulgar display of animosity" before,
> predominately in short, angry white women driving
> "Scandinavian armored personnel carriers" (aka: Volvo), with
> closely trimmed eyebrows, and beaming scowls of superiority
> down on the "little people" as she transports her "honor
> role student" to school at twenty miles below the speed
> limit!

Wow. There is just so much US-centrism in that paragraph... I don't
understand half of it half as well as I'd like, and I like less than
half of it half as well as it deserves.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3 is killing Python

2014-07-14 Thread Rick Johnson
On Monday, July 14, 2014 6:28:19 PM UTC-5, Chris Angelico wrote:
> And I know what would happen if the USA weren't here.
> People in other countries would have made similar
> improvements to the world.

Yes, i wholeheartedly agree with that statement.

Is the USA the *ONLY* country to have ever liberated the world
from the clutches of evil?...No! Will the USA be the *LAST* to
do so?...OF COURSE NOT! I'm not so blind as you may believe.

But, if the USA *DID NOT* exist during the perilous times of
the world wars, how many generations of people would have
suffered before a powerful enough contender came along to
unclench the grips of evil?

I "SHUDDER" TO THINK!

How many minutes, or hours, or days in a concentration camp
would YOU, Chris Angelico, trade so you could have your
selfish wish to wipe USA's prestige from the history books?

You see Chris, the battle between "good" and "evil" [1] will
always exist, and in fact, if it did not exist, the world
would be a stagnate cess-pool of rot and decay because it is
the very battle that is waged against "evil", which is just
another form of competition, that spins the cogs of
evolution.

Of course the "moral authority" of "doing good" has it's
hormonal payoffs, yes?

SELFISHNESS, MEET GLUTTONY
GLUTTONY, SELFISHNESS!

Ha, however, our "chemically induced" happiness is just a
method of pacification, and protects our delicate emotional
"beings" from the most abysmal of apathetic truths.

Living creatures are lazy by nature, and we will, if not
"challenged", waste away, in order to maintain forward
evolution, the tools of pain, jealously, terror, envy, etc,
etc... are employed to "compel" us to compete with each
other --from the friendliest of banter to the deepest depths
of human depravity-- we are but pawns in a greater game!

LET THE GAMES BEGIN!

> Social justice? Do you honestly think the USofA is the
> example to hold up and say "Look, we have perfectly solved
> the problems of social injustice"?

Point to my statement that mentioned ANYTHING about
"perfect". I don't believe in perfection, since such an
"idea" is unattainable by both the human hand, or human mind.

> I guess you've eliminated racism since I last heard.

Yup. And next we've decided to solve the middle east crisis!

> Oh, and I agree that all people are created equal. (I'll
> leave aside the argument about whether your statement is
> proof that English is sexist, or that the US founding
> fathers were the sexist ones.) I also believe that our
> Creator sees us as equal. But all through history, we
> flawed human beings have had a problem with seeing people
> differently, for various reasons. The Apostle James wrote
> about a major problem with "wealthist" Christians: And
> there've been plenty of other problems creeping in. God
> treats us all the same way: flawed, fallible people whom
> He loves enough to die for. If you want to believe in true
> equality, you need to follow His example.

I'm confused by your logic. First you admit all humans are
fallible, but somehow, you believe that a collection of
humans should be "infallible". Please explain this enigma.


REFERENCES:

[1] And i use the terms very loosely here. Please, let's not
get into a debate of what "good" and "evil" are with all
the religious nonsense and such.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3 is killing Python

2014-07-14 Thread Chris Angelico
On Tue, Jul 15, 2014 at 11:54 AM, Rick Johnson
 wrote:
> But, if the USA *DID NOT* exist during the perilous times of
> the world wars, how many generations of people would have
> suffered before a powerful enough contender came along to
> unclench the grips of evil?
>
> I "SHUDDER" TO THINK!
>
> How many minutes, or hours, or days in a concentration camp
> would YOU, Chris Angelico, trade so you could have your
> selfish wish to wipe USA's prestige from the history books?

I dunno. It's not like Great Britain, Australia, or New Zealand did
anything significant in either war, is it. And a lot of US citizens
fought in British or other military units, because the US wasn't in
the war yet. That's what I mean by "if the US were not, others would
take up the slack" - the same people would do the same work, under a
different flag.

> You see Chris, the battle between "good" and "evil" [1] will
> always exist, and in fact, if it did not exist, the world
> would be a stagnate cess-pool of rot and decay because it is
> the very battle that is waged against "evil", which is just
> another form of competition, that spins the cogs of
> evolution.
>
> [1] And i use the terms very loosely here. Please, let's not
> get into a debate of what "good" and "evil" are with all
> the religious nonsense and such.

Easiest to use the Dungeons & Dragons definitions of those terms
(which don't conflict with most religious definitions): evil is
selfishness, good is altruism.

>> I guess you've eliminated racism since I last heard.
>
> Yup. And next we've decided to solve the middle east crisis!

Good. Call me when you get there, and I'll give you the rest of the
directions. Some people in Australia are still racist, but racism is
nothing like the problem it is in America, where you boast so much of
equality.

>> Oh, and I agree that all people are created equal. (I'll
>> leave aside the argument about whether your statement is
>> proof that English is sexist, or that the US founding
>> fathers were the sexist ones.) I also believe that our
>> Creator sees us as equal. But all through history, we
>> flawed human beings have had a problem with seeing people
>> differently, for various reasons. The Apostle James wrote
>> about a major problem with "wealthist" Christians: And
>> there've been plenty of other problems creeping in. God
>> treats us all the same way: flawed, fallible people whom
>> He loves enough to die for. If you want to believe in true
>> equality, you need to follow His example.
>
> I'm confused by your logic. First you admit all humans are
> fallible, but somehow, you believe that a collection of
> humans should be "infallible". Please explain this enigma.

Where do I say anything about a collection of humans being infallible?
I believe I specifically said *fallible*. That's, uhh, the opposite of
infallible.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Python Brasil 10] Registrations are now open!

2014-07-14 Thread Renato Oliveira
Hi all,

The call for papers are now open!

http://2014.pythonbrasil.org.br/dashboard/proposals/

We're going to hava an English Track, so feel free to submit your proposals!

See you at Python Brasil 10!

Renato Oliveira
@_renatooliveira 
Labcodes - www.labcodes.com.br



On Mon, Jul 7, 2014 at 11:16 AM, Renato Oliveira <
renatooliveira@gmail.com> wrote:

> Hey everyone!
> Registrations for Python Brasil are now open!
>
> http://2014.pythonbrasil.org.br/register
>
> Sadly the payment form is in portuguese, so if you have any trouble please
> let me know (in private message).
> The call for papers will open on Jul 10th as you can see here
>
> http://2014.pythonbrasil.org.br/about
>
> For now the announced keynotes are:
> Alex Gaynor
> http://2014.pythonbrasil.org.br/news/keynotes-alex-gaynor
>
> Fernando Perez
> http://2014.pythonbrasil.org.br/news/keynotes-fernando-perez
>
> Lynn Root
> http://2014.pythonbrasil.org.br/news/keynotes-lynn-root
>
> And this beach is waiting for you:
> http://2014.pythonbrasil.org.br/venue
>
> Please, help us by spreading the word :)
> Thanks
> Renato Oliveira
>
> @_renatooliveira 
> Labcodes - www.labcodes.com.br
>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Python Brasil 10] Registrations are now open!

2014-07-14 Thread Renato Oliveira
have*

Renato Oliveira
@_renatooliveira 
Labcodes - www.labcodes.com.br



On Mon, Jul 14, 2014 at 11:53 PM, Renato Oliveira <
renatooliveira@gmail.com> wrote:

> Hi all,
>
> The call for papers are now open!
>
> http://2014.pythonbrasil.org.br/dashboard/proposals/
>
> We're going to hava an English Track, so feel free to submit your
> proposals!
>
> See you at Python Brasil 10!
>
> Renato Oliveira
> @_renatooliveira 
> Labcodes - www.labcodes.com.br
>
>
>
> On Mon, Jul 7, 2014 at 11:16 AM, Renato Oliveira <
> renatooliveira@gmail.com> wrote:
>
>> Hey everyone!
>> Registrations for Python Brasil are now open!
>>
>> http://2014.pythonbrasil.org.br/register
>>
>> Sadly the payment form is in portuguese, so if you have any trouble
>> please let me know (in private message).
>> The call for papers will open on Jul 10th as you can see here
>>
>> http://2014.pythonbrasil.org.br/about
>>
>> For now the announced keynotes are:
>> Alex Gaynor
>> http://2014.pythonbrasil.org.br/news/keynotes-alex-gaynor
>>
>> Fernando Perez
>> http://2014.pythonbrasil.org.br/news/keynotes-fernando-perez
>>
>> Lynn Root
>> http://2014.pythonbrasil.org.br/news/keynotes-lynn-root
>>
>> And this beach is waiting for you:
>> http://2014.pythonbrasil.org.br/venue
>>
>> Please, help us by spreading the word :)
>> Thanks
>> Renato Oliveira
>>
>> @_renatooliveira 
>> Labcodes - www.labcodes.com.br
>>
>>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Python-Dev] Python Job Board

2014-07-14 Thread Ethan Furman

On 07/14/2014 06:01 PM, Wes Turner wrote:

 From 
http://www.reddit.com/r/Python/comments/17c69p/i_was_told_by_a_friend_that_learning_python_for/c84bswd
:


* http://www.python.org/community/jobs/
* https://jobs.github.com/positions?description=python
* http://careers.joelonsoftware.com/jobs?searchTerm=python
* http://www.linkedin.com/jsearch?keywords=python
* http://www.indeed.com/q-Python-jobs.html
* http://www.simplyhired.com/a/jobs/list/q-python
* http://seeker.dice.com/jobsearch/servlet/JobSearch?op=300&FREE_TEXT=python
* http://careers.stackoverflow.com/jobs/tag/python
* http://www.pythonjobs.com/
* http://www.djangojobs.org/


Nice, thanks!

--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list


Re:initializing "parameters" class in Python only once?

2014-07-14 Thread Dave Angel
Catherine M Moroney  Wrote in
 message:
> Hello,
> 
> Pardon me for not using the proper Python language terms, but I hope 
> that people can still understand the question:
> 
> The problem:  I'm writing a large Python program and I have a bunch of
> parameters (whose values are static) that I want to make available to
> the rest of the code with minimum overhead and duplicate processing.
> 
> I think that the simplest way would be to create a file called 
> "Params.py" and then simply have statements like a = 1, b = 2, etc.
> in there (no classes, no methods, just a bunch of declarations).  But, 
> some of these static parameters have to be calculated rather than simply 
> hard-coded.
> 
> I thought of creating a class called Params and having a bunch of
> methods (decorated with @classmethod) that set/calculate the value of
> all the parameters.  Easy enough, but then I have to create a Params
> object in every source file that uses these parameters, and that seems
> wasteful.

No, you don't want to create separate instances of the Params
 class.  You want to create exactly one object,  and have each
 source file get their attributes from the same object.

That object could be the same module object as already mentioned.
 Or it could be an object created in the module exactly once. I
 like the latter method and I'll explain why after showing
 how.

In parametersetup.py, you do something like:

class Foo:  # assuming python 3.x
def __init__(self ):
self.parm1 = 42
self.otherparm =3


parms = Foo ()  # this is the sole instance and its only created here.
del Foo # in case you want to make sure.

In each source file you have something like:

from parametersetup import parms

and you refer to parms.param1


Now, why the extra fuss? In case you later want a different set of
 parms for each thread, or for certain modules, or for debugging. 
 You're halfway there.



-- 
DaveA

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3 is killing Python

2014-07-14 Thread Michael Torrie
On 06/03/2014 12:12 AM, wxjmfa...@gmail.com wrote:
> I was myself really suprised to fall on such a case and
> after thinking no, such cases may logically happen.

Putting in this comment not for JMF but for poor souls who find this
thread on a search and are led astray by jmf's trolling.

Either it was your code or an issue with the Windows console that caused
the exception.  When you try to print out unicode strings, Python must
convert them to the character encoding of the terminal in order to print
them out.  On sane systems this is UTF-8.  On Windows it could be
anything.  Do you want Python to fail silently or do you want to fail
with a useful message, with the option of specifying the exact behavior
you want (replace unrepresentable characters with spaces, question
marks, etc)?

Seems like jmf, though being a self-proclaimed unicode expert,
continually confusing unicode with encoding schemes.

> 
> It's not important. I'm no more writing Py apps, only
> considering software through an unicode eye.

Please just stop posting to this list.

thanks.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3 is killing Python

2014-07-14 Thread Michael Torrie
On 05/31/2014 09:48 AM, jmf wrote:
> 

Absolutely FALSE.  Python 3.3 and up can handle any and all unicode
characters you want to throw at it, without surprises such as what you
get in javascript.  Python 3 uses UTF-4 encoding under the hood, with a
compression optimization that removes leading zeros from binary
representation of each character.

Windows command consoles are not unicode compliant, and so running
python programs a command prompt console will often lead to exceptions
because Python must convert unicode to the character set that the
console is using, and when a character is hit that cannot be encoded
Python defaults to being correct and throws an exception, instead of
failing silently.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3 is killing Python

2014-07-14 Thread Rick Johnson
On Monday, July 14, 2014 9:11:47 PM UTC-5, Chris Angelico wrote:
> I dunno. It's not like Great Britain, Australia, or New
> Zealand did anything significant in either war, is it.

Most of Europe occupied, London bombed into the stone age;
things were looking grim Chris! Maybe you should read up on
some WW2 history, it's quite humbling to think what *could*
have happened.

> Some people in Australia are still racist, but racism is
> nothing like the problem it is in America, where you boast
> so much of equality.

Where do you get your info about America, from CNN? And for
someone who is a self-described "Aussie" you sure seem to
know more about Americans than Americans know about
themselves... hmm, another enigma!

Chris, one thing you need to understand about America is
that a whole grievance industry exists to perpetuate hate.
And sadly, most Americans are too stupid to realize this.

You see, a divided people are not going to cause the rulers
any troubles because they are too busy fighting amongst
themselves -- the same effect is employed in prison
populations to protect the guards.

In ancient Rome, the Caesars used games and bread to control
the masses, today, they use the grievance industry and, for
the complete moronic zombies, sporting events.

All "isms" and social problems just boil down to hate. And
since you can never remove hate from the heart of man, you
will *NEVER* solve these issues. The best you can hope for
is to reduce the levels a bit via "intelligent interventions".

So in short, none of these issues will ever be solved until
people realize who the real enemy is -> themselves.

MIRROR, MIRROR, ON THE WALL, WHO'S THE MOST JUDGMENTAL 
OF THEM ALL?


 The origins of xenophobia:


In order to defeat our own hatred of others, we must
circumvent our per-programmed primal fears, which is not
easy to do, and while these fears play a vital survival role
in *early* development of both the *individuals* of a group
AND the group itself, in modern times, these fears have
become a crutch preventing humans from evolving socially.

HENCE THE GRIEVANCE INDUSTRY PERPETRATED BY A MEDIA 
CIRCUS THAT WILL DO ANYTHING TO GET RATINGS!

  
   THOUGHT EXPERIMENT
  
  
  Imagine your a small kitten: innocent, carefree, and full
  of curiosity! You love exploring the world, stuffing
  yourself into boxes, climbing to high places, and chasing
  balls of strings -- ah what a life!
  
  You see your siblings and notice they have fur like you ,
  and whiskers like you, and paws and tails and blah like
  you. And you are comfortable because these other
  "lifeforms" resemble you, and so you consider them to be
  "safe".
  
  Then one day, whilst frolicking in the backyard, you see a
  glimmer from under a log, ooh, whats this you ask
  rhetorically...?
  
  So you get closer to inspect, and you see two eyes, and
  you think, hmm, it has two eyes just like my bothers and
  sisters so it must be safe...!
  
  And so you get yet closer, but just then you start to
  notice some differences, whoa, this thing has no fur, it
  has no paws, and no whiskers, and it has strange patterns
  on it's back and it's making a rattling noise, oh well, no
  need to let fear get in my way, i'll just go over and
  introduce myself... AND THAT WAS THE END OF "FLUFFY THE
  KITTEN"!
  
  MEOW!

You see, since hate is merely an extrapolation of
xenophobia, which is itself a per-programmed reflex utilized
unconsciously to protect an organism from self destruction
via *utter* ignorance of dangerous predators, we are
fighting a losing battle when we expect the vast majority of
earths "intelligent" inhabitants, of which most are
zombie-fied *idiots*, to violate their own source code.

JUST GO GRAB A BEER AND WATCH THE GAME YOU BEER-BELLIED FOOL!

PS: That was a "general" you, not to be taken as a literal 
statement to Chris.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3 is killing Python

2014-07-14 Thread Chris Angelico
On Tue, Jul 15, 2014 at 1:47 PM, Michael Torrie  wrote:
> Python 3 uses UTF-4 encoding under the hood, with a
> compression optimization that removes leading zeros from binary
> representation of each character.

Sorry to nitpick, but in the interests of terminological accuracy I
have to point out that it's UTF-32 or UCS-4, not UTF-4 :)

But otherwise, yes, quite correct. And a system that few, but not no,
other languages use; I do wonder if other languages have considered
switching to this kind of system, but avoided it lest jmf start
haunting them too...

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3 is killing Python

2014-07-14 Thread Chris Angelico
On Tue, Jul 15, 2014 at 2:18 PM, Rick Johnson
 wrote:
> On Monday, July 14, 2014 9:11:47 PM UTC-5, Chris Angelico wrote:
>> I dunno. It's not like Great Britain, Australia, or New
>> Zealand did anything significant in either war, is it.
>
> Most of Europe occupied, London bombed into the stone age;
> things were looking grim Chris! Maybe you should read up on
> some WW2 history, it's quite humbling to think what *could*
> have happened.

Yeah, because nobody managed to do anything during all that time, the
Royal Air Force was nowhere to be seen, and the various Resistances in
occupied countries were completely ineffectual.

>> Some people in Australia are still racist, but racism is
>> nothing like the problem it is in America, where you boast
>> so much of equality.
>
> Where do you get your info about America, from CNN? And for
> someone who is a self-described "Aussie" you sure seem to
> know more about Americans than Americans know about
> themselves... hmm, another enigma!

No... I have friends who are America experts. Actually, when I say
friends... they're more like family really. I don't want to scare you,
they can be a little bit inappropriate... and loud... and heavy.
Really, morbidly obese. I'm talking about the genuine article here,
and I converse with them on a daily basis.

And this is distinctly off-topic for this list. Talk about Python or
drop the issue, it really isn't as significant as you think it is.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3 is killing Python

2014-07-14 Thread Martin S
Yes, we all know that Abu Ghraib, Guantanamo, school shootings and the lack of 
proper health care for all are the pinnacle of US culture. Or figments of the 
imagination of Baghdad Bob. 

Now, maybe return to Python? 

/martin 

On 15 Jul 2014, Rick Johnson  wrote:
>On Monday, July 14, 2014 9:11:47 PM UTC-5, Chris Angelico wrote:
>> I dunno. It's not like Great Britain, Australia, or New
>> Zealand did anything significant in either war, is it.
>
>Most of Europe occupied, London bombed into the stone age;
>things were looking grim Chris! Maybe you should read up on
>some WW2 history, it's quite humbling to think what *could*
>have happened.
>
>> Some people in Australia are still racist, but racism is
>> nothing like the problem it is in America, where you boast
>> so much of equality.
>
>Where do you get your info about America, from CNN? And for
>someone who is a self-described "Aussie" you sure seem to
>know more about Americans than Americans know about
>themselves... hmm, another enigma!
>
>Chris, one thing you need to understand about America is
>that a whole grievance industry exists to perpetuate hate.
>And sadly, most Americans are too stupid to realize this.
>
>You see, a divided people are not going to cause the rulers
>any troubles because they are too busy fighting amongst
>themselves -- the same effect is employed in prison
>populations to protect the guards.
>
>In ancient Rome, the Caesars used games and bread to control
>the masses, today, they use the grievance industry and, for
>the complete moronic zombies, sporting events.
>
>All "isms" and social problems just boil down to hate. And
>since you can never remove hate from the heart of man, you
>will *NEVER* solve these issues. The best you can hope for
>is to reduce the levels a bit via "intelligent interventions".
>
>So in short, none of these issues will ever be solved until
>people realize who the real enemy is -> themselves.
>
>MIRROR, MIRROR, ON THE WALL, WHO'S THE MOST JUDGMENTAL 
>OF THEM ALL?
>
>
> The origins of xenophobia:
>
>
>In order to defeat our own hatred of others, we must
>circumvent our per-programmed primal fears, which is not
>easy to do, and while these fears play a vital survival role
>in *early* development of both the *individuals* of a group
>AND the group itself, in modern times, these fears have
>become a crutch preventing humans from evolving socially.
>
>HENCE THE GRIEVANCE INDUSTRY PERPETRATED BY A MEDIA 
>CIRCUS THAT WILL DO ANYTHING TO GET RATINGS!
>
>  
>   THOUGHT EXPERIMENT
>  
>  
>  Imagine your a small kitten: innocent, carefree, and full
>  of curiosity! You love exploring the world, stuffing
>  yourself into boxes, climbing to high places, and chasing
>  balls of strings -- ah what a life!
>  
>  You see your siblings and notice they have fur like you ,
>  and whiskers like you, and paws and tails and blah like
>  you. And you are comfortable because these other
>  "lifeforms" resemble you, and so you consider them to be
>  "safe".
>  
>  Then one day, whilst frolicking in the backyard, you see a
>  glimmer from under a log, ooh, whats this you ask
>  rhetorically...?
>  
>  So you get closer to inspect, and you see two eyes, and
>  you think, hmm, it has two eyes just like my bothers and
>  sisters so it must be safe...!
>  
>  And so you get yet closer, but just then you start to
>  notice some differences, whoa, this thing has no fur, it
>  has no paws, and no whiskers, and it has strange patterns
>  on it's back and it's making a rattling noise, oh well, no
>  need to let fear get in my way, i'll just go over and
>  introduce myself... AND THAT WAS THE END OF "FLUFFY THE
>  KITTEN"!
>  
>  MEOW!
>
>You see, since hate is merely an extrapolation of
>xenophobia, which is itself a per-programmed reflex utilized
>unconsciously to protect an organism from self destruction
>via *utter* ignorance of dangerous predators, we are
>fighting a losing battle when we expect the vast majority of
>earths "intelligent" inhabitants, of which most are
>zombie-fied *idiots*, to violate their own source code.
>
>JUST GO GRAB A BEER AND WATCH THE GAME YOU BEER-BELLIED FOOL!
>
>PS: That was a "general" you, not to be taken as a literal 
>statement to Chris.

-- Sent with K-@ Mail - the evolution of emailing.-- 
https://mail.python.org/mailman/listinfo/python-list


Re: NaN comparisons - Call For Anecdotes

2014-07-14 Thread Steven D'Aprano
On Mon, 14 Jul 2014 18:44:15 +0200, Anders J. Munch wrote:

> alister wrote:
>> I don't have time to start this discussion over again on another
>> mailing list.
>> Don't anyone on those lists read python-list also?
>>
>> they possibly do, but prefer to keep discussions to the proper forum
> 
> The semantics of the Python programming language is on-topic for
> python-list. This is about float.__eq__, not about numpy or SciPy. Maybe
> they just don't like beer?

It's about NAN != NAN. The heaviest uses of NANs are numpy and scipy 
users.

You remind me of the proverbial drunk who lost his keys in the park, but 
looks for them in the street under the street light because that's where 
the light is. That's assuming that you actually want an honest answer to 
your question.

If you wanted to learn about use-cases for NANs, you ought to ask 
somewhere where there was a high proportion of numeric programmers, not 
on some list merely because it was convenient.

I'll give you the benefit of the doubt, and assume that when you first 
posted you hadn't realised that the audience here does not have the 
relevant experience, but by refusing to ask the question elsewhere, and 
by making snide comments that "they don't like beer", that pretty much 
gives the game away that you're looking to have your opinion confirmed 
rather than looking for an honest answer.


-- 
Steven
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: initializing "parameters" class in Python only once?

2014-07-14 Thread Steven D'Aprano
On Mon, 14 Jul 2014 15:24:26 -0700, Catherine M Moroney wrote:

> The problem:  I'm writing a large Python program and I have a bunch of
> parameters (whose values are static) that I want to make available to
> the rest of the code with minimum overhead and duplicate processing.
> 
> I think that the simplest way would be to create a file called
> "Params.py" and then simply have statements like a = 1, b = 2, etc. in
> there (no classes, no methods, just a bunch of declarations).

That sounds exactly right to me.


> But, some
> of these static parameters have to be calculated rather than simply
> hard-coded.

I don't think that should be a problem. You can include calculations:

a = 1
b = 2
c = a**2 + b**2 - a + 1


The only difficulty is if you want those values to be calculated on 
demand, rather than at program startup. If that's the case, I think the 
best solution is to turn them into functions:

def c():
return a**2 + b**2 - a + 1


This, sadly, requires you to tell the difference between params that 
should be constants and those which should be function calls. If that is 
a serious problem, you should consider a singleton class with properties, 
but if the simpler solution works for you, stick to the simpler solution!


> I thought of creating a class called Params and having a bunch of
> methods (decorated with @classmethod) that set/calculate the value of
> all the parameters.  Easy enough, but then I have to create a Params
> object in every source file that uses these parameters, and that seems
> wasteful.

I don't think that Params with class methods is the best solution. I 
would do something like this:

# === module params.py ===
class Params(object):
a = 1
b = 2

@property
def c(self):
return self.a**2 + self.b**2 - self.a + 1


params = Params()
del Params  # hide the class



Then callers just say:

from params import params
print params.c


All modules now see the same params instance, so it is (almost) a 
singleton.


-- 
Steven
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3 is killing Python

2014-07-14 Thread Steven D'Aprano
On Mon, 14 Jul 2014 21:18:05 -0700, Rick Johnson wrote:

> London bombed into the stone age


Sigh. How can one even begin to answer a statement of such ignorance?


For what little it is worth, if any one country won World War Two, it was 
the USSR. I don't recall the exact numbers off the top of my head, but 
while the Brits and Americans were having a relatively easy time of it 
fighting the second-best German soldiers, the best, and by far the 
majority, of the German armed forces were on the Eastern Front engaged in 
the biggest, fiercest, most brutal battles of the war, bar none.

The Soviets destroyed the German airforce, smashed their tank battalions, 
bled their armies dry, then steamrolled over Eastern Europe, East 
Germany, and Berlin. The Western Front was, in comparison, a school 
picnic. One can understand why, following WW2, the western powers formed 
NATO and were so worried about the Red Army that they invited the Germans 
to join.


-- 
Steven
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Twitter Client on Terminal by Python

2014-07-14 Thread Omar Abou Mrad
Dear Orakaro,

Cool app you have there. Please consider the following comments as feedback
in the most positive sense possible:

- I didn't care for the figlet, it's noise beyond anything else, if you
drop it, you would drop the pyfiglet dependency as well
- What's with the SQLAlchemy dependency? I checked your table definitions
and if I'm not mistaken all you're using is Theme, Message, Tweet. My first
question on that front is why are message and tweet stored locally? Are you
doing local caching to speed things up? What about theme?

Good job and take care!

Regards,

Omar


On Sun, Jul 13, 2014 at 9:00 PM, Orakaro  wrote:

> Hello!
>
> I'm @dtvd88 on Twitter and very new here.
> I read from python.org that anything Python-related can be discussed, and
> not sure if I can share my OSS package here to get feedback or not ?
>
> I just wrote a Twitter Client on Terminal by Python, it has very beautiful
> display and even can display image on terminal. Check it out and maybe you
> guys will love it :)
>
> Homepage: http://www.rainbowstream.org/
> Github: https://github.com/DTVD/rainbowstream
>
> Thanks for any feedback and sorry if this kind of topics is not tolerated
> here.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list