pls donate acces

2023-03-01 Thread Tom
   I need make an scrpit to impressive my friends

    

   Envoyé à partir de [1]Courrier pour Windows

    

References

   Visible links
   1. https://go.microsoft.com/fwlink/?LinkId=550986
-- 
https://mail.python.org/mailman/listinfo/python-list


hi

2023-03-04 Thread Tom
   Bonjour je suis français et je ne comprend pas comment je peux acceder a
   python merci de me repondre

   CORDIALEMENT Lilian

    

   Envoyé à partir de [1]Courrier pour Windows

    

References

   Visible links
   1. https://go.microsoft.com/fwlink/?LinkId=550986
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python with no significant whitespace

2005-01-25 Thread Tom
Just though I'd point out that Logix *does* use whitespace for
delimiting blocks. Or rather, it can use whitespace, and the languages
that come as standard do.

With Logix you could quite easily make a version of Python with, e.g.,
braces instead of whitespace for delimiting blocks. That's probably
what the Stephen was getting at.

Tom.

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


Socket Support When Compiling Python 2.3.5 On Cygwin

2005-08-25 Thread tom
I compiled Python 2.3.5 from source on my Cygwin machine (XP), and I got
the following error when I tried to initialize Zope:

Traceback (most recent call last):
  File "/opt/Zope-2.7.7/lib/python/ZEO/runzeo.py", line 42, in ?
import socket
  File "/opt/Python23//lib/python2.3/socket.py", line 44, in ?
import _socket
ImportError: No module named _socket

Apparently, Zope depends on the
$PY23_HOME/lib/python2.3/lib-dynload/_socket.dll, and this file doesn't
exist on my system.  What do I need to do to make sure that this file will
be created with I compile Python 2.3.5?

The really weird thing about this is that I also compiled Python 2.4 on
this system, and the socket files were created.  What's different about
2.3.5?

Thanks in advance!

Tom Purl
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Socket Support When Compiling Python 2.3.5 On Cygwin

2005-08-26 Thread tom
Thanks for the response Jason.  I re-ran make and noticed the following:

building '_socket' extension
gcc -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fno-strict-aliasing -I.
-I/tmp/Python-2.3.5/./Include -I/usr/local/include
-I/tmp/Python-2.3.5/Include -I/tmp/Python-2.3.5 -c
/tmp/Python-2.3.5/Modules/socketmodule.c -o
build/temp.cygwin-1.5.18-i686-2.3/socketmodule.o
/tmp/Python-2.3.5/Modules/socketmodule.c: In function `socket_inet_ntop':
/tmp/Python-2.3.5/Modules/socketmodule.c:3045: error: `INET_ADDRSTRLEN'
undeclared (first use in this function)
/tmp/Python-2.3.5/Modules/socketmodule.c:3045: error: (Each undeclared
identifier is reported only once
/tmp/Python-2.3.5/Modules/socketmodule.c:3045: error: for each function it
appears in.)
/tmp/Python-2.3.5/Modules/socketmodule.c:3045: warning: unused variable `ip'

I then did a Google search on this error and found the following thread on
the Cygwin mailing list:

http://www.mail-archive.com/cygwin@cygwin.com/msg58066.html

Coincidentally, this question was posted by you.  So you've helped me
doubely today.  Not bad!

So, as you well know, this is a problem with Cygwin 1.5.18 and will be
fixed in the next version.

Thanks for all of the help!

Tom Purl

> Tom,
>
> On Thu, Aug 25, 2005 at 10:39:47AM -0500, [EMAIL PROTECTED] wrote:
>> What do I need to do to make sure that this file will be created with
>> I compile Python 2.3.5?
>
> Are there any error messages when the socket module is built during the
> Python build?  If so, then post them to the list.
>
> Jason
>
> --
> PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
> Fingerprint: 7A73 1405 7F2B E669 C19D  8784 1AFD E4CC ECF4 8EF6
>

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


simple problem with os.rename() parameters - path with spaces

2005-09-09 Thread Tom
I'm having a problem using a path with spaces as a parameter to 
os.rename() in a program on WinXP.

This works fine at the command line (where the folder "c:\aa bb" exists)

 > os.rename( "c\aa bb", "c:\cc dd" );
 >

But, I can't get it to work in my program, eg.

print SrcDir
print NewDir
os.rename( SrcDir, NewDir );

when I run this I get something like this:

"e:\\music\\Joni Mitchell\\ogg-8"
"e:\\music.ogg\\Joni Mitchell\\ogg-8"

Traceback (most recent call last):
   File "E:\Music\MoveMusic.py", line 64, in ?
 main();
...
   File "E:\Music\MoveMusic.py", line 49, in Visit
 os.mkdir( NewDir );
OSError: [Errno 22] Invalid argument: '"e:\\music.ogg\\Joni 
Mitchell\\ogg-8"'

I've tried different combinations of single backslash vs. double 
backslash, and quoted vs. non-quoted, but it always fails.

The problem is not specific to os.rename.  If I instead use mkdir( 
SrcDir ) I get the same problem.

Thanks,
Tom.

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


Re: simple problem with os.rename() parameters - path with spaces

2005-09-10 Thread Tom
Peter Hansen wrote:
> Tom wrote:
> 
>>I'm having a problem using a path with spaces as a parameter to 
>>os.rename() in a program on WinXP.
>>
>>This works fine at the command line (where the folder "c:\aa bb" exists)
>>
>> > os.rename( "c\aa bb", "c:\cc dd" );
>> >
>>
>>But, I can't get it to work in my program, eg.
>>
>>print SrcDir
>>print NewDir
>>os.rename( SrcDir, NewDir );
>>
>>when I run this I get something like this:
>>
>>"e:\\music\\Joni Mitchell\\ogg-8"
>>"e:\\music.ogg\\Joni Mitchell\\ogg-8"
> 
> 
> What kind of device is drive E: ?  Are you certain it allows spaces in 
> filenames?  Can you do the same renaming *using the same drive* at the 
> command line or from Explorer?
> 
> -Peter

Drive E: is removable, so I was careful to verify that that was a factor 
in the problem.

Yes, I can do the same renaming, with the same drive, at the command line.

I think I put the emphasis in the wrong place in my question.  This 
isn't really about os.rename().  It is about putting a filename with 
spaces into a string object and then using it as a parameter to an 'os' 
command.

Tom.

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


Re: simple problem with os.rename() parameters - path with spaces

2005-09-10 Thread Tom
Yes, I am sure about those things.
I've tried shutil.move and got the same result.
Forward slash?  I'll give that a try and report back here if it works.

Thanks,
Tom.

Larry Bates wrote:
> Are you sure the source directory exists and you
> have rights to rename it?  Because the rename works
> for me.
> 
> But you may want to look at shutil.move and/or
> use forward slashes (they work under Windows)
> 
> -Larry Bates
> 
> 
> Tom wrote:
> 
>>I'm having a problem using a path with spaces as a parameter to
>>os.rename() in a program on WinXP.
>>
>>This works fine at the command line (where the folder "c:\aa bb" exists)
>>
>>
>>>os.rename( "c\aa bb", "c:\cc dd" );
>>>
>>
>>But, I can't get it to work in my program, eg.
>>
>>print SrcDir
>>print NewDir
>>os.rename( SrcDir, NewDir );
>>
>>when I run this I get something like this:
>>
>>"e:\\music\\Joni Mitchell\\ogg-8"
>>"e:\\music.ogg\\Joni Mitchell\\ogg-8"
>>
>>Traceback (most recent call last):
>>  File "E:\Music\MoveMusic.py", line 64, in ?
>>main();
>>...
>>  File "E:\Music\MoveMusic.py", line 49, in Visit
>>os.mkdir( NewDir );
>>OSError: [Errno 22] Invalid argument: '"e:\\music.ogg\\Joni
>>Mitchell\\ogg-8"'
>>
>>I've tried different combinations of single backslash vs. double
>>backslash, and quoted vs. non-quoted, but it always fails.
>>
>>The problem is not specific to os.rename.  If I instead use mkdir(
>>SrcDir ) I get the same problem.
>>
>>Thanks,
>>Tom.
>>

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


Re: simple problem with os.rename() parameters - path with spaces

2005-09-10 Thread Tom
Peter Hansen wrote:
> Tom wrote:
> 
>>Drive E: is removable, so I was careful to verify that that was a factor 
>>in the problem.
>>
>>Yes, I can do the same renaming, with the same drive, at the command line.
>>
>>I think I put the emphasis in the wrong place in my question.  This 
>>isn't really about os.rename().  It is about putting a filename with 
>>spaces into a string object and then using it as a parameter to an 'os' 
>>command.
> 
> 
> That can't really be all there is to the issue, since other people can 
> successfully use spaces in filenames passed to 'os' commands including 
> os.rename.  There must be something special with _your_ situation.  What 
> else could it be except the file system?
> 
> Oh... wait, I see now.  Look closely at your error message:
> 
> Traceback (most recent call last):
>File "E:\Music\MoveMusic.py", line 64, in ?
>  main();
> ...
>File "E:\Music\MoveMusic.py", line 49, in Visit
>  os.mkdir( NewDir );
> OSError: [Errno 22] Invalid argument: '"e:\\music.ogg\\Joni 
> Mitchell\\ogg-8"'
> 
> Where do you think those double quotation marks came from?  What happens 
> if you try the following instead of using the variables you were trying 
> to use?
> 
> os.rename("e:\\music\\Joni Mitchell\\ogg-8",
>  "e:\\music.ogg\\Joni Mitchell\\ogg-8")
> 
> Now try it with this and observe how you get (I predict) the same error 
> message as you originally got, and note what your mistake was:
> 
> os.rename('"e:\\music\\Joni Mitchell\\ogg-8"',
>  '"e:\\music.ogg\\Joni Mitchell\\ogg-8"')

This produced the msg:
OSError: [Errno 22] Invalid argument

I'm now using forward slashes instead of backslashes - this simplifies 
things a bit.

The problem seems to be that I'm trying to create more than one 
directory at a time.  In the above example, the dir 'Joni Mitchell' 
doesn't exist.

The functions that I'm calling (os.rename and shutil.move) use mkdir, 
not makedirs.  The solution is for me to use makedirs with all of the 
path except the leaf before I move/rename the old dir.

Thanks for your help,
Tom.


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


Re: rounding problem

2005-02-23 Thread tom
On Wed, 23 Feb 2005 19:04:47 -0600, Andy Leszczynski wrote:

> It is on Windows, Linux, Python 2.3:
> 
> [GCC 3.3.2 (Mandrake Linux 10.0 3.3.2-6mdk)] on linux2 Type "help",
> "copyright", "credits" or "license" for more information.
>  >>> a=1.1
>  >>> a
> 1.1001
>  >>>
>  >>>
>  >>>
> Is it normal?

Yes. Quite normal.

Floating point numbers are by nature approximations. When you enter your
variable "a" at the prompt, you are asking for a very raw (i.e totally
unformatted!) dump of what your variable "a" contains. It is the
most precise representation of the float 1.1 that your computer can store.
 It is probably the best precision your hardware math processor subsystem
has to offer. And, incidentally, that ain't too shabby since a 1 in the
16th decimal place ain't worth spit!

Try putting a print statement in front of your variable.
>>> print a
>>> 1.1

The print statement ,by itself, adds the most minimial formatting, which
amounts to dropping the last significant digit your math processor holds.
That last digit will *always* contain some arithmetic slop.

If you do any serious work with floats, you will want to learn about
significant figures and the use of the very essential round() function in
whatever language you are using. If you do, you will find that this
situation is really a math thing and has little to do with computers or
any particular language. It's the exact same problem one runs into when
using a slide rule.

If anyone remembers those things :-)
Thomas Bartkus

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


Re: UrlLib2 Proxy and Https

2004-12-10 Thread Tom
I would like to access an HTTPS site via a proxy
The following code is working for HTTP://www.hotmail.com but not for HTTPS
I have try with other sites without success
  l_proxy_info = {
 'user' : mylogin,
 'pass' : mypassword,
 'host' : myproxy,
 'port' : 8080
  }
I have no idea if this is your problem, but you are aware that https is 
usually on port 443, not 80 or 8080 like http?

HTH
Tom
--
http://mail.python.org/mailman/listinfo/python-list


What's the best GUI toolkit in Python,Tkinter,wxPython,QT,GTK?

2005-03-27 Thread Tom
1) Portable to Windows, Unix-like platforms, and the Macintosh;
2) Powerful, GUI is very beautiful ;
3) Efficiency of development is high;
What's the best, Tkinter, wxPython, QT, GTK or other?
Thanks!
--
http://mail.python.org/mailman/listinfo/python-list


How to call a function in embeded python code in delphi?

2005-04-13 Thread Tom
delphi 7
python 2.3
win98
Python for Delphi V3.25
In Delphi:
1   Create a new Form ;
2   Drop a TMemo(Memo1) to contain python code;
3   Drop a TPythonInputOutput (PythonInputOutput1) ;
4   Drop a TPythonEngine (PythonEngine1) ;
5   Drag a PythonDelphiVar component and name it bx.  Set the VarName 
property to the same as its name;
6   Connect the attribute IO of the TPythonEngine to the 
TPythonInputOutput;
7   Drop a TButton (Button1) ;
8   Write python code in the Memo1 (set Memo1's property of lines):

  def ax(m,n):
 y=10
 bx.value=y+m+n
 ...
Now, As click Button1, how to call the funtion ax passing the 
arguments(such as m=33 and n=25), and get bx.ValueAsString  ;

Delphi Code:
---
unit Unit1;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, 
Forms,
  Dialogs, PythonEngine, StdCtrls;

type
  TForm1 = class(TForm)
Memo1: TMemo;
Button1: TButton;
PythonEngine1: TPythonEngine;
bx: TPythonDelphiVar;
PythonInputOutput1: TPythonInputOutput;
procedure Button1Click(Sender: TObject);
  private
{ Private declarations }
  public
{ Public declarations }
  end;
var
  Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
 /
 // //
 //  How to call the funtion ax passing the //
 //  arguments(such as m=33 and n=25), and  //
 //  get bx.ValueAsString ??// 

 // //
 /
 showmessage( bx.ValueAsString );
end;
end.

---

Thank you very much!!



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


QA Engineering/ Python/ Contract/ Austin, TX

2011-09-26 Thread TOM
Tom Gugger
Independent Recruiter
tgug...@bex.net

US Citizens or Greencard
On Site


QA Engineering/ Python/ Contract/ Austin, TX

This is an immediate start, such as next week. I need three
contractors
for a 4--6 month contract in Austin, TX for Quality Assurance
Engineers.
The location is Austin, TX.

This is an automation project.

Must Have — Good Network domain knowledge such as TCP/IP.

Must Have --- experience testing  Data, Voice, and IPTV traffic.

Must Have --- Strong Python

A Plus --- Fanfare

Please make sure all the required skills show on the resume. If
interested and
qualified, email resume to tgug...@bex.net.
-- 
http://mail.python.org/mailman/listinfo/python-list


Inotify on netfilter socket

2006-11-17 Thread tom
Hi Guys,

I'm wondering if it's possible to set up an inotify watch on a netfilter 
socket.  I want to monitor for incoming packets to the netfilter QUEUE 
target, but I can't seem to do it. select.select works on it, but i 
wanted to use inotify really.  Is there any way to create a tangible 
file which i can hook in to the netfilter socket?  I was using 
python-inotify and the ipqueue module.  Any suggestions welcome, or do 
you guys think that this would be better on the iptables/netfilter 
mailing lists?

Cheers, Tom
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Having trouble converting popen2 to subprocess

2006-11-18 Thread tom
Daniel Klein wrote:
> Here's a c routine that prints a single line :
>
> #include 
> main()
> {
>   printf ("Hello World!\n");
> }
>
> And now the Python program (called 'po.py') that uses 'popen2' :
>
> import popen2
> (fin, fout) = popen2.popen2(r'c:\home\hw.exe', -1, 't')
> print fin.readline()
> fin.close()
> fout.close()
>
> When this is run it properly outputs the one line from the c routine :
>
> C:\>python c:\python\po.py
> Hello World!
>
> Now here is my attempt to use the 'subprocess' module :
>
> from subprocess import *
> p = Popen(r'c:\home\hw.exe', bufsize=-1, stdin=PIPE, stdout=PIPE,
> universal_newlines=True)
> fin = p.stdin
> print fin.readline()
> fin.close()
>
> When this is run, I get no output :
>
> C:\>python c:\python\sp.py
>
>
> C:\>
>
> As you can see, I get no exception.
>
> I've tried various combinations of the Popen arguments with no joy.
>
> The platform is Windows XP Pro, so I did not try things like
> 'close_fds'.
>
> What am I missing ?
>
> Daniel Klein
>   
subprocess will actually execute as a subprocess, so you have to wait 
for the command to finish before you look at the stdout.  Advantages of 
this being that you can interfere with stdin/out whilst the program is 
running.  I believe .wait will be what you want, although i haven't look 
at the docstring, so double check.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: basic python questions

2006-11-18 Thread tom
[EMAIL PROTECTED] wrote:
> I have taken the coments and think I have implemented most. My only
> question is how to use the enumerator. Here is what I did, I have tried
> a couple of things but was unable to figure out how to get the line
> number.
>
>   
Try this in the interpreter,

l = [5,4,3,2,1]
for count, i in enumerate(l):
print count, i


> def Xref(filename):
> try:
> fp = open(filename, "r")
> except:
> raise "Couldn't read input file \"%s\"" % filename
> dict = {}
> line_num=0
> for words in iter(fp.readline,""):
> words = set(words.split())
> line_num = line_num+1
> for word in words:
> word = word.strip(".,!?:;")
> if not dict.has_key(word):
> dict[word] = []
> dict[word].append(line_num)
> fp.close()
> keys = sorted(dict);
> for key in keys:
> print key," : ", dict[key]
> return dict
>
> Marc 'BlackJack' Rintsch wrote:
>   
>> In <[EMAIL PROTECTED]>,
>> [EMAIL PROTECTED] wrote:
>>
>> 
>>> def Xref(filename):
>>> try:
>>> fp = open(filename, "r")
>>> lines = fp.readlines()
>>> fp.close()
>>> except:
>>> raise "Couldn't read input file \"%s\"" % filename
>>> dict = {}
>>> for line_num in xrange(len(lines)):
>>>   
>> Instead of reading the file completely into a list you can iterate over
>> the (open) file object and the `enumerate()` function can be used to get
>> an index number for each line.
>>
>> 
>>> if lines[line_num] == "":  continue
>>>   
>> Take a look at the lines you've read and you'll see why the ``continue``
>> is never executed.
>>
>> 
>>> words = lines[line_num].split()
>>> for word in words:
>>> if not dict.has_key(word):
>>> dict[word] = []
>>> if line_num+1 not in dict[word]:
>>> dict[word].append(line_num+1)
>>>   
>> Instead of dealing with words that appear more than once in a line you may
>> use a `set()` to remove duplicates before entering the loop.
>>
>> Ciao,
>>  Marc 'BlackJack' Rintsch
>> 
>
>   

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


Re: basic python questions

2006-11-18 Thread tom
tom wrote:
> [EMAIL PROTECTED] wrote:
>   
>> I have taken the coments and think I have implemented most. My only
>> question is how to use the enumerator. Here is what I did, I have tried
>> a couple of things but was unable to figure out how to get the line
>> number.
>>
>>   
>> 
> Try this in the interpreter,
>
> l = [5,4,3,2,1]
> for count, i in enumerate(l):
> print count, i
>
>
>   
you could do it like this.

for count, line in enumerate(fb):
for word in line.split():
   etc...

filehandles are iterators themselves.

dont take my words for granted though, i'm kinda new to all this too :)
>> def Xref(filename):
>> try:
>> fp = open(filename, "r")
>> except:
>> raise "Couldn't read input file \"%s\"" % filename
>> dict = {}
>> line_num=0
>> for words in iter(fp.readline,""):
>> words = set(words.split())
>> line_num = line_num+1
>> for word in words:
>> word = word.strip(".,!?:;")
>> if not dict.has_key(word):
>> dict[word] = []
>> dict[word].append(line_num)
>> fp.close()
>> keys = sorted(dict);
>> for key in keys:
>> print key," : ", dict[key]
>> return dict
>>
>> Marc 'BlackJack' Rintsch wrote:
>>   
>> 
>>> In <[EMAIL PROTECTED]>,
>>> [EMAIL PROTECTED] wrote:
>>>
>>> 
>>>   
>>>> def Xref(filename):
>>>> try:
>>>> fp = open(filename, "r")
>>>> lines = fp.readlines()
>>>> fp.close()
>>>> except:
>>>> raise "Couldn't read input file \"%s\"" % filename
>>>> dict = {}
>>>> for line_num in xrange(len(lines)):
>>>>   
>>>> 
>>> Instead of reading the file completely into a list you can iterate over
>>> the (open) file object and the `enumerate()` function can be used to get
>>> an index number for each line.
>>>
>>> 
>>>   
>>>> if lines[line_num] == "":  continue
>>>>   
>>>> 
>>> Take a look at the lines you've read and you'll see why the ``continue``
>>> is never executed.
>>>
>>> 
>>>   
>>>> words = lines[line_num].split()
>>>> for word in words:
>>>> if not dict.has_key(word):
>>>> dict[word] = []
>>>> if line_num+1 not in dict[word]:
>>>> dict[word].append(line_num+1)
>>>>   
>>>> 
>>> Instead of dealing with words that appear more than once in a line you may
>>> use a `set()` to remove duplicates before entering the loop.
>>>
>>> Ciao,
>>> Marc 'BlackJack' Rintsch
>>> 
>>>   
>>   
>> 
>
>   

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


Re: [Zopyrus] A python IDE for teaching that supports cyrillic i/o

2006-11-18 Thread tom
Oleg Broytmann wrote:
> On Sat, Nov 18, 2006 at 09:01:04PM +0200, Kirill Simonov wrote:
>   
>> Could anyone suggest me a simple IDE suitable for teaching Python as a
>> first programming language to high school students
>> 
which operating system would this concern?  IDLE which you might find 
comes with python, or is installable separately is a good bet, one nice 
feature is that when you open up the initial parenthese on a method 
call, it can list the arguments that the method expects.  ipython is 
very good too, it allows tab completion of class methods/attributes and 
the like, which can make navigating your way around a new class 
magnitudes easier.  only the former can really be considered an IDE.  
It'd be great to see them combined somehow.

I personally use pida (http://pida.berlios.de).  It is perhaps not a 
beginners IDE, but it has advantages such as being able to plug in a few 
different editors, some of which are very easy to use.  It has a class 
browser which you can have on a sidebar, integrated docbook support, the 
ability to open python and other types of shell as part of the window,  
syntax checking and more.  It can aid development to no end.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: print with variable justification (with *)

2006-11-18 Thread tom
Why Tea wrote:
> print format % values
> An optional minimum width of the conversion, specified using one or
> more digits or an asterisk (*), which means that the width is taken
> from the next item in values
>
> That's from one of O'reilly's books. But there is no example and I
> couldn't get it to work by trials and errors. Does anyone have a
> working example?
>
> /Why Tea
>
>   
value = 3.141592654
print "%1.3f" % value


there you go :)   look at printf in c for general ideas about the format 
specifiers
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: syntax error in sum(). Please explicate.

2006-11-18 Thread tom
Michael Press wrote:
> I have not written python codes nor run any. I saw this
> code posted and decided to try it. It fails. I read the
> tutorial and the entry for the built in function sum,
> but still do not see the problem. The code was cut and
> paste. Please help. Thanks.
>
> _BEGIN_CODE_
> #!/usr/bin/python
>
> ps = [none, 2,3,5,7,11,13,17,19,23,29]
>
>   
None has a capital N ^ 
> def phi(x, a):
> return x - sum(phi(x // ps[i+1], i) for i in range(a))
>
> def pi(n):
> from math import sqrt
> if n <= 1:
> return 0
> a = pi(int(sqrt(n)))
> return phi(n, a) + a - 1
> __END_CODE__
>
> Here is the result of running it:
>
>   File "/Users/mdp/source/prime_counter_python", line 6
> return x - sum(phi(x // ps[i+1], i) for i in range(a))
>   ^
> SyntaxError: invalid syntax
>
>   
can you paste the complete code?  I'm not sure why that's a syntax error 
there.  with a bit of fudging it seems to run in the interpreter ok...
> Here are some lines from python -v:
>
> Python 2.3 (#1, Sep 13 2003, 00:49:11) 
> [GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin
> Type "help", "copyright", "credits" or "license" for more information
>
>   

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


Re: print with variable justification (with *)

2006-11-18 Thread tom
John Machin wrote:
> tom wrote:
>   
>> Why Tea wrote:
>> 
>>> print format % values
>>> An optional minimum width of the conversion, specified using one or
>>> more digits or an asterisk (*), which means that the width is taken
>>> from the next item in values
>>>
>>> That's from one of O'reilly's books. But there is no example and I
>>> couldn't get it to work by trials and errors. Does anyone have a
>>> working example?
>>>
>>> /Why Tea
>>>
>>>
>>>   
>> value = 3.141592654
>> print "%1.3f" % value
>> 
>
> Please consider reading the subject of a message occasionally :)
>   

Sorry bout that !

> | >>> value = 3.141592654
> | >>> print "%1.3f" % value
> | 3.142
> | >>> print "%10.3f" % value
> |  3.142
> | >>> print "%*.3f" % (1, value)
> | 3.142
> | >>> print "%*.3f" % (10, value)
> |  3.142
> | >>> for n in range(11):
> | ... print "%*.3f" % (n, value)
> | ...
> | 3.142
> | 3.142
> | 3.142
> | 3.142
> | 3.142
> | 3.142
> |  3.142
> |   3.142
> |3.142
> | 3.142
> |  3.142
> | >>>
>   
>> there you go :)
>> 
>
> There *you* go :)
>
>   
>>  look at printf in c for general ideas about the format
>> specifiers
>> 
>
> Unfortunately this is about the same advice as given by the official
> Python tutorial:
>
> """Most formats work exactly as in C [snip] Using * to pass the width
> or precision in as a separate (integer) argument is supported"""
>
> Not quite so many folks come to Python with a background in C these
> days. Is anyone aware of a tutorial that covers % formatting from a
> standing start?
>
>   
If you're on a unix system you can probably do `man fprintf`, but it 
will mean wading through a lot of stuff you're no interested in.  This 
has a good little section on it though, specifically for python

http://rgruet.free.fr/PQR24/PQR2.4.html

> Cheers,
> John
>
>   

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


Re: Dealing with marketing types...

2005-06-11 Thread tom
On Fri, 10 Jun 2005 21:57:40 -0700, fuzzylollipop wrote:

> I was completely serious, he is _NOT_ going to win this one. He has
> already lost. I have been on both sides of this scenario, the "new guys"
> were brought in and will win since they are the new "experts from out of
> town".

Not only do I take you seriously - I agree!

I also have been on both sides of this scenario although my take on it is
slightly different.  It's not so much the "experts from out of town" as it
is the tendency to dump the guy(s) that brought them to the party.

The sequence goes like this:
1) When there is little or no money to be made, you start out with an
implied status as a partner. This means you work long + extra hours for
little pay on the promise that you will be rewarded when/if success comes.

2) Then the product gets out the door and it's more long hours with little
pay.  Much massaging and tweaking and still little money incoming.

3) Success & money start to roll in. Now your status drops from partner to
hired hand. An overpaid hired hand at that.  Now that the heavy lifting is
done, managment is wondering whether they need to actually reward the
guy(s) who brought them to the party.  The rational parts of their brains
shut down while every fiber of their larcenous beings wants them to
believe they can now dispense with the high priced talent (you!) for some
low bucks commodity labor.  There scads of outsourcing firms tripping over
one another to sell them the latter.

> There may be some other _VALID_ business reason that management has
> already made up their mind to hire these Java people. Probably because
> they want to sell the company or merge with someone or something and
> having a Java product would make them more attractive.

Yes, there is a possible _VALID_ reason. That would be the perception,
probably accurate, that a technology like Java will shelter them from
total dependency on some individual developer (you!).  In other words,
there is a greater likelihood that they can find replacement talent should
they need it.  Thats the optimistic view.  More often it sinks to the
sleazy when they decide to stiff the original guys who did all the extra
work up front.  If they can replace them, there will be no need to "pay
off" on the extra work they did up front.

I have had this happen to me as an employee.  Later, as an outside
consultant, I was frequently disgusted to realize how many manager/owners
were merely seeking to avoid the payoff for the guys who went the extra
mile to give them a profitable product. Tis business in the USA, sad to
say.

> There are 2 things he can do.
> 
> 1. Get your resume ready and approach the CEO or whomever and say. Why
> is this happening? Since I can guarantee you they have already decided
> to port this app to Java.

Resume ready is certainly wise and I concur with your gaurantee.

> 2. Be quiet, keep his head down, learn Java fatt, start agreeing
> with the new party line and get on the bandwagon if he really wants to
> stay at this company ( I wouldn't )

I disgree here.  The party line is nothing but a cover.  The goal is to
break the dependency on the guru(s) who did the developement or worse,
outright replacement.  The likelihood of staying on is slim and will
become increasingly unpleasant unless the employer is so lacking in
concience as to fire him outright.

Let me add an Item #3 -
If you have some entrepeneurial savvy and can keep your emotions out of
it tou can simply tell them you have decided strike out on your own and
tell them that you will be available. They will be happy to hear you are
leaving and happier still to hear you can be available for backup. 
Their goals and fears are addressed at the same time.  AND there is a very
high possibility that they will *need* you at a later date for which you
can charge them dearly.

That last item #3 has actually worked for me with (2) prior employers. 
I did have to eat my indignation and keep it friendly but it did pay off
in the end.
Thomas Bartkus


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


RE: Dealing with marketing types...

2005-06-11 Thread tom
On Sat, 11 Jun 2005 10:27:26 -0700, bruce wrote:

> i don't know what the original thread is/was...
> 
> but.. if you are part of an initial project.. get in writing what your role
> is if you're as a partner, get it in writing... if you're as a hired
> gun.. get it in writing... if you can't get anything in writing.. then make
> sure you have your own copies of any/all code that you're created/been a
> part of...
> 
> in this day/age, you need to protect yourself
> 
> and trust me, if your code is valuable, and you walk away with it because
> you feel you've been treated in an unfair manner (assuimng no written
> statement of your role), then let the other guy come after you... things get
> resolved in a much more equitable manner when the concerned parties are
> reasonably equal...
> 
> -bruce

I agree completely and you do need to read the original post.
Thomas Bartkus

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


getting rid of leading zeros in float expotential

2007-06-03 Thread tom
Hi! I'm wondering whether there's an easy way to remove unnecessary 
leading zeros from my floating point number.

realS = float(-1.25e-5)
imgS = float(-7.6e4)

print complex(realS, imgS)

 >> (-1.25e-005-76000j)

I would like it to look like (-1.25e-5-76000j)
-- 
http://mail.python.org/mailman/listinfo/python-list


NoneType object not iterable

2007-07-13 Thread tom
Hi!
My code is

 > db = {}
 >
> def display():
> keyList = db.keys()
> sortedList = keyList.sort()
> for name in sortedList:
> line = 'Name: %s, Number: %s' % (name, db[name])
> print line.replace('\r', '')

And it gives following error:

> for name in sortedList:
> TypeError: 'NoneType' object is not iterable

How can sortedList variable turn into NoneType? I just don't get it...
-- 
http://mail.python.org/mailman/listinfo/python-list


keyword checker - keyword.kwlist

2007-05-10 Thread tom
Hi

I try to check whether a given input is keyword or not. However this 
script won't identify keyword input as a keyword. How should I modify it 
to make it work?

#!usr/bin/env python
import keyword

input = raw_input('Enter identifier to check >> ')
if input in keyword.kwlist:
 print input + "is keyword"

else:
 print input + "is not keyword"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: keyword checker - keyword.kwlist

2007-05-10 Thread tom
> 
> Hmm... I tried, and identify it.
> Try to change the 'input' variable name with other...
> 
Changed input variable to myInput, but the result is still the same.

for example, 'else' isn't identified as a keyword by the script though 
it exists in keyword.kwlist.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: keyword checker - keyword.kwlist

2007-05-10 Thread tom
Still no go. I just can't get it right. My current script:

#!usr/bin/env python
import keyword

myInput = raw_input('Enter identifier to check >> ')
if myInput in keyword.kwlist:
 print myInput, "is keyword"

else:
 print myInput, "is not keyword"

print keyword.kwlist
print keyword.__file__

And the output:

Enter identifier to check >> else
else
is not keyword
['and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 
'elif', 'else', 'except', 'exec', 'finally', 'for', 'from', 'global', 
'if', 'import', 'in', 'is', 'lambda', 'not', 'or', 'pass', 'print', 
'raise', 'return', 'try', 'while', 'with', 'yield']
F:\Ohjelmat\Python25\Lib\keyword.pyc
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: keyword checker - keyword.kwlist

2007-05-10 Thread tom
Hamilton, William kirjoitti:
>> From: [EMAIL PROTECTED]
>> F:\Ohjelmat\Python25\Lib\keyword.pyc
> 
> That's your problem.  Rename keyword.py to keywordcheck.py, and delete
> keyword.pyc in this directory, and it should work fine.
> 
> ---
> -Bill Hamilton
I tried the trick but the error stays. I really don't know what to do 
anymore.

And what about the print function. Why does it print newline even if 
there is colon after variable? I'm lost.

I'm using Eclipe enviroment and Pydev for it. My python interpreter is 
2.5.1.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: keyword checker - keyword.kwlist

2007-05-12 Thread tom
Gabriel Genellina kirjoitti:
> En Thu, 10 May 2007 17:03:13 -0300, <[EMAIL PROTECTED]> escribió:
> my_input = raw_input("...").strip()
> 
> as Peter Otten suggested before
> 
> --Gabriel Genellina
> 
Ok, it seems to work with strip(). Thanks for your help.

Do you guys have any clue why mine previous code doesn't work?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: keyword checker - keyword.kwlist

2007-05-12 Thread tom
[EMAIL PROTECTED] kirjoitti:
> Gabriel Genellina kirjoitti:
>> En Thu, 10 May 2007 17:03:13 -0300, <[EMAIL PROTECTED]> escribió:
>> my_input = raw_input("...").strip()
>>
>> as Peter Otten suggested before
>>
>> --Gabriel Genellina
>>
> Ok, it seems to work with strip(). Thanks for your help.
> 
> Do you guys have any clue why mine previous code doesn't work?
Oh, repr() function revealed the issue. Thank you all!
-- 
http://mail.python.org/mailman/listinfo/python-list


Can Epydoc exclude wxPython?

2007-03-05 Thread tom
I would like to use Epydoc (3.0beta1) to document my wxPython (2.6.10) 
application.  The problem is that I can't seem to instruct Epydoc to not 
also generate partial documentation of wxPython, which makes too much 
verbiage for a user to wade through in order see the documentation of my 
program.

For example, if my module consists of only the three lines

import wx
class BasicPanel(wx.Panel):
 pass

the generated documentation for BasicPanel is completely swamped by the 
over 100 instance methods and static methods for wx._core.Window, etc.

I've tried using the "exclude" command in a config file and command line 
and also sprinkling around "@undocumented" commands in the .py file. 
Neither of these make any difference as far as I can see, but they 
aren't documented well in Epydocs so I'm not completely sure that I'm 
using them correctly, although I've tried many, many variations all to 
no avail.  I've also tried turning off introspection and/or parsing, but 
then the Epydoc output isn't as good.

Does anyone know of a way to avoid this?  Short of fixing this in 
Epydoc, how about a different documentation package -- I chose Epydoc 
because it included clickable inheritance trees in the docs.  Is there 
another package that does this?

I installed Epydoc using epydoc-3.0beta1.win32.exe on Windows XP and am 
using Python 2.4.3.

Thanks for any help,
Tom

P.S. -  I haven't found any other group or mailing list that might be a 
more focused forum for this question.  Please let me know if you know of 
one.
-- 
http://mail.python.org/mailman/listinfo/python-list


Stack experiment

2007-04-03 Thread tom
Hi! Im new to Python and doing exercise found from internet. It is 
supposed to evaluate expression given with postfix operator using 
Stack() class.

class Stack:
 def __init__(self):
 self.items = []

 def push(self, item):
 self.items.append(item)

 def pop(self):
 return self.items.pop()

 def isEmpty(self):
 return (self.items == [])

def evaluatePostfix(expr):
 import re
 tokenList = re.split(" ([^0-9])", expr)
 stack = Stack()
 for token in tokenList:
 if token == '' or token == ' ':
 continue
 if token == '+':
 sum = stack.pop() + stack.pop()
 stack.push(sum)
 elif token == '*':
 product = stack.pop() * stack.pop()
 stack.push(product)
 else:
 stack.push(int(token))
 return stack.pop()

print evaluatePostfix("56 47 + 2 *")

Errormsg:
Traceback (most recent call last):
   File "C:\*\postfix1.py", line 31, in 
 print evaluatePostfix("56 47 + 2 *")
   File "C:\*\postfix1.py", line 28, in evaluatePostfix
 stack.push(int(token))
ValueError: invalid literal for int() with base 10: '56 47'

How can I avoid the error and get desired result?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Stack experiment

2007-04-03 Thread tom
Ok, I got it running. Thank you!

I removed the space and top of that I had foul indentation in return 
statement.

I'll try the approaches you suggest.
-- 
http://mail.python.org/mailman/listinfo/python-list


Simple integer comparison problem

2007-04-14 Thread tom
Hi!
I ran in problem with simple exercise. I'm trying to get program to 
return grade when given points but no matter what, I always get F.

def grader():
 print "Insert points: "
 points = raw_input('> ')
 int(points)

 if points > 89 and points <= 100:
 return "A"
 elif points > 89 and points <= 89:
 return "B"
 elif points > 69 and points <= 79:
 return "C"
 elif points > 59 and points <= 69:
 return "D"
 else:
 return "F"

grade = grader()
print grade
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple integer comparison problem

2007-04-14 Thread tom
Thanks for help!
-- 
http://mail.python.org/mailman/listinfo/python-list


The smallest and largest values of numeric types

2007-04-17 Thread tom
Hi!
How can I determine the smallest and largest values of numeric types 
(for example int) possible in my system? I think there exists a function 
for this task but I don't know it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The smallest and largest values of numeric types

2007-04-17 Thread tom
Thank you for your answers. Seems like the limits of numeric values 
aren't considered as important in Python as in C ;)
-- 
http://mail.python.org/mailman/listinfo/python-list


Memory Leak after Py_Finalize()

2009-03-26 Thread Tom
Hi,
I have ported Python, numarray and numpy to the PharLap Embedded
Operating System. Python 2.5.2 numpy 1.3.0b1
My problem is the massive memory loss coming back after Py_Finalize()
when using numpy. I have seen similar posts but am unclear how to
proceed. Here are my symptomns:-

Py_Initialize()
Py_Main()
 import numpy
Py_Finalize()

This gives me a 2.34 MB memory loss each time through. Its similar for
numarray.
Do I need to do something before coming back from Py_Main ?  (like
setting all the reference counts to 0 and forcing the garbage
collector to run). Doing a >>> del numpy is not enough.
I understand there is a memory loss when stopping and starting Python
(I observe it to be about 70K) - my problem is that I dont know how to
shutdown numpy cleanly - I want the opposite of "import numpy".
--
http://mail.python.org/mailman/listinfo/python-list


some jordan shoes and something for wholesale

2008-06-21 Thread tom
would you  want to buy cheap something?welcome to www.wholenikee.cn
--
http://mail.python.org/mailman/listinfo/python-list


httplib HTTP: Logging request message

2008-06-27 Thread tom
With module httplid, I can do
conn.request("POST", "/target", params, headers)

Now, I want to log the request message that is sent by the request
method.  I don't don't see a method for that task.  Any suggestion?

For a response, I can log the response message by using the call
method.  Though, I have to get rid of the extra strings "replay: " and
"header: ".

data = response.read()
print data

/***what the print call will output***/
reply: 'HTTP/1.0 204 \r\n'
header: Content-Length: 0
--
http://mail.python.org/mailman/listinfo/python-list


Re: httplib HTTP: Logging request message

2008-07-01 Thread tom
I guess the easies way to do it is to copy and modify the httplib
module to log both outgoing and incoming messages.

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


Re: Filling in Degrees in a Circle (Astronomy)

2008-08-23 Thread tom

W. eWatson wrote:
The other night I surveyed a site for astronomical use by measuring the 
altitude (0-90 degrees above the horizon) and az (azimuth, 0 degrees 
north clockwise around the site to 360 degrees, almost north again) of 
obstacles, trees. My purpose was to feed this profile of obstacles 
(trees) to an astronomy program that would then account for not sighting 
objects below the trees.


When I got around to entering them into the program by a file, I found 
it required the alt at 360 azimuth points in order from 0 to 360 (same 
as 0). Instead I have about 25 points, and expected the program to be 
able to do simple linear interpolation between those.


Is there some simple operational device in Python that would allow me to 
create an array (vector) of 360 points from my data by interpolating 
between azimuth points when necessary? All my data I rounded to the 
nearest integer. Maybe there's an interpolation operator?


As an example, supposed I had made 3 observations: (0,0) (180,45) and 
(360,0). I would want some thing like (note the slope of the line from 0 
to 179 is 45/180 or 0.25):

alt: 0, 0.25, 0.50, 0.75, ... 44.75, 45.0
az : 0, 1,2,3,  180

Of course, I don't need the az.




If I understand you right, I think using interpolation as provided by 
scipy would do what you need.


Here's an example:

from scipy.interpolate.interpolate import interp1d

angles = [0, 22, 47.5, 180, 247.01, 360]
altitudes = [18, 18, 26, 3, 5, 18]

desired_angles = range(0, 361)

skyline = interp1d(angles, altitudes, kind="linear")
vals = skyline(desired_angles)

# that is, vals will be the interpolated altitudes at each of the
# desired angles.

if 1:  # plot this out with matplotlib
import pylab as mx
mx.figure()
mx.plot(angles, altitudes, 'x')
mx.plot(desired_angles, vals)
mx.show()
--
http://mail.python.org/mailman/listinfo/python-list


Re: Filling in Degrees in a Circle (Astronomy)

2008-08-23 Thread tom

W. eWatson wrote:

tom wrote:

W. eWatson wrote:
The other night I surveyed a site for astronomical use by measuring 
the altitude (0-90 degrees above the horizon) and az (azimuth, 0 
degrees north clockwise around the site to 360 degrees, almost north 
again) of obstacles, trees. My purpose was to feed this profile of 
obstacles (trees) to an astronomy program that would then account for 
not sighting objects below the trees.


When I got around to entering them into the program by a file, I 
found it required the alt at 360 azimuth points in order from 0 to 
360 (same as 0). Instead I have about 25 points, and expected the 
program to be able to do simple linear interpolation between those.


Is there some simple operational device in Python that would allow me 
to create an array (vector) of 360 points from my data by 
interpolating between azimuth points when necessary? All my data I 
rounded to the nearest integer. Maybe there's an interpolation operator?


As an example, supposed I had made 3 observations: (0,0) (180,45) and 
(360,0). I would want some thing like (note the slope of the line 
from 0 to 179 is 45/180 or 0.25):

alt: 0, 0.25, 0.50, 0.75, ... 44.75, 45.0
az : 0, 1,2,3,  180

Of course, I don't need the az.




If I understand you right, I think using interpolation as provided by 
scipy would do what you need.


Here's an example:

from scipy.interpolate.interpolate import interp1d

angles = [0, 22, 47.5, 180, 247.01, 360]
altitudes = [18, 18, 26, 3, 5, 18]

desired_angles = range(0, 361)

skyline = interp1d(angles, altitudes, kind="linear")
vals = skyline(desired_angles)

# that is, vals will be the interpolated altitudes at each of the
# desired angles.

if 1:  # plot this out with matplotlib
import pylab as mx
mx.figure()
mx.plot(angles, altitudes, 'x')
mx.plot(desired_angles, vals)
mx.show()
I decided this morning and roll up my sleeves and write the program. I 
plan to take a deeper plunge in the next month than my so far erratic 
look over the last 18 or more months  It's working.


The above looks like it's on the right track. Is scipy some collection 
of astro programs? mx is a graphics character plot?


I just hauled it into IDLE and tried executing it.
from scipy.interpolate.interpolate import interp1d
ImportError: No module named scipy.interpolate.interpolate

Apparently, something is missing.

I posted a recent msg a bit higher that will probably go unnoticed, so 
I'll repeat most of it. How do I get my py code into some executable 
form so that Win users who don't have python can execute it?





Both scipy and matplotlib are not part of the standard Python 
distribution so they would need to be installed separately.  Scipy is 
useful for scientific data analysis, and matplotlib is useful for making 
plots.


Since you want to wrap everything into a  Windows executable, it's 
probably easiest for you not to use scipy.  At the least, I suspect it 
would make your executable file much larger, but I've never made a 
Windows executable so I don't know the details.


As for making an executable, I'm not the one to ask, but googling leads 
to this:

http://effbot.org/pyfaq/how-can-i-create-a-stand-alone-binary-from-a-python-script.htm
which looks like a good place to start.

Tom

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


Re: Filling in Degrees in a Circle (Astronomy)

2008-08-24 Thread tom



http://matplotlib.sourceforge.net/

I'm using Python 2.4. The install looks pretty complicated for Windows. 
It doesn't seem like matplotlib is a module.




Maybe going with the enthought edition would be easiest for you as it is 
a very complete set of tools all in one package.  It's at 
http://www.enthought.com/products/epd.php


These are really nice tools for scientific (and other) data analysis, 
and are very competitive with most professional packages.  There are 
other bundles as well, like Sage.  I've always used enthought.


On the other hand, I think making tools that use these in a bundled exe 
might be more difficult, and if possible, might not be consistent with 
their license agreements, and might make for large packages.  I never 
really looked into this.


Also, with matplotlib, you might just try installing it without anything 
else and see how it goes.  Just download the exe and double-click, or 
the egg file and do whatever one does with those.  I bet it will work... 
I think it will just default to using Tk for the GUI, which you already 
have installed with Python, and it won't use agg (an anti-aliasing 
library), so your plots won't be quite as pretty.  But they'll still be 
nice, and it will likely work.




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


Re: Do I have to use threads?

2010-01-13 Thread Tom
On Jan 7, 5:38 pm, MRAB  wrote:
> Jorgen Grahn wrote:
> > On Thu, 2010-01-07, Marco Salden wrote:
> >> On Jan 6, 5:36 am, Philip Semanchuk  wrote:
> >>> On Jan 5, 2010, at 11:26 PM, aditya shukla wrote:
>
> >>>> Hello people,
> >>>> I have 5 directories corresponding 5  different urls .I want to  
> >>>> download
> >>>> images from those urls and place them in the respective  
> >>>> directories.I have
> >>>> to extract the contents and download them simultaneously.I can  
> >>>> extract the
> >>>> contents and do then one by one. My questions is for doing it  
> >>>> simultaneously
> >>>> do I have to use threads?
> >>> No. You could spawn 5 copies of wget (or curl or a Python program that  
> >>> you've written). Whether or not that will perform better or be easier  
> >>> to code, debug and maintain depends on the other aspects of your  
> >>> program(s).
>
> >>> bye
> >>> Philip
> >> Yep, the more easier and straightforward the approach, the better:
> >> threads are always (programmers')-error-prone by nature.
> >> But my question would be: does it REALLY need to be simultaneously:
> >> the CPU/OS only has more overhead doing this in parallel with
> >> processess. Measuring sequential processing and then trying to
> >> optimize (e.g. for user response or whatever) would be my prefered way
> >> to go. Less=More.
>
> > Normally when you do HTTP in parallell over several TCP sockets, it
> > has nothing to do with CPU overhead. You just don't want every GET to
> > be delayed just because the server(s) are lazy responding to the first
> > few ones; or you might want to read the text of a web page and the CSS
> > before a few huge pictures have been downloaded.
>
> > His "I have to [do them] simultaneously" makes me want to ask "Why?".
>
> > If he's expecting *many* pictures, I doubt that the parallel download
> > will buy him much.  Reusing the same TCP socket for all of them is
> > more likely to help, especially if the pictures aren't tiny. One
> > long-lived TCP connection is much more efficient than dozens of
> > short-lived ones.
>
> > Personally, I'd popen() wget and let it do the job for me.
>
>  From my own experience:
>
> I wanted to download a number of webpages.
>
> I noticed that there was a significant delay before it would reply, and
> an especially long delay for one of them, so I used a number of threads,
> each one reading a URL from a queue, performing the download, and then
> reading the next URL, until there were none left (actually, until it
> read the sentinel None, which it put back for the other threads).
>
> The result?
>
> Shorter total download time because it could be downloading one webpage
> while waiting for another to reply.
>
> (Of course, I had to make sure that I didn't have too many threads,
> because that might've put too many demands on the website, not a nice
> thing to do!)

A fair few of my scripts require multiple uploads and downloads, and I
always use threads to do so. I was using an API which was quite badly
designed, and I got a list of UserId's from one API call then had to
query another API method to get info on each of the UserId's I got
from the first API. I could have used twisted, but in the end I just
made a simple thread pool (30 threads and an in/out Queue). The
result? A *massive* speedup, even with the extra complications of
waiting until all the threads are done then grouping the results
together from the output Queue.

Since then I always use native threads.

Tom
-- 
http://mail.python.org/mailman/listinfo/python-list


python replace/sub/wildcard/regex issue

2010-01-18 Thread tom
hi...

trying to figure out how to solve what should be an easy python/regex/
wildcard/replace issue.

i've tried a number of different approaches.. so i must be missing
something...

my initial sample text are:

Soo ChoiLONGEDITBOX">Apryl Berney
Soo ChoiLONGEDITBOX">Joel Franks
Joel FranksGEDITBOX">Alexander Yamato

and i'm trying to get

Soo Choi foo Apryl Berney
Soo Choi foo Joel Franks
Joel Franks foo Alexander Yamato

the issue i'm facing.. is how to start at "' and
substitute inclusive of the stuff inside the regex...

i've tried derivations of

name=re.sub("]*\">"," foo ",name)

but i'm missing something...

thoughts... thanks

tom
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: python replace/sub/wildcard/regex issue

2010-01-18 Thread tom
hi chris...

should the reply you sent me be implemented all on one line? like:

test='Soo ChoiLONGEDITBOX">Apryl Berney'
new_text = "\n".join(line[:line.index('<')] + line[line.rindex('>')+1:] for
line in test.split('\n'))

and what would line be?

thanks



-Original Message-
From: python-list-bounces+bedouglas=earthlink@python.org
[mailto:python-list-bounces+bedouglas=earthlink@python.org]on Behalf
Of Chris Rebert
Sent: Monday, January 18, 2010 8:32 PM
To: tom
Cc: python-list@python.org
Subject: Re: python replace/sub/wildcard/regex issue


On Mon, Jan 18, 2010 at 8:04 PM, tom  wrote:
> hi...
>
> trying to figure out how to solve what should be an easy python/regex/
> wildcard/replace issue.
>
> i've tried a number of different approaches.. so i must be missing
> something...
>
> my initial sample text are:
>
> Soo ChoiLONGEDITBOX">Apryl Berney
> Soo ChoiLONGEDITBOX">Joel Franks
> Joel FranksGEDITBOX">Alexander Yamato
>
> and i'm trying to get
>
> Soo Choi foo Apryl Berney
> Soo Choi foo Joel Franks
> Joel Franks foo Alexander Yamato
>
> the issue i'm facing.. is how to start at "' and
> substitute inclusive of the stuff inside the regex...
>
> i've tried derivations of
>
> name=re.sub("]*\">"," foo ",name)
>
> but i'm missing something...
>
> thoughts... thanks

"Some people, when confronted with a problem, think 'I know, I'll use
regular expressions.' Now they have two problems."

Assuming your sample text is representative of all your test:

new_text = "\n".join(line[:line.index('<')] +
line[line.rindex('>')+1:] for line in your_text.split('\n'))

Cheers,
Chris
--
http://blog.rebertia.com
--
http://mail.python.org/mailman/listinfo/python-list

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


Vote to Add Python Package "pubsub" to the Python Standard Library

2010-05-26 Thread Tom
I vote for adding the Python package "pubsub" to the Python standard
library.  It has recently been added to wxpython (replacing the old
wx.lib.pubsub package), but it has application to non-gui programs as
well.

For more information see: .

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


Re: how to iterate over several lists?

2009-06-05 Thread Tom
On Fri, 5 Jun 2009 04:07:19 + (UTC), kj 
wrote:

>
>
>Suppose I have two lists, list_a and list_b, and I want to iterate
>over both as if they were a single list.  E.g. I could write:
>
>for x in list_a:
>foo(x)
>for x in list_b:
>foo(x)
>
>But is there a less cumbersome way to achieve this?  I'm thinking
>of something in the same vein as Perl's:
>
>for $x in (@list_a, @list_b) {
>  foo($x);
>}
>
>TIA!
>
>kynn

def chain(*args):
  return (item for seq in args for item in seq)

for x in chain(list_a, list_b):
foo(x)
-- 
http://mail.python.org/mailman/listinfo/python-list


waling a directory with very many files

2009-06-14 Thread tom
i can traverse a directory using os.listdir() or os.walk(). but if a
directory has a very large number of files, these methods produce very
large objects talking a lot of memory.

in other languages one can avoid generating such an object by walking
a directory as a liked list. for example, in c, perl or php one can
use opendir() and then repeatedly readdir() until getting to the end
of the file list. it seems this could be more efficient in some
applications.

is there a way to do this in python? i'm relatively new to the
language. i looked through the documentation and tried googling but
came up empty.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: waling a directory with very many files

2009-06-14 Thread tom
On Jun 14, 1:35 pm, Tim Golden  wrote:
>
> If you're on Windows, you can use the win32file.FindFilesIterator
> function from the pywin32 package. (Which wraps the Win32 API
> FindFirstFile / FindNextFile pattern).

thanks, tim.

however, i'm not using windows. freebsd and os x.
-- 
http://mail.python.org/mailman/listinfo/python-list


Removing newlines from string on windows (without replacing)

2009-07-25 Thread Tom
This is my first post to this mailing list, so hi :)

I have an annoying problem. While I mainly use Linux when I distribute
this program to friends and on the internet, it'll get used on Windows.
So, I tested my python program on my Windows Vista dual boot, running
the same version of python (2.6) as my Linux, and got an error at the
following code.

s = sauce.replace("\n", "")

Sauce is a string, read from a file, that I need to remove newlines
from. This code works fine in Linux, but not in Windows. rstrip("\n")
won't work for me, so anybody know how to get this working on Windows?

Thanks! :D

--print "Tom"

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


Re: Removing newlines from string on windows (without replacing)

2009-07-26 Thread Tom
Sorry for not providing enough information - and Rhodri, for sending
my second message I used the GMX webmail client rather than my usual
Linux client as I was testing it on windows. That must have screwed it
up, I need to download Thunderbird on Mozzila.

The thing that was messing it up was that the endlines are handled
differently on each each OS, so I changed the code to strip the
endlines to be:

if os.name == "nt":
s = sauce.rstrip("\r\n")
else:
s = sauce.replace("\n", "")

This works fine now, (os.name returns nt on windows and posix on
linux)
Thanks for the help, and sorry for slow response and lack of detail,
I'm still trying to get used to this usenet thing :P

--
print "Tom"
-- 
http://mail.python.org/mailman/listinfo/python-list


Globalize all variables in function without knowing names.

2009-07-26 Thread Tom
Does anyknow know how to do this? The reason I'm asking is because I'm
trying to make a mini-programming language for fun, and need to work
with variables.

The user types 'set NAME "DATA" ' or whatever else the variable is
going to be called/contain.

I have:
def variablework(varname, varset):
exec("global "+varname) #DEFUNCT
vars()[varname] = varset
exec("print "+varname)   #Debug purposes only

This sets the variable (varname is the name of the variable, and
varset is the data for it to contain) all fine and dandy, but it is
local, and after some googling I realised that you can't globalised
variables using exec. So I think the next best thing would be to find
a way to globalize every variable in the function, but I don't know
how to do this. If there isn't a way of doing this, can someone
suggest another way of globalizing variable without knowing their
names?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Removing newlines from string on windows (without replacing)

2009-07-26 Thread Tom
> (Even if it so happens sauce
> will only ever have LFs at the end, it's still better to use the
> method that is closest to your intended meaning.)

Oh, you're right. I'll change that now. I suppose removing all
endlines will be better, incase, somehow, endlines in the middle of
the line arrises.

> if it's not important to preserve trailing spaces

The way I parse the file currently splits away all whitespace later
on. While I could change this, I have a nice system worked out and my
code is working, so it's not top priority.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Globalize all variables in function without knowing names.

2009-07-26 Thread Tom
Ah, thanks for that Dennis. I have a system already figured out where
the user manually pre-enters all the variables into a .py file, which
obviously isn't very efficient. The language isn't going to be used
much except by me, so I suppose I'll just work with that until I look
more into dictionaries, but I'm still beginning Python, and before
that the only coding I did was a little bit of C++, so I'll wait up
for that :P
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Globalize all variables in function without knowing names.

2009-07-27 Thread Tom
> Dictionaries are fundamental to Python and very useful. Not learning
> about them before starting to write code is like not learning about the
> accelerator pedal before starting to drive a car.

Heh, I just looked at the actual tutorial for Dictionaries and I have
to say they are very useful. Basically just arrays with strings(or any
other data type, except lists) instead of numbers. I'll work on trying
to integrate them into my language code as, like you said, user
data... Then when a user requests a variable it just accessess the
dictionary, that should work. Thanks!
This is easier than I thought.

> Have you done the tutorial?

I did the first few sections, and then flipped back to it later on to
find out what I needed to know as I coded applications. A bad idea, in
retrospect, particilary as it slowed down my coding time alot.
-- 
http://mail.python.org/mailman/listinfo/python-list


@lru_cache on functions with no arguments

2017-07-31 Thread tom
As part of the Python 3 cleanup in Django there are a fair few uses of 
@functools.lru_cache on functions that take no arguments. A lru_cache isn't 
strictly needed here, but it's convenient to just cache the result. Some 
examples are here: https://github.com/django/django/pull/8825/files

I did some profiling and I found that using `@lru_cache(maxsize=None)` on such 
functions is twice as fast as a standard `@lru_cache()`, apparently because 
with a `maxsize` the lru_cache code requires a lock acquisition and a fair bit 
more state to track.

Am I right in thinking that using `maxsize=None` is best for functions that 
accept no arguments? Should we even be using a `lru_cache` in such situations, 
or write our own simple cache decorator instead?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: @lru_cache on functions with no arguments

2017-08-01 Thread tom
Hello all,
Thank you for the replies! So, here is the context:

1. The functions Django wants to cache require Django to be initialized and the 
settings loaded. This means the return values are not available at definition 
time. (Matt Wheeler hits it on the head).

2. Django has a long-standing no-dependencies rule, which may change in the 
near future but for now it is stdlib only. We can't add a dependency on 
`lazy-property`.

This is all a bit off-topic anyway. I was merely asking about the tradeoffs for 
using maxsize=None vs maxsize=default in `lru_cache`.

On my Ubuntu machine I am getting some interesting benchmark results. If you 
disable the LRU cache C extension, so it uses the following implementations:

1. maxsize is not none: 
https://github.com/python/cpython/blob/master/Lib/functools.py#L526-L581

2. maxsize is none: 
https://github.com/python/cpython/blob/master/Lib/functools.py#L509-L522

And you have a simple function:

def test():
   return object()

I get the following numbers without much variance:

1. lru_cache(maxsize=None) - 870ns 

2. lru_cache() - 1300ns

3. no cache - 100ns

So, in the best case, without the C extension lru_cache is 8x as slow as the 
function itself. I get that it's not a great comparison as few functions are as 
simple as that, but a 700ns overhead is quite a bit, and if you're putting it 
around simple functions and expecting them to be faster, that may not be true.

With the C extension I get 50ns for both. So obviously a lot faster. Maybe it 
doesn't matter...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: @lru_cache on functions with no arguments

2017-08-01 Thread tom
> _sentinel = object()
> _val = _sentinel
> def val():
> if _val is _sentinel:
> # Calculate _val
> return _val
> 
> seems entirely sufficient for this case. Write a custom decorator if you use 
> the idiom often enough to make it worth the effort.

I did some timings with this as part of my timings above and found it to be 
significantly slower than lru_cache with the C extension. I had to add 
`nonlocal` to get `_val` to resolve, which I think kills performance a bit.

I agree with the premise though, it might be worth exploring.

> There is a more elegant and faster approach if you use a non-data
> descriptor instead of a property or a lru_cache. If you use a non-data
> descriptor property, you can even get rid of subsequent function calls.
> I dumped some example code in a gist,
> https://gist.github.com/tiran/da7d4c43d493c5aa7d7abc4d8a0678a6

Thank you! That's an interesting and great idea. It's faster, but not faster 
than lru-cache with the C extension. I'll investigate further.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: @lru_cache on functions with no arguments

2017-08-03 Thread tom
On Thursday, 3 August 2017 16:37:22 UTC+1, Ian  wrote:
> On Thu, Aug 3, 2017 at 8:35 AM, Paul  Moore ...@gmail.com> wrote:
> > On Tuesday, 1 August 2017 15:54:42 UTC+1, t...@tomforb.es  wrote:
> >> > _sentinel = object()
> >> > _val = _sentinel
> >> > def val():
> >> > if _val is _sentinel:
> >> > # Calculate _val
> >> > return _val
> >> >
> >> > seems entirely sufficient for this case. Write a custom decorator if you 
> >> > use the idiom often enough to make it worth the effort.
> >>
> >> I did some timings with this as part of my timings above and found it to 
> >> be significantly slower than lru_cache with the C extension. I had to add 
> >> `nonlocal` to get `_val` to resolve, which I think kills performance a bit.
> >>
> >> I agree with the premise though, it might be worth exploring.
> >
> > It's worth pointing out that there's nothing *wrong* with using lru_cache 
> > with maxsize=None. You're going to find it hard to get a pure-Python 
> > equivalent that's faster (after all, even maintaining a single variable is 
> > still a dict lookup, which is all the cache does when LRU functionality is 
> > disabled).
> 
> The single variable is only a dict lookup if it's a global. Locals and
> closures are faster.
> 
> def simple_cache(function):
> sentinel = object()
> cached = sentinel
> 
> @functools.wraps(function)
> def wrapper(*args, **kwargs):
> nonlocal cached
> if args or kwargs:
> return function(*args, **kwargs)  # No caching with args
> if cached is sentinel:
> cached = function()
> return cached
> return wrapper
> 
> *Zero* dict lookups at call-time. If that's not (marginally) faster
> than lru_cache with maxsize=None I'll eat my socks.

I hope you washed them!

def test_func():
   return 1

%timeit test_simple_cache()
The slowest run took 11.06 times longer than the fastest. This could mean that 
an intermediate result is being cached.
1000 loops, best of 3: 183 ns per loop

%timeit test_lru_cache()
The slowest run took 42.92 times longer than the fastest. This could mean that 
an intermediate result is being cached.
1000 loops, best of 3: 46.9 ns per loop

%timeit test_func()
1000 loops, best of 3: 55.3 ns per loop
-- 
https://mail.python.org/mailman/listinfo/python-list


Google App Engine dev_appserver and pdb?

2013-05-30 Thread Tom P

Is there a way to use pdb to debug Google apps written in Python?
When I start the development system to run the app "test" like this -

'./google_appengine/dev_appserver.py' './test'

 - I'd like to send the program into debug. I couldn't see anything in 
the documentation how to do this. If I do this -

python -mpdb './google_appengine/dev_appserver.py' './test'
 - then dev_appserver.py goes into debug but doesn't know anything 
about "test".


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


Custom build of Python

2012-06-20 Thread KACVINSKY Tom
I had reason to build Python 2.6.8 with Microsoft Visual Studio 2010.  I was 
able to get the pcbuild solution to build, and I have the necessary 
exes/dlls/pyds in the amd64 build directory.  What is not clear to is how to 
complete the build and make an installation.  I could not find any 
documentation for this.

Any help on this matter would be appreciated.

Thanks,

Tom

This email and any attachments are intended solely for the use of the 
individual or entity to whom it is addressed and may be confidential and/or 
privileged.

If you are not one of the named recipients or have received this email in error,

(i) you should not read, disclose, or copy it,

(ii) please notify sender of your receipt by reply email and delete this email 
and all attachments,

(iii) Dassault Systemes does not accept or assume any liability or 
responsibility for any use of or reliance on this email.

For other languages, go to http://www.3ds.com/terms/email-disclaimer
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Custom build of Python

2012-06-20 Thread KACVINSKY Tom
Terry,

At this stage, I don't want or need an MSI.  I just want something that will 
bundle the executables/dynamic load libraries + compiled Python files and stick 
them into a compliant directory structure.

Regards,

Tom
-Original Message-
From: python-list-bounces+tky=3ds@python.org 
[mailto:python-list-bounces+tky=3ds@python.org] On Behalf Of Terry Reedy
Sent: Wednesday, June 20, 2012 4:13 PM
To: python-list@python.org
Subject: Re: Custom build of Python

On 6/20/2012 2:24 PM, KACVINSKY Tom wrote:
> I had reason to build Python 2.6.8 with Microsoft Visual Studio 2010.
> I was able to get the pcbuild solution to build, and I have the
> necessary exes/dlls/pyds in the amd64 build directory.  What is not
> clear to is how to complete the build and make an installation.  I
> could not find any documentation for this.

If you mean 'make a .msi file', I am not sure that is not officially supported 
beyond the inclusion of msilib.

> Any help on this matter would be appreciated.

3.3 is now being built with VS2010. Perhaps its repository has something that 
will help you.

--
Terry Jan Reedy



--
http://mail.python.org/mailman/listinfo/python-list
This email and any attachments are intended solely for the use of the 
individual or entity to whom it is addressed and may be confidential and/or 
privileged.

If you are not one of the named recipients or have received this email in error,

(i) you should not read, disclose, or copy it,

(ii) please notify sender of your receipt by reply email and delete this email 
and all attachments,

(iii) Dassault Systemes does not accept or assume any liability or 
responsibility for any use of or reliance on this email.

For other languages, go to http://www.3ds.com/terms/email-disclaimer
-- 
http://mail.python.org/mailman/listinfo/python-list


bdist_wininst [was: Custom build of Python]

2012-06-21 Thread KACVINSKY Tom
I found what I was looking for:

python setup.py bdist_wininst

But... I follow all of the instructions for building Python on Windows and then 
follow the instructions for using bdist_wininst, and I get this:

C:\Users\tky\Python\Python-2.6.8>PCbuild\amd64\python.exe setup.py bdist_wininst
running bdist_wininst
running build
running build_ext
INFO: Can't locate Tcl/Tk libs and/or headers
Traceback (most recent call last):
  File "setup.py", line 2049, in 
main()
  File "setup.py", line 2044, in main
'Lib/smtpd.py']
  File "C:\Users\tky\Python\Python-2.6.8\lib\distutils\core.py", line 152, in 
setup
dist.run_commands()
  File "C:\Users\tky\Python\Python-2.6.8\lib\distutils\dist.py", line 975, in 
run_commands
self.run_command(cmd)
  File "C:\Users\tky\Python\Python-2.6.8\lib\distutils\dist.py", line 995, in 
run_command
cmd_obj.run()
  File 
"C:\Users\tky\Python\Python-2.6.8\lib\distutils\command\bdist_wininst.py", line 
125, in run
self.run_command('build')
  File "C:\Users\tky\Python\Python-2.6.8\lib\distutils\cmd.py", line 333, in 
run_command
self.distribution.run_command(command)
  File "C:\Users\tky\Python\Python-2.6.8\lib\distutils\dist.py", line 995, in 
run_command
cmd_obj.run()
  File "C:\Users\tky\Python\Python-2.6.8\lib\distutils\command\build.py", line 
134, in run
self.run_command(cmd_name)
  File "C:\Users\tky\Python\Python-2.6.8\lib\distutils\cmd.py", line 333, in 
run_command
self.distribution.run_command(command)
  File "C:\Users\tky\Python\Python-2.6.8\lib\distutils\dist.py", line 995, in 
run_command
cmd_obj.run()
  File "C:\Users\tky\Python\Python-2.6.8\lib\distutils\command\build_ext.py", 
line 340, in run
self.build_extensions()
  File "setup.py", line 167, in build_extensions
raise ValueError("No source directory; cannot proceed.")
ValueError: No source directory; cannot proceed.

Does anyone know of a way to get bdist_wininst to work out of the box?   I am 
not comfortable with hacking distutils.  What do the maintainers do in this 
case?

Thanks,

Tom

-Original Message-
From: python-list-bounces+tky=3ds@python.org 
[mailto:python-list-bounces+tky=3ds@python.org] On Behalf Of KACVINSKY Tom
Sent: Wednesday, June 20, 2012 4:29 PM
To: python-list@python.org
Subject: RE: Custom build of Python

Terry,

At this stage, I don't want or need an MSI.  I just want something that will 
bundle the executables/dynamic load libraries + compiled Python files and stick 
them into a compliant directory structure.

Regards,

Tom
-Original Message-
From: python-list-bounces+tky=3ds@python.org 
[mailto:python-list-bounces+tky=3ds@python.org] On Behalf Of Terry Reedy
Sent: Wednesday, June 20, 2012 4:13 PM
To: python-list@python.org
Subject: Re: Custom build of Python

On 6/20/2012 2:24 PM, KACVINSKY Tom wrote:
> I had reason to build Python 2.6.8 with Microsoft Visual Studio 2010.
> I was able to get the pcbuild solution to build, and I have the
> necessary exes/dlls/pyds in the amd64 build directory.  What is not
> clear to is how to complete the build and make an installation.  I
> could not find any documentation for this.

If you mean 'make a .msi file', I am not sure that is not officially supported 
beyond the inclusion of msilib.

> Any help on this matter would be appreciated.

3.3 is now being built with VS2010. Perhaps its repository has something that 
will help you.

--
Terry Jan Reedy



--
http://mail.python.org/mailman/listinfo/python-list
This email and any attachments are intended solely for the use of the 
individual or entity to whom it is addressed and may be confidential and/or 
privileged.

If you are not one of the named recipients or have received this email in error,

(i) you should not read, disclose, or copy it,

(ii) please notify sender of your receipt by reply email and delete this email 
and all attachments,

(iii) Dassault Systemes does not accept or assume any liability or 
responsibility for any use of or reliance on this email.

For other languages, go to http://www.3ds.com/terms/email-disclaimer
--
http://mail.python.org/mailman/listinfo/python-list
This email and any attachments are intended solely for the use of the 
individual or entity to whom it is addressed and may be confidential and/or 
privileged.

If you are not one of the named recipients or have received this email in error,

(i) you should not read, disclose, or copy it,

(ii) please notify sender of your receipt by reply email and delete this email 
and all attachments,

(iii) Dassault Systemes does not accept or assume any liability or 
responsibility for any use of or reliance on this email.

For other languages, go to http://www.3ds.com/terms/email-disclaimer
-- 
http://mail.python.org/mailman/listinfo/python-list


distutils that supports msvc10 and that can be backfitted into Python 2.6

2012-06-26 Thread KACVINSKY Tom
Hi,

I have need for a distutils that supports msvc10, and which can be back-fitted 
into Python 2.6.  Is there such a beast?

Thanks in advance,

Tom

This email and any attachments are intended solely for the use of the 
individual or entity to whom it is addressed and may be confidential and/or 
privileged.

If you are not one of the named recipients or have received this email in error,

(i) you should not read, disclose, or copy it,

(ii) please notify sender of your receipt by reply email and delete this email 
and all attachments,

(iii) Dassault Systemes does not accept or assume any liability or 
responsibility for any use of or reliance on this email.

For other languages, go to http://www.3ds.com/terms/email-disclaimer
-- 
http://mail.python.org/mailman/listinfo/python-list


Help: PYMALLOC_DBUG and PIL

2012-07-04 Thread tom z
Hi~ all,
I encounter a odd problem, when i compile Python with PYMALLOC_DEBUG, the
PIL module can't work fine, it always make core-dump like this

[Switching to Thread 182897301792 (LWP 16102)]
0x004df264 in PyObject_Malloc (nbytes=64) at Objects/obmalloc.c:804
804 if ((pool->freeblock = *(block **)bp) != NULL) {
Current language:  auto; currently c
(gdb) bt
#0  0x004df264 in PyObject_Malloc (nbytes=64) at
Objects/obmalloc.c:804
#1  0x004dfb97 in _PyObject_DebugMallocApi (id=109 'm', nbytes=32)
at Objects/obmalloc.c:1461
#2  0x004dfd22 in _PyObject_DebugReallocApi (api=109 'm', p=0x0,
nbytes=32) at Objects/obmalloc.c:1523
#3  0x004dfac0 in _PyMem_DebugRealloc (p=0x0, nbytes=32) at
Objects/obmalloc.c:1416
#4  0x004c68d9 in list_resize (self=0x2a988409b8, newsize=1) at
Objects/listobject.c:62
#5  0x004c6f63 in app1 (self=0x2a988409b8, v=0x2a958cea90) at
Objects/listobject.c:277
#6  0x004c6fdd in PyList_Append (op=0x2a988409b8,
newitem=0x2a958cea90) at Objects/listobject.c:289
#7  0x00558c7f in symtable_add_def (st=0x2a99a4ca68,
name=0x2a958cea90, flag=4) at Python/symtable.c:910
#8  0x0055a953 in symtable_visit_params (st=0x2a99a4ca68,
args=0x924380, toplevel=1) at Python/symtable.c:1318
#9  0x0055aaa7 in symtable_visit_arguments (st=0x2a99a4ca68,
a=0x9243c8) at Python/symtable.c:1365
#10 0x00558f3d in symtable_visit_stmt (st=0x2a99a4ca68, s=0x9244d0)
at Python/symtable.c:1012
#11 0x0055919e in symtable_visit_stmt (st=0x2a99a4ca68, s=0x924500)
at Python/symtable.c:1029
#12 0x005574d7 in PySymtable_Build (mod=0x931798,
filename=0x7fbfffa2c0
"../lib/python2.7/site-packages/PIL/BmpImagePlugin.py",
future=0x2a9883aae0) at Python/symtable.c:240
#13 0x00531f14 in PyAST_Compile (mod=0x931798,
filename=0x7fbfffa2c0
"../lib/python2.7/site-packages/PIL/BmpImagePlugin.py", flags=0x7fbfff9020,
arena=0x8eedd0) at Python/compile.c:282
#14 0x00545967 in parse_source_module (
pathname=0x7fbfffa2c0
"../lib/python2.7/site-packages/PIL/BmpImagePlugin.py", fp=0x91a060) at
Python/import.c:843
#15 0x00545e75 in load_source_module (name=0x7fbfffb3e0
"PIL.BmpImagePlugin",
pathname=0x7fbfffa2c0
"../lib/python2.7/site-packages/PIL/BmpImagePlugin.py", fp=0x91a060) at
Python/import.c:1027

i've no idea about this, someone could get me help~

---
thanks a lot
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help: PYMALLOC_DBUG and PIL

2012-07-05 Thread tom z
Thanks  Roman. of course, i use PYMALLOC_DEBUG with PYMALLOC.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie question on python programming

2012-07-21 Thread Tom P

On 07/21/2012 02:30 AM, Ian Kelly wrote:

On Fri, Jul 20, 2012 at 5:38 PM, Chris Williams
 wrote:

Hello

I hope this is the right newsgroup for this post.

I am just starting to learn python programming and it seems very
straightforward so far. It seems, however, geared toward doing the sort of
programming for terminal output.

Is it possible to write the sort of applications you can create in something
like c-sharp or visual c++, or should I be looking at some other programming
language? I am using ubuntu 12.04.


There are plenty of options for GUI programming in Python.  Among the
most popular are Tkinter, wxPython, PyGTK, and PyQT, all of which are
cross-platform and free.  Also, since you specifically mention the
.NET languages, IronPython runs on .NET and so is able to make full
use of the .NET APIs including Windows Forms and WPF.  A more
comprehensive list can be found at:

http://wiki.python.org/moin/GuiProgramming



Another platform independent approach is to write the program as a web 
server something like this-

def application(environ, start_response):
start_response("200 OK", [("Content-type", "text/plain")])
return ["Hello World!"]

if __name__ == '__main__':
from wsgiref.simple_server import make_server
server = make_server('localhost', 8080, application)
server.serve_forever()

Run this and then use your browser to connect to localhost:8080
You can then use html features such as forms for input/output.

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


looking for a neat solution to a nested loop problem

2012-08-06 Thread Tom P

consider a nested loop algorithm -

for i in range(100):
for j in range(100):
do_something(i,j)

Now, suppose I don't want to use i = 0 and j = 0 as initial values, but 
some other values i = N and j = M, and I want to iterate through all 
10,000 values in sequence - is there a neat python-like way to this? I 
realize I can do things like use a variable for k in range(1): and 
then derive values for i and j from k, but I'm wondering if there's 
something less clunky.

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


Re: looking for a neat solution to a nested loop problem

2012-08-06 Thread Tom P

On 08/06/2012 06:18 PM, Nobody wrote:

On Mon, 06 Aug 2012 17:52:31 +0200, Tom P wrote:


consider a nested loop algorithm -

for i in range(100):
  for j in range(100):
  do_something(i,j)

Now, suppose I don't want to use i = 0 and j = 0 as initial values, but
some other values i = N and j = M, and I want to iterate through all
10,000 values in sequence - is there a neat python-like way to this?


for i in range(N,N+100):
for j in range(M,M+100):
do_something(i,j)

Or did you mean something else?


no, I meant something else ..

  j runs through range(M, 100) and then range(0,M), and i runs through 
range(N,100) and then range(0,N)


.. apologies if I didn't make that clear enough.



Alternatively:

import itertools

for i, j in itertools.product(range(N,N+100),range(M,M+100)):
do_something(i,j)

This can be preferable to deeply-nested loops.

Also: in 2.x, use xrange() in preference to range().



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


Re: looking for a neat solution to a nested loop problem

2012-08-06 Thread Tom P

On 08/06/2012 06:03 PM, John Gordon wrote:

In  Tom P  writes:


consider a nested loop algorithm -



for i in range(100):
  for j in range(100):
  do_something(i,j)



Now, suppose I don't want to use i = 0 and j = 0 as initial values, but
some other values i = N and j = M, and I want to iterate through all
10,000 values in sequence - is there a neat python-like way to this? I
realize I can do things like use a variable for k in range(1): and
then derive values for i and j from k, but I'm wondering if there's
something less clunky.


You could define your own generator function that yields values
in whatever order you want:

def my_generator():
 yield 9
 yield 100
 for i in range(200, 250):
 yield i
 yield 5


Thanks, I'll look at that but I think it just moves the clunkiness from 
one place in the code to another.


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


Re: looking for a neat solution to a nested loop problem

2012-08-06 Thread Tom P

On 08/06/2012 08:29 PM, Grant Edwards wrote:

On 2012-08-06, Grant Edwards  wrote:

On 2012-08-06, Tom P  wrote:

On 08/06/2012 06:18 PM, Nobody wrote:

On Mon, 06 Aug 2012 17:52:31 +0200, Tom P wrote:


consider a nested loop algorithm -

for i in range(100):
   for j in range(100):
   do_something(i,j)

Now, suppose I don't want to use i = 0 and j = 0 as initial values, but
some other values i = N and j = M, and I want to iterate through all
10,000 values in sequence - is there a neat python-like way to this?


for i in range(N,N+100):
for j in range(M,M+100):
do_something(i,j)

Or did you mean something else?


no, I meant something else ..

j runs through range(M, 100) and then range(0,M), and i runs through
range(N,100) and then range(0,N)


In 2.x:

 for i in range(M,100)+range(0,M):
 for j in range(N,100)+range(0,N):
 do_something(i,j)

Dunno if that still works in 3.x.  I doubt it, since I think in 3.x
range returns an iterator, not?


Indeed it doesn't work in 3.x, but this does:

 from itertools import chain

 for i in chain(range(M,100),range(0,M)):
 for j in chain(range(N,100),range(0,N)):
 do_something(i,j)



 ah, that looks good - I guess it works in 2.x as well?
--
http://mail.python.org/mailman/listinfo/python-list


Beautiful Soup Table Parsing

2012-08-08 Thread Tom Russell
I am parsing out a web page at
http://online.wsj.com/mdc/public/page/2_3021-tradingdiary2.html?mod=mdc_pastcalendar
using BeautifulSoup.

My problem is that I can parse into the table where the data I want
resides but I cannot seem to figure out how to go about grabbing the
contents of the cell next to my row header I want.

For instance this code below:

soup = 
BeautifulSoup(urlopen('http://online.wsj.com/mdc/public/page/2_3021-tradingdiary2.html?mod=mdc_pastcalendar'))

table = soup.find("table",{"class": "mdcTable"})
for row in table.findAll("tr"):
for cell in row.findAll("td"):
print cell.findAll(text=True)

brings in a list that looks like this:

[u'NYSE']
[u'Latest close']
[u'Previous close']
[u'Week ago']
[u'Issues traded']
[u'3,114']
[u'3,136']
[u'3,134']
[u'Advances']
[u'1,529']
[u'1,959']
[u'1,142']
[u'Declines']
[u'1,473']
[u'1,070']
[u'1,881']
[u'Unchanged']
[u'112']
[u'107']
[u'111']
[u'New highs']
[u'141']
[u'202']
[u'222']
[u'New lows']
[u'15']
[u'11']
[u'42']
[u'Adv. volume*']
[u'375,422,072']
[u'502,402,887']
[u'345,372,893']
[u'Decl. volume*']
[u'245,106,870']
[u'216,507,612']
[u'661,578,907']
[u'Total volume*']
[u'637,047,653']
[u'728,170,765']
[u'1,027,754,710']
[u'Closing tick']
[u'+131']
[u'+102']
[u'-505']
[u'Closing Arms (TRIN)\x86']
[u'0.62']
[u'0.77']
[u'1.20']
[u'Block trades*']
[u'3,874']
[u'4,106']
[u'4,463']
[u'Adv. volume']
[u'1,920,440,454']
[u'2,541,919,125']
[u'1,425,279,645']
[u'Decl. volume']
[u'1,149,672,387']
[u'1,063,007,504']
[u'2,812,073,564']
[u'Total volume']
[u'3,186,154,537']
[u'3,643,871,536']
[u'4,322,541,539']
[u'Nasdaq']
[u'Latest close']
[u'Previous close']
[u'Week ago']
[u'Issues traded']
[u'2,607']
[u'2,604']
[u'2,554']
[u'Advances']
[u'1,085']
[u'1,596']
[u'633']
[u'Declines']
[u'1,390']
[u'880']
[u'1,814']
[u'Unchanged']
[u'132']
[u'128']
[u'107']
[u'New highs']
[u'67']
[u'87']
[u'41']
[u'New lows']
[u'36']
[u'36']
[u'83']
[u'Closing tick']
[u'+225']
[u'+252']
[u'+588']
[u'Closing Arms (TRIN)\x86']
[u'0.48']
[u'0.46']
[u'0.69']
[u'Block trades']
[u'10,790']
[u'8,961']
[u'5,890']
[u'Adv. volume']
[u'1,114,620,628']
[u'1,486,955,619']
[u'566,904,549']
[u'Decl. volume']
[u'692,473,754']
[u'377,852,362']
[u'1,122,931,683']
[u'Total volume']
[u'1,856,979,279']
[u'1,883,468,274']
[u'1,714,837,606']
[u'NYSE Amex']
[u'Latest close']
[u'Previous close']
[u'Week ago']
[u'Issues traded']
[u'434']
[u'432']
[u'439']
[u'Advances']
[u'185']
[u'204']
[u'202']
[u'Declines']
[u'228']
[u'202']
[u'210']
[u'Unchanged']
[u'21']
[u'26']
[u'27']
[u'New highs']
[u'10']
[u'12']
[u'29']
[u'New lows']
[u'4']
[u'7']
[u'13']
[u'Adv. volume*']
[u'2,365,755']
[u'5,581,737']
[u'11,992,771']
[u'Decl. volume*']
[u'4,935,335']
[u'4,619,515']
[u'15,944,286']
[u'Total volume*']
[u'7,430,052']
[u'10,835,106']
[u'28,152,571']
[u'Closing tick']
[u'+32']
[u'+24']
[u'+24']
[u'Closing Arms (TRIN)\x86']
[u'1.63']
[u'0.64']
[u'1.12']
[u'Block trades*']
[u'75']
[u'113']
[u'171']
[u'NYSE Arca']
[u'Latest close']
[u'Previous close']
[u'Week ago']
[u'Issues traded']
[u'1,188']
[u'1,205']
[u'1,176']
[u'Advances']
[u'580']
[u'825']
[u'423']
[u'Declines']
[u'562']
[u'361']
[u'730']
[u'Unchanged']
[u'46']
[u'19']
[u'23']
[u'New highs']
[u'17']
[u'45']
[u'42']
[u'New lows']
[u'5']
[u'25']
[u'12']
[u'Adv. volume*']
[u'72,982,336']
[u'140,815,734']
[u'73,868,550']
[u'Decl. volume*']
[u'58,099,822']
[u'31,998,976']
[u'185,213,281']
[u'Total volume*']
[u'146,162,965']
[u'175,440,329']
[u'260,075,071']
[u'Closing tick']
[u'+213']
[u'+165']
[u'+83']
[u'Closing Arms (TRIN)\x86']
[u'0.86']
[u'0.73']
[u'1.37']
[u'Block trades*']
[u'834']
[u'1,043']
[u'1,593']

What I want to do is only be getting the data for NYSE and nothing
else so I do not know if that's possible or not. Also I want to do
something like:

If cell.contents[0] == "Advances":
Advances = next cell or whatever??---> this part I am not sure how to do.

Can someone help point me in the right direction to get the first data
point for the Advances row? I have others I will get as well but
figure once I understand how to do this I can do the rest.

Thanks,

Tom
-- 
http://mail.python.org/mailman/listinfo/python-list


Problem with subprocess.call and windows schtasks

2012-11-18 Thread Tom Borkin
Hi,
I have this code:

#!\Python27\python

import subprocess
#subprocess.call(['SchTasks /Create /SC ONCE /TN "My Tasks" /TR "C:/Program
Files/Apache Group/Apache2/htdocs/ccc/run_alert.py" /ST 07:50'], shell=True)
subprocess.call(['SchTasks /Create /SC ONCE /TN "test" /TR "run_alert.py"
/ST 07:50'], shell=True)
With either call, I get this error:
C:\Program Files\Apache Group\Apache2\htdocs\ccc>cron_alert_activity.py
The system cannot find the path specified.

If I remove the ", shell=True" I get this:
C:\Program Files\Apache Group\Apache2\htdocs\ccc>cron_alert_activity.py
 C:\Program Files\Apache Group\Apache2\htdocs\ccc\cron_alert_activity.py,
line 4, in 
  subprocess.call(['SchTasks /Create /SC ONCE /TN "test" /TR "run_alert.py"
/ST 07:50'])
 File "C:\Python27\lib\subprocess.py", line 493, in call
  return Popen(*popenargs, **kwargs).wait()
 File "C:\Python27\lib\subprocess.py", line 679, in __init__ errread,
errwrite)
 File "C:\Python27\lib\subprocess.py", line 896, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
The file exists in said directory. I can execute it from the cmd prompt.

So I tried this:
pgm = "SchTasks"
args = ['/Create /SC ONCE /TN "test" /TR "run_alert.py" /ST 07:50']
#args = ['/Create', '/SC ONCE', '/TN "test"', '/TR "run_alert.py"', '/ST
07:50']
cmd = [pgm]
cmd.extend(args)
subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0]
but got this error:
ERROR: Invalid argument/option - <>

If I use the other args list I get this error:
ERROR: Invalid argument/option - '/SC ONCE'
so apparently it liked the first argument.

Please advise.
TIA,
Tom
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Problem with subprocess.call and windows schtasks

2012-11-20 Thread Tom Borkin
Using shlex, I now have this:
#!\Python27\python
import os, subprocess
path = os.path.join("C:\\", "Program Files", "Apache Group", "Apache2",
"htdocs", "ccc", "run_alert.py")
#subprocess.call(['SchTasks', '/Create', '/SC', 'ONCE', '/TN', '"test"',
'/TR', path, '/ST', '23:50'])
subprocess.call(['SchTasks', '/Create', '/SC', 'ONCE', '/TN', '"test"',
'/TR', 'run_alert.py', '/ST', '23:50'])
Both of the above commands throw the same error:
ERROR: The filename, directory name or volume label syntax is incorrect.

Pls advise.
TIA,
Tom



On Sun, Nov 18, 2012 at 12:39 PM, Chris Rebert  wrote:

> On Sun, Nov 18, 2012 at 5:48 AM, Tom Borkin  wrote:
> > Hi,
> > I have this code:
> >
> > #!\Python27\python
> >
> > import subprocess
> > #subprocess.call(['SchTasks /Create /SC ONCE /TN "My Tasks" /TR
> "C:/Program
> > Files/Apache Group/Apache2/htdocs/ccc/run_alert.py" /ST 07:50'],
> shell=True)
> > subprocess.call(['SchTasks /Create /SC ONCE /TN "test" /TR "run_alert.py"
> > /ST 07:50'], shell=True)
> > With either call, I get this error:
> > C:\Program Files\Apache Group\Apache2\htdocs\ccc>cron_alert_activity.py
> > The system cannot find the path specified.
> >
> > If I remove the ", shell=True" I get this:
> > C:\Program Files\Apache Group\Apache2\htdocs\ccc>cron_alert_activity.py
> >  C:\Program Files\Apache Group\Apache2\htdocs\ccc\cron_alert_activity.py,
> > line 4, in 
> >   subprocess.call(['SchTasks /Create /SC ONCE /TN "test" /TR
> "run_alert.py"
> > /ST 07:50'])
> >  File "C:\Python27\lib\subprocess.py", line 493, in call
> >   return Popen(*popenargs, **kwargs).wait()
> >  File "C:\Python27\lib\subprocess.py", line 679, in __init__ errread,
> > errwrite)
> >  File "C:\Python27\lib\subprocess.py", line 896, in _execute_child
> > startupinfo)
> > WindowsError: [Error 2] The system cannot find the file specified
> > The file exists in said directory. I can execute it from the cmd prompt.
>
> Per the docs (
> http://docs.python.org/2/library/subprocess.html#frequently-used-arguments
> ):
> "If passing a single string [as the `args` argument], either `shell`
> must be True (see below) or else the string must simply name the
> program to be executed **without specifying any arguments.**"
> (emphasis mine)
>
> > So I tried this:
> > pgm = "SchTasks"
> > args = ['/Create /SC ONCE /TN "test" /TR "run_alert.py" /ST 07:50']
> > #args = ['/Create', '/SC ONCE', '/TN "test"', '/TR "run_alert.py"', '/ST
> > 07:50']
> > cmd = [pgm]
> > cmd.extend(args)
> > subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0]
> > but got this error:
> > ERROR: Invalid argument/option - <>
> >
> > If I use the other args list I get this error:
> > ERROR: Invalid argument/option - '/SC ONCE'
> > so apparently it liked the first argument.
> >
> > Please advise.
>
> Your tokenization of your command is incorrect. Consult the Note box
> in the docs regarding `args` tokenization, and apply it to your
> command:
> http://docs.python.org/2/library/subprocess.html#subprocess.Popen
>
> The-docs-are-your-friend-ly Yours,
> Chris
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Problem with subprocess.call and windows schtasks

2012-11-21 Thread Tom Borkin
On Wed, Nov 21, 2012 at 6:01 AM, Tim Golden  wrote:

> subprocess.call([
>   'SchTasks', '/Create',
>   '/SC', 'ONCE',
>   '/TN', 'test',
>   '/TR', path,
>   '/ST', '23:50'
> ])
>
Thank you. Yes, it was the quoting of "test". Oops :-}
Thanks again,
Tom
-- 
http://mail.python.org/mailman/listinfo/python-list


Why Doesn't This MySQL Statement Execute?

2012-12-18 Thread Tom Borkin
Hi;
I have this test code:

if i_id == "1186":
  sql = 'insert into interactions values(Null, %s, "Call Back", "%s")'
% (i_id, date_plus_2)
  cursor.execute(sql)
  db.commit()
  print sql
It prints the sql statement, but it doesn't execute. If I copy and paste
the sql into the mysql command line it does execute without warnings or
errors. What gives?
TIA,
Tom
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why Doesn't This MySQL Statement Execute?

2012-12-18 Thread Tom Borkin
No (lol). It returns a date as a string: "2012-12-12" for example.
Tom


On Tue, Dec 18, 2012 at 6:02 PM, Wayne Werner  wrote:

> On Tue, 18 Dec 2012, Tom Borkin wrote:
>
>  Hi;
>> I have this test code:
>>
>> if i_id == "1186":
>>   sql = 'insert into interactions values(Null, %s, "Call Back",
>> "%s")' % (i_id, date_plus_2)
>>   cursor.execute(sql)
>>   db.commit()
>>   print sql
>> It prints the sql statement, but it doesn't execute. If I copy and paste
>> the sql into the mysql command line it does execute without warnings or
>> errors. What gives?
>>
>
> Does date_plus_2 contain
>
>  "Robert"); DROP TABLE interactions; --
>
> By any chance?
> -W
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why Doesn't This MySQL Statement Execute?

2012-12-18 Thread Tom Borkin
Actually, what I originally had was:
cursor.execute("""insert into interactions values(Null, %s, "Call Back",
%s)""", (i_id, date_plus_2))
and that didn't work, either. I tried your variation like:
cursor.execute("""insert into interactions values(Null, %s, "Call Back",
%s)""" % (i_id, date_plus_2))
and no cigar :(
Tom
-- 
http://mail.python.org/mailman/listinfo/python-list


Windows subprocess.call problem

2013-01-21 Thread Tom Borkin
Hi;
I have this code:

#!/Python27/python
import os, subprocess, sys
lyrics_path = "/Users/Tom/Documents/lyrics"
os.chdir(lyrics_path)

songs = ['livin-la-vida-loca', 'whos-that-lady']
for song in songs:
  subprocess.call(['notepad.exe', '%s.txt' % song])
my_songs_path = "aa english lyrics"
os.chdir(my_songs_path)
for song in my_songs:
  subprocess.call(['notepad.exe', '%s.txt' % song])
  print song

It opens the first song and hangs on subsequent songs. It doesn't open the
next song or execute the print until I have closed the first one. I want it
to open all in the list, one after another, so I have all those songs
available. Please advise.
TIA,
Tom
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Uniquely identifying each & every html template

2013-01-21 Thread Tom P

On 01/21/2013 01:39 PM, Oscar Benjamin wrote:

On 21 January 2013 12:06, Ferrous Cranus  wrote:

Τη Δευτέρα, 21 Ιανουαρίου 2013 11:31:24 π.μ. UTC+2, ο χρήστης Chris Angelico 
έγραψε:


Seriously, you're asking for something that's beyond the power of
humans or computers. You want to identify that something's the same
file, without tracking the change or having any identifiable tag.

That's a fundamentally impossible task.


No, it is difficult but not impossible.
It just cannot be done by tagging the file by:

1. filename
2. filepath
3. hash (math algorithm producing a string based on the file's contents)

We need another way to identify the file WITHOUT using the above attributes.


This is a very old problem (still unsolved I believe):
http://en.wikipedia.org/wiki/Ship_of_Theseus


Oscar

That wiki article gives a hint to a poosible solution -use a timestamp 
to determine which key is valid when.

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


Re: Windows subprocess.call problem

2013-01-21 Thread Tom Borkin
nob...@nowhere.com had an excellent suggestion that worked right off the
bat and achieved exactly what I was after. Thanks all!
Tom


On Mon, Jan 21, 2013 at 9:04 AM, Dave Angel  wrote:

> On 01/21/2013 06:25 AM, Tom Borkin wrote:
>
>> Hi;
>> I have this code:
>> 
>>
>> for song in my_songs:
>>subprocess.call(['notepad.exe'**, '%s.txt' % song])
>>print song
>>
>> It opens the first song and hangs on subsequent songs. It doesn't open the
>> next song or execute the print until I have closed the first one. I want
>> it
>> to open all in the list, one after another, so I have all those songs
>> available. Please advise.
>>
>
> Why not just pass all the filenames as parameters in one invocation of
> notepad?  Assuming Notepad is written reasonably, that'll give it all to
> you in one window, instead of opening many separate ones.
>
>
> --
> DaveA
> --
> http://mail.python.org/**mailman/listinfo/python-list<http://mail.python.org/mailman/listinfo/python-list>
>
-- 
http://mail.python.org/mailman/listinfo/python-list


problem python

2012-06-06 Thread Tom King
hi im new in python and i have a problem about 

when i type python in my command line console i get an error message 

'import site' failed; use -v for traceback
Python 2.4.3 (#1, May  5 2011, 18:44:23) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 


what is going on and how i can fix it
thanks in andvance-- 
http://mail.python.org/mailman/listinfo/python-list


Need to build Python 2.6 with Microsoft Visual Studio 2010

2012-06-06 Thread Tom Kacvinsky
For reasons beyond my control, I have a need to build Python 2.6 with
MSVC 2010 (for x64).  Does anyone have any hints as to how I can
accomplish this?  I see there are instructions for building Python 2.7
with MSVC 2010, but those are using the Python 2.7 source as the base
for patching, so they do me little to no good.  My main tripping point
right now is the deprecation of vcbuild (replaced by msbuild).  I can
run msbuild on the 2.6 solution files:

msbuild PCbuild\pcbuild.sln /p:Configuration="Release" /
p:platform="x64"

but I get all sorts of errors, related to vcbuild not being
available.  Will this be as simple as getting the project/solution
files up to date for MSVC 2010, or am I going to have to patch a lot
of code?

Any and all help is much appreciated

Thanks in advance,

Tom
-- 
http://mail.python.org/mailman/listinfo/python-list


Decorator Pattern with Iterator

2012-06-11 Thread Tom Harris
Greetings,

I have a class that implements the iterator protocol, and tokenises a
string into a series of tokens. As well as the token, it keeps track of
some information such as line number, source file, etc.

for tokens in Tokeniser():
  do_stuff(token)

What I want is to be able to wrap the tokeniser to add functionality to the
base parser without subclassing, e.g.

for tokens in processor(Tokeniser()):
  do_stuff(token)

Sort of Decorator pattern, so that I can chain more processors,  but I
cannot think how to implement it. Any clues for me?

Thanks

TomH
-- 
http://mail.python.org/mailman/listinfo/python-list


Installing numpy over an older numpy

2012-06-15 Thread Tom Kacvinsky
I am having problems installing a newer version of numpy over an older 
installation.  The general problem is that the older version's distutils code 
is being used instead of the distutils code in the newer version, no matter how 
much I play around with sys.path in setup.py and the like.

Any ideas on how to install a newer version over an older version?

Thanks,

Tom
-- 
http://mail.python.org/mailman/listinfo/python-list


pthreads in C++ with embedded Python

2011-06-07 Thread Tom Brown
Hi guys!

I am trying to build a C++ application that uses pthreads and embedded
python. I've simplified the problem down so that the Python code is a single
class that subclasses from Queue. The main thread of the C++ application
adds to the queue. A worker thread in the C++ application reads from the
queue.

I am using:
PyGILState_Ensure()
PyGILState_Release()

to lock the GIL and release it.

I'm finding this situation happening:
1) main thread locks the GIL
2) worker thread locks the GIL
3) main thread tries to release the GIL, but the thread state is not current
and the program aborts with this error:
Fatal Python error: This thread state must be current when releasing

Other times, the program runs to completion, only to segfault just before it
exits.

C++ code can be found here:
http://pastie.org/2035072

Python code can be found here:
http://pastie.org/2035086


I've tried several different APIs without any success. This is my first
attempt at embedding Python. So, what is correct way to do this?

Any suggestions will be appreciated.

Thanks!
Tom
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pthreads in C++ with embedded Python

2011-06-08 Thread Tom Brown
On Wed, Jun 8, 2011 at 2:11 PM, Jason Tackaberry  wrote:

> On 11-06-07 07:29 PM, Tom Brown wrote:
>
>> Any suggestions will be appreciated.
>>
>
> Why are you calling PyEval_ReleaseLock() in the CmdThread constructor?
>  This looks suspicious.
>
> Also, I don't see where CmdThread::lock() and CmdThread::unlock() are being
> invoked in your example.  Relics from your effort to create a reduced
> testcase I assume?
>
>
Jason,

I found that PyEval_ReleaseLock() was necessary to keep the program from
hanging. The lock() and unlock() methods were used in a previous attempt to
lock/unlock the GIL.

I kept banging at this and finally gave up on the GIL. I used a mutex
instead. This allowed me to get rid of the Python API calls that dealt with
the GIL. It works great in the test program. I'll find out how well it
performs in the real program.

Thanks!
Tom
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python getting stuck

2011-02-27 Thread Tom Zych
Colin J. Williams wrote:
> On 26-Feb-11 18:55 PM, Shanush Premathasarathan wrote:
>> When I use cut, copy, paste, and any keyboard shortcuts, Python
>> freezes and I am unable to use Python. Please Help as quick as
>> possible!!!

> What operating system are you using?

If it's some kind of Unix, are you using a text console, or X?
If X, what window manager?

-- 
Tom Zych / freethin...@pobox.com
Quidquid latine dictum sit, altum viditur.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I'm happy with Python 2.5

2011-02-27 Thread Tom Zych
n00m wrote:
> Am I turmoiling your wishful thinking?
> You may nourish it till the end of time.

Let us cease to nourish those fabled ones who dwell under bridges.

-- 
Tom Zych / freethin...@pobox.com
Quidquid latine dictum sit, altum viditur.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python3.2m installed as (additional) binary

2011-02-27 Thread Tom Zych
andrew cooke wrote:
> I just downloaded, built and altinstalled Python3.2 on Linux x64.  I noticed 
> that in /usr/local/bin I have two identical (says diff) binaries called 
> Python3.2 and Python3.2m.  Is this expected?  I can find very little 
> reference to them apart from a short discussion in python-dev where someone 
> asks if users will be confused by this and Barry Warsaw replies saying that 
> they won't see them (well, I do!).
> 
> All I did was the usual ./configure; make; sudo make altinstall
> 
> So is this a bug?
> 
> pl6 Python-3.2: ls -l /usr/local/bin/python3.2*
> -rwxr-xr-x 2 root root 7368810 2011-02-27 13:03 /usr/local/bin/python3.2
> -rwxr-xr-x 2 root root 7368810 2011-02-27 13:03 /usr/local/bin/python3.2m
> -rwxr-xr-x 1 root root1826 2011-02-27 13:03 
> /usr/local/bin/python3.2m-config
> pl6 Python-3.2: diff  /usr/local/bin/python3.2 /usr/local/bin/python3.2m
> pl6 Python-3.2:

It looks like they're hard links of each other. Try:
  ls -li /usr/local/bin/python3.2*

Are the inode numbers the same?

I suspect the "m" name is what gets built and the "no m" is an alias for
backwards-compatibility. Not sure why they did the "m", though.

-- 
Tom Zych / freethin...@pobox.com
Quidquid latine dictum sit, altum viditur.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python3.2m installed as (additional) binary

2011-02-27 Thread Tom Zych
Tom Zych wrote:
> andrew cooke wrote:
>> -rwxr-xr-x 2 root root 7368810 2011-02-27 13:03 /usr/local/bin/python3.2
>> -rwxr-xr-x 2 root root 7368810 2011-02-27 13:03 /usr/local/bin/python3.2m

> I suspect the "m" name is what gets built and the "no m" is an alias for
> backwards-compatibility. Not sure why they did the "m", though.

Ah, this may be it:

http://bugs.python.org/issue9807

Search for "build flag". Apparently the "m" indicates that it was
compiled with a nonstandard compiler option, or some such; maybe
something to do with being on a 64-bit platform. The makefile or
configure log may shed some light.

-- 
Tom Zych / freethin...@pobox.com
Quidquid latine dictum sit, altum viditur.

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


Lumberjack Song

2011-02-28 Thread Tom Zych
We all like computers here. No doubt many of us like computer games.
And most of us will be at least somewhat familiar with Monty Python.
Therefore, I present (drum roll)...

http://www.youtube.com/watch?v=Zh-zL-rhUuU

(For the Runescape fans out there, this should be quite hilarious.
Possibly not as much for those unfamiliar with Runescape...)

-- 
Tom Zych / freethin...@pobox.com
Quidquid latine dictum sit, altum viditur.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OT: Code Examples

2011-03-01 Thread Tom Zych
Erik de Castro Lopo wrote:
> Why Python? I really can't understand the rush of every man and
> his dog to Python.
> Its not that I'm a stick in the mud stuck with C and C++, rather
> that I used Python for a number of years from 1998 to 2004 and
> rejected it in favour of strict statically typed functional
> langauges like Ocaml and Haskell.

Hmm, if we abused this guy enough for his heresy, do you think
he'd say he didn't expect the Spanish Inquisition? Then we could
riff on that theme for days :-D

-- 
Tom Zych / freethin...@pobox.com
Quidquid latine dictum sit, altum viditur.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 3.2 is excellent, but

2011-03-01 Thread Tom Zych
jmfauth wrote:
> Well, Python (as 3.2) has never reached this level of excellence, but
> __pycache__, no, not for me.
> 
> (I feel better now, after I wrote it.)

Could you be more specific? :)

-- 
Tom Zych / freethin...@pobox.com
Quidquid latine dictum sit, altum viditur.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OT: Code Examples

2011-03-01 Thread Tom Zych
geremy condra  wrote:
> Ah, so you're looking for an argument. This is abuse, you want room
> 12A just down the hall.

They have comfy chairs there. No one expects it.

-- 
Tom Zych / freethin...@pobox.com
Quidquid latine dictum sit, altum viditur.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I am not able to open IDLE in python on Vista.

2011-03-01 Thread Tom Zych
Andrea Crotti  wrote:
> Best solution would be to avoid Windows Vista.

s/Vista//

There, fixed that for ya.

-- 
Tom Zych / freethin...@pobox.com
Quidquid latine dictum sit, altum viditur.
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   3   4   5   6   7   >