Is there a way to "link" a python program from several files?

2008-02-16 Thread Edward A. Falk
IOW, is there a "linker" for python?  I've written a program comprised of about
five .py files.  I'd like to find a way to combine them into a single
executable.  Obviously, I could hand-edit them into a single .py file, but
I'm looking for a way to keep them as seperate files for development but
distribute the result as a single file.

If this were C, I'd compile and link them and distribute the resulting
executable.  I'm trying to do that, but for Python.

TIA,

-- 
-Ed Falk, [EMAIL PROTECTED]
http://thespamdiaries.blogspot.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is there a way to "link" a python program from several files?

2008-02-20 Thread Edward A. Falk
In article <[EMAIL PROTECTED]>,
BlueBird  <[EMAIL PROTECTED]> wrote:
>
>I wrote a small wiki page to sum-up my findings about such typical
>problem:
>
>http://www.freehackers.org/Packaging_a_python_program
>

Excellent references, but maybe a bit of overkill.  Everybody in my
target audience has python on their systems, I just want to send a
single .py (or .pyc) file so there's no complicated install procedure.

I mean, how *are* large python programs normally distributed under Linux?

-- 
-Ed Falk, [EMAIL PROTECTED]
http://thespamdiaries.blogspot.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Answer: Is there a way to "link" a python program from several files?

2008-03-03 Thread Edward A. Falk
In article <[EMAIL PROTECTED]>,
George Sakkis  <[EMAIL PROTECTED]> wrote:
>
>What's so complicated about "python setup.py install" ? Even that is
>not strictly necessary for pure python packages; a user may just
>unpack the archive, cd to the extracted directory and execute the
>appropriate .py file(s).

Aha.  Completely forgot about setup.py.

Unfortunately, under Linux, all it seems to do is build a tarball for
me, which when unpacked produces several discrete .py files, leaving
me back where I started.

Anyway, I did what I should have done in the first place and trolled
/usr/bin to see how other people had done it.

It turns out there are a few answers:  First, you can simply just produce
the program as a single .py file (which is what I wound up doing).

Second, you can put all the .py files other than the "main" one into
/usr/share/ and then append that directory to your
path before importing anything.

Third, you can put all the .py files other than the "main" one into
/usr/lib/python2.2/site-packages/ and then you don't
have to modify your path.


The second and third methods have the advantage that you can have .pyc
files hanging around.


Anyway, thanks for all your input.

-- 
-Ed Falk, [EMAIL PROTECTED]
http://thespamdiaries.blogspot.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Does python hate cathy?

2008-03-24 Thread Edward A. Falk

Interestingly, if you change

  swaroop = Person('Swaroop', 'M')
  swaroop.sayHi()
  swaroop.howMany()
  kalam = Person('Abdul Kalam', 'M')
  kalam.sayHi()
  kalam.howMany()
  cathy = Person('Catherine', 'F')
  cathy.sayHi()
  cathy.howMany()
  swaroop.sayHi()
  swaroop.howMany()

to

  def main():
swaroop = Person('Swaroop', 'M')
swaroop.sayHi()
swaroop.howMany()
kalam = Person('Abdul Kalam', 'M')
kalam.sayHi()
kalam.howMany()
cathy = Person('Catherine', 'F')
cathy.sayHi()
cathy.howMany()
swaroop.sayHi()
swaroop.howMany()
return 0


  if __name__ == "__main__":
sys.exit(main())


The problem goes away.  (This is a good coding practice in any event.)

As others have pointed out, the order in which local variables are deleted
is undefined.  It looks to me as if the class Person got deleted before
Catherine did. 

Adding

  del kalam
  del cathy
  del swaroop

to the end of the program did fix the problem, presumably by forcing
kalam, cathy, and swaroop from being deleted before Person.

However, Adding

self.myclass = Person

to the __init__() method didn't stop the problem.  I thought it might, because
then each of the objects would have held a reference to Person.  Actually, I 
would
have thought they'd hold a reference by merely existing, so is this not a bug?

-- 
-Ed Falk, [EMAIL PROTECTED]
http://thespamdiaries.blogspot.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Does python hate cathy?

2008-03-25 Thread Edward A. Falk
In article <[EMAIL PROTECTED]>,
Patrick Mullen <[EMAIL PROTECTED]> wrote:

>Then again, I can count the number of times I have ever needed __del__
>with no fingers (never used it!).  Still, quite interesting to
>explore.

I used it once, for an object that had a doubly-linked list.
The __del__() method walked the list, setting all the elements'
prev/next pointers to None to make sure the elements of the list would
get garbage-collected.

-- 
-Ed Falk, [EMAIL PROTECTED]
http://thespamdiaries.blogspot.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: very rare python expression

2008-08-12 Thread Edward A. Falk
In article <[EMAIL PROTECTED]>,
Paul Rubin   wrote:
>"ðÏ" <[EMAIL PROTECTED]> writes:
>> I saw a strange python code in pygame project. What does "while
>> not(x&528or x in l):" mean? Below code works in python2.5, so "x&528"
>> is not HTML strings.
>
>It parses as "x & 528 or x in l".  Looks like it came from
>
>  http://www.pygame.org/project/833/
>
>and is an attempt to squash the program to as few bytes as possible.

Sheesh.  The 80's called; they want their floppy drives back.

Even with the whitespace restored, it's awful style.

-- 
-Ed Falk, [EMAIL PROTECTED]
http://thespamdiaries.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list

Re: Python Programming Challenges for beginners?

2009-11-30 Thread Edward A. Falk
In article <09ea817f-57a9-44a6-b815-299ae3ce7...@x5g2000prf.googlegroups.com>,
alex23   wrote:
>On Nov 27, 1:24 pm, astral orange <457r0...@gmail.com> wrote:
>> I would like to test out what I know so far by solving programming
>> challenges.
>
>Project Euler can be a lot of fun: http://projecteuler.net/

Oooh, that *does* look like fun.

-- 
-Ed Falk, f...@despams.r.us.com
http://thespamdiaries.blogspot.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: parsing json data

2009-11-30 Thread Edward A. Falk
There's a json parsing library in 2.6.  (Sadly, 2.6 is not out for
Ubuntu yet.)

-- 
-Ed Falk, f...@despams.r.us.com
http://thespamdiaries.blogspot.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Which is more pythonic?

2009-12-03 Thread Edward A. Falk
In article ,
Filip GruszczyÅ ski   wrote:
>
>for choice in self.__choices:
>   choicesBox.addItem(choice)

This is the easiest to read.  I'm guessing that this is not inner-loop
stuff that needs to be optimized, so you should favor readability over
performance.
-- 
-Ed Falk, f...@despams.r.us.com
http://thespamdiaries.blogspot.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: When will Python 3 be fully deployed

2009-12-06 Thread Edward A. Falk
In article ,
vsoler   wrote:
>I recently read that many libraries, including Numpy have not been
>ported to Python 3.
>
>When do you think that Python 3 will be fully deployed?

It will never be fully deployed.  There will always be people out there who
haven't felt it necessary to upgrade their systems.

The question you should be asking is "when will the percentage of systems
without Python 3 be so small that I don't care about the customers I'll lose
if I switch?"

I can say personally that I still haven't seen any needs pressing enough to
upgrade my perfectly-function Ubuntu 8 system.  That means I can't even run
Python 2.6 code.  I'm still using 2.5.

>Should I stick, so far, to Python 2.6?

For development purposes, you should stick with the oldest version that will
actually run your code.  Every time you move to a more modern version, you're
leaving potential users/customers out in the cold.

-- 
-Ed Falk, f...@despams.r.us.com
http://thespamdiaries.blogspot.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: myths about python 3

2010-01-27 Thread Edward A. Falk
In article ,
Daniel Fetchinson   wrote:
>Hi folks,
>
>1. Print statement/function creates incompatibility between 2.x and 3.x!
>
>Certainly false or misleading, if one uses 2.6 and 3.x the
>incompatibility is not there. Print as a function works in 2.6:

Yes, but does print as a statement work?

Your argument is that python 2.x code can be ported to 3.x and still
run under 2.6 if you're careful about how you do the port.  That's
not the same as saying they're compatible.


>2. Integer division creates incompatibility between 2.x and 3.x!

Same as above.  Saying you can make it work by rewriting your code
is not the same as saying that it works.


If they'd wanted wide adoption of python 3, they should have made it
as compatible as possible with python 2 code.  If they dropped the
print statement, then they did not do so.
-- 
-Ed Falk, f...@despams.r.us.com
http://thespamdiaries.blogspot.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: myths about python 3

2010-01-27 Thread Edward A. Falk
In article ,
Grant Edwards   wrote:
>
>That said, I don't expect to start using Python 3 until library
>availability or my Linux distro forces me to.

If python 3 is much more efficient than python 2, or it has features
I really need for some application I'll write in the future, I might
be tempted to switch.  Maybe some future version of python 3 will
be compatible with python 2 source code.  That would help.

-- 
-Ed Falk, f...@despams.r.us.com
http://thespamdiaries.blogspot.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to set up web service by python?

2009-10-24 Thread Edward A. Falk
In article <7kh22qf38i28...@mid.uni-berlin.de>,
Diez B. Roggisch  wrote:
>
>As you don't show us the code, I can only guess - but experience tells 
>me that you try & bind your service to a priviledged (<=1024) port, 
>which *nix only allows with root-privileges.

Concur.

You need root privileges to run any service on port 80.  Try using 8080
instead.
-- 
-Ed Falk, f...@despams.r.us.com
http://thespamdiaries.blogspot.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: transpose array

2009-10-27 Thread Edward A. Falk
In article ,
yoshco   wrote:
>hello everyone
>i have 3 arrays
>xVec=[a1,a2,a3,a4,a5]
>yVec=[b1.b2.b3.b4.b5]
>zVec=[c1,c2,c3,c4,c5]
>
>and i want to output them to a ascii file like so
>
>a1,b1,c1
>a2,b2,c2
>a3,b3,c3
>...

Elegant or obfuscated, you be the judge:

  vv = [xVec, yVec, zVec]

  for i in range(len(xVec)):
print >>f,  ", ".join([x[i] for x in vv])


To be honest, I'd be more likely to do it like this, for readability if
for no other reason:

  for i in range(len(xVec)):
print >>f, "%f, %f, %f" % (xVec[i], yVec[i], zVec[i])



It might help if we knew what you're *really* trying to do.

-- 
-Ed Falk, f...@despams.r.us.com
http://thespamdiaries.blogspot.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python simply not scaleable enough for google?

2009-11-14 Thread Edward A. Falk
In article ,
Terry Reedy   wrote:
>
>I can imagine a day when code compiled from Python is routinely 
>time-competitive with hand-written C.

I can't.  Too much about the language is dynamic.  The untyped variables
alone are a killer.

int a,b,c;
...
a = b + c;

In C, this compiles down to just a few machine instructions.  In Python,
the values in the variables need to be examined *at run time* to determine
how to add them or if they can even be added at all.  You'll never in
a million years get that down to just two or three machine cycles.

Yes, technically, the speed of a language depends on its implementation,
but the nature of the language constrains what you can do in an
implementation.  Python the language is inherently slower than C the
language, no matter how much effort you put into the implementation.  This
is generally true for all languages without strongly typed variables.

-- 
-Ed Falk, f...@despams.r.us.com
http://thespamdiaries.blogspot.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python simply not scaleable enough for google?

2009-11-15 Thread Edward A. Falk
In article ,
Robert Brown   wrote:
>
>It's hard to refute your assertion.  You're claiming that some future
>hypothetical Python implementation will have excellent performance via a JIT.
>On top of that you say that you're willing to change the definition of the
>Python language, say by adding type declarations, if an implementation with a
>JIT doesn't pan out.  If you change the Python language to address the
>semantic problems Willem lists in his post and also add optional type
>declarations, then Python becomes closer to Common Lisp, which we know can be
>executed efficiently, within the same ballpark as C and Java.

Ya know; without looking at Go, I'd bet that this was some of the thought
process that was behind it.

-- 
-Ed Falk, f...@despams.r.us.com
http://thespamdiaries.blogspot.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Language mavens: Is there a programming with "if then else ENDIF" syntax?

2009-11-16 Thread Edward A. Falk
In article ,
Steve Ferg   wrote:
>I've often thought that a language with this kind of block-free syntax
>would be nice and intuitive:
>
>if  then
>do stuff
>elif  then
>do stuff
>else
>do stuff
>endif
>
>Note that you do not need block delimiters.

"then", "else", and "endif" *are* the block delimiters

-- 
-Ed Falk, f...@despams.r.us.com
http://thespamdiaries.blogspot.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Code for finding the 1000th prime

2009-11-17 Thread Edward A. Falk
In article ,
mrholtsr   wrote:
>I am absolutely new to python and barely past beginner in programming.
>Also I am not a mathematician. Can some one give me pointers for
>finding the 1000th. prime for a course I am taking over the internet
>on Introduction to Computer Science and Programming. Thanks, Ray

OK, newbie soccer is over.

http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes

Everything you need is in there.

-- 
-Ed Falk, f...@despams.r.us.com
http://thespamdiaries.blogspot.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: When will Python go mainstream like Java?

2010-02-22 Thread Edward A. Falk
You mean it's not?

-- 
-Ed Falk, f...@despams.r.us.com
http://thespamdiaries.blogspot.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: DOS Follies (Was: Docstrings...)

2010-03-03 Thread Edward A. Falk
In article ,
D'Arcy J.M. Cain  wrote:
>On Wed, 03 Mar 2010 20:44:08 +0100
>mk  wrote:
>> It reminds me of why Windows uses backslashes for path separation 
>> instead of slashes: what I've *heard*, and do not know if it's true, 
>> it's because Gates fancied using / for options switch instead of -, and 
>> to hell with established practice.
>
>That was because CP/M used slashes for options and DOS copied that.  By
>the time hierarchy was added it was too late to change.

And CP/M got it from the various PDP-11 operating systems.  I *think*
that Tops-10 had it as well.  In fact, I think using / to delimit
commandline options goes back to the PDP-8.

-- 
-Ed Falk, f...@despams.r.us.com
http://thespamdiaries.blogspot.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python only prints integers

2011-01-06 Thread Edward A. Falk
In article ,
Ian   wrote:
>
>In Python 3, the '/' operator always performs true division.

How can I get integer division?

-- 
-Ed Falk, f...@despams.r.us.com
http://thespamdiaries.blogspot.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: INCONTROVERTIBLE PROOF of the Incompetence of FBI

2010-06-15 Thread Edward A. Falk
In article <25a8c044-c361-4851-bbb4-58c195733...@g19g2000yqc.googlegroups.com>,
nanothermite911fbibustards   wrote:
>This is all due to DISINFORMATION - FBI bustards are the cause of it.

Dude, seriously.  Get your dosage adjusted.  And find a different
newsgroup.
-- 
-Ed Falk, f...@despams.r.us.com
http://thespamdiaries.blogspot.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I strongly dislike Python 3

2010-06-28 Thread Edward A. Falk
In article ,
Thomas Jollans   wrote:

>There is no reason for print not being a function. Also, do you use
>print *that* much? Really?

I use it all the time.  Who doesn't?  What do you use instead?

-- 
-Ed Falk, f...@despams.r.us.com
http://thespamdiaries.blogspot.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I strongly dislike Python 3

2010-06-28 Thread Edward A. Falk
In article ,
Grant Edwards   wrote:
>
>Maybe it's just me, but I find both debugging and small scripts to be
>very useful.

Ditto.  I've also written a number of large scripts, and I *always*
use print in them.

-- 
-Ed Falk, f...@despams.r.us.com
http://thespamdiaries.blogspot.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I strongly dislike Python 3

2010-06-28 Thread Edward A. Falk
In article ,
Stephen Hansen   wrote:
>
>No one said otherwise, or that print was useless and never used in such 
>contexts.

I was responding to the question "Also, do you use print *that*
much? Really?"  The implication being that in the majority of useful
python programs, you don't really need to use print.

My answer is yes, I use print in 100% of the scripts I write, including
the large useful ones.

For this reason alone, python 3 is incompatible with python 2 (which
has already been acknowledged.)

Until such time as 100% of the systems I might ever want to run my progams
on have python 3 installed, I cannot port my programs over from python 2.

-- 
-Ed Falk, f...@despams.r.us.com
http://thespamdiaries.blogspot.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I strongly dislike Python 3

2010-06-28 Thread Edward A. Falk
In article ,
Stephen Hansen   wrote:
>
>Any other use, I basically operate on a file object.

I use file objects all the time.  I use print with them.

-- 
-Ed Falk, f...@despams.r.us.com
http://thespamdiaries.blogspot.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I strongly dislike Python 3

2010-06-29 Thread Edward A. Falk
In article ,
Stephen Hansen   wrote:
>>
>> Uhmm, just add the parenthesis to your old scripts. You can
>> do that without breaking on 2.x.
>
>Only sort of. But in Python 2.6+, you only need to "from __future__ 
>import print_function" to make code work in both 2.x and 3.x (at least 
>insofar as the print situation is concerned).  

Nice.  Once 100% of the installed base is at 2.6, I'll finally be able
to write code that compatible with 3.0.

-- 
-Ed Falk, f...@despams.r.us.com
http://thespamdiaries.blogspot.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: why is this group being spammed?

2010-07-18 Thread Edward A. Falk
In article <334170d5-a336-4506-bda1-279b40908...@k1g2000prl.googlegroups.com>,
be.krul  wrote:
>why is this group being spammed?

They're *all* being spammed.  Why?  Because they can, and because Google
doesn't care.

-- 
-Ed Falk, f...@despams.r.us.com
http://thespamdiaries.blogspot.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: why is this group being spammed?

2010-07-18 Thread Edward A. Falk
In article ,
Alf P. Steinbach /Usenet  wrote:
>
>Consider, there would be almost no spam if spamming didn't pay.

Or if ISPs refused to tolerate it from their customers.

-- 
-Ed Falk, f...@despams.r.us.com
http://thespamdiaries.blogspot.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: urgent requirement at Hyderabad

2010-08-11 Thread Edward A. Falk
In article ,
Stefan Behnel   wrote:
>In case anyone wondered: Hyderabad is likely referring to some place in Asia:

It's one of the high-tech cities in India.  A lot of out-sourcing
winds up there.

-- 
-Ed Falk, f...@despams.r.us.com
http://thespamdiaries.blogspot.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: That interesting notation used to describe how long a loop will take.

2010-10-04 Thread Edward A. Falk
In article ,
Roy Smith   wrote:
>In article ,
> Tobiah  wrote:
>
>Google for "Big-O notation".  Depending on your level of interest, 
>expect to spend anywhere from an hour to the next four years reading 
>what pops out :-)

Yeah, that's my problem with Wikipedia too.  Plus, they like to just
roll up their sleeves and dive right into the math.  It's like a bucket
of ice water to the face if you're a mathematical layman.

Tobiah, for the purposes of 99% of the work you'll be doing in computing,
you don't need all that math.  Just think of O(foo) as meaning "On the
order of foo".  This means basically that you evaluate foo, and the time
your algorithm takes to execute is proportional to that.

So for example, O(n^2) means that the time the algorithm takes to run
is roughly on the order of n^2 where n is the size of your data set.

A good example is a simple sort algorithm which runs in O(n^2), meaning
that if you double the number of points, you quadruple the time it takes
to sort them.  A better sorting algorithm runs in O(n*log(n)).

The best example is the quadratic sieve* for factoring large numbers,
which runs in O(exp( n^(1/2) (log n)^(1/2) )).  I was at a party
celebrating the expiration of the RSA patent and someone (I think it
was Lucky Green) went to the white board, wrote down this expression
and explained that this term meant that the program ran in worse than
polynomial time, but this other term meant that at it least ran in better
than exponential time.  Meaning that the algorithm ran in "superpolynomial
subexponential runtime".

This led to the really silly song documented here:
http://www.xent.com/FoRK-archive/oct00/0429.html


(*Yes, yes, I know they were talking about the polynomial sieve, but
I couldn't find the runtime for that.)

-- 
-Ed Falk, f...@despams.r.us.com
http://thespamdiaries.blogspot.com/
-- 
http://mail.python.org/mailman/listinfo/python-list