Re: Function for the path of the script?

2013-10-29 Thread Peter Cacioppi
Steven said

Isn't freedom of choice wonderful?

Didn't somebody once say we're all adults here. I forget who said that. 
Eddard Stark? The guy always did keep his head in a crisis.

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


Re: how to avoid checking the same condition repeatedly ?

2013-10-29 Thread Peter Cacioppi
Nobody (yes, his name is Nobody) said:

If you're sufficiently concerned about performance that you're willing to
trade clarity for it, you shouldn't be using Python in the first place.

I think the correct thing to say here is, IF you know this subroutine is a 
bottleneck, THEN probably this subroutine (or even the module it lives within) 
should be recoding in a language closer to the metal (like C).

I don't think it's correct to imply that people very concerned about 
performance should not use Python. (And I agree, Nobody implied that ;) But 
sometimes performance concerns require the bottleneck(s) be recoded in a manner 
that sacrifices readability for performance, to include a different language. 
Python generally plays well with other languages, no? So code it in Py, profile 
it, refactor the bottlenecks as needed.

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


Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea.

2013-10-29 Thread Chris Angelico
On Tue, Oct 29, 2013 at 3:03 PM,  ru...@yahoo.com wrote:
 Regarding esr's smart-questions, although I acknowledge
 it has useful advice, I have always found it elitist and
 abrasive.  I wish someone would rewrite it without the
 we are gods attitude.

I find it actually pretty appropriate. The attitude comes from a
hierarchy in which we are not at the top - but neither is esr. On the
roleplaying game Threshold, there's a help file about that, which
succinctly sums up what I'm trying to say, but it doesn't seem to be
on the web, so unless you want to telnet to thresholdrpg.com, create
an account, and type help hierarchy at the prompt, you can't see the
text of it. Oh well. :| Anyway, point is: We're in a hierarchy (or
actually several independent and unrelated ones), and being at the top
means (in the open source world) being everyone's servant; and the
people at the top simply don't have time to be _everyone's_ servant
personally, so they need some sous-servants to help them to help
people. (Obvious example of that in the Python community is Guido at
the top, other core committers and PEP writers and so on helping him,
and then the large crew of core question-answerers, bug triagers,
patch writers, etc, etc, etc.) You offer courtesy to those who are
above you; they're giving of their time freely, making themselves your
servants, and all they ask is that you make it easy for them to do so.
That's a pretty good deal for all of us at the bottom of the hierarchy
:)

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


Re: how to avoid checking the same condition repeatedly ?

2013-10-29 Thread Chris Angelico
On Tue, Oct 29, 2013 at 5:14 PM, Peter Cacioppi
peter.cacio...@gmail.com wrote:
 Nobody (yes, his name is Nobody) said:

 If you're sufficiently concerned about performance that you're willing to
 trade clarity for it, you shouldn't be using Python in the first place.

 I don't think it's correct to imply that people very concerned about 
 performance should not use Python. (And I agree, Nobody implied that ;)

No, I don't think he implied that. You can care about performance
while still putting code clarity as a higher priority :) If you
actually profile and find that something-or-other is a bottleneck,
chances are you can break it out into a function with minimal loss of
clarity, and then reimplement that function in C (maybe wielding
Cython for the main work). That doesn't compromise clarity.
Duplicating a loop to hoist a condition _does_. Of course, in C, you
can let the compiler do it for you, but Python can't be sure that it's
as constant as you think, so it can't be changed.

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


Re: how to avoid checking the same condition repeatedly ?

2013-10-29 Thread Peter Cacioppi
Chris said

 If you actually profile and find that something-or-other is a bottleneck,
chances are you can break it out into a function with minimal loss of
clarity, and then reimplement that function in C (maybe wielding
Cython for the main work). That doesn't compromise clarity. 

Well, I'm not going to go back and forth saying does too, does not with you. 
I have a 7 year old for those sorts of arguments. 

And I think we are saying more or less the same thing.

I agree that isolating your bottleneck to the tightest possible subroutine 
usually doesn't compromise clarity. 

But once you are re-implementing the bottleneck in a different language esp 
a language  notorious for high performance nuggets of opaqueness... that does 
compromise clarity, to some extent.

(Does not, does too, does not, does too, ok we're done with that part)

But this sort of bottleneck refactoring can be done in a careful way that 
minimizes the damage to readability. And a strength of py is it tends to 
encourage this as pretty as possible approach to bottleneck refactoring.

This is what you're saying, right?

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


Re: Organising packages/modules - importing functions from a common.py in a separate directory?

2013-10-29 Thread Victor Hooi
Hi,

Hmm, this post on SO seems to suggest that importing from another sibling 
directory in a package ins't actually possibly in Python without some ugly 
hacks?

http://stackoverflow.com/questions/6323860/sibling-package-imports

Did I read the above correctly?

Is there another way I can structure my code so that I can run the sync_em.py 
and sync_pg.py scripts, and they can pull common functions from somewhere?

Cheers,
Victor

On Tuesday, 29 October 2013 12:08:10 UTC+11, Victor Hooi  wrote:
 Hi,
 
 
 
 If I try to use:
 
 
 
 from .common.common_foo import setup_foo_logging
 
 
 
 I get:
 
 
 
 ValueError: Attempted relative import in non-package
 
 
 
 And the absolute imports don't seem to be able to find the right modules.
 
 
 
 Is it something to do with the fact I'm running the sync_em.py script from 
 the foo_loading/em_load directory?
 
 
 
 I thought I could just refer to the full path, and it'd find it, but 
 evidently not...hmm.
 
 
 
 Cheers,
 
 Victor
 
 
 
 On Tuesday, 29 October 2013 12:01:03 UTC+11, Ben Finney  wrote:
 
  Victor Hooi victorh...@gmail.com writes:
 
  
 
  
 
  
 
   Ok, so I should be using absolute imports, not relative imports.
 
  
 
  
 
  
 
  I'd say it is fine to use relative imports, so long as they are
 
  
 
  explicit. (In Python 3, the default for an import is to be absolute, and
 
  
 
  the *only* way to do a relative import is to make it explicitly
 
  
 
  relative. So you may as well start doing so now.)
 
  
 
  
 
  
 
   Hmm, I just tried to use absolute imports, and it can't seem to locate
 
  
 
   the modules:
 
  
 
  
 
  
 
   In the file foo_loading/em_load/sync_em.py, I have:
 
  
 
  
 
  
 
   from common.common_bex import setup_foo_logging
 
  
 
  
 
  
 
  So I'd recommend this be done with an explicit relative import:
 
  
 
  
 
  
 
  from .common.common_bex import setup_foo_logging
 
  
 
  
 
  
 
  or, better, import a module:
 
  
 
  
 
  
 
  from .common import common_bex
 
  
 
  
 
  
 
  or a whole package:
 
  
 
  
 
  
 
  from . import common
 
  
 
  
 
  
 
  -- 
 
  
 
   \ “I went over to the neighbor's and asked to borrow a cup of |
 
 
`\   salt. ‘What are you making?’ ‘A salt lick.’” —Steven Wright |
 
  
 
  _o__)  |
 
  
 
  Ben Finney
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to avoid checking the same condition repeatedly ?

2013-10-29 Thread Chris Angelico
On Tue, Oct 29, 2013 at 5:53 PM, Peter Cacioppi
peter.cacio...@gmail.com wrote:
 But this sort of bottleneck refactoring can be done in a careful way that 
 minimizes the damage to readability. And a strength of py is it tends to 
 encourage this as pretty as possible approach to bottleneck refactoring.

 This is what you're saying, right?

Yep, that's about the size of it. Want some examples of what costs no
clarity to reimplement in another language? Check out the Python
standard library. Some of that is implemented in C (in CPython) and
some in Python, and you can't tell and needn't care which. Code
clarity isn't hurt, because those functions would be named functions
even without.

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


Re: Organising packages/modules - importing functions from a common.py in a separate directory?

2013-10-29 Thread Peter Otten
Victor Hooi wrote:

 Hi,
 
 Hmm, this post on SO seems to suggest that importing from another sibling
 directory in a package ins't actually possibly in Python without some ugly
 hacks?
 
 http://stackoverflow.com/questions/6323860/sibling-package-imports
 
 Did I read the above correctly?

Yes.
 
 Is there another way I can structure my code so that I can run the
 sync_em.py and sync_pg.py scripts, and they can pull common functions from
 somewhere?

The packages you are trying to access in your original post 

 foo_loading/
 __init__.py
 common/
 common_foo.py
 em_load/
 __init__.py
 config.yaml
 sync_em.py
 pg_load/
 __init__.py
 config.yaml
 sync_pg.py


aren't actually siblings in the sense of the stackoverflow topic above, they 
are subpackages of foo_loading, and as you already found out

 So from within the sync_em.py script, I'm trying to import a function from 
foo_loading/common/common_foo.py.
 
 from ..common.common_foo import setup_foo_logging
 
 I get the error:
 
 ValueError: Attempted relative import in non-package 
 
 If I change directories to the parent of foo_loading, then run
 
 python -m foo_loading.em_load.sync_em sync_em.py
 
 it works. However, this seems a bit roundabout, and I suspect I'm not 
doing things correctly.
 
 Ideally, I want a user to be able to just run sync_em.py from it's own 
directory, and have it correctly import the logging/config modules from 
common_foo.py, and just work.
 
 What is the correct way to achieve this?

you can access them as long as the *parent* directory of foo_loading is in 
sys.path through PYTHONPATH, or as the working directory, or any other 
means. However, if you step into the package, e. g.

$ cd foo_loading
$ python -c 'import common'

then from Python's point of view 'common' is a toplevel package rather than 
the intended 'foo_loading.common', and intra-package imports will break.

To preserve your sanity I therefore recommend that you 

(1) avoid to put package directories into sys.path
(1a) avoid to cd into a package
(2) put scripts you plan to invoke directly rather than import outside the 
package.

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


Re: Curdling: Concurrent package installer for python

2013-10-29 Thread Mark Lawrence

On 29/10/2013 02:11, Blaine LaFreniere wrote:

Sounds nice. I'll see about checking it out later. Good luck with the project.



Since when is making a drink a project?  As it happens I don't 
particularly like tea, so I'll have coffee please, black, no sugar.  Or 
have I made a wrong assumption about your context?


--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

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


Re: Slicing with negative strides

2013-10-29 Thread Duncan Booth
Steven D'Aprano st...@pearwood.info wrote:

 Does anyone here use slices (or range/xrange) with negative strides
 other than -1?
 
 E.g. sequence[2:15:-3]

With any negative stride your example is just the empty sequence.

 
 
 If so, there is a discussion (long, long, looong discussion) on
 the python-ideas mailing list, debating whether or not to deprecate or
 change the behaviour of slicing with negative strides. So if you care
 about the current behaviour, now is the time to stand up and be
 counted. 
 
 (Standing up *here* is fine, don't feel that you have to join yet
 another list.)
 
For those of us that don't really want to join another mailing list, could 
you summarise what change is being proposed?


-- 
Duncan Booth http://kupuguy.blogspot.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Slicing with negative strides

2013-10-29 Thread Mark Lawrence

On 29/10/2013 05:22, Steven D'Aprano wrote:

Does anyone here use slices (or range/xrange) with negative strides other
than -1?

E.g. sequence[2:15:-3]



In 10 ish years I don't recall ever considering it, let alone doing it.

--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

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


Re: Organising packages/modules - importing functions from a common.py in a separate directory?

2013-10-29 Thread Jean-Michel Pichavant
- Original Message -
 Hi,
 
 If I try to use:
 
 from .common.common_foo import setup_foo_logging
 
 I get:
 
 ValueError: Attempted relative import in non-package

If you're using python 3, forget what I said about not using relative imports. 
I think they've implemented the necessary grammar to make it work.

Cheers,

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


Re: Slicing with negative strides

2013-10-29 Thread Mark Lawrence

On 29/10/2013 08:53, Duncan Booth wrote:

Steven D'Aprano st...@pearwood.info wrote:


Does anyone here use slices (or range/xrange) with negative strides
other than -1?

E.g. sequence[2:15:-3]


With any negative stride your example is just the empty sequence.




If so, there is a discussion (long, long, looong discussion) on
the python-ideas mailing list, debating whether or not to deprecate or
change the behaviour of slicing with negative strides. So if you care
about the current behaviour, now is the time to stand up and be
counted.

(Standing up *here* is fine, don't feel that you have to join yet
another list.)


For those of us that don't really want to join another mailing list, could
you summarise what change is being proposed?



Umpteen options have been put forward.  IMHO the bookies favourite is 
currently being endorsed by Tim Peters and Terry Reedy, yours odds may 
vary :)


--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

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


problem importing

2013-10-29 Thread C. Ng
Hi all,
So I cloned a package xyz from github. OS is ubuntu 12.04.
Then install successfully using sudo python setup.py install
Now when I try to import xyz, I get ImportError: No module named xyz unless 
my current working directory is in xyz.
Appreciate your help. Thanks.


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


Re: Slicing with negative strides

2013-10-29 Thread Terry Reedy

On 10/29/2013 4:53 AM, Duncan Booth wrote:

Steven D'Aprano st...@pearwood.info wrote:


Does anyone here use slices (or range/xrange) with negative strides
other than -1?

E.g. sequence[2:15:-3]


With any negative stride your example is just the empty sequence.


The idea is that one would not have to reverse 2 and 15 to get a 
non-empty sequence.


--
Terry Jan Reedy

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


Re: problem importing

2013-10-29 Thread Peter Otten
C. Ng wrote:

 Hi all,
 So I cloned a package xyz from github. OS is ubuntu 12.04.
 Then install successfully using sudo python setup.py install
 Now when I try to import xyz, I get ImportError: No module named xyz
 unless my current working directory is in xyz. Appreciate your help.
 Thanks.

Maybe the author called the toplevel package pyxyz or XYZ -- when you don't 
provide the actual package name/github url we can only guess.

Or

$ which python

and

$ sudo which python

point to different Python installations.

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


[OT] Re: Python Front-end to GCC

2013-10-29 Thread Antoine Pitrou
Steven D'Aprano steve+comp.lang.python at pearwood.info writes:
 
 On Fri, 25 Oct 2013 21:36:42 +0100, Mark Lawrence wrote:
 
  Mind you, the thought of a bot with a Ph.D. is mind boggling.
 
 You can buy degrees on the Internet quite cheaply:
 
 http://en.wikipedia.org/wiki/List_of_animals_with_fraudulent_diplomas
 
 PhD's are more expensive, which leads me to think that Mark Jenssen is 
 being a tad flexible with the truth when he claims to have one.

He could be an upper-class twit. He would certainly have his chance in
the yearly competition ;-)

Regards

Antoine.


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


Re: Slicing with negative strides

2013-10-29 Thread Steven D'Aprano
On Tue, 29 Oct 2013 08:53:08 +, Duncan Booth wrote:

 Steven D'Aprano st...@pearwood.info wrote:
 
 Does anyone here use slices (or range/xrange) with negative strides
 other than -1?
 
 E.g. sequence[2:15:-3]
 
 With any negative stride your example is just the empty sequence.

Gah, sorry about that, that's the suggested *new* syntax. Possibly my 
subconscious likes it better than my conscious :-)

Try this instead: sequence[15:2:-3]


 If so, there is a discussion (long, long, looong discussion) on the
 python-ideas mailing list, debating whether or not to deprecate or
 change the behaviour of slicing with negative strides. So if you care
 about the current behaviour, now is the time to stand up and be
 counted.
 
 (Standing up *here* is fine, don't feel that you have to join yet
 another list.)
 
 For those of us that don't really want to join another mailing list,
 could you summarise what change is being proposed?

* Negative strides should be deprecated and then removed.

* Or just deprecated.

* Or change the semantics of negative strides so that 
  seq[2:15:-2] works as expected.

* Or get rid of negative indexing.

* Or add new syntax to control whether or not the end points are included.

* Or ... 


It's Python-Ideas, otherwise known as Bike-Shed Central :-)

I think the main idea which is likely (since Guido seems to be slightly 
leaning that way) is to deprecate negative strides, remove them in a 
release or three, and then re-introduce them in Python 4000 but with more 
intuitive semantics.



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


Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea.

2013-10-29 Thread Skybuck Flying

Because it's logical.



What is logical?


To put the exit condition at the bottom is logical.

The exit condition glues the loop to the code that will be executed next 
which is also at the bottom.


Example:

Loop

NextCode

^


Placing the exit ondition near next code makes more sense at least in 
situation where I was programming.


I will give you an example:



LoopBegin( Step = 10 )

   if ButtonExists then
   begin
   ClickButton()
   end;

LoopEnd( ButtonClicked )

Execute next code...

This loop waits for the button to appear, once it's found it is clicked and 
then the loop exits to continue the next code.


Putting this exit condition on the top makes no sense.

Bye,
 Skybuck. 


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


Help with guessing game :D

2013-10-29 Thread Robert Gonda
Hey guys, so I figured I will give python a shot. I got to exercise that has 
asked me to create a number guessing game which weren't a problem, 
guessesTaken = 0 #This is a Guesses taken counter
print(Hello, what's your name?) #Asking the user to input their name
N = raw_input() #What the user's name is
import random #This is importing the random function
number = random.randint(1, 999) #This tells the random function to generate a 
random number between 1 to 1000
print(N + , I'm thinking of a number between 1-1000) #Not needed but tells 
the user their name and tells them that it's thinking of a number betweeen 1 to 
1000
while guessesTaken  10: 
print('Take a guess.') 
guess = input()
guess = int(guess)
guessesTaken = guessesTaken + 1
if guess  number: #Says that if the guess is too low it will print a 
message saying that the guess is too low
print('Your guess is too low.') 
if guess  number: #Says that if the guess is too high it will print a 
message saying that the guess is too high
print('Your guess is too high.')
if guess == number:
break #Breaks the loop, meaning it will continue to loop for 10 times 
while giving them messages from above depending on their results
if guess == number:
guessesTaken = str(guessesTaken)
print(Congrat's,  + N + ! You managed to get the number in  + 
guessesTaken +  guesses!) #Tells the user they managed to guess it in x 
number of times
if guess != number: #If the user is unable to guess the number in 10 times it 
will stop the loop and give the user a message
number = str(number)
print(No, the right number was + number)

However the problem is that it also asked me to do the following : If at least 
one of the digit guessed is right it will say y otherwise n which I can't 
seem to do :/ any help?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help with guessing game :D

2013-10-29 Thread Chris Angelico
On Tue, Oct 29, 2013 at 10:45 PM, Robert Gonda
robertgonda1...@gmail.com wrote:
 N = raw_input() #What the user's name is
 print(N + , I'm thinking of a number between 1-1000) #Not needed but tells 
 the user their name and tells them that it's thinking of a number betweeen 1 
 to 1000
 guess = input()
 guess = int(guess)

Which version of Python are you using? The raw_input call is very
Python 2, but you're using print as a function, and then you're
converting input()'s result to an integer, both of which suggest
Python 3.x. If you're using Python 2, do NOT use input() - it is
dangerous, deceptively so. In Python 3, that problem no longer
applies.

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


Re: Help with guessing game :D

2013-10-29 Thread Robert Gonda
On Tuesday, 29 October 2013 11:53:55 UTC, Chris Angelico  wrote:
 On Tue, Oct 29, 2013 at 10:45 PM, Robert Gonda
 
 robertgonda1...@gmail.com wrote:
 
  N = raw_input() #What the user's name is
 
  print(N + , I'm thinking of a number between 1-1000) #Not needed but 
  tells the user their name and tells them that it's thinking of a number 
  betweeen 1 to 1000
 
  guess = input()
 
  guess = int(guess)
 
 
 
 Which version of Python are you using? The raw_input call is very
 
 Python 2, but you're using print as a function, and then you're
 
 converting input()'s result to an integer, both of which suggest
 
 Python 3.x. If you're using Python 2, do NOT use input() - it is
 
 dangerous, deceptively so. In Python 3, that problem no longer
 
 applies.
 
 
 
 ChrisA

Hi Chris and thanks for the reply, I'm using python 3.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help with guessing game :D

2013-10-29 Thread Robert Gonda
On Tuesday, 29 October 2013 11:54:49 UTC, Robert Gonda  wrote:
 On Tuesday, 29 October 2013 11:53:55 UTC, Chris Angelico  wrote:
 
  On Tue, Oct 29, 2013 at 10:45 PM, Robert Gonda
 
  
 
  robertgonda1...@gmail.com wrote:
 
  
 
   N = raw_input() #What the user's name is
 
  
 
   print(N + , I'm thinking of a number between 1-1000) #Not needed but 
   tells the user their name and tells them that it's thinking of a number 
   betweeen 1 to 1000
 
  
 
   guess = input()
 
  
 
   guess = int(guess)
 
  
 
  
 
  
 
  Which version of Python are you using? The raw_input call is very
 
  
 
  Python 2, but you're using print as a function, and then you're
 
  
 
  converting input()'s result to an integer, both of which suggest
 
  
 
  Python 3.x. If you're using Python 2, do NOT use input() - it is
 
  
 
  dangerous, deceptively so. In Python 3, that problem no longer
 
  
 
  applies.
 
  
 
  
 
  
 
  ChrisA
 
 
 
 Hi Chris and thanks for the reply, I'm using python 3.

Tried to get rid of it but it just gives me an error, that's why I used 
raw_input
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Cookie fr*cking problem

2013-10-29 Thread Neil Cerutti
On 2013-10-29, Steven D'Aprano st...@pearwood.info wrote:
 On Mon, 28 Oct 2013 13:20:17 +, Neil Cerutti wrote:

 On 2013-10-27, Ben Finney ben+pyt...@benfinney.id.au wrote:
 I have no particular objection to you responding to those
 instances of bad behaviour that I've omitted.
 
 So you omitted them, eh?
 
 You just omitted the body of the letter, that's all! You've
 left out the body of the letter, that's all. Yours is not to
 reason why, Jamison. You've left out the body of the letter!
 
 ...
 
 Fine. Send it that way, and tell them the body will follow.

 Was that the letter made out to the solicitors Hummerdinger,
 Hummerdinger, Hummerdinger, Hummerdinger, and McCormack? As I
 recall, not only did the secretary leave out one of the
 Hummerdingers, but he left out the most important one.

Yep, from, Animal Crackers. Although I believe it's,
Hunger-Dunger. You were close though. You were close though,
and I bet you still are. ;)

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


Re: Help with guessing game :D

2013-10-29 Thread Alister
On Tue, 29 Oct 2013 05:05:19 -0700, Robert Gonda wrote:
 
  
  converting input()'s result to an integer, both of which suggest
 
 

if you need to be checking individual digits you are probably best 
keeping the input  number to be checked as strings.

it would then be a trivial task to expand this program to work with words 
as well as numbers.




-- 
No one gets too old to learn a new way of being stupid.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help with guessing game :D

2013-10-29 Thread Robert Gonda
On Tuesday, 29 October 2013 12:58:09 UTC, Alister  wrote:
 On Tue, 29 Oct 2013 05:05:19 -0700, Robert Gonda wrote:
 
  
 
   
 
   converting input()'s result to an integer, both of which suggest
 
  
 
  
 
 
 
 if you need to be checking individual digits you are probably best 
 
 keeping the input  number to be checked as strings.
 
 
 
 it would then be a trivial task to expand this program to work with words 
 
 as well as numbers.
 
 
 
 
 
 
 
 
 
 -- 
 
 No one gets too old to learn a new way of being stupid.

I see, so how should i do it? I wouldn't mind having no text in it I just need 
the program to generate the number and the user to try to guess what the number 
is, so for example if a python would generate num 770 and the user would guess 
870 it would say NYN
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help with guessing game :D

2013-10-29 Thread Alister
On Tue, 29 Oct 2013 06:03:55 -0700, Robert Gonda wrote:

 On Tuesday, 29 October 2013 12:58:09 UTC, Alister  wrote:
 On Tue, 29 Oct 2013 05:05:19 -0700, Robert Gonda wrote:
 
 
  
 
   
   converting input()'s result to an integer, both of which suggest
 
 
  
 
  
 
 
 if you need to be checking individual digits you are probably best
 
 keeping the input  number to be checked as strings.
 
 
 
 it would then be a trivial task to expand this program to work with
 words
 
 as well as numbers.
 
 
 
 
 
 
 
 
 
 --
 
 No one gets too old to learn a new way of being stupid.
 
 I see, so how should i do it? I wouldn't mind having no text in it I
 just need the program to generate the number and the user to try to
 guess what the number is, so for example if a python would generate num
 770 and the user would guess 870 it would say NYN

remember that strings are a sequence.
they can be used as iterators  sliced in the same way as lists  tuples.




-- 
Let a fool hold his tongue and he will pass for a sage.
-- Publilius Syrus
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help with guessing game :D

2013-10-29 Thread Robert Gonda
On Tuesday, 29 October 2013 13:07:08 UTC, Alister  wrote:
 On Tue, 29 Oct 2013 06:03:55 -0700, Robert Gonda wrote:
 
 
 
  On Tuesday, 29 October 2013 12:58:09 UTC, Alister  wrote:
 
  On Tue, 29 Oct 2013 05:05:19 -0700, Robert Gonda wrote:
 
  
 
  
 
   
 
  
 

 
converting input()'s result to an integer, both of which suggest
 
  
 
  
 
   
 
  
 
   
 
  
 
  
 
  if you need to be checking individual digits you are probably best
 
  
 
  keeping the input  number to be checked as strings.
 
  
 
  
 
  
 
  it would then be a trivial task to expand this program to work with
 
  words
 
  
 
  as well as numbers.
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  --
 
  
 
  No one gets too old to learn a new way of being stupid.
 
  
 
  I see, so how should i do it? I wouldn't mind having no text in it I
 
  just need the program to generate the number and the user to try to
 
  guess what the number is, so for example if a python would generate num
 
  770 and the user would guess 870 it would say NYN
 
 
 
 remember that strings are a sequence.
 
 they can be used as iterators  sliced in the same way as lists  tuples.
 
 
 
 
 
 
 
 
 
 -- 
 
 Let a fool hold his tongue and he will pass for a sage.
 
   -- Publilius Syrus

Now you have confused me completely, sorry im just new to python and just 
learning everything :) could you perhaps give me an example? or part of the 
code that's missing?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help with guessing game :D

2013-10-29 Thread Mark Lawrence

On 29/10/2013 11:45, Robert Gonda wrote:

As you've already received and responded to advice please could you 
read, digest and action this https://wiki.python.org/moin/GoogleGroupsPython


TIA.

--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

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


Re: how to avoid checking the same condition repeatedly ?

2013-10-29 Thread Neil Cerutti
On 2013-10-28, Nobody nob...@nowhere.com wrote:
 On Mon, 28 Oct 2013 09:50:19 +, Wolfgang Maier wrote:
 So my question is: is there an agreed-upon generally best way
 of dealing with this?

 Yes. Just leave the test inside the loop.

 If you're sufficiently concerned about performance that you're
 willing to trade clarity for it, you shouldn't be using Python
 in the first place.

When you detect a code small, as Wolfgang did, e.g., I'm
repeating the same exact test condition in several places, you
should not simply ignore it, even in Python.

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


Re: Help with guessing game :D

2013-10-29 Thread Robert Gonda
On Tuesday, 29 October 2013 13:44:45 UTC, Mark Lawrence  wrote:
 On 29/10/2013 11:45, Robert Gonda wrote:
 
 
 
 As you've already received and responded to advice please could you 
 
 read, digest and action this https://wiki.python.org/moin/GoogleGroupsPython
 
 
 
 TIA.
 
 
 
 -- 
 
 Python is the second best programming language in the world.
 
 But the best has yet to be invented.  Christian Tismer
 
 
 
 Mark Lawrence

ah okay, sorry didn't know about that
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How do I update a virtualenv?

2013-10-29 Thread Skip Montanaro
 Where specifically are these instructions that tell you to put the
 virtualenv under VCS control?

https://devcenter.heroku.com/articles/getting-started-with-python

 As you are a Heroku customer (I'm not), would you be willing to
 suggest they alter them based on advice from this forum?

It's not my job to pretend to be an expert about something I am
clearly not. All I would be doing is passing along your perspective on
the matter. I presume they have reasonable reasons for doing things
the way they do it. It would be better for people expert in VCS issues
to discuss this stuff with the Heroku people, who presumably know a
thing or two about application deployment, and can give you their
perspective on why they use git push as a deployment tool.

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


Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea.

2013-10-29 Thread Steven D'Aprano
On Tue, 29 Oct 2013 12:37:36 +0100, Skybuck Flying wrote:

 To put the exit condition at the bottom is logical.
 
 The exit condition glues the loop to the code that will be executed next
 which is also at the bottom.

Skybuck, please excuse my question, but have you ever done any 
programming at all? You don't seem to have any experience with actual 
programming languages.

In a while loop, such as in Python, the test is at the top of the loop 
because the test is performed at the start of the loop, not the end:

while x  0:
do_this()
do_that()


It would be inappropriate (as well as ugly!) to put the test at the end 
of the loop, like this:

x = 0
while:
do_this()
do_that()
many more lines go here
possibly even pages of code
until finally, at long last
you get to the end where you find the test...
x  0

... and discover whether or not the while loop was actually entered or 
not. Similarly with for-loops, the loop condition is at the beginning 
because it runs at the beginning. This would be silly:

for i:
body of loop goes here
could be many many lines of code
even pages of code
but eventually, at long last
we get to the end, and find out
what the first value for i will be
in range(100, 110)


There is one sort of loop where it makes sense to have the loop condition 
at the end. Python doesn't have such a loop, but Pascal does: the repeat 
until loop. Unlike while, repeat until is always executed at least once, 
so the loop condition isn't tested until the end of the loop:

repeat
do this
do that
do something else
until x  0



[...]
 LoopBegin( Step = 10 )
 
 if ButtonExists then
 begin
 ClickButton()
 end;
 
 LoopEnd( ButtonClicked )
 
 Execute next code...
 
 This loop waits for the button to appear, once it's found it is clicked
 and then the loop exits to continue the next code.

What if the button has already appeared before the loop starts?

I think that is better written as:


# Check the loop condition at the start
while the button does not exist:
wait a bit
# Outside the loop
click the button

(Although such a loop is called a busy wait loop, since it keeps the 
computer being busy without doing anything useful. There are better ways 
to do this than a loop.)

Even in Pascal, I would use a while loop rather than repeat, but if you 
insist on using repeat, clicking the button still should go on the 
outside of the loop:

# this is wasteful, since even if the button exists, the loop still 
# waits a bit, for no good reason
repeat
 wait a bit
until the button exists
click the button



 Putting this exit condition on the top makes no sense.

Wait until you actually start programming before deciding what makes 
sense or doesn't.



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


Re: Help with guessing game :D

2013-10-29 Thread Alister
On Tue, 29 Oct 2013 06:10:30 -0700, Robert Gonda wrote:

 On Tuesday, 29 October 2013 13:07:08 UTC, Alister  wrote:
 On Tue, 29 Oct 2013 06:03:55 -0700, Robert Gonda wrote:
 
 
 
  On Tuesday, 29 October 2013 12:58:09 UTC, Alister  wrote:
 
  On Tue, 29 Oct 2013 05:05:19 -0700, Robert Gonda wrote:
 
 
  
 
  
 
   
 
  
 

converting input()'s result to an integer, both of which
suggest
 
 
  
 
  
 
   
 
  
 
   
 
  
 
  
  if you need to be checking individual digits you are probably best
 
 
  
  keeping the input  number to be checked as strings.
 
 
  
 
  
 
  
  it would then be a trivial task to expand this program to work with
 
  words
 
 
  
  as well as numbers.
 
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
  --
 
 
  
  No one gets too old to learn a new way of being stupid.
 
 
  
  I see, so how should i do it? I wouldn't mind having no text in it I
 
  just need the program to generate the number and the user to try to
 
  guess what the number is, so for example if a python would generate
  num
 
  770 and the user would guess 870 it would say NYN
 
 
 
 remember that strings are a sequence.
 
 they can be used as iterators  sliced in the same way as lists 
 tuples.
 
 
 
 
 
 
 
 
 
 --
 
 Let a fool hold his tongue and he will pass for a sage.
 
  -- Publilius Syrus
 
 Now you have confused me completely, sorry im just new to python and
 just learning everything :) could you perhaps give me an example? or
 part of the code that's missing?

you will probably learn more through trial  error than you will from 
being given an answer

to shine some more light on my advise try the following

code=7689
for digit in code:
print(digit)

does this give you any Ideas on how to proceed?



-- 
If you're right 90% of the time, why quibble about the remaining 3%?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Function for the path of the script?

2013-10-29 Thread Grant Edwards
On 2013-10-28, Ben Finney ben+pyt...@benfinney.id.au wrote:
 Grant Edwards invalid@invalid.invalid writes:

 On 2013-10-27, Ben Finney ben+pyt...@benfinney.id.au wrote:

  What workflow requires you to know the filename of the module, within
  the module?

 If you have a utility that can be used to do several related things,
 one way to tell that utility which you want to do is with command line
 arguments.

 That's a case for inspecting the command line.

 For example your utility checks sys.argv[1] for a command or option
 flag. Another way is to give the file multiple names, and check
 sys.argv[0] to see what name you've been invoked under.

 Exactly so. This isn't a use case for finding the filesystem location
 of the module.

Indeed. I was answering a question about a use case knowing the
_filename_, not the path for the file.


-- 
Grant Edwards   grant.b.edwardsYow! I wonder if I should
  at   put myself in ESCROW!!
  gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Function for the path of the script?

2013-10-29 Thread Grant Edwards
On 2013-10-29, Steven D'Aprano st...@pearwood.info wrote:
 On Mon, 28 Oct 2013 21:00:39 -0700, rurpy wrote:

 This was pointed out before but since you said you ignore posts from GG
 you probably missed it, and will probably miss this one too, and thus
 continue to post bad information.
   
 This is a small but illustrative example of why such broad- brush
 filtering is a bad idea.  But it is your choice.

[...]

 If you don't want to be associated with the typical GG posts, you
 have the choice to stop using GG. And just as you make the choice
 that the convenience of GG outweighs the annoyance of being filtered,
 I expect Grant has made the choice that the convenience of avoiding
 unwanted GG posts outweighs the risk of throwing out a useful post or
 two.

At the time I made that choice there was a significant problem with
spam being sent using GG posts.  I'm told that the list server
attempted to filter out those posts, but those of us who read this via
Usenet got the full broadside of ads and scams.  Based on the S/N
ratio of non-spam GG posts, the choice was pretty obvious.

-- 
Grant Edwards   grant.b.edwardsYow! Edwin Meese made me
  at   wear CORDOVANS!!
  gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help with guessing game :D

2013-10-29 Thread Robert Gonda
On Tuesday, 29 October 2013 14:25:10 UTC, Alister  wrote:
 On Tue, 29 Oct 2013 06:10:30 -0700, Robert Gonda wrote:
 
 
 
  On Tuesday, 29 October 2013 13:07:08 UTC, Alister  wrote:
 
  On Tue, 29 Oct 2013 06:03:55 -0700, Robert Gonda wrote:
 
  
 
  
 
  
 
   On Tuesday, 29 October 2013 12:58:09 UTC, Alister  wrote:
 
  
 
   On Tue, 29 Oct 2013 05:05:19 -0700, Robert Gonda wrote:
 
  
 
  
 
   
 
  
 
   
 
  
 

 
  
 
   
 
  
 
 
 
 converting input()'s result to an integer, both of which
 
 suggest
 
  
 
  
 
   
 
  
 
   
 
  
 

 
  
 
   
 
  
 

 
  
 
   
 
  
 
   
 
   if you need to be checking individual digits you are probably best
 
  
 
  
 
   
 
   keeping the input  number to be checked as strings.
 
  
 
  
 
   
 
  
 
   
 
  
 
   
 
   it would then be a trivial task to expand this program to work with
 
  
 
   words
 
  
 
  
 
   
 
   as well as numbers.
 
  
 
  
 
   
 
  
 
   
 
  
 
   
 
  
 
   
 
  
 
   
 
  
 
   
 
  
 
   
 
  
 
   
 
  
 
   
 
   --
 
  
 
  
 
   
 
   No one gets too old to learn a new way of being stupid.
 
  
 
  
 
   
 
   I see, so how should i do it? I wouldn't mind having no text in it I
 
  
 
   just need the program to generate the number and the user to try to
 
  
 
   guess what the number is, so for example if a python would generate
 
   num
 
  
 
   770 and the user would guess 870 it would say NYN
 
  
 
  
 
  
 
  remember that strings are a sequence.
 
  
 
  they can be used as iterators  sliced in the same way as lists 
 
  tuples.
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  --
 
  
 
  Let a fool hold his tongue and he will pass for a sage.
 
  
 
 -- Publilius Syrus
 
  
 
  Now you have confused me completely, sorry im just new to python and
 
  just learning everything :) could you perhaps give me an example? or
 
  part of the code that's missing?
 
 
 
 you will probably learn more through trial  error than you will from 
 
 being given an answer
 
 
 
 to shine some more light on my advise try the following
 
 
 
 code=7689
 
 for digit in code:
 
   print(digit)
 
 
 
 does this give you any Ideas on how to proceed?
 
 
 
 
 
 
 
 -- 
 
 If you're right 90% of the time, why quibble about the remaining 3%?

Unfortunately I'm not that sort of person, the way my brain learns is by 
experimenting, but first I need to know exactly what to write. Then I will play 
around with it and customize it to my needs, sorry to be such a bother guys :/ 
and thanks again for your help it's appreciated a lot :)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: trying to strip out non ascii.. or rather convert non ascii

2013-10-29 Thread wxjmfauth
Le mardi 29 octobre 2013 06:22:27 UTC+1, Steven D'Aprano a écrit :
 On Mon, 28 Oct 2013 07:01:16 -0700, wxjmfauth wrote:
 
 
 
  And of course, logically, they are very, very badly handled with the
 
  Flexible String Representation.
 
 
 
 I'm reminded of Cato the Elder, the Roman senator who would end every 
 
 speech, no matter the topic, with Ceterum censeo Carthaginem esse 
 
 delendam (Furthermore, I consider that Carthage must be destroyed).
 
 
 
 But at least he had the good grace to present that as an opinion, instead 
 
 of repeating a falsehood as if it were a fact.
 
 
 
 
 
 
 
 
 
 -- 
 
 Steven

--

 import timeit
 timeit.timeit(a = 'hundred'; 'x' in a)
0.12621293837694095
 timeit.timeit(a = 'hundreij'; 'x' in a)
0.26411553466961735

If you are understanding the coding of characters, Unicode
and what this FSR does, it is a child play to produce gazillion
of examples like this.

(Notice the usage of a Dutch character instead of a boring €).

jmf


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


Re: trying to strip out non ascii.. or rather convert non ascii

2013-10-29 Thread Tim Chase
On 2013-10-29 08:38, wxjmfa...@gmail.com wrote:
  import timeit
  timeit.timeit(a = 'hundred'; 'x' in a)  
 0.12621293837694095
  timeit.timeit(a = 'hundreij'; 'x' in a)  
 0.26411553466961735

That reads to me as If things were purely UCS4 internally, Python
would normally take 0.264... seconds to execute this test, but core
devs managed to optimize a particular (lower 127 ASCII characters
only) case so that it runs in less than half the time.

Is this not what you intended to demonstrate?  'cuz that sounds
like a pretty awesome optimization to me.

-tkc



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


Re: trying to strip out non ascii.. or rather convert non ascii

2013-10-29 Thread Mark Lawrence

On 29/10/2013 15:38, wxjmfa...@gmail.com wrote:

It's okay folks I'll snip all the double spaced google crap as the 
poster is clearly too bone idle to follow the instructions that have 
been repeatedly posted here asking for people not to post double spaced 
google crap.



Le mardi 29 octobre 2013 06:22:27 UTC+1, Steven D'Aprano a écrit :

On Mon, 28 Oct 2013 07:01:16 -0700, wxjmfauth wrote:

And of course, logically, they are very, very badly handled with the
Flexible String Representation.


I'm reminded of Cato the Elder, the Roman senator who would end every
speech, no matter the topic, with Ceterum censeo Carthaginem esse
delendam (Furthermore, I consider that Carthage must be destroyed).

But at least he had the good grace to present that as an opinion, instead
of repeating a falsehood as if it were a fact.

--

Steven


--


import timeit
timeit.timeit(a = 'hundred'; 'x' in a)

0.12621293837694095

timeit.timeit(a = 'hundreij'; 'x' in a)

0.26411553466961735

If you are understanding the coding of characters, Unicode
and what this FSR does, it is a child play to produce gazillion
of examples like this.

(Notice the usage of a Dutch character instead of a boring €).

jmf



You've stated above that logically unicode is badly handled by the fsr. 
 You then provide a trivial timing example.  WTF???


--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

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


Re: how to avoid checking the same condition repeatedly ?

2013-10-29 Thread rusi
On Tuesday, October 29, 2013 7:14:51 PM UTC+5:30, Neil Cerutti wrote:
 On 2013-10-28, Nobody  wrote:
  If you're sufficiently concerned about performance that you're
  willing to trade clarity for it, you shouldn't be using Python
  in the first place.
 
 
 When you detect a code small, as Wolfgang did, e.g., I'm
 repeating the same exact test condition in several places, you
 should not simply ignore it, even in Python.

Yes
It is an agenda of functional programming that such programs should be 
modularly writeable without loss of performance:
http://homepages.inf.ed.ac.uk/wadler/topics/deforestation.html
[the trees there include lists]

Unfortunately for the imperative programmer, some forms of modularization are 
simply not conceivable that are natural for functional programmers (or as 
Steven noted shell-script writers). eg The loop:

while pred:
  statement
is simply one unit and cannot be split further.

Whereas in a FPL one can write:
iterate statementtakeWhile pred
-- the  being analogous to | in bash
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help with guessing game :D

2013-10-29 Thread Alister
On Tue, 29 Oct 2013 07:40:20 -0700, Robert Gonda wrote:
  
  remember that strings are a sequence.
  they can be used as iterators  sliced in the same way as lists 
 
  tuples.
  
  Let a fool hold his tongue and he will pass for a sage.
 
 
  
-- Publilius Syrus
 
 
  
  Now you have confused me completely, sorry im just new to python and
  just learning everything :) could you perhaps give me an example? or
  part of the code that's missing?

 you will probably learn more through trial  error than you will from
 being given an answer
 
 to shine some more light on my advise try the following
 
 code=7689
 for digit in code:
  print(digit)
 
 does this give you any Ideas on how to proceed?
 
 Unfortunately I'm not that sort of person, the way my brain learns is by
 experimenting, but first I need to know exactly what to write. Then I
 will play around with it and customize it to my needs, sorry to be such
 a bother guys :/ and thanks again for your help it's appreciated a lot
 :)

I wont provide the code but i will try to break the problem down into 
simple steps (this is the most important skill to develop in programming)


set the number to be guessed
get the user input
step through each digit in the input
compare to the co-responding digit in the number to be guessed
generate the required output

actually let me just expand on my earlier teaser code

does this switch on any light-bulbs for you

data='7865'
guess=input('guess')
for key,digit in enumerate(data):
print digit,guess[key]
-- 
Watch all-night Donna Reed reruns until your mind resembles oatmeal.
-- 
https://mail.python.org/mailman/listinfo/python-list


Pickle virtual machines implemented in other languages?

2013-10-29 Thread Patrick

Hi Everyone

I was just wondering if anyone had tried to implement a pickle virtual 
machine in another language? I was thinking that it might make for a 
nice little form of cross language IPC within a trusted environment.


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


Re: Help with guessing game :D

2013-10-29 Thread rusi
On Tuesday, October 29, 2013 8:10:20 PM UTC+5:30, Robert Gonda wrote:
 
 Unfortunately I'm not that sort of person, the way my brain learns is by 
 experimenting, but first I need to know exactly what to write. Then I will 
 play 
 around with it and customize it to my needs, sorry to be such a bother guys 
 :/ 
 and thanks again for your help it's appreciated a lot :)

D
o
n
't

w
o
r
r
y

R
o
b
e
r
t

In case you did not get the gist of 
https://wiki.python.org/moin/GoogleGroupsPython
(which is a it verbose)
your posts come to us like the above.
Just keep a line of context and trim off the rest
a
n
d

y
o
u

s
h
o
u
l
d

b
e

f
i
n
e
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pickle virtual machines implemented in other languages?

2013-10-29 Thread Ned Batchelder

On 10/29/13 12:12 PM, Patrick wrote:

Hi Everyone

I was just wondering if anyone had tried to implement a pickle virtual 
machine in another language? I was thinking that it might make for a 
nice little form of cross language IPC within a trusted environment.




Pickle can execute class constructors, which is what makes it insecure.  
But this also means that you need to have the class definitions on the 
receiving end, which means the receiving end must be in Python.  Unless 
you special-case some set of Python classes and their equivalents in the 
other language, you are limited to the primitive builtins like string, 
dict, list, float, etc.  In that case, you might as well just use json 
as your transport format.


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


Re: Help with guessing game :D

2013-10-29 Thread Robert Gonda
On Tuesday, 29 October 2013 16:24:57 UTC, rusi  wrote:
 On Tuesday, October 29, 2013 8:10:20 PM UTC+5:30, Robert Gonda wrote:
 
  
 
  Unfortunately I'm not that sort of person, the way my brain learns is by 
 
  experimenting, but first I need to know exactly what to write. Then I will 
  play 
 
  around with it and customize it to my needs, sorry to be such a bother guys 
  :/ 
 
  and thanks again for your help it's appreciated a lot :)
 
 
 
 D
 
 o
 
 n
 
 't
 
 
 
 w
 
 o
 
 r
 
 r
 
 y
 
 
 
 R
 
 o
 
 b
 
 e
 
 r
 
 t
 
 
 
 In case you did not get the gist of 
 
 https://wiki.python.org/moin/GoogleGroupsPython
 
 (which is a it verbose)
 
 your posts come to us like the above.
 
 Just keep a line of context and trim off the rest
 
 a
 
 n
 
 d
 
 
 
 y
 
 o
 
 u
 
 
 
 s
 
 h
 
 o
 
 u
 
 l
 
 d
 
 
 
 b
 
 e
 
 
 
 f
 
 i
 
 n
 
 e

  I honestly don't get it? this any better? ;D
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help with guessing game :D

2013-10-29 Thread rusi
On Tuesday, October 29, 2013 10:01:38 PM UTC+5:30, Robert Gonda wrote:

   I honestly don't get it? this any better? ;D

In google groups you will see a small 'show quoted text'
Click it you will see what a cascading avalanche of mess is produced.


Yes GG is stupid, not you. But if you use it (as many of us here do) you are 
expected to compensate for that stupidity
-- 
https://mail.python.org/mailman/listinfo/python-list


stacked decorators and consolidating

2013-10-29 Thread Tim Chase
I've got some decorators that work fine as such:

  @dec1(args1)
  @dec2(args2)
  @dec3(args3)
  def myfun(...):
pass

However, I used that sequence quite a bit, so I figured I could do
something like

  dec_all = dec1(args1)(dec2(args2)(dec3(args3)))

to consolidate the whole mess down to

  @dec_all
  def myfun(...):
pass

However, this yields different (test-breaking) results.  Messing
around, I found that if I write it as

  dec_all = lambda fn: dec1(args1)(dec2(args2)(dec3(args3)(fn)))

it works and passes all preexisting tests.

What am I missing that would cause this difference in behavior?

-tkc




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


Re: Running Python programmes

2013-10-29 Thread darnold
Maybe you're inadvertently running Python with either the '-i' switch or with 
the PYTHONINSPECT environment variable set? 
When you do that, your script will launch an interactive prompt after it 
completes.
 

C:\Python27echo print hello  hello.py

C:\Python27python hello.py
hello

C:\Python27python -i hello.py
hello

 ^Z


C:\Python27set PYTHONINSPECT=1

C:\Python27python hello.py
hello

 ^Z

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


Re: Help with guessing game :D

2013-10-29 Thread Robert Gonda
On Tuesday, 29 October 2013 16:40:01 UTC, rusi  wrote:
 On Tuesday, October 29, 2013 10:01:38 PM UTC+5:30, Robert Gonda wrote:
 
 
 
I honestly don't get it? this any better? ;D
 
 
 
 In google groups you will see a small 'show quoted text'
 
 Click it you will see what a cascading avalanche of mess is produced.
 
 
 
 
 
 Yes GG is stupid, not you. But if you use it (as many of us here do) you are 
 expected to compensate for that stupidity

 Is this better then?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help with guessing game :D

2013-10-29 Thread rusi
On Tuesday, October 29, 2013 10:35:52 PM UTC+5:30, Robert Gonda wrote:
  Is this better then?

By a bit. For most here not enough
Open the 'show quoted text' in your last post it shows like so
[Ive replaced '' by '' so GG will show it

 On Tuesday, October 29, 2013 10:01:38 PM UTC+5:30, Robert Gonda wrote:
  
  
  
I honestly don't get it? this any better? ;D
  
  
  
 In google groups you will see a small 'show quoted text'
  
 Click it you will see what a cascading avalanche of mess is produced.
  
  
  
  
  
 Yes GG is stupid, not you. But if you use it (as many of us here do) you are 
expected to compensate for that stupidity 

Now the actual content and what people expect to see is the following


 On Tuesday, October 29, 2013 10:01:38 PM UTC+5:30, Robert Gonda wrote:
  
I honestly don't get it? this any better? ;D
  
 In google groups you will see a small 'show quoted text'
 Click it you will see what a cascading avalanche of mess is produced.
 Yes GG is stupid, not you. But if you use it (as many of us here do) you are 
expected to compensate for that stupidity 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help with guessing game :D

2013-10-29 Thread Neil Cerutti
On 2013-10-29, Alister alister.w...@ntlworld.com wrote:
 set the number to be guessed
 get the user input
 step through each digit in the input
 compare to the co-responding digit in the number to be guessed
 generate the required output

 actually let me just expand on my earlier teaser code

 does this switch on any light-bulbs for you

 data='7865'
 guess=input('guess')
 for key,digit in enumerate(data):
   print digit,guess[key]

I just want to add that this programming exercise, while pretty
common, stinks.

A new programmer shouldn't be embroiled in the morass of
interactive programming.

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


Re: Help with guessing game :D

2013-10-29 Thread rurpy
On 10/29/2013 05:45 AM, Robert Gonda wrote:
 Hey guys, so I figured I will give python a shot. I got to exercise that has 
 asked me to create a number guessing game which weren't a problem, 
 guessesTaken = 0 #This is a Guesses taken counter
 print(Hello, what's your name?) #Asking the user to input their name
 N = raw_input() #What the user's name is
 import random #This is importing the random function
 number = random.randint(1, 999) #This tells the random function to generate a 
 random number between 1 to 1000
 print(N + , I'm thinking of a number between 1-1000) #Not needed but tells 
 the user their name and tells them that it's thinking of a number betweeen 1 
 to 1000
 while guessesTaken  10: 
 print('Take a guess.') 
 guess = input()
 guess = int(guess)
 guessesTaken = guessesTaken + 1
 if guess  number: #Says that if the guess is too low it will print a 
 message saying that the guess is too low
 print('Your guess is too low.') 
 if guess  number: #Says that if the guess is too high it will print a 
 message saying that the guess is too high
 print('Your guess is too high.')
 if guess == number:
 break #Breaks the loop, meaning it will continue to loop for 10 times 
 while giving them messages from above depending on their results
 if guess == number:
 guessesTaken = str(guessesTaken)
 print(Congrat's,  + N + ! You managed to get the number in  + 
 guessesTaken +  guesses!) #Tells the user they managed to guess it in x 
 number of times
 if guess != number: #If the user is unable to guess the number in 10 times it 
 will stop the loop and give the user a message
 number = str(number)
 print(No, the right number was + number)
 
 However the problem is that it also asked me to do the following : If at 
 least one of the digit guessed is right it will say y otherwise n which I 
 can't seem to do :/ any help?

and

On 10/29/2013 08:25 AM, Alister wrote:
 On Tue, 29 Oct 2013 06:10:30 -0700, Robert Gonda wrote:
[...]
 Now you have confused me completely, sorry im just new to python and
 just learning everything :) could you perhaps give me an example? or
 part of the code that's missing?
 
 you will probably learn more through trial  error than you will from 
 being given an answer

While this is true for some people sometimes, I don't think
it is always true.  Very often it is easier and faster to 
learn something be seeing a worked out example and studying
it to see how it works.  This is especially true when one 
is new to a programming language and doesn't have a good
understanding of the terminology and concepts that people
who have been using the language take for granted.

 to shine some more light on my advise try the following
 
 code=7689
 for digit in code:
   print(digit)
 
 does this give you any Ideas on how to proceed?

Robert, please see if this is what you were trying to do:

-
guessesTaken = 0 #This is a Guesses taken counter
print(Hello, what's your name?) #Asking the user to input their name
N = input() #What the user's name is
import random #This is importing the random function
number = random.randint(1, 999) #This tells the random function to generate a 
random number between 1 to 1000

number_str = str (number) # Convert 'guess' to a string of digits.
while len (number_str)  3:   # If there are less than 3 digits, add leading 
0s until it is three digits.
number_str = 0 + number_str

print(N + , I'm thinking of a number between 1-1000) #Not needed but tells 
the user their name and tells them that it's thinking of a number betweeen 1 to 
1000
while guessesTaken  10: 
print('Take a guess.') 
guess = input()
guess = int(guess)
guessesTaken = guessesTaken + 1
if guess  number: #Says that if the guess is too low it will print a 
message saying that the guess is too low
print('Your guess is too low.') 
if guess  number: #Says that if the guess is too high it will print a 
message saying that the guess is too high
print('Your guess is too high.')
if guess == number:
break #Breaks the loop, meaning it will continue to loop for 10 times 
while giving them messages from above depending on their results

guess_str = str (guess) # Convert 'guess' to a string of digits.
while len (guess_str)  3:  # If there are less than 3 digits, add leading 
0s until it is three digits.
guess_str = 0 + guess_str
if len (guess_str)  3: guess_str = guess_str[-2:]  # Make sure it is no 
longer than 3 digits.
# Here, we know that 'number_str' is exactly 3 digits.  'guess_str' is at 
least
# 3 digits but could be more if the user entered, for example, 34567.
print (digits matched: , end='')
for i in range (2, -1, -1):
# 'i' will have the values, 2, 1, 0. 
if guess_str[i] == number_str[i]: print (Y, end='')
else: print (N, end='')
print()

if guess == number:
guessesTaken = 

Re: Help with guessing game :D

2013-10-29 Thread rusi
On Tuesday, October 29, 2013 10:52:04 PM UTC+5:30, Neil Cerutti wrote:
 I just want to add that this programming exercise, while pretty
 common, stinks.
 
 A new programmer shouldn't be embroiled in the morass of
 interactive programming.

Cheers to that!
If the 'print' statement were called a 'debug' statement, then it would be more 
clear that a clean and correct program should have no debug (ie print) 
statements.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: stacked decorators and consolidating

2013-10-29 Thread MRAB

On 29/10/2013 16:54, Tim Chase wrote:

I've got some decorators that work fine as such:

   @dec1(args1)
   @dec2(args2)
   @dec3(args3)
   def myfun(...):
 pass

However, I used that sequence quite a bit, so I figured I could do
something like

   dec_all = dec1(args1)(dec2(args2)(dec3(args3)))

to consolidate the whole mess down to

   @dec_all
   def myfun(...):
 pass

However, this yields different (test-breaking) results.  Messing
around, I found that if I write it as

   dec_all = lambda fn: dec1(args1)(dec2(args2)(dec3(args3)(fn)))

it works and passes all preexisting tests.

What am I missing that would cause this difference in behavior?


If you apply the stacked decorators you get:

myfun = dec1(args1)(dec2(args2)(dec3(args3)(myfun)))

If you apply dec_all you get:

myfun = dec1(args1)(dec2(args2)(dec3(args3)))(myfun)

See the difference? You need the lambda to fix that.
--
https://mail.python.org/mailman/listinfo/python-list


First day beginner to python, add to counter after nested loop

2013-10-29 Thread jonas . thornvall
I have a 25 row javascript that i try to convert to python to get into the 
language but i run into problem i do not understand howto reach outer loop 
after finnish inner loop, in fact i do not understand when finished. The 
javascript i try to conver is below. 

#!/usr/bin/python
import math
# Function definition is here
def sq(number):
   
   square=1;
   factor=2;
   exponent=2;
   print(x,= );
   while (number3):
 while (square=number):
   factor+=1;
   square=math.pow(factor,exponent);
   now i want to add conter when loop finished, no end like basic
   ??? factor--;
   ??? print(factor, );
   ??? square=math.pow(factor,exponent);
   ??? number=number-(factor*factor);
   ??? square=1; 
   ??? factor=1;
   ---here does second loop finish
return

print(Exp=x^2);
for x in range (22,23):
  sq(x);



Here is the javascript with loop i try to convert.

HTML
HEADTITLETEST/TITLE/HEAD
SCRIPT language=Javascript
function sq(number){  
   square=1;
   factor=2;
   exponent=2;
   document.write(x,= );
   while (number3){
   
   while (square=number)
 {  factor++;
square=Math.pow(factor,exponent);

   }
   factor--;
   document.write(factor, );
   square=Math.pow(factor,exponent);
   number=number-(factor*factor);
   square=1; 
   factor=1;
  } 
  document.write(+,number,BR);
}
document.write(Exp=x^2BR);
for (x=1;x100;x++){
  sq(x);
 }
/script
BODY
/BODY
/HTML
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help with guessing game :D

2013-10-29 Thread Robert Gonda
On Tuesday, October 29, 2013 5:24:08 PM UTC, ru...@yahoo.com wrote:
 On 10/29/2013 05:45 AM, Robert Gonda wrote:
 
  Hey guys, so I figured I will give python a shot. I got to exercise that 
  has asked me to create a number guessing game which weren't a problem, 
 
  guessesTaken = 0 #This is a Guesses taken counter
 
  print(Hello, what's your name?) #Asking the user to input their name
 
  N = raw_input() #What the user's name is
 
  import random #This is importing the random function
 
  number = random.randint(1, 999) #This tells the random function to generate 
  a random number between 1 to 1000
 
  print(N + , I'm thinking of a number between 1-1000) #Not needed but 
  tells the user their name and tells them that it's thinking of a number 
  betweeen 1 to 1000
 
  while guessesTaken  10: 
 
  print('Take a guess.') 
 
  guess = input()
 
  guess = int(guess)
 
  guessesTaken = guessesTaken + 1
 
  if guess  number: #Says that if the guess is too low it will print a 
  message saying that the guess is too low
 
  print('Your guess is too low.') 
 
  if guess  number: #Says that if the guess is too high it will print a 
  message saying that the guess is too high
 
  print('Your guess is too high.')
 
  if guess == number:
 
  break #Breaks the loop, meaning it will continue to loop for 10 
  times while giving them messages from above depending on their results
 
  if guess == number:
 
  guessesTaken = str(guessesTaken)
 
  print(Congrat's,  + N + ! You managed to get the number in  + 
  guessesTaken +  guesses!) #Tells the user they managed to guess it in x 
  number of times
 
  if guess != number: #If the user is unable to guess the number in 10 times 
  it will stop the loop and give the user a message
 
  number = str(number)
 
  print(No, the right number was + number)
 
  
 
  However the problem is that it also asked me to do the following : If at 
  least one of the digit guessed is right it will say y otherwise n which 
  I can't seem to do :/ any help?
 
 
 
 and
 
 
 
 On 10/29/2013 08:25 AM, Alister wrote:
 
  On Tue, 29 Oct 2013 06:10:30 -0700, Robert Gonda wrote:
 
 [...]
 
  Now you have confused me completely, sorry im just new to python and
 
  just learning everything :) could you perhaps give me an example? or
 
  part of the code that's missing?
 
  
 
  you will probably learn more through trial  error than you will from 
 
  being given an answer
 
 
 
 While this is true for some people sometimes, I don't think
 
 it is always true.  Very often it is easier and faster to 
 
 learn something be seeing a worked out example and studying
 
 it to see how it works.  This is especially true when one 
 
 is new to a programming language and doesn't have a good
 
 understanding of the terminology and concepts that people
 
 who have been using the language take for granted.
 
 
 
  to shine some more light on my advise try the following
 
  
 
  code=7689
 
  for digit in code:
 
  print(digit)
 
  
 
  does this give you any Ideas on how to proceed?
 
 
 
 Robert, please see if this is what you were trying to do:
 
 
 
 -
 
 guessesTaken = 0 #This is a Guesses taken counter
 
 print(Hello, what's your name?) #Asking the user to input their name
 
 N = input() #What the user's name is
 
 import random #This is importing the random function
 
 number = random.randint(1, 999) #This tells the random function to generate a 
 random number between 1 to 1000
 
 
 
 number_str = str (number) # Convert 'guess' to a string of digits.
 
 while len (number_str)  3:   # If there are less than 3 digits, add leading 
 0s until it is three digits.
 
 number_str = 0 + number_str
 
 
 
 print(N + , I'm thinking of a number between 1-1000) #Not needed but tells 
 the user their name and tells them that it's thinking of a number betweeen 1 
 to 1000
 
 while guessesTaken  10: 
 
 print('Take a guess.') 
 
 guess = input()
 
 guess = int(guess)
 
 guessesTaken = guessesTaken + 1
 
 if guess  number: #Says that if the guess is too low it will print a 
 message saying that the guess is too low
 
 print('Your guess is too low.') 
 
 if guess  number: #Says that if the guess is too high it will print a 
 message saying that the guess is too high
 
 print('Your guess is too high.')
 
 if guess == number:
 
 break #Breaks the loop, meaning it will continue to loop for 10 times 
 while giving them messages from above depending on their results
 
 
 
 guess_str = str (guess) # Convert 'guess' to a string of digits.
 
 while len (guess_str)  3:  # If there are less than 3 digits, add 
 leading 0s until it is three digits.
 
 guess_str = 0 + guess_str
 
 if len (guess_str)  3: guess_str = guess_str[-2:]  # Make sure it is no 
 longer than 3 digits.
 
 # Here, we know that 'number_str' is exactly 3 digits.  'guess_str' is at 
 

RELEASED: Python 2.6.9 final

2013-10-29 Thread Barry Warsaw
Hello Pythoneers and Pythonistas,

Five years ago this month, we released Python 2.6.  It was an important
version in Python's evolution, as it was developed in tandem with Python 3.0
and had the express intent of starting the transition toward Python 3.

Amazingly, here we are five years later, and I am happy (and a little sad) to
announce the Python 2.6.9 final release.

Python 2.6.9 is a security-only source-only release, and with this, I
officially retire the Python 2.6 branch.  All maintenance of Python 2.6,
including for security issues, has now ended.

So too has my latest stint as Python Release Manager.  Over the 19 years I
have been involved with Python, I've been honored, challenged, stressed, and
immeasurably rewarded by managing several Python releases.  I wish I could
thank each of you individually for all the support you've generously given me
in this role.  You deserve most of the credit for all these great releases;
I'm just a monkey pushing buttons. :)

Here then are some release notes about 2.6.9.

For ongoing maintenance, please see Python 2.7.

Future issues with Python 2.6 may still be tracked in the Python bug tracker,
and you may wish to visit specific issues to see if unofficial patches are
available for 2.6.

http://bugs.python.org

The source can be downloaded from:

http://www.python.org/download/releases/2.6.9/

You can also see what's changed since Python 2.6.8:

http://www.python.org/download/releases/2.6.9/NEWS.txt

Users on OS X 10.9 (Mavericks) please note that issue 18458, which can crash
the interactive interpreter, is *not* fixed in 2.6.9.  If this issue affects
you, please review the tracker for possible options:

http://bugs.python.org/issue18458

Enjoy,
-Barry
(on behalf of the Python development community)


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: stacked decorators and consolidating

2013-10-29 Thread Peter Otten
Tim Chase wrote:

 I've got some decorators that work fine as such:
 
   @dec1(args1)
   @dec2(args2)
   @dec3(args3)
   def myfun(...):
 pass
 
 However, I used that sequence quite a bit, so I figured I could do
 something like
 
   dec_all = dec1(args1)(dec2(args2)(dec3(args3)))

With these shortcuts

a = dec1(args1)
b = dec2(args2)
c = dec3(args3)
 
to make it look less messy your first attempt is

dec_all = a(b(c))

and the final decorated function will be

a(b(c))(myfun)

when it should be

a(b(c(myfun)))

i. e. instead of decorating myfun three times you are decorating the 
decorator c twice and then use the result of that decoration to decorate 
myfunc.

Does that help? I have my doubts ;)

 to consolidate the whole mess down to
 
   @dec_all
   def myfun(...):
 pass
 
 However, this yields different (test-breaking) results.  Messing
 around, I found that if I write it as
 
   dec_all = lambda fn: dec1(args1)(dec2(args2)(dec3(args3)(fn)))
 
 it works and passes all preexisting tests.
 
 What am I missing that would cause this difference in behavior?
 
 -tkc


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


Re: Help with guessing game :D

2013-10-29 Thread rusi
On Tuesday, October 29, 2013 10:54:08 PM UTC+5:30, ru...@yahoo.com wrote:
 Also, what Mark and Rusi were trying to say (not very clearly)
 is that when you post from Google Groups, Google Groups insert
 a lot of empty lines in the  the at the top of the message.

So from the most recent post do you infer that your explanations were 
successful in creating some understanding?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: stacked decorators and consolidating

2013-10-29 Thread Tim Chase
On 2013-10-29 17:42, MRAB wrote:
 If you apply the stacked decorators you get:
 
  myfun = dec1(args1)(dec2(args2)(dec3(args3)(myfun)))
 
 If you apply dec_all you get:
 
  myfun = dec1(args1)(dec2(args2)(dec3(args3)))(myfun)
 
 See the difference? You need the lambda to fix that.

In this case, they happen to be CherryPy decorators:

  @cherrypy.expose()
  @cherrypy.tools.json_in()
  @cherrypy.tools.json_out()
  def myfunc(...): pass

I'd have figured they would be associative, making the result end up
the same either way, but apparently not.  Thanks for helping shed
some light on the subtle difference.

-tkc




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


Re: Help with guessing game :D

2013-10-29 Thread Robert Gonda
On Tuesday, 29 October 2013 17:52:15 UTC, rusi  wrote:
 On Tuesday, October 29, 2013 10:54:08 PM UTC+5:30, ru...@yahoo.com wrote:
 
  Also, what Mark and Rusi were trying to say (not very clearly)
 
  is that when you post from Google Groups, Google Groups insert
 
  a lot of empty lines in the  the at the top of the message.
 
 
 
 So from the most recent post do you infer that your explanations were 
 successful in creating some understanding?

 While of course it has, the bottom line is once I get it to work I will be 
 able to experiment with it, I'm new to this and while you might not think 
 this is a good way to learn i have been thought like this all my life (as 
 far as I can remember) so it's not so easy for me when I don't even know 
 where or have to begin and I don't mean to sound offensive. Thank you for 
 your reply sir.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help with guessing game :D

2013-10-29 Thread Robert Gonda
On Tuesday, 29 October 2013 11:45:39 UTC, Robert Gonda  wrote:
 Hey guys, so I figured I will give python a shot. I got to exercise that has 
 asked me to create a number guessing game which weren't a problem, 
 
 guessesTaken = 0 #This is a Guesses taken counter
 
 print(Hello, what's your name?) #Asking the user to input their name
 
 N = raw_input() #What the user's name is
 
 import random #This is importing the random function
 
 number = random.randint(1, 999) #This tells the random function to generate a 
 random number between 1 to 1000
 
 print(N + , I'm thinking of a number between 1-1000) #Not needed but tells 
 the user their name and tells them that it's thinking of a number betweeen 1 
 to 1000
 
 while guessesTaken  10: 
 
 print('Take a guess.') 
 
 guess = input()
 
 guess = int(guess)
 
 guessesTaken = guessesTaken + 1
 
 if guess  number: #Says that if the guess is too low it will print a 
 message saying that the guess is too low
 
 print('Your guess is too low.') 
 
 if guess  number: #Says that if the guess is too high it will print a 
 message saying that the guess is too high
 
 print('Your guess is too high.')
 
 if guess == number:
 
 break #Breaks the loop, meaning it will continue to loop for 10 times 
 while giving them messages from above depending on their results
 
 if guess == number:
 
 guessesTaken = str(guessesTaken)
 
 print(Congrat's,  + N + ! You managed to get the number in  + 
 guessesTaken +  guesses!) #Tells the user they managed to guess it in x 
 number of times
 
 if guess != number: #If the user is unable to guess the number in 10 times it 
 will stop the loop and give the user a message
 
 number = str(number)
 
 print(No, the right number was + number)
 
 
 
 However the problem is that it also asked me to do the following : If at 
 least one of the digit guessed is right it will say y otherwise n which I 
 can't seem to do :/ any help?

 Back to question, name is also not working, I currently have python 3.3.2 and 
 the only to get that work is the write raw_input, I have no idea why, did i 
 do soemthing wrong?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First day beginner to python, add to counter after nested loop

2013-10-29 Thread Neil Cerutti
On 2013-10-29, jonas.thornv...@gmail.com jonas.thornv...@gmail.com wrote:
 I have a 25 row javascript that i try to convert to python to get into the 
 language but i run into problem i do not understand howto reach outer loop 
 after finnish inner loop, in fact i do not understand when finished. The 
 javascript i try to conver is below. 

 #!/usr/bin/python
 import math
 # Function definition is here
 def sq(number):

square=1;
factor=2;
exponent=2;
print(x,= );
while (number3):
  while (square=number):
factor+=1;
square=math.pow(factor,exponent);
now i want to add conter when loop finished, no end like basic
??? factor--;  
??? print(factor, );
??? square=math.pow(factor,exponent);
??? number=number-(factor*factor);
??? square=1; 
??? factor=1;
---here does second loop finish
 return

 print(Exp=x^2);
 for x in range (22,23):
   sq(x);



 Here is the javascript with loop i try to convert.

Output:
7 = 2 + 3 
number  square  factor  exponent
7   1   2   2
9   3
3   1   1


HTML
HEADTITLETEST/TITLE/HEAD
SCRIPT language=Javascript
 function sq(number){  
square=1;
factor=2;
exponent=2;
document.write(x,= );
while (number3) {
  while (square=number) {
factor++;
square=Math.pow(factor,exponent);
  }
  factor--;  
  document.write(factor, );
  square=Math.pow(factor,exponent);
  number=number-(factor*factor);
  square=1; 
  factor=1;
   }   
   document.write(+,number,BR);
 }
 document.write(Exp=x^2BR);
 for (x=1;x100;x++){
   sq(x);
  }
/script
BODY
/BODY
/HTML

What on does function sq do? Squank? Squarp? Squijel?

For number 7, I'm thinking I get output:

7 = 2 + 3

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


Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea.

2013-10-29 Thread wolfgang kern

Bernhard Schornak replied to a Flying-Bucket-post:

Methink we all know about the often not-so-logical ideas from
Buck, they merely come from an abstracted view and are far away
from todays hardware given opportunities.

OTOH, I sometimes got to think about his weird ideas, but mainly
figured that his demands are already covered by hardware but may
not have entered his Delphi/Python-HLL-world yet.
Most of the asked features may be found implemented in the C/C+-
area even just as intrisincs since a while anyway now.

__
wolfgang
(for those who dont know:
 I'm a purist machine code programmer since more than 35 years)





 


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


Re: RELEASED: Python 2.6.9 final

2013-10-29 Thread Tim Chase
On 2013-10-29 13:48, Barry Warsaw wrote:
 All maintenance of Python 2.6, including for security issues, has
 now ended.
 
 So too has my latest stint as Python Release Manager.

I'm sorry to see you step down, but am thankful for your many years of
solid work.  Wishing you the best,

-tkc




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


Re: First day beginner to python, add to counter after nested loop

2013-10-29 Thread jonas . thornvall
Den tisdagen den 29:e oktober 2013 kl. 19:09:03 UTC+1 skrev Neil Cerutti:
 On 2013-10-29, jonas.thornv...@gmail.com jonas.thornv...@gmail.com wrote:
 
  I have a 25 row javascript that i try to convert to python to get into the 
  language but i run into problem i do not understand howto reach outer loop 
  after finnish inner loop, in fact i do not understand when finished. The 
  javascript i try to conver is below. 
 
 
 
  #!/usr/bin/python
 
  import math
 
  # Function definition is here
 
  def sq(number):
 
 
 
 square=1;
 
 factor=2;
 
 exponent=2;
 
 print(x,= );
 
 while (number3):
 
   while (square=number):
 
 factor+=1;
 
 square=math.pow(factor,exponent);
 
 now i want to add conter when loop finished, no end like basic
 
 ??? factor--;  
 
 ??? print(factor, );
 
 ??? square=math.pow(factor,exponent);
 
 ??? number=number-(factor*factor);
 
 ??? square=1; 
 
 ??? factor=1;
 
 ---here does second loop finish
 
  return
 
 
 
  print(Exp=x^2);
 
  for x in range (22,23):
 
sq(x);
 
 
 
 
 
 
 
  Here is the javascript with loop i try to convert.
 
 
 
 Output:
 
 7 = 2 + 3 
 
 number  square  factor  exponent
 
 7   1   2   2
 
 9   3
 
 3   1   1
 
 
 
 
 
 HTML
 
 HEADTITLETEST/TITLE/HEAD
 
 SCRIPT language=Javascript
 
  function sq(number){  
 
 square=1;
 
 factor=2;
 
 exponent=2;
 
 document.write(x,= );
 
 while (number3) {
 
   while (square=number) {
 
 factor++;
 
 square=Math.pow(factor,exponent);
 
   }
 
   factor--;  
 
   document.write(factor, );
 
   square=Math.pow(factor,exponent);
 
   number=number-(factor*factor);
 
   square=1; 
 
   factor=1;
 
}   
 
document.write(+,number,BR);
 
  }
 
  document.write(Exp=x^2BR);
 
  for (x=1;x100;x++){
 
sq(x);
 
   }
 
 /script
 
 BODY
 
 /BODY
 
 /HTML
 
 
 
 What on does function sq do? Squank? Squarp? Squijel?
 
 
 
 For number 7, I'm thinking I get output:
 
 
 
 7 = 2 + 3
 
 
 
 -- 
 
 Neil Cerutti

It write out numbers on modular? square form, just copy past the HTML embedded 
javascript into text, save as HTML run i brower and you see.

Decimal base 
1234=1000+200+30+4 i bad at terminiology but let us call modular base 10 form.

The script convert to modular square form number and write out. 
1234= 35 3 +0
35^2 + 3^3 = 1225 + 9 =1234

It is very basic
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help with guessing game :D

2013-10-29 Thread rurpy
On Tuesday, October 29, 2013 11:52:15 AM UTC-6, rusi wrote:
 On Tuesday, October 29, 2013 10:54:08 PM UTC+5:30, ru...@yahoo.com wrote:
  Also, what Mark and Rusi were trying to say (not very clearly)
  is that when you post from Google Groups, Google Groups insert 
  a lot of empty lines in the  the at the top of the message.

 So from the most recent post do you infer that your explanations 
 were successful in creating some understanding?

I have been suitably chastened and will have more respect for a variety
of approaches in the future.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help with guessing game :D

2013-10-29 Thread rurpy
On Tuesday, October 29, 2013 11:45:56 AM UTC-6, Robert Gonda wrote:
 Thank you very much for your reply, however it gives me an error,
 something about the end, do you know whats wrong with it? 
 (Still not sure if im posting this right so sorry)

...an error, something about the 'end' is not much to go on. :-)

Most of the time, when there is an error in a python program,
Python will print traceback error message.  When asking for 
help please copy and paste those lines in your post.  Without
that it is just a guessing game for anyone to try and figure
out what is wrong.

Did perhaps your traceback message look like this?

  File xx3.py, line 28
print (digits matched: , end='')
  ^

If so, you are running your program with python2, not python3.
So you need to either figure out how to run python3 (does entering
the command python3 do anything?) or change the program to work
with python2.

If the error message was different than above, you need to post 
it here if people are to have any chance of helping you figure 
out what is wrong.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help with guessing game :D

2013-10-29 Thread rusi
On Tuesday, October 29, 2013 11:56:28 PM UTC+5:30, ru...@yahoo.com wrote:
 On Tuesday, October 29, 2013 11:52:15 AM UTC-6, rusi wrote:
  On Tuesday, October 29, 2013 10:54:08 PM UTC+5:30, ru...@yahoo.com wrote:
   Also, what Mark and Rusi were trying to say (not very clearly)
   is that when you post from Google Groups, Google Groups insert 
   a lot of empty lines in the  the at the top of the message.
 
 
  So from the most recent post do you infer that your explanations 
  were successful in creating some understanding?
 
 
 I have been suitably chastened and will have more respect for a variety
 of approaches in the future.

Heh! Dont be hard on yourself!
When youve been a teacher long enough you will know
- communication is the exception*
- misunderstanding is quite ok
- non-understanding is the norm

* Yeah Fr. Thomas Keating talks about the fact that he prefers communion to 
communication.  Hopefully when I go to heaven I'll find out how the admin there 
is so efficient
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First day beginner to python, add to counter after nested loop

2013-10-29 Thread jonas . thornvall
Den tisdagen den 29:e oktober 2013 kl. 19:23:28 UTC+1 skrev 
jonas.t...@gmail.com:
 Den tisdagen den 29:e oktober 2013 kl. 19:09:03 UTC+1 skrev Neil Cerutti:
 
  On 2013-10-29, jonas.thornv...@gmail.com jonas.thornv...@gmail.com wrote:
 
  
 
   I have a 25 row javascript that i try to convert to python to get into 
   the language but i run into problem i do not understand howto reach outer 
   loop after finnish inner loop, in fact i do not understand when finished. 
   The javascript i try to conver is below. 
 
  
 
  
 
  
 
   #!/usr/bin/python
 
  
 
   import math
 
  
 
   # Function definition is here
 
  
 
   def sq(number):
 
  
 
  
 
  
 
  square=1;
 
  
 
  factor=2;
 
  
 
  exponent=2;
 
  
 
  print(x,= );
 
  
 
  while (number3):
 
  
 
while (square=number):
 
  
 
  factor+=1;
 
  
 
  square=math.pow(factor,exponent);
 
  
 
  now i want to add conter when loop finished, no end like basic
 
  
 
  ??? factor--;  
 
  
 
  ??? print(factor, );
 
  
 
  ??? square=math.pow(factor,exponent);
 
  
 
  ??? number=number-(factor*factor);
 
  
 
  ??? square=1; 
 
  
 
  ??? factor=1;
 
  
 
  ---here does second loop finish
 
  
 
   return
 
  
 
  
 
  
 
   print(Exp=x^2);
 
  
 
   for x in range (22,23):
 
  
 
 sq(x);
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
   Here is the javascript with loop i try to convert.
 
  
 
  
 
  
 
  Output:
 
  
 
  7 = 2 + 3 
 
  
 
  number  square  factor  exponent
 
  
 
  7   1   2   2
 
  
 
  9   3
 
  
 
  3   1   1
 
  
 
  
 
  
 
  
 
  
 
  HTML
 
  
 
  HEADTITLETEST/TITLE/HEAD
 
  
 
  SCRIPT language=Javascript
 
  
 
   function sq(number){  
 
  
 
  square=1;
 
  
 
  factor=2;
 
  
 
  exponent=2;
 
  
 
  document.write(x,= );
 
  
 
  while (number3) {
 
  
 
while (square=number) {
 
  
 
  factor++;
 
  
 
  square=Math.pow(factor,exponent);
 
  
 
}
 
  
 
factor--;  
 
  
 
document.write(factor, );
 
  
 
square=Math.pow(factor,exponent);
 
  
 
number=number-(factor*factor);
 
  
 
square=1; 
 
  
 
factor=1;
 
  
 
 }   
 
  
 
 document.write(+,number,BR);
 
  
 
   }
 
  
 
   document.write(Exp=x^2BR);
 
  
 
   for (x=1;x100;x++){
 
  
 
 sq(x);
 
  
 
}
 
  
 
  /script
 
  
 
  BODY
 
  
 
  /BODY
 
  
 
  /HTML
 
  
 
  
 
  
 
  What on does function sq do? Squank? Squarp? Squijel?
 
  
 
  
 
  
 
  For number 7, I'm thinking I get output:
 
  
 
  
 
  
 
  7 = 2 + 3
 
  
 
  
 
  
 
  -- 
 
  
 
  Neil Cerutti
 
 
 
 It write out numbers on modular? square form, just copy past the HTML 
 embedded javascript into text, save as HTML run i brower and you see.
 
 
 
 Decimal base 
 
 1234=1000+200+30+4 i bad at terminiology but let us call modular base 10 form.
 
 
 
 The script convert to modular square form number and write out. 
 
 1234= 35 3 +0
 
 35^2 + 3^3 = 1225 + 9 =1234
 
 
 
 It is very basic

And it work for any exponential form square, cubic etc. I want to implement in 
python since javascript lack bignumb, and diskread write function.

Exp=x^2
77= 88191 353 26 3 +2
Exp=x^3
77= 1981 153 33 10 4 3 3 +4
Exp=x^4
77= 296 100 33 12 9 5 4 3 3 2 2 2 +12
Exp=x^5
77= 95 33 15 9 6 5 5 3 3 2 2 +9
Exp=x^6
77= 44 28 18 13 9 7 6 5 5 4 3 3 3 3 2 2 2 2 2 2 2 2 +64
Exp=x^7
77= 25 20 16 14 11 7 5 4 3 3 3 2 2 2 2 2 2 2 2 2 2 +128
Exp=x^8
77= 17 12 11 10 9 7 7 6 5 5 5 4 4 4 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 
2 +33
Exp=x^9
77= 12 11 8 7 7 7 5 5 4 4 4 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 +510
Exp=x^10
77= 9 9 7 7 6 6 6 5 5 5 5 5 4 4 4 4 4 4 4 4 3 3 3 3 3 3 3 3 3 3 2 2 2 2 
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 
2 2 2 2 2 2 2 +502
Exp=x^11

Here is code for doing it for any exponent.

HTML
HEADTITLETEST/TITLE/HEAD
SCRIPT language=Javascript

function sq(number,exponent){  
   exp=1;
   factor=2;
   multip=Math.pow(2,exponent);
   document.write(x,= );
   while (numbermultip){
   
   while (exp=number)
 {  factor++;
exp=Math.pow(factor,exponent);

   }
   factor--;
   document.write(factor, );
   exp=Math.pow(factor,exponent);
   number=number-Math.pow(factor,exponent);
   exp=1; 
   factor=1;
  } 
  document.write(+,number,BR);
}


//Set exponent by change y
y=10;
x=77


for (y=2;y20;y++){
document.write(Exp=x^,y,BR);
sq(x,y);
}

/script
BODY
/BODY
/HTML
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help with guessing game :D

2013-10-29 Thread Robert Gonda
On Tuesday, 29 October 2013 18:27:41 UTC, ru...@yahoo.com  wrote:
 On Tuesday, October 29, 2013 11:45:56 AM UTC-6, Robert Gonda wrote:
 
  Thank you very much for your reply, however it gives me an error,
 
  something about the end, do you know whats wrong with it? 
 
  (Still not sure if im posting this right so sorry)
 
 
 
 ...an error, something about the 'end' is not much to go on. :-)
 
 
 
 Most of the time, when there is an error in a python program,
 
 Python will print traceback error message.  When asking for 
 
 help please copy and paste those lines in your post.  Without
 
 that it is just a guessing game for anyone to try and figure
 
 out what is wrong.
 
 
 
 Did perhaps your traceback message look like this?
 
 
 
   File xx3.py, line 28
 
 print (digits matched: , end='')
 
   ^
 
 
 
 If so, you are running your program with python2, not python3.
 
 So you need to either figure out how to run python3 (does entering
 
 the command python3 do anything?) or change the program to work
 
 with python2.
 
 
 
 If the error message was different than above, you need to post 
 
 it here if people are to have any chance of helping you figure 
 
 out what is wrong.

 It says that there is an error in this program and something about invalid 
 syntax, should i perhaps redownload it?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help with guessing game :D

2013-10-29 Thread Robert Gonda
On Tuesday, 29 October 2013 18:35:56 UTC, Robert Gonda  wrote:
 On Tuesday, 29 October 2013 18:27:41 UTC, ru...@yahoo.com  wrote:
 
  On Tuesday, October 29, 2013 11:45:56 AM UTC-6, Robert Gonda wrote:
 
  
 
   Thank you very much for your reply, however it gives me an error,
 
  
 
   something about the end, do you know whats wrong with it? 
 
  
 
   (Still not sure if im posting this right so sorry)
 
  
 
  
 
  
 
  ...an error, something about the 'end' is not much to go on. :-)
 
  
 
  
 
  
 
  Most of the time, when there is an error in a python program,
 
  
 
  Python will print traceback error message.  When asking for 
 
  
 
  help please copy and paste those lines in your post.  Without
 
  
 
  that it is just a guessing game for anyone to try and figure
 
  
 
  out what is wrong.
 
  
 
  
 
  
 
  Did perhaps your traceback message look like this?
 
  
 
  
 
  
 
File xx3.py, line 28
 
  
 
  print (digits matched: , end='')
 
  
 
^
 
  
 
  
 
  
 
  If so, you are running your program with python2, not python3.
 
  
 
  So you need to either figure out how to run python3 (does entering
 
  
 
  the command python3 do anything?) or change the program to work
 
  
 
  with python2.
 
  
 
  
 
  
 
  If the error message was different than above, you need to post 
 
  
 
  it here if people are to have any chance of helping you figure 
 
  
 
  out what is wrong.
 
 
 
  It says that there is an error in this program and something about invalid 
  syntax, should i perhaps redownload it?

 never mind you was right, for some reason I had version 2.7 :/ , and btw I 
 was wondering, is it also possible to make it more complex? such as if the 
 computer will again show “Y” if a digit is correct but if a digit is 
 incorrect it will say H as in too high or “L” if it's too low? (while still 
 keeping Y). Do tell me if it sounds confusing :/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help with guessing game :D

2013-10-29 Thread Dave Angel
On 29/10/2013 14:05, Robert Gonda wrote:


   Back to question, name is also not working, I currently have
python 3.3.2 and the only to get that work is the write raw_input, I
have no idea why, did i do soemthing wrong?


Why did you add those two  symbols in front of your new text?  Each
such symbol is supposed to indicate that another level of quoting is
occuring.  So when I saw your message, I first concluded that you sent a
blank reply.

(I also added another character in front of it, so you'd see it.
Apparently googlegroups messes up your view of things in order to cover
up its bugs in posting.

As for your question.  Yes, you did something wrong.  You thoroughly
underspecified the phrase  not working.

When you run a program and it gets an exception, read the whole
traceback. And when you want help here, copy the WHOLE TRACEBACk.

If raw_input() is working without an exception, then you are NOT running
Python3.x.  Figure that out first, perhaps by sticking these two lines
at the beginning of your code:

import sys
print(sys.version)



-- 
DaveA


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


Re: Help with guessing game :D

2013-10-29 Thread Robert Gonda
On Tuesday, 29 October 2013 19:09:01 UTC, Dave Angel  wrote:
 On 29/10/2013 14:05, Robert Gonda wrote:
 
 
 
 
 
Back to question, name is also not working, I currently have
 
 python 3.3.2 and the only to get that work is the write raw_input, I
 
 have no idea why, did i do soemthing wrong?
 
 
 
 
 
 Why did you add those two  symbols in front of your new text?  Each
 
 such symbol is supposed to indicate that another level of quoting is
 
 occuring.  So when I saw your message, I first concluded that you sent a
 
 blank reply.
 
 
 
 (I also added another character in front of it, so you'd see it.
 
 Apparently googlegroups messes up your view of things in order to cover
 
 up its bugs in posting.
 
 
 
 As for your question.  Yes, you did something wrong.  You thoroughly
 
 underspecified the phrase  not working.
 
 
 
 When you run a program and it gets an exception, read the whole
 
 traceback. And when you want help here, copy the WHOLE TRACEBACk.
 
 
 
 If raw_input() is working without an exception, then you are NOT running
 
 Python3.x.  Figure that out first, perhaps by sticking these two lines
 
 at the beginning of your code:
 
 
 
 import sys
 
 print(sys.version)
 
 
 
 
 
 
 
 -- 
 
 DaveA

Hi dave, yes you was right. I had python 2.7 but I upgraded to python 3 now, 
thanks for help :) by the way, is this showing normally?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: trying to strip out non ascii.. or rather convert non ascii

2013-10-29 Thread wxjmfauth
Le mardi 29 octobre 2013 16:52:49 UTC+1, Tim Chase a écrit :
 On 2013-10-29 08:38, wxjmfa...@gmail.com wrote:
 
   import timeit
 
   timeit.timeit(a = 'hundred'; 'x' in a)  
 
  0.12621293837694095
 
   timeit.timeit(a = 'hundreij'; 'x' in a)  
 
  0.26411553466961735
 
 
 
 That reads to me as If things were purely UCS4 internally, Python
 
 would normally take 0.264... seconds to execute this test, but core
 
 devs managed to optimize a particular (lower 127 ASCII characters
 
 only) case so that it runs in less than half the time.
 
 
 
 Is this not what you intended to demonstrate?  'cuz that sounds
 
 like a pretty awesome optimization to me.
 
 
 
 -tkc



That's very naive. In fact, what happens is just the opposite.
The best case with the FSR is worst than the worst case
without the FSR.

And this is just without counting the effect that this poor
Python is spending its time in switching from one internal
representation to one another, without forgetting the fact
that this has to be tested every time.
The more unicode manipulations one applies, the more time
it demands.

Two tasks, that come in my mind: re and normalization.
It's very interesting to observe what happens when one
normalizes latin text and polytonic Greek text, both with
plenty of diactrics.



Something different, based on my previous example.

What a European user is supposed to think, when she/he
sees, she/he can be penalized by such an amount,
simply by using non ascii characters for a product
which is supposed to be unicode compliant ?

jmf

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


Re: First day beginner to python, add to counter after nested loop

2013-10-29 Thread Dave Angel
On 29/10/2013 14:35, jonas.thornv...@gmail.com wrote:

(Deleting hundreds of quad-spaced garbage.  Please be more considerate
of others if you choose to use buggy googlegroups, maybe starting by
studying:

)

Please indent by 4 columns, not 1.  Since indentation is how scope is
specified in Python, it's very important to get it right.

 i do not understand howto reach outer loop after finnish inner loop, in fact 
 i do not understand when finished.

The inner loop is finished whenever you stop indenting by 8 columns.  If
you have a fundamental problem like this, keep it simple till you
understand it:


q = 12
for x in range(10):
for y in range(3):
q = 3*q + 1
print(inner, q)
print(outer, x*q)

print(done)

Because of the detenting, the print(outer, x*q) is in the outer loop.


-- 
DaveA


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


Re: Organising packages/modules - importing functions from a common.py in a separate directory?

2013-10-29 Thread Victor Hooi
Hi,

Wait - err, subpackage != module, right? Do you think you could explain what a 
sub-package is please? I tried Googling, and couldn't seem to find the term in 
this context.

Also, so you're saying to put the actual script that I want to invoke *outside* 
the Python package.

Do you mean something like this:

 sync_em.py
 sync_pg.py
 foo_loading/ 
 __init__.py 
 common/ 
 common_foo.py 
 em_load/ 
 __init__.py 
 config.yaml 
 em.py
 pg_load/ 
 __init__.py 
 config.yaml 
 pg.py

and the sync_em.py and sync_pg.py would just be thin wrappers pulling in things 
from em.py and pg.py? Is that a recommended approach to organise the code?

Would it make any difference if I actually packaged it up so you could install 
it in site-packages? Could I then call modules from other modules within the 
package?

Cheers,
Victor

On Tuesday, 29 October 2013 18:44:47 UTC+11, Peter Otten  wrote:
 Victor Hooi wrote:
 
 
 
  Hi,
 
  
 
  Hmm, this post on SO seems to suggest that importing from another sibling
 
  directory in a package ins't actually possibly in Python without some ugly
 
  hacks?
 
  
 
  http://stackoverflow.com/questions/6323860/sibling-package-imports
 
  
 
  Did I read the above correctly?
 
 
 
 Yes.
 
  
 
  Is there another way I can structure my code so that I can run the
 
  sync_em.py and sync_pg.py scripts, and they can pull common functions from
 
  somewhere?
 
 
 
 The packages you are trying to access in your original post 
 
 
 
  foo_loading/
 
  __init__.py
 
  common/
 
  common_foo.py
 
  em_load/
 
  __init__.py
 
  config.yaml
 
  sync_em.py
 
  pg_load/
 
  __init__.py
 
  config.yaml
 
  sync_pg.py
 
 
 
 
 
 aren't actually siblings in the sense of the stackoverflow topic above, they 
 
 are subpackages of foo_loading, and as you already found out
 
 
 
  So from within the sync_em.py script, I'm trying to import a function from 
 
 foo_loading/common/common_foo.py.
 
  
 
  from ..common.common_foo import setup_foo_logging
 
  
 
  I get the error:
 
  
 
  ValueError: Attempted relative import in non-package 
 
  
 
  If I change directories to the parent of foo_loading, then run
 
  
 
  python -m foo_loading.em_load.sync_em sync_em.py
 
  
 
  it works. However, this seems a bit roundabout, and I suspect I'm not 
 
 doing things correctly.
 
  
 
  Ideally, I want a user to be able to just run sync_em.py from it's own 
 
 directory, and have it correctly import the logging/config modules from 
 
 common_foo.py, and just work.
 
  
 
  What is the correct way to achieve this?
 
 
 
 you can access them as long as the *parent* directory of foo_loading is in 
 
 sys.path through PYTHONPATH, or as the working directory, or any other 
 
 means. However, if you step into the package, e. g.
 
 
 
 $ cd foo_loading
 
 $ python -c 'import common'
 
 
 
 then from Python's point of view 'common' is a toplevel package rather than 
 
 the intended 'foo_loading.common', and intra-package imports will break.
 
 
 
 To preserve your sanity I therefore recommend that you 
 
 
 
 (1) avoid to put package directories into sys.path
 
 (1a) avoid to cd into a package
 
 (2) put scripts you plan to invoke directly rather than import outside the 
 
 package.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: trying to strip out non ascii.. or rather convert non ascii

2013-10-29 Thread Mark Lawrence

On 29/10/2013 19:16, wxjmfa...@gmail.com wrote:

Le mardi 29 octobre 2013 16:52:49 UTC+1, Tim Chase a écrit :

On 2013-10-29 08:38, wxjmfa...@gmail.com wrote:


import timeit



timeit.timeit(a = 'hundred'; 'x' in a)



0.12621293837694095



timeit.timeit(a = 'hundreij'; 'x' in a)



0.26411553466961735




That reads to me as If things were purely UCS4 internally, Python

would normally take 0.264... seconds to execute this test, but core

devs managed to optimize a particular (lower 127 ASCII characters

only) case so that it runs in less than half the time.



Is this not what you intended to demonstrate?  'cuz that sounds

like a pretty awesome optimization to me.



-tkc




That's very naive. In fact, what happens is just the opposite.
The best case with the FSR is worst than the worst case
without the FSR.

And this is just without counting the effect that this poor
Python is spending its time in switching from one internal
representation to one another, without forgetting the fact
that this has to be tested every time.
The more unicode manipulations one applies, the more time
it demands.

Two tasks, that come in my mind: re and normalization.
It's very interesting to observe what happens when one
normalizes latin text and polytonic Greek text, both with
plenty of diactrics.



Something different, based on my previous example.

What a European user is supposed to think, when she/he
sees, she/he can be penalized by such an amount,
simply by using non ascii characters for a product
which is supposed to be unicode compliant ?

jmf



Please provide hard evidence to support your claims or stop posting this 
ridiculous nonsense.  Give us real world problems that can be reported 
on the bug tracker, investigated and resolved.


--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

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


Re: Help with guessing game :D

2013-10-29 Thread rurpy
On Tuesday, October 29, 2013 1:03:00 PM UTC-6, Robert Gonda wrote:
 never mind you was right, for some reason I had version 2.7 :/ ,
 and btw I was wondering, is it also possible to make it more
 complex? such as if the computer will again show “Y” if a digit
 is correct but if a digit is incorrect it will say H as in
 too high or “L” if it's too low? (while still keeping Y).
 Do tell me if it sounds confusing :/

Sure it's possible.  What do you think would happen if you 
replaced the code that compares the digits and prints Y or
N with with something like this?

  if guess_str[i]  number_str[i]: print (H, end='')
  if guess_str[i]  number_str[i]: print (L, end='')
  if guess_str[i] == number_str[i]: print (Y, end='')

(you are comparing 1-character long strings containing a
digit between 0 and 9 but they will compare the same 
way numbers do.)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea.

2013-10-29 Thread rurpy
On Tuesday, October 29, 2013 8:08:16 AM UTC-6, Steven D'Aprano wrote:
 On Tue, 29 Oct 2013 12:37:36 +0100, Skybuck Flying wrote:
[...]
 Skybuck, please excuse my question, but have you ever done any 
 programming at all? You don't seem to have any experience with actual 
 programming languages.
[...]
 Wait until you actually start programming before deciding what makes 
 sense or doesn't.

Couldn't you have simply made your points without the above comments?
Those points stand perfectly fine on their own without the ad hominem
attack.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First day beginner to python, add to counter after nested loop

2013-10-29 Thread jonas . thornvall
Den tisdagen den 29:e oktober 2013 kl. 20:24:57 UTC+1 skrev Dave Angel:
 On 29/10/2013 14:35, jonas.thornv...@gmail.com wrote:
 
 
 
 (Deleting hundreds of quad-spaced garbage.  Please be more considerate
 
 of others if you choose to use buggy googlegroups, maybe starting by
 
 studying:
 
 
 
 )
 
 
 
 Please indent by 4 columns, not 1.  Since indentation is how scope is
 
 specified in Python, it's very important to get it right.
 
 
 
  i do not understand howto reach outer loop after finnish inner loop, in 
  fact i do not understand when finished.
 
 
 
 The inner loop is finished whenever you stop indenting by 8 columns.  If
 
 you have a fundamental problem like this, keep it simple till you
 
 understand it:
 
 
 
 
 
 q = 12
 
 for x in range(10):
 
 for y in range(3):
 
 q = 3*q + 1
 
 print(inner, q)
 
 print(outer, x*q)
 
 
 
 print(done)
 
 
 
 Because of the detenting, the print(outer, x*q) is in the outer loop.
 
 
 
 
 
 -- 
 
 DaveA


Why did Python not implement end... The end is really not necessary for the 
programming language it can be excluded, but it is a courtesy to the programmer 
and could easily be transformed to indents automaticly, that is removed before 
the compiliation/interpretation of code.  

Got the script working though :D, good start. It seem though that Python 
automaticly add linebreaks after printout. Is there a way to not have print 
command change line? Or must i build up a string/strings for later printout?

#!/usr/bin/python
import math
# Function definition is here
def sq(number):
   
  square=1;
  factor=2;
  exponent=2;
  print(x,= );
  while (number3):
 while (square=number):
factor+=1;
square=math.pow(factor,exponent);
 factor-=1; 
 print(factor,^2);
 square=math.pow(factor,exponent);
 number=number-(factor*factor);
 square=1; 
 factor=1;
  print(+,number);
  return

print(Exp=x^2);
for x in range (21,22):
  sq(x);
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help with guessing game :D

2013-10-29 Thread Robert Gonda
On Tuesday, 29 October 2013 19:55:13 UTC, ru...@yahoo.com  wrote:
 On Tuesday, October 29, 2013 1:03:00 PM UTC-6, Robert Gonda wrote:
 
  never mind you was right, for some reason I had version 2.7 :/ ,
 
  and btw I was wondering, is it also possible to make it more
 
  complex? such as if the computer will again show “Y” if a digit
 
  is correct but if a digit is incorrect it will say H as in
 
  too high or “L” if it's too low? (while still keeping Y).
 
  Do tell me if it sounds confusing :/
 
 
 
 Sure it's possible.  What do you think would happen if you 
 
 replaced the code that compares the digits and prints Y or
 
 N with with something like this?
 
 
 
   if guess_str[i]  number_str[i]: print (H, end='')
 
   if guess_str[i]  number_str[i]: print (L, end='')
 
   if guess_str[i] == number_str[i]: print (Y, end='')
 
 
 
 (you are comparing 1-character long strings containing a
 
 digit between 0 and 9 but they will compare the same 
 
 way numbers do.)

So your saying that it doesn't matter what rule I add it will work for as 
long as I add it to that line? (or replace?)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First day beginner to python, add to counter after nested loop

2013-10-29 Thread jonas . thornvall
Den tisdagen den 29:e oktober 2013 kl. 21:08:39 UTC+1 skrev 
jonas.t...@gmail.com:
 Den tisdagen den 29:e oktober 2013 kl. 20:24:57 UTC+1 skrev Dave Angel:
 
  On 29/10/2013 14:35, jonas.thornv...@gmail.com wrote:
 
  
 
  
 
  
 
  (Deleting hundreds of quad-spaced garbage.  Please be more considerate
 
  
 
  of others if you choose to use buggy googlegroups, maybe starting by
 
  
 
  studying:
 
  
 
  
 
  
 
  )
 
  
 
  
 
  
 
  Please indent by 4 columns, not 1.  Since indentation is how scope is
 
  
 
  specified in Python, it's very important to get it right.
 
  
 
  
 
  
 
   i do not understand howto reach outer loop after finnish inner loop, in 
   fact i do not understand when finished.
 
  
 
  
 
  
 
  The inner loop is finished whenever you stop indenting by 8 columns.  If
 
  
 
  you have a fundamental problem like this, keep it simple till you
 
  
 
  understand it:
 
  
 
  
 
  
 
  
 
  
 
  q = 12
 
  
 
  for x in range(10):
 
  
 
  for y in range(3):
 
  
 
  q = 3*q + 1
 
  
 
  print(inner, q)
 
  
 
  print(outer, x*q)
 
  
 
  
 
  
 
  print(done)
 
  
 
  
 
  
 
  Because of the detenting, the print(outer, x*q) is in the outer loop.
 
  
 
  
 
  
 
  
 
  
 
  -- 
 
  
 
  DaveA
 
 
 
 
 
 Why did Python not implement end... The end is really not necessary for the 
 programming language it can be excluded, but it is a courtesy to the 
 programmer and could easily be transformed to indents automaticly, that is 
 removed before the compiliation/interpretation of code.  
 
 
 
 Got the script working though :D, good start. It seem though that Python 
 automaticly add linebreaks after printout. Is there a way to not have print 
 command change line? Or must i build up a string/strings for later printout?
 
 
 
 #!/usr/bin/python
 
 import math
 
 # Function definition is here
 
 def sq(number):
 

 
   square=1;
 
   factor=2;
 
   exponent=2;
 
   print(x,= );
 
   while (number3):
 
  while (square=number):
 
 factor+=1;
 
 square=math.pow(factor,exponent);
 
  factor-=1;   
 
  print(factor,^2);
 
  square=math.pow(factor,exponent);
 
  number=number-(factor*factor);
 
  square=1; 
 
  factor=1;
 
   print(+,number);
 
   return
 
 
 
 print(Exp=x^2);
 
 for x in range (21,22):
 
   sq(x);

They could had used print and prinln from basic? I do not want new line 
everytime i write out some terms. And i do not like it add extra space after 
each print of variable print(factor,^2) writes out 12 ^2 and i do not think 
there is any space after the factor?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help with guessing game :D

2013-10-29 Thread Robert Gonda
On Tuesday, 29 October 2013 19:55:13 UTC, ru...@yahoo.com  wrote:
 On Tuesday, October 29, 2013 1:03:00 PM UTC-6, Robert Gonda wrote:
 
  never mind you was right, for some reason I had version 2.7 :/ ,
 
  and btw I was wondering, is it also possible to make it more
 
  complex? such as if the computer will again show “Y” if a digit
 
  is correct but if a digit is incorrect it will say H as in
 
  too high or “L” if it's too low? (while still keeping Y).
 
  Do tell me if it sounds confusing :/
 
 
 
 Sure it's possible.  What do you think would happen if you 
 
 replaced the code that compares the digits and prints Y or
 
 N with with something like this?
 
 
 
   if guess_str[i]  number_str[i]: print (H, end='')
 
   if guess_str[i]  number_str[i]: print (L, end='')
 
   if guess_str[i] == number_str[i]: print (Y, end='')
 
 
 
 (you are comparing 1-character long strings containing a
 
 digit between 0 and 9 but they will compare the same 
 
 way numbers do.)

 Is it possible to further more specify it? H only shows if the guess is at 
 most 3 higher then the answer?. But L is only given if the guess is at most 3 
 lower the answer? I'm starting to like this ;D
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First day beginner to python, add to counter after nested loop

2013-10-29 Thread Neil Cerutti
On 2013-10-29, jonas.thornv...@gmail.com
jonas.thornv...@gmail.com wrote:
 Got the script working though :D, good start. It seem though
 that Python automaticly add linebreaks after printout. Is there
 a way to not have print command change line? Or must i build up
 a string/strings for later printout?

print takes an keyword argument, called end, that defaults to
\n. You can provide something else:

print(xzzz, end=)

 #!/usr/bin/python
 import math
 # Function definition is here
 def sq(number):
   square=1;

Get in the habit of not using the semicolon to end lines. Python
doesn't need them, except when two statements appear without a
newline between them.

   factor=2;
   exponent=2;
   print(x,= );

That ought to be

print(number, = , end=)

There's no need to refer to global x when you've passed it in as
number.

   while (number3):
  while (square=number):
 factor+=1;
 square=math.pow(factor,exponent);

You don't want to use math.pow. Just use pow or the ** operator.

 square = factor**exponent

  factor-=1;   
  print(factor,^2);
  square=math.pow(factor,exponent);
  number=number-(factor*factor);

Analogous with factor += 1, you can do

  number -= factor * factor

Note the usual spacing of python operators and identifiers.

  square=1; 
  factor=1;
   print(+,number);
   return

A bare return at the end of a Python function is not needed. All
functions return None if they fall off the end.

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


Re: First day beginner to python, add to counter after nested loop

2013-10-29 Thread Mark Lawrence

On 29/10/2013 20:11, jonas.thornv...@gmail.com wrote:


I do not want new line everytime i write out some terms.



I wish you'd apply that thinking to your posts.

--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

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


Re: First day beginner to python, add to counter after nested loop

2013-10-29 Thread Ned Batchelder

On 10/29/13 4:08 PM, jonas.thornv...@gmail.com wrote:

Why did Python not implement end... The end is really not necessary for the 
programming language it can be excluded, but it is a courtesy to the programmer 
and could easily be transformed to indents automaticly, that is removed before 
the compiliation/interpretation of code.


If you're going to indent your code correctly anyway, then the ends 
are just extra noise.  And if you aren't going to indent your code to 
match the structure, then you have two different channels of 
information: the human pays attention to the indentation, and the 
computer pays attention to the ends.  That's a recipe for creating lots 
of subtle bugs.  You get used to reading the indentation.

They could had used print and prinln from basic? I do not want new line everytime i write 
out some terms. And i do not like it add extra space after each print of variable 
print(factor,^2) writes out 12 ^2 and i do not think there is any space after 
the factor?



The print statement is very simple, and has not had a lot of features 
added to it, because you very quickly outgrow it anyway. If you want 
fine control over the output of your program, you use string formatting, 
for example with the .format() method on strings.


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


personal library

2013-10-29 Thread patrick vrijlandt
Hello list,

Python has been a hobby for me since version 1.5.2. Over the years I
accumulated quite a lot of reusable code. It is nicely organised in
modules, directories and subdirectories. With every project, the library
grows and is developed further. I would like to ask your advice for two
problems:

For most projects I use python's most recent, stable release. Obviously,
some 3rd party libraries still do not support Python3 (like wx) and I will
use 2.7. Does this mean I should maintain seperate libraries for 2 and 3,
or can this be done easier? I do like new language features!

How do I arrange that I can access the most recent version of my library on
every computer in my home network? Development is usually on my desktop,
sometimes on my laptop, and of course I use python for maintenance tasks on
other computers in the house (e.g. The children's). I now have the library
on a network share and local copies on each computer, but of course I
forget to synchronise often enough.

As said, python is a hobby, and the solution should be as lightweight as
possible! I'm usually on windows (vista, xp or 7).

Thanks!

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


Re: Help with guessing game :D

2013-10-29 Thread rurpy
On Tuesday, October 29, 2013 2:21:08 PM UTC-6, Robert Gonda wrote:
 Is it possible to further more specify it? H only shows if the
 guess is at most 3 higher then the answer?. But L is only given
 if the guess is at most 3 lower the answer? I'm starting to
 like this ;D

To do that, you'll need to convert the string digits back to
numbers that you can do arithmetic on.  The int() function
can do that.  Then you can do something like

 if guess_num  number_num + 3: ... print what you want here.

You'll find you get more and better answers to your questions 
if you attempt to do something yourself and when you find it is 
not doing what you want, post here saying what you tried, what 
it did, and how what it did is different from what you want.

You'll also get better responses if you edit out the empty
and excess  lines in the quoted text of your replies,
which you are still not doing.
-- 
https://mail.python.org/mailman/listinfo/python-list


Using urlparse.parse_qs() - first element in dict is keyed on URL+key, instead of just key?

2013-10-29 Thread Victor Hooi
Hi,

I'm attempting to use urlparse.parse_qs() to parse the following url:


https://www.foo.com/cat/dog-13?utm_source=foo1043cutm_medium=emailutm_campaign=ba^Cn=HC

However, when I attempt to parse it, I get:

{'https://www.foo.com/cat/dog-13?utm_source': ['foo1043c'],
 'utm_campaign': ['ba^Cn=HC'],
 'utm_medium': ['email']}

For some reason - the utm_source doesn't appear to have been extracted 
correctly, and it's keying the result on the url plus utm_source, rather than 
just 'utm_source'?

Cheers,
Victor
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Using urlparse.parse_qs() - first element in dict is keyed on URL+key, instead of just key?

2013-10-29 Thread Victor Hooi
Hi,

My bad - PEBKAC - didn't read the docs properly.

I need to use urlparse.urlparse() to extract the query first.

So for anybody searching this, you can use something liek:

In [39]: url
Out[39]: 
'https://www.foo.com/cat/dog-13?utm_source=foo1043cutm_medium=emailutm_campaign=ba^Cn=HC'

In [40]: urlparse.parse_qs(urlparse.urlparse(url).query)
Out[40]:
{'utm_campaign': ['ba^Cn=HC'],
 'utm_medium': ['email'],
 'utm_source': ['foo1043c']}

Cheers,
Victor

On Wednesday, 30 October 2013 09:34:15 UTC+11, Victor Hooi  wrote:
 Hi,
 
 
 
 I'm attempting to use urlparse.parse_qs() to parse the following url:
 
 
 
 
 https://www.foo.com/cat/dog-13?utm_source=foo1043cutm_medium=emailutm_campaign=ba^Cn=HC
 
 
 
 However, when I attempt to parse it, I get:
 
 
 
 {'https://www.foo.com/cat/dog-13?utm_source': ['foo1043c'],
 
  'utm_campaign': ['ba^Cn=HC'],
 
  'utm_medium': ['email']}
 
 
 
 For some reason - the utm_source doesn't appear to have been extracted 
 correctly, and it's keying the result on the url plus utm_source, rather than 
 just 'utm_source'?
 
 
 
 Cheers,
 
 Victor
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: stacked decorators and consolidating

2013-10-29 Thread Gregory Ewing

Tim Chase wrote:

I'd have figured they would be associative, making the result end up
the same either way, but apparently not.


They're not associative because function application
is not associative: f(g(x)) is not the same thing as
f(g)(x).

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


Re: First day beginner to python, add to counter after nested loop

2013-10-29 Thread Gregory Ewing

Neil Cerutti wrote:

Get in the habit of not using the semicolon to end lines.


Also, you don't need to put parentheses around the
conditions of while and if statements.

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


xlutils 1.7.0 released!

2013-10-29 Thread Chris Withers

Hi All,

I'm pleased to announce the release of xlutils 1.7.0:

http://pypi.python.org/pypi/xlutils/1.7.0

This release features a handy new view module that lets you do things like:

 def print_data(rows):
... for row in rows:
... for value in row:
... print value,
... print

 from xlutils.view import View, Row, Col
 print_data(view['Sheet1'][:2, :1])
R0C0
R1C0
 print_data(view['Sheet1'][Row(1):Row(2), Col('A'):Col('B')])
R0C0 R0C1
R1C0 R1C1

There's also some help for values that are dates or times:

 for row in View(join(test_files,'date.xls'))[0]:
... for value in row:
... print repr(value)
datetime.datetime(2012, 4, 13, 0, 0)

Please have a play and let me know what you think.

Full docs here:

http://pythonhosted.org/xlutils/

Details of all things Python and Excel related can be found here:

http://www.python-excel.org/

cheers,

Chris

--
Simplistix - Content Management, Batch Processing  Python Consulting
- http://www.simplistix.co.uk
--
https://mail.python.org/mailman/listinfo/python-list


Looking For Advice

2013-10-29 Thread crclemens73
Hey Guys,

A group of guys and myself have been working on a project/business plan to 
develop a Hotel Concierge application for tablets. We have been working on it 
for over a year and have hotels here in Chicago that are on board and very 
interested with our concept. We also are in the works with some large APIs as 
well as some contracts with some large APIs that want to work with us. Recently 
our developer had to drop out of the group because he became too busy with his 
other projects and we have been at a standstill for a couple of weeks. Can 
anyone provide me some direction on where to find start looking for another 
developer or if this sounds like an interesting venture and you would like more 
information please contact me at crclemen...@gmail.com.

I appreciate any help you can offer.
-- 
https://mail.python.org/mailman/listinfo/python-list


mush 1.0 released! - Type-based dependency injection for scripts

2013-10-29 Thread Chris Withers

Hi All,

I'm very happy to announce the first public release of Mush, a light 
weight dependency injection framework aimed at enabling the easy testing 
and re-use of chunks of code that make up scripts.


For a worked example of how to use Mush to reduce the copy'n'paste in 
your scripts, please see here:


http://pythonhosted.org/mush/examples.html

Full docs are here:

http://pythonhosted.org/mush/

Downloads are here:

https://pypi.python.org/pypi/mush

Compatible with Python 2.6, 2.7, 3.2 and 3.3 on Linux, Mac OS X and Windows:

http://jenkins.simplistix.co.uk/view/mush/

Any problems, please give me a shout on the simplis...@googlegroups.com 
list!


cheers,

Chris

--
Simplistix - Content Management, Batch Processing  Python Consulting
- http://www.simplistix.co.uk
--
https://mail.python.org/mailman/listinfo/python-list


Re: how to avoid checking the same condition repeatedly ?

2013-10-29 Thread Peter Cacioppi
Chris said :
Want some examples of what costs no clarity to reimplement in another 
language? Check out the Python standard library. Some of that is implemented in 
C (in CPython) and some in Python, and you can't tell and needn't care which.

To ME (a consumer of the CPython library) there is zero cost to clarity.

To the angels that maintain/develop this library and need to go inside the 
black box regularly  there is a non-zero cost to clarity.

Right? 

(I'd rather run the risk of stating the obvious than missing something clever, 
that's why I keep hitting this sessile equine).

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


Mail client wrapping

2013-10-29 Thread Jason Friedman
I am receiving lines like this:

Accordingly, this element has largely given way in modern cases to a less =
rigid formulation: that the evidence eliminates, to a sufficient degree,  =
other responsible causes (including the conduct of the plaintiff and third=
parties). For example, in New York State, the defendant's exclusivity of  =
control must be such that the likelihood of injury was, more likely than  =
not, the result of the defendant's negligence.

I want the original:

Accordingly, this element has largely given way in modern cases to a less
rigid formulation: that the evidence eliminates, to a sufficient degree,
other responsible causes (including the conduct of the plaintiff and third
parties). For example, in New York State, the defendant's exclusivity of
control must be such that the likelihood of injury was, more likely than
not, the result of the defendant's negligence.

I know I can create a new list and iterate over the input lines, but was
wondering if there is a one-liner lurking in here?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Mail client wrapping

2013-10-29 Thread Skip Montanaro
The mail message is encoded. You will have a header like this:

Content-Transfer-Encoding: quoted-printable

If you are processing email messages you should investigate Python's
email module.

http://docs.python.org/2/library/email

Skip

On Tue, Oct 29, 2013 at 7:36 PM, Jason Friedman jsf80...@gmail.com wrote:
 I am receiving lines like this:

 Accordingly, this element has largely given way in modern cases to a less =
 rigid formulation: that the evidence eliminates, to a sufficient degree,  =
 other responsible causes (including the conduct of the plaintiff and third=
 parties). For example, in New York State, the defendant's exclusivity of  =
 control must be such that the likelihood of injury was, more likely than  =
 not, the result of the defendant's negligence.

 I want the original:

 Accordingly, this element has largely given way in modern cases to a less
 rigid formulation: that the evidence eliminates, to a sufficient degree,
 other responsible causes (including the conduct of the plaintiff and third
 parties). For example, in New York State, the defendant's exclusivity of
 control must be such that the likelihood of injury was, more likely than
 not, the result of the defendant's negligence.

 I know I can create a new list and iterate over the input lines, but was
 wondering if there is a one-liner lurking in here?

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

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


  1   2   3   >