i need your help

2005-12-18 Thread g
  hi.i dont know it is true or not to write you about that.I ve problem to run phyton in my personal computer.I install it and there is no error when installing but when i want to run pythonw.exe, no window opened.Only i can run python.exe in dos shell when i click.when cilicking to w9xpopen.exe gives an message saying can not run...I am using winxp as an operating system.I wonder how can i over come that stuation as a new python learners.If you help me to overcome to such problem i will be so happy...   Thanx for reading that e-mail, and sorry for taking your time..    Emrah GÜN     Middle East Technical University, Computer education and instruction technology department  1st year student.
 __Do You Yahoo!?Tired of spam?  Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- 
http://mail.python.org/mailman/listinfo/python-list

Re: HTML parsing bug?

2006-01-30 Thread G.
> //   - this is a comment in JavaScript, which is itself inside
> an HTML comment

This is supposed to be one line. Got wrapped during posting.

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


Re: os.path.islink()

2004-12-08 Thread Tim G
You may well be able to do it with the win32file module
functions: GetFileAttributesEx or GetFileInformationByHandle
It's not my area of expertise, but usually a bit of poking around
in msdn.microsoft.com yields some results, as does Googling
around for other people (often VB or Delphi-based) who have
done the same thing.

TJG

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


Re: Problem remotely shutting down a windows computer with python

2005-01-04 Thread Tim G
> I have a problem when using the python script found here:
>
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/360649
>
> It is a script to remotely shutdown a windows computer.  When I use
it,
> the computer shuts down, but doesn't power off like with a regular
> shutdown. It stays on the "Safe to power off" screen and I have to
push
> the power button to actually power off.  Anyone know why this happens
> with this script?  Thanks for any help.
>
> Eric

I see that others have answered the question
pretty completely, but just to add the obligatory
WMI solution:
[ assumes you're using the wmi module from
http://tgolden.sc.sabren.com/python/wmi.html ]



import wmi
c = wmi.WMI (computer="other_machine", privileges=["RemoteShutdown"])
os = c.Win32_OperatingSystem (Primary=1)[0]
os.Win32Shutdown (Flags=12)


The Flags=12 bit should shut down all the way.

TJG

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


Re: Installing IPython on win2k

2005-01-08 Thread Tim G
Dave Merrill wrote:
> Hi, I'm new to python, and ipython, but not to programming, having
trouble
> getting ipython installed on windows 2000, python 233. Any help would
be
> much appreciated; I'm sure I'm being some basic flavor of dense...

First of all, rest assured that it does work (and quite
easily) so welcome to Python and iPython and I hope
the going's a bit smoother as you go along.

> Then downloaded ipython-0.6.6.zip and unzipped it. When I
double-click
> setup.py, I get only a brief wait cursor; nothing else happens, and
> importing ipython as a test fails.

First of all, ipython isn't really an import into python; you run
it and it runs python (if you understand me). So when you've
installed it, I think it puts an item on your start menu. On
linux, it puts an executable ipython onto your path.

I've just downloaded and run the setup.py, and it does
create a Start Menu item which will start iPython. Look
out for that and see if it does the business.

> Both files in the scripts dir, ipython and pycolor, have no filename
> extension, which seems odd to my newbie eye. I tried renaming them to
.py,
> still no difference.

This is a unixism. Some unix types decry the use of file extensions
because the information the extension gives -- which executable
program to use -- is already embedded in the first line of a file.

>
> My apologies for this basic question, and my no doubt ignorant
flailing
> about. Very much looking forward to getting this working.
> 
> Thanks,
> 
> Dave Merrill

Good luck and happy hunting

TJG

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


Re: simple input that can understand special keys?

2005-02-28 Thread Tim G
Gabriel B. wrote:
> i'm writting an application that will use Tinker in a newer future.
> Now it's console only. I simply ommit some data on the display,
> print() some other and go on. The problem is that i can't test the
> actions tiggered by special keys, like Page Up/Down or the F1...12
>
> Right now i'm using raw_input() since even the Tk version will have
> only one input place, and for debuging i'm literally writting pageup,
> pagedow and the F's. But i want to put it in test while i write the
> GUI.
>
> is there any hope for me? I wanted to stay only with the console for
> now. And it's windows by the way :)
>
> Thanks

This is a notoriously un-cross-platform sort of issue.
Don't know about Tk, but for Windows, you could
use one of the existing console/curses packages:

Chris Gonnerman's WConIO:
http://newcenturycomputers.net/projects/wconio.html

The effbot's console module:
http://effbot.org/zone/console-index.htm

or a Win32 curses port:
http://flangy.com/dev/python/curses/

or you could splash out a bit and go for Pygame,
which gives you pretty much complete control over
pretty much everything:
http://pygame.org

or you could use the part-of-the-batteries mscvrt
module:
http://www.python.org/doc/2.4/lib/msvcrt-console.html


TJG

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


Re: HELP: Python equivalent of UNIX command "touch"

2005-03-03 Thread Tim G
Since no-one's suggested this yet, I highly recommend
UnxUtils: http://unxutils.sourceforge.net/ which includes
a touch.exe. Obviously, this doesn't answer your call for
a Python version, but if you're happy with touch under
Unix, maybe this will work for you.

TJG

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


newbie: dictionary - howto get key value

2005-03-10 Thread G. Völkl
Hello,

I use a dictionary:

phone = {'mike':10,'sue':8,'john':3}

phone['mike']   --> 10

I want to know who has number 3?

3 -->  'john'

How to get it in the python way ?

Thanks
   Gerhard


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


Re: HELP Printing with wxPython

2005-05-11 Thread Tim G
> Hello all, I'm trying hard to make possible to print some simple text
from
> python to the default printer using wxPython, after days of internet
> searches I found this page:
http://wiki.wxpython.org/index.cgi/Printing but
> is impossible to use this script even if I do exactly as said there.
I think
> the script is buggy or I am not able to use it, even if seems very
simple to
> use...
>
> Anyone can give me an hint on how to easily and simply print some
text? Is
> there a library ready to download and use? Something like
SendPrinter("some
> text\n")?

On the strict wxPython front, I can't help
you, but I might be able to offer some help.
Depends a little bit on how much you're tied
to wxPython and how much you need to be cross-platform.

Essentially, if you're on Windows (and have no need
to run on anything else) then consider some of the
solutions here:

http://tgolden.sc.sabren.com/python/win32_how_do_i/print.html

If you're on Unix / whatever with no need to do
anything else, then I'm sure there are straightforward
ways to push stuff to a printer. (Something using lpr
he thinks, hoping someone with real knowledge can chip
in).

If you *really* want to use wxPython for cross-platform
needs, or just because you think it's cleaner, then try
on the wxPython lists if you haven't already.

TJG

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


Re: Windows vs Linux [was: p2exe using wine/cxoffice]

2005-10-26 Thread Tim G
Thomas Heller wrote:
> FYI, if you don't know this already: You also can resize the console without
> going through the properties menu with 'mode con cols=... lines=...'.

Good grief! I haven't used "mode con" in years; forgotten
it even existed! Thanks for bringing that back, Thomas.

TJG

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


Re: Windows vs Linux

2005-10-26 Thread Tim G

Bernhard Herzog wrote:
> "Tim Golden" <[EMAIL PROTECTED]> writes:
>
> > But as far as I can tell
> > from my experience and from the docs -- and I'm not near a
> > Linux box at the mo -- having used ctrl-r to recall line x
> > in the history, you can't just down-arrow to recall x+1, x+2 etc.
> > Or can you?
>
> You can.  It works fine on this box, at least.
> GNU bash, version 2.05a.0(1)-release (i386-pc-linux-gnu)
> libreadline 4.2a

Sadly, this seems not to be the case on my Ubuntu Breezy:
bash 3.00.16, libreadline 4.3/5.0 (not sure which one
bash is using). ctrl-r is fine; but you can't down-arrow
from there; it just beeps at you. Is there some setting I'm
missing?

TJG

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


Re: Problems with threaded Hotkey application

2005-11-23 Thread Tim G
And just to confirm, it does in fact work. If you move the
RegisterHotKey line to within the thread's run method, the thread's
message loop picks up the hotkey press.

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


Re: Problems with threaded Hotkey application

2005-11-23 Thread Tim G
One obvious point is that, according to:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wceui40/html/cerefWM_HOTKEY.asp

the WM_HOTKEY message is posted to the queue *of the thread which
registered the hotkey*. I haven't yet tried it myself to see, but in
your example the main thread registers the hotkey, and the KeyCatch
thread is waiting to receive it.

TJG

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


Call for a cooperation

2005-12-06 Thread G. Sica
Dear all,
I'm a PhD researcher in logic at the University of Leiden in Holland.
At the present I'm doing a work about the implementation of some parts
of the Braille code related to the representation of the logical and
mathematical symbols.
In order to the well development of this work I will need a little
software helping me in the execution of some automatic operations
related to the analysis of Braille code.
I've written the structure of the software I need. 
You can find it (including the related information) at the web-page:
http://www.polimetrica.org/indexen.html 
I'm writing to this list because would like to know if there is someone
interested in writing the software by using Python. 
It should then be distributed under terms of the GNU GPL license.
I'm sorry, but my skills related to programming languages are very poor.
Many thanks in advance for the help.

All the best,
nico

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


Re: COM problem .py versus .exe

2005-06-29 Thread Tim G
Greg Miller wrote:
> I tried the code snippet using win32api.GetFileVersionInfo(), what I
> get now is the following when running on the executable machine:
>
> . . . FileFlagsMask => 63
> FileType => 2
> FileVersionMS => 65536
> FileVersionLS => 1
> Signature => -17890115
> FileSubtype => 0
> FileFlags => 0
> ProductVersionLS => 1
> FileDate => None
> ProductVersionMS => 65536
> FileOS => 4
> StrucVersion => 65536

> I can't find too much on the 'net about these output values.

>From the pywin32 help entry for GetFileVersionInfo:

"Information to return: \\ for VS_FIXEDFILEINFO"

Google for VS_FIXEDFILEINFO and hit "I'm Feeling Lucky". You've
still got to work out how to piece the values together, but I'm
sure you're just as capable of doing that as I am. (And probably
more so).

TJG

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


Re: [Tutor] How to get 4 numbers from the user in one line for easycomparision?

2005-07-03 Thread Alan G

> I  Just need to figure out how to get 4 numbers from 
> the player on one line for easy comparison, 

Unless there is a set of batteries somewhere that I don't know 
about I think you have to rely on reading the line as a string 
and then splitting it.

line = raw_input('Type 4 numbers separated by spaces: ')
numbers = [int(n) for n in line.split(' ')]

HTH,

Alan G.

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


c/c++ extensions and help()

2005-07-28 Thread Lenny G.
Is there a way to make a c/c++ extension have a useful method
signature?  Right now, help(myCFunc) shows up like:

myCFunc(...)
  description of myCFunc

I'd like to be able to see:

myCFunc(myArg1, myArg2)
  description of myCFunc


Is this currently possible?

Thanks,
Lenny G.

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


cgi - secure sessions

2006-02-01 Thread infini . g
Hey,

I was just wondering if / how would it be possible to create secure
sessions for a website using Python CGI... I thought of using cookies,
and things looked promising for a while; I could login through a form
which pointed to a cgi script which created sent the user cookies, but
I found that when a script to detect the cookies was run through a
server side include line in the html, it couldn't get any cookies, but
it would work fine when run directly through the browser (which is
useless to me).

If anybody could help with this it would be great. Python is the only
programming language that I'm relatively comfortable in at the moment,
so using the usual PHP or Javascript just isn't an option for me
unfortunately.

GazaM

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


Checkbuttons in a Text widget

2006-02-17 Thread Lou G
I'm trying to show a number of Checkbuttons (each with associated text
based on a list of names) inside a y-scrollable Text widget like so:

[ ] Bob
[ ] Carol
[ ] Ted
[ ] Alice
etc.
etc.

There may be quite a few (as many as 100 or so). I'm uncertain as to
the correct way to get these into the Text widget. I've tried
text.insert and it doesn't seem to do the job. Help?

Thanks,
Lou G

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


Re: Checkbuttons in a Text widget

2006-02-17 Thread Lou G
For anyone who might be able to use this technique:
I kept playing around and got it to work:

for i in nameList:
btnText = name[i]
self.sv = []
cb = []
cb.append(Checkbutton(self.datalist, text=btnText,
variable=self.sv[i], background='white', font=("Courier", 10)))
self.datalist.window_create(INSERT, window=cb[i])
self.datalist.insert(END, '\n') 

Thank you for your replies,
Lou

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


constructing bytestrings

2005-08-11 Thread Lenny G.
I use 's = os.read(fd, 12)' to grab 12 bytes from a file.  Now, I want
to create a string, s1, which contains 16-12=4 bytes: 4,0,0,0, followed
by the contents of s.

I know how to 's1 = "\x04\x00\x00\x00"' and how to 's3 = s1+s', but I
don't know how to construct s1 dynamically (i.e., given N, construct
"N" followed by N-1 "0", where "N" and "0" are single byte values with
N<16).  How do I do this?

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


fully-qualified namespaces?

2005-09-12 Thread Lenny G.
Suppose I have a python module named Hippo.  In the Hippo module is a
class named Crypto.  The Crypto class wants to 'from Crypto.Hash import
SHA' which refers to the module/classes in python-crypto.  Other
classes in the Hippo module want to 'import Crypto' referring to
Hippo.Crypto.

How do I do this?  For now, I just renamed my Hippo.Crypto to
Hippo.HippoCrypto and everything is okay as long as I use 'HippoCrypto'
to refer to that class.  But, this is of course redundant.  What I
really want to do is use

'import Crypto' # to refer to python-crypto
'import Hippo.Crypto'   # to refer to Hippo.Crypto

but the 2nd item doesn't seem to work from within the Hippo module.
What am I missing?

  Thanks,
  Lenny G.

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


Re: fully-qualified namespaces?

2005-09-12 Thread Lenny G.
Thanks George.  But I have to apologize -- I think I used the wrong
term in my question.  Hippo is actually a package, not a module.  So I
have:

Hippo/
  __init__.py
  Crypto.py
  Potamus.py

And inside Crypto.py, I need to access python-crypto's Crypto.Hash
package.  Inside Potamus.py, I need to access Hippo.Crypto, e.g.,

Hippo/
  __init__.py
  Crypto.py# wants to import python-crypto's Crypto.Hash
  Potamus.py   # wants to import Hippo's Crypto

Can I do this?  Crypto.py can't seem to access python-crypto's Crypto
namespace, because it's own namespace takes precendence.  I tried using
the renaming trick inside of Crypto.py, but it still can't find the
original python-crypto Crypto.  Maybe there's something I can do in the
__init__.py?  Maybe something with __path__?  Is there a better way to
access namespaces from the module files themselves?

  Thanks,
  Lenny G.

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


Re: fully-qualified namespaces?

2005-09-12 Thread Lenny G.
Thanks Michael.  That's actually what I already have, e.g.,

Hippo/
  __init__.py
  HippoCrypto.py
  Potamus.py

Of course, this has the disadvantage of not really taking advantage of
the Hippo namespace -- I might as well have:

HippoCrypto.py
Hippo/
  __init__.py
  Potamus.py

or even get rid of the namespace altogether:

HippoCrypto.py
HippoPotamus.py

Since Hippo.HippoCrypto was already in the Hippo namespace (and clearly
unambiguous with the top-level Crypto namespace from python-crypto), I
thought there might be some way to use this fact to shorten up the name
by removing the redundancy (as can be done in java/C++/etc namespaces).

It sounds like you are saying that there either isn't a way to make the
interpreter utilize this type of namespace difference, or that doing so
is so convoluted that it is certainly worse than just living with
Hippo.HippoCrypto.  I can live with these facts (with a little bit of
discomfort ;) ) -- just wanted to make sure that I understood.

  Lenny G.

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


FTP Error: Windows AS/400

2005-09-13 Thread Tim G.
I am trying to use Win Python to ftp files from an AS/400 IFS directory
down to my Windows machine.

I seem to get stuck when I am trying to send a command to the AS/400 to
switch file systems from native to IFS and then to issue a cd to my
folder.  I get the error below.

If anyone has had experience trying to ftp from a 400, I would greatly
appreciate any info on the topic.


Code:

import ftplib, os

filename=''
path = "jde7333"
os.chdir('c:\\ftp_jde400')

ftp = ftplib.FTP('test400')
ftp.login('oneworld', 'onew0r1d')
#ftp.sendcmd('quote site namefmt 1')
ftp.sendcmd('site namefmt 1')
ftp.cwd(path)
#remotefiles = ftp.nlst()
#ftp.retrlines('LIST')
#for filename in remotefiles:
#file = open(filename, 'wb')
#ftp.retrbinary('RETR ' + filename, file.write, 1024)
#file.close()

ftp.quit()


Error:

Traceback (most recent call last):
  File "C:\Python24\Tools\scripts\ftp400.py", line 10, in ?
ftp.cwd(path)
  File "C:\Python24\lib\ftplib.py", line 494, in cwd
return self.voidcmd(cmd)
  File "C:\Python24\lib\ftplib.py", line 246, in voidcmd
return self.voidresp()
  File "C:\Python24\lib\ftplib.py", line 221, in voidresp
resp = self.getresp()
  File "C:\Python24\lib\ftplib.py", line 214, in getresp
raise error_perm, resp
ftplib.error_perm: 501 Unknown extension in database file name.

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


FTP Windows AS/400

2005-09-13 Thread Tim G.
I am trying to execute a win python script that connects to an AS/400;
changes from the native lib to the IFS file system; then, changes to a
directory in IFS; gets a file.

Any help would be greatly appreciated.

I cannot get the script to switch from native to IFS.  I get the
following error:

Traceback (most recent call last):
  File "C:\Python24\Tools\scripts\ftp400.py", line 9, in ?
ftp.cwd(path)
  File "C:\Python24\lib\ftplib.py", line 494, in cwd
return self.voidcmd(cmd)
  File "C:\Python24\lib\ftplib.py", line 246, in voidcmd
return self.voidresp()
  File "C:\Python24\lib\ftplib.py", line 221, in voidresp
resp = self.getresp()
  File "C:\Python24\lib\ftplib.py", line 214, in getresp
raise error_perm, resp
ftplib.error_perm: 501 Unknown extension in database file name.

here is the script:

import ftplib, os

filename=''
path = "directory"
os.chdir('c:\\ftp_jde400')

ftp = ftplib.FTP('server', 'user', 'password')
ftp.sendcmd('site namefmt 1')
ftp.cwd(path)
#remotefiles = ftp.nlst()
#ftp.retrlines('LIST')
#for filename in remotefiles:
#file = open(filename, 'wb')
#ftp.retrbinary('RETR ' + filename, file.write, 1024)
#file.close()

ftp.quit()

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


Re: Can Python installation be as clean as PHP?

2006-05-09 Thread G. Monzón
Please don't compare PHP with Python... They are very different worlds.

Maybe not all the Python's core functions are implemented in C, but
Python is really a lot more efficient than PHP in every case you want
to compare.

If you "look inside", there's nothing to compare... they are extremely
different worlds... they are like hell and heaven, from the awesome
brilliant C Python implementation, to the ugly C PHP hack... (after all
it is my personal opinion, I've worked with PHP for more than 4 years,
for websites and console scripting).

Python is more efficient than PHP in every aspect...  I don't know why
got (and still is) so popular, IMHO Python should have taken its place
as the best "web scripting language".

OTOH, my php install have lots more than a single executable file.
Perhaps you don't use any php extension? don't think so... do you use
pear? and pecl? you need lots of files too, and until you don't know
what do they are and what you need or not, you will be in the same
issue as you're with Python. I think you will get it early, as you
find everything is more straightforward than you thought.

Gonzalo Monzón.

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


Re: Can Python installation be as clean as PHP?

2006-05-09 Thread G. Monzón

Carl Banks wrote:
> G. Monzón wrote:
> > Please don't compare PHP with Python... They are very different worlds.
>
> I'm not.  I was simply agreeing that the single executable way the OP
> claimed PHP does it can *sometimes* be preferrable in Python, and
> giving him recommendations thereto.
>
> Carl Banks

Sorry Carl, my reply was for the OP. I pressed the wrong reply
button... doesn't meant you did any comparation!

I said that about comparing, as the OP thought Python coded in Python
approach for a lot of core libraries isn't as efficient as in PHP
'cause they are all coded in C. And that's not true.

Yes, it could be obvious for some people that it "should" run faster
than Python, having all core functions coded in C, yes, but in overall
performance matters, that's not true in any case.

Python has all the primitives C coded as said in this thread. PHP
"primitives" are no more than hash-tables and lots zvals... far away
from the hi-tuned advanced data-types Python exposes. That makes a big
performance improvement over PHP, regards C or Python coded core
functions -let language implementation details apart-. Major loss of
performance in Python and PHP is on translating data values to C side
and all the functions calling done for as little as a value assignment
to a variable. So, sometimes, to code a function in C or let it be
Python, makes no more than a 1us per call difference...
I'd like to see this value compared to PHP. That's why PHP need a C
implementation for all core functions, as if they would be PHP coded,
performance would be even a lot worse.

And I would't say PHP is slow. But It depends on what you need to do.
'Cause PHP can be really slow and ultra-high memory consuming. While
you had this troubles with PHP, is nice to see how Python performs:
consumes a lot less of memory and goes 50 % more fast.

About a single executable file, I thought PHP is being distributed in
windows and linux as an executable plus an dinamic link library, that's
the minimum thing you need to run scripts. So OP is wrong, there is not
a single executable file. You need two files at least + php.ini +
extensions to run almost any PHP script.

And a PHP or Python without extensions or batteries, wouldn't be very
handy... oh well, that depends on the task to do.

Anyway, PHP isn't a bad tool for a *lot* of web-side scripting, but I'd
prefer if I could use Python in many of my work projects. :-) I'd feel
happier !

Regards,
Gonzalo.

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


Re: Incrementally converting a C app to Python

2006-05-09 Thread G. Monzón
Hi Bjorn,

I think the best approach is highly-dependent to your current C
application design and "way of doing things". For a type of application
you would take the opposite path than for other I thought.

Yes I did that one time, but I re-coded all from scratch... and since
that I usually do in reverse: code in Python, then optimize if needed
in C via pyrex coded extensions and glue.

If you don't know well the current application internals, both
approaches can be harder: to convert step by step to python or
re-implement from scratch. You need to know well what is doing there
that pretty hard to read code for being sure for success and good
starting guidelines.

I thought If your app doesn't have very critical parts, and if you
really know what the application is doing "inside", I would bet for a
complete reimplementation from scratch. More if you say current C code
has a lots of bugs! And all the code you need to be in C, can be easily
done via pyrex, ctypes, etc. Have in mind I don't know your
application!

Swig is harder, is more suited to export whole libraries to between
languages. Anyway, I'm no expert with Swig! :-)

Regards,
Gonzalo Monzón.

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


hidden file detection

2006-05-19 Thread Lenny G.
What's the best way to do cross-platform hidden file detection?  I want
to do something like weed-out the files that should be 'hidden' from
os.listdir() (which would be files that start with '.' under Unix,
files that have the hidden attribute set on windows, and whatever it is
that makes Mac files hidden).  Is there a util or lib that does this
for me?

Thanks,
Gary

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


Looking for Pythonic Examples

2006-02-28 Thread G. Völkl
Hello 

I am looking for examples of Pythonic Thinking:

One example I found:

Here some lines of the web side of Bruce Eckel:
http://www.mindview.net/WebLog/log-0053

How to read a text file:
for line in file("FileName.txt"):
  # Process line
It is a easy and sophisticated thing in python,
but hard to do or more complicated in other languages 
like java.

Does anyone know more examples ?

Does anyone know books about real good python programming ?

Best Regards

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


Re: DO NOT USE JAVA BECAUSE IT IS NOT OPEN SOURCE

2006-04-06 Thread Dean G.

[EMAIL PROTECTED] wrote:
> Programing Languiges Are Ment to be free. That is why i am starting The
> Coo De Tar thats french for Blow of state it is a flash/java
> alternative and if you are going to use a server side languige use
> Perl,Python or better yet Ruby. What is the point of a languige without
> a standerd and without a open source distrabution. Coo De Tar will be
> released as a api for perl,python and ruby. Java sucks because it IS
> NOT FREE. I AM A GNU GUY I BELEVE THAT SOFTWARE MUST AND SHALL BE
> FREE!! do not use java because it is an oxymoron

Wait, you aren't going far enough. All intellectual property is an
afont. You must stop using all patented devices, all copyrighted
materials, and all tradmarked names. Also, if you know any trade
secrets, you must stop using and condoning them as well.

Of course this means you must stop driving cars, for every car has
patented devices. Even many bicycles are so encumbered, so you might
need to walk. But be careful, many shoes are also patented and
trademarked. God only knows if they also use trade secrets as well, but
ignorance is bliss.

You will also find that such devices as microwaves are truely evil. Not
only are they patented, but they also use closed source software to
operate the device. The chips that run this code are very likely
patented as well. Finally, the manual may be copyrighted. No honorable
human being could even consider using such a device as they offend
every ideal we stand for.

While I am typing this, I realised that my computer uses a patented
CPU, and the BIOS itself is not open source. I will need to switch to
an open CPU design, and find an open source BIOS. I will need to be
very careful not to utilize an evil closed source driver for any of my
peripherals, and be certain that none of the devices are patented. This
means I will need to use technology that is 17 years old or more, so I
expect to be back online soo with a 300 baud modem. I'm not sure if
Fast Page Mode memory is free yet, so I will use an iron core memory
just to be sure. I will need to solder together my own devices, as even
though the patents have expired, the old devices are still encumbered
by trademarks. I'll get back to you in 20 years after I have removed
the last traces of evil intellectual property from my life.

So long commrad,

Dean G.

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


Re: A critique of cgi.escape

2006-09-25 Thread Gabriel G

At Monday 25/9/2006 11:08, Jon Ribbens wrote:


>> What precisely do you think it would "break"?
>
> existing code, and existing tests.

I'm sorry, that's not good enough. How, precisely, would it break
"existing code"? Can you come up with an example, or even an
explanation of how it *could* break existing code?


FWIW, a *lot* of unit tests on *my* generated html code would break, 
and I imagine a *lot* of other people's code would break too. So 
changing the defaults is not a good idea.
But if you want, import this on sitecustomize.py and pretend it said 
quote=True:


import cgi
cgi.escape.func_defaults = (True,)
del cgi



Gabriel Genellina
Softlab SRL 






__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas


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

Re: A critique of cgi.escape

2006-09-26 Thread Gabriel G

At Tuesday 26/9/2006 04:16, Lawrence D'Oliveiro wrote:


>> >> What precisely do you think it would "break"?
> FWIW, a *lot* of unit tests on *my* generated html code would break...
Why did you write your code that way?


Uhm, maybe because I relied on the published documentation of a 
published standard module? Just modify the behavior in *your* own 
cgi.escape and all of us will be happy...




Gabriel Genellina
Softlab SRL 






__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas


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

Re: A critique of cgi.escape

2006-09-26 Thread Gabriel G

At Tuesday 26/9/2006 12:53, Jon Ribbens wrote:


> BTW, I am curious about how you do unit testing. The example that I used
> in my summary is a very common pattern but would break in cgi.escape
> changed it's semantics. What do you do instead?

To be honest I'm not sure what *sort* of code people test this way. It
just doesn't seem appropriate at all for web page generating code. Web
pages need to be manually viewed in web browsers, and validated, and
checked for accessibility. Checking they're equal to a particular
string just seems bizarre (and where does that string come from
anyway?)


By example, I do not validate a "page". I validate that all methods 
that make up pieces of a page, build them the way they should - these 
are our "unit tests". Then, it's up to the templating library to join 
all the pieces into the final html page.
I validated the original html against the corresponding dtd some time 
ago (using the w3c validator), and ocasionally when things "looks 
wrong" on a browser, but most of the time the html generated pages 
are not validated nor checked as a whole.
What you describe are another kind of tests, and really should not 
depend on the details of cgi.escape - as the usability test of an MP3 
player does not care about some transitor's hFE used inside...




Gabriel Genellina
Softlab SRL 






__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas


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

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread Gabriel G

At Thursday 28/9/2006 12:23, Ramon Diaz-Uriarte wrote:


Going back to the original question, a related question: does anybody
know why there are so few books on data structures and algorithms that
use Python?

I remember that, at least ~ 12 years ago there were many (and very
good) books that used Pascal for this topic. So when I did my own
search for one in Python (just for my own consumption and
enlightnment) and could only find the same one as the original poster
of this thread [1], I was very surprised. No publishers have felt the
need to fill this gap?


Maybe, because with Pascal you got *nothing* more than the bare 
language, and you had to implement most of the structures and 
algorithms yourself. (This was by design).
Python, on the other hand, comes with "batteries included". What's 
the point in reimplementing another mapping/dictionary structure 
using Python, having the built-in dict type which is rather efficient?
I would not use Python to teach *basic* data structures, instead, I'd 
use it as a second stage to teach more complex structures and how to 
design algorithms.



Gabriel Genellina
Softlab SRL 






__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas


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

Re: where the extra space comes from on the stdout

2006-10-02 Thread Gabriel G

At Saturday 30/9/2006 19:09, Steve Holden wrote:


> while 1:
>  print 'Question [Y/[N]]?',
>  if sys.stdin.readline().strip() in ('Y','y'):
>  #do something
>  pass
>
> $ python q.py
> Question [Y/[N]]?y
>   Question [Y/[N]]?y
>   Question [Y/[N]]?y
>
Yup. When you execute a print statement with a comma at the end it
doesn't output the space, it simply sets a flag reminding it that there
should be a space before the next item on the same line. If the next
character out is a newline then the space flag is reset, but in this
case the newline was provided by the input, so you get a space at the
start of the next output.


You could try using
print '\rQuestion?',


Gabriel Genellina
Softlab SRL 






__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas


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

Re: saving an exception

2006-10-03 Thread Gabriel G
At Tuesday 3/10/2006 02:15, Bryan wrote:

>i would like to save an exception and reraise it at a later time.
>def foo():
>Â  Â  try:
>Â  Â  Â  Â  1/0
>Â  Â  except Exception, e:
>Â  Â  Â  Â  exception = e
>
>if exception: raise exception
>
>with the above code, i'm able to successfully raise the exception, but the
>line number of the exception is at the place of the explicit raise instead
>of the where the exception originally occurred. Â is there anyway to fix
>this?

The raise statement has 3 arguments, the third 
being the traceback (not used so much, except in cases like yours).
You can get the values using sys.exc_info()
(Don't store the traceback more than needed 
because it holds a reference to all previous stack frames...)


Gabriel Genellina
Softlab SRL 





__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas

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


Re: Howto pass Array/Hash into Function

2006-10-03 Thread Gabriel G

At Tuesday 3/10/2006 06:05, Wijaya Edward wrote:


How can I pass Array, Hash, and a plain variable
in to a function at the same time.

I come from Perl. Where as you probably know
it is done like this:

sub myfunc {

my ($plain_var, $hash_ref,$arref) = @_;
# Do sth with those variables

   return;
}


In Python your functions have formal arguments:

def myfunc(plain_var, some_dict, some_list):
# ...
return

You also have positional and keyword arguments, and default values. 
Read the Python tutorial 




Gabriel Genellina
Softlab SRL 






__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas


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

Re: PEP 358 and operations on bytes

2006-10-03 Thread Gabriel G

At Tuesday 3/10/2006 21:52, Ben Finney wrote:


Gerrit Holl <[EMAIL PROTECTED]> writes:

> operations that aren't currently defined in PEP 358, like:
>
> - str methods endswith, find, partition, replace, split(lines),
>   startswith,
> - Regular expressions
>
> I think those can be useful on a bytes type. Perhaps bytes and str
> could share a common parent class? They certainly share a lot of
> properties and possible operations one might want to perform.

Looking at those, I don't see why they wouldn't be useful for *all*
sequence types. Perhaps there needs to be a 'seq' type containing
those common methods, that is the superclass of 'str', 'bytes',
'list', 'tuple' et cetera.


find() could be useful sometimes.
But what means partition, replace, split, etc on a generic sequence?



Gabriel Genellina
Softlab SRL 






__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas


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

Re: A problem about File path encode

2006-10-10 Thread Gabriel G

At Tuesday 10/10/2006 11:32, Kevien Lee wrote:


I agree with the problem caue of the the escape character,but when i folllow
these meth,it still didn't work.


Explain "didn't work". A full traceback would be useful.


It is so strang that the code work on another computer (OS is WinXP),but throw
error on mine.Why?plese help me


Using *exactly* the same file name? "D:\Downloads\second.xml" works 
fine too, but that's just because \d and \s are not recognised as 
escape sequences.



>   There is a problem about File path encode ,when i want to parse
> an xml file.
> xmldoc=minidom.parse("D:\Downloads\1.xml")
>IOError: [Errno 2] No such file or directory: 'D:\\Downloads\x01.xml'


--
Gabriel Genellina
Softlab SRL 






__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas


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

MemoryError - IMAP retrieve self._sock.recv(recv_size)

2006-10-18 Thread Stephen G
Hi there.  I have been receiving MemoryErrors using the Windows version of 
Python 2.5.  The script I have written times the sending and the reception of 
emails with various attachments.

I get many exceptions when using the IMAP downloads.  This happens randomly; 
sometimes the file downloads OK, and other times no. 

Using an exception and traceback function, I can see the following...

MemoryError

  File "C:\Documents and Settings\root\Desktop\TMO\Python 
scripts\imap-v2.3a.py", line 263, in main
typ, data = M.fetch(num, '(RFC822)')

  File "C:\Python25\lib\imaplib.py", line 437, in fetch
typ, dat = self._simple_command(name, message_set, message_parts)

  File "C:\Python25\lib\imaplib.py", line 1055, in _simple_command
return self._command_complete(name, self._command(name, *args))

  File "C:\Python25\lib\imaplib.py", line 885, in _command_complete
typ, data = self._get_tagged_response(tag)

  File "C:\Python25\lib\imaplib.py", line 986, in _get_tagged_response
self._get_response()

  File "C:\Python25\lib\imaplib.py", line 948, in _get_response
data = self.read(size)

  File "C:\Python25\lib\imaplib.py", line 236, in read
return self.file.read(size)

  File "C:\Python25\lib\socket.py", line 308, in read
data = self._sock.recv(recv_size)

Is this a know bug or is there something I can do to work around this?

Thanks,

Stephen


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


Re: MemoryError - IMAP retrieve self._sock.recv(recv_size)

2006-10-18 Thread Stephen G
Fredrik,

Thanks for the response.  I did see that, but having been dated 2005 I thought 
that it might have been patched.  I am also sometimes getting the same problem 
with the urllib.py module.  T

his may have to do with the interaction between Python and the mobile 
optimization client that I am testing.  I do not see this problem when using 
Internet Explorer and the optimization client, nor is there a problem when 
using Python and no optimization client.  I am working with the optimization 
client vendor to have them test my Python script with their product.  This 
problem is intermittent with the optimization client which is annoying since 
most of the time it works.

Iteration Number 12
18/10/2006 14:01:23
Downloading http://tmotest.de/ftp/3MB.doc
Error: problem downloading 3MB.doc

error

  File "C:\Documents and Settings\root\Desktop\TMO\Python 
scripts\http-v2.3a.py", line 130, in main
urllib.urlretrieve(total_URL, downloaded_file)

  File "C:\Python25\lib\urllib.py", line 89, in urlretrieve
return _urlopener.retrieve(url, filename, reporthook, data)

  File "C:\Python25\lib\urllib.py", line 248, in retrieve
block = fp.read(bs)

  File "C:\Python25\lib\socket.py", line 308, in read
data = self._sock.recv(recv_size)

I am hesitant to make any changes to the python libraries as I need to 
distribute these scripts with a standard Python install.  I guess an other 
option is to try and learn something like Perl and recode all the test 
scripts...
 


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


Re: "best" rational number library for Python?

2006-10-31 Thread Gabriel G

At Tuesday 31/10/2006 21:16, [EMAIL PROTECTED] wrote:


casevh> You must use "gmake". "make" fails during "make check"

Very weird:

piggy:% make -v
GNU Make 3.80
piggy:% gmake -v
GNU Make 3.80

Nevertheless, using "gmake" instead of "make" did indeed work.  Thanks for
the hint.


Ouch! Like bash behaving different when invoked with the name "sh". 
Why do those programs try to be s smart?



--
Gabriel Genellina
Softlab SRL 


__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: unpickling Set as set

2006-11-08 Thread Gabriel G

At Wednesday 8/11/2006 05:26, George Sakkis wrote:


Or you may have this done automatically by hacking the Set class:

from sets import Set
import cPickle as pickle

Set.__reduce__ = lambda self: (set, (self._data,))

s = Set([1,2,3])
x = pickle.dumps(s)
print pickle.loads(x)


This doesn't work though if you have already pickled the Set before
replacing its __reduce__, so it may not necessarily be what you want.
If there is a way around it, I'd like to know it.


Perhaps registering a suitable reduce function in the copy_reg module.
If the sets were pickled alone, and it's not too much trouble, using: 
a_set = set(a_set) just after unpickling may be enough.
And if they were instance attributes, __setstate__ on the class can 
do the conversion.



--
Gabriel Genellina
Softlab SRL 


__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: is this the right way to do subclasses?

2006-11-08 Thread Gabriel G

At Wednesday 8/11/2006 16:33, John Salerno wrote:


> class Character(object):
> def __init__(self, name, strength, dexterity, intelligence):
> self.name = name
> self.health = 10
> self.strength = strength
> self.dexterity = dexterity
> self.intelligence = intelligence
> self.fix_attributes()
>
> class Fighter(Character):
> def fix_attributes(self):
> self.health += 2
> self.strength += 1
>
> You may need a no-op implementation of fix_attributes() in the Character
> class.
>
> Peter

But how does this take care of the initialization of the stats? I won't
be able to use Fighter to create a character without doing everything in
Character, right?


Just try and see! :)
(Python is not Java, thanks Guido!)


--
Gabriel Genellina
Softlab SRL 


__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
-- 
http://mail.python.org/mailman/listinfo/python-list

Python and Java

2007-04-04 Thread Sreelatha G

Hi

  I am new to python .I need your help in solving my problem.
  Is there any way to call python files in a java file .How is it possible?


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

Re: Python to tell what is the IP of my PC .

2006-11-08 Thread Nicolas G
On 11/9/06, Tim Williams <[EMAIL PROTECTED]> wrote:
On 8 Nov 2006 15:35:31 -0800, NicolasG <[EMAIL PROTECTED]> wrote:> How can I use python to get the real IP address of my DSL router (when> my PC is part of the local home LAN) ?
The router will the PC's default gateway IP address,  if you are on awindows platform,  you can view it by typing IPCONFIG (enter) from acommand prompt.This is the  router local IP, I need to get the router "outside" IP witch is the real one. 
A quick google, gave me this,  look at the comments at the end for anexample of finding the Default Gateway IP address using Python
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/162994import
 win32api raise the error "module not exsit"and socket.gethostbyname(name)the router doesn't have a hostname.cheers ;)-- Nicolas GSkype: nicolasg_
mobile: +30 69 45 714 578
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: how do i map this?

2006-11-12 Thread Gabriel G

At Monday 13/11/2006 01:55, John Machin wrote:


Ben Finney wrote:
> "ronrsr" <[EMAIL PROTECTED]> writes:
>
> > #row is a dictionary with keys: zid, keywords, citation, quotation
> > def print_row(row):
> >print """
> >   [...]
> >   """
>
> You're printing a string, and never using that 'row' parameter.

If that is so, why is he getting that message "TypeError: format
requires a mapping"?


Apparently the posted code doesn't match the actual code. If that 
print_row() matched the stack trace, should say % row at the end.

Perhaps there is another function print_row?
Or you cut something from the end?


--
Gabriel Genellina
Softlab SRL 


__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Python Question About Compiling.

2006-11-29 Thread Gabriel G

At Thursday 30/11/2006 03:40, Scheol Service wrote:


i know this. Is there better directions on how to use it?


Have you tried it? What's your actual problem? See http://www.py2exe.org/


--
Gabriel Genellina
Softlab SRL 


__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: One detail...

2006-12-01 Thread Gabriel G

At Saturday 2/12/2006 00:40, [EMAIL PROTECTED] wrote:

I'm trying to do in Zope, which doesn't allow "_" characters at the 
beginning of identifiers. Even in an external method, it gives me an 
error when I try to reference the o.a. Is there a trick to do it 
some other way?


Better to ask on a Zope group.
But why do you want to do that? As you have noticed, you must provide 
security assertions for your objects so it's not an easy way. And 
dictionaries are fully supported by ZPT and DTML - as it appears to 
be what you want.



--
Gabriel Genellina
Softlab SRL 


__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
-- 
http://mail.python.org/mailman/listinfo/python-list

Programming Games with python, I know this subject was disccused need help

2006-08-04 Thread Over G
HI

I would like to start to program games, with python, where to start?

What packages I need,?

Thanks.

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


Re: Programming Games with python, I know this subject was disccused need help

2006-08-04 Thread Over G

Goalie_Ca wrote:
> Well, with these libraries you won't need much else.
>
> http://www.pygame.org/news.html
> and
> http://sourceforge.net/projects/pyallegro/
>
>
> Over G wrote:
> > HI
> >
> > I would like to start to program games, with python, where to start?
> >
> > What packages I need,?
> >
> > Thanks.

Thanks ofr the very quick answer!

Still can you shad more light on the second link, what is project
allegro ?

thanks/

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


Re: lazy arithmetic

2006-08-24 Thread Gabriel G

At Friday 25/8/2006 02:18, [EMAIL PROTECTED] wrote:


> x+y get translated to x.__add__(y)

No that's not true at all. The self argument to __add__ ends
up being the Add instance, not the Item instance:

z=x+y  is translated to z.__add__(y)


Well, I deleted my response after I noticed that Simon Forman has 
done it very well.
Just a note: print z after this line and compare with self inside 
__init__ if you're still not convinced.




Gabriel Genellina
Softlab SRL 






__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas


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

Re: question about class, functions and scope

2006-08-28 Thread Gabriel G

At Saturday 26/8/2006 06:13, nephish wrote:


i have an app that runs three classes as threads in the same program.
some of them need to be able to share some functions. Can i set a
function before i define a class and have the class use it ? Kinda like
this.

def some_function(var1, var2):
do something with var1, var2
return result


It's ok - but beware of concurrency problems. By example, two threads 
trying to update the  same thing. (Doesn't happen in your small example).




Gabriel Genellina
Softlab SRL 






__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas


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

Re: Python web service ...

2006-08-28 Thread Nicolas G
If I want to run my program as a web service I need to setup a
webserver , am I right ?
Whars that difference ? can a webservice be run without a webserver ?

On 8/29/06, Jorge Vargas <[EMAIL PROTECTED]> wrote:
> On 26 Aug 2006 04:07:35 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> > Hi folks, I have accomplished to make a python program that make some
> > image manipulation to bmp files.
> > I now want to provide this program as a web service. A user can visit a
> > site and through a web interface he should upload the file to the web
> > server , the server then will do the image process with the python
> > program I have wrote and when it finish the user must get the image
> > file back .
> >
> > My question is how difficult is to set up a web server that can run
> > python easy ? should I try ZOPE or there is something better in mind ?
>
> is that webservice or webserver?
> if webservice try ZSI of it's a webserver why don't you try CherryPy?
> >
> > --
> > http://mail.python.org/mailman/listinfo/python-list
> >
>


-- 
Nicolas G

mobile: +30 69 45 714 578
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: a question about my script

2006-08-31 Thread Gabriel G

At Thursday 31/8/2006 10:01, alper soyler wrote:


I changed the script as you wrote below:


directory = 'pub/kegg/genomes'


Sorry, in the original comment I said "change it to be an absolute 
path" but didn't write it well.

This line should read:
directory = '/pub/kegg/genomes'



Gabriel Genellina
Softlab SRL 






__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas


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

Re: a question about ftplib

2006-09-01 Thread Gabriel G

At Friday 1/9/2006 06:32, alper soyler wrote:

Thank you very much for your help. The program works however, after 
downloading 121 '.pep' files, it gave me time out error:


Traceback (most recent call last):
  File "ftp1.0.py", line 18, in ?
for filename in ftp.nlst():
  ...
  File "/usr/lib/python2.4/ftplib.py", line 324, in ntransfercmd
conn.connect(sa)
  File "", line 1, in connect
socket.error: (110, 'Connection timed out')

How can I continue from the last download or  is there any way to 
arrange the time? Thank you very much.


You can change the default timeout for sockets with 
socket.setdefaulttimeout(secs) (this is a module function; call it at 
the beginning of your script).
To continue from the last download, you could skip downloading files 
when they already exist on your disk: before opening it for write, 
use os.path.exists(full_filename) to detect it, and skip the download part.


If you want to continue even after an exception happens, use the 
try/except syntax.

I don't have your code at hand to show the details, but it was something like:

for directory in dirlist:
cwd(directory)
for filename in directory:
download file

You may want to change it to:

for directory in dirlist:
try:
  cwd(directory)
  for filename in directory:
if (filename already exists): continue
try:
  download file
except: print '%s: %s' % sys.exc_info()[:2]
except: print '%s: %s' % sys.exc_info()[:2]

This way, if an error happens within downloading a file, goes on the 
next; and if an error happens procesing a directory, goes on the next too.
As a general guide, bare except clauses (that is, without a matching 
exception class) are not good, but for an utility script like yours I 
think it's fine.



Gabriel Genellina
Softlab SRL  






__
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas


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

Re: *POLL* How many sheeple believe in the 911 fairy tale and willing to accept an Orwellian doublespeak and enslavement world ?

2007-01-17 Thread Carl G.

<[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
...

Please explain what 911 conspiracy theories have to do with the Python 
computer language?

If this is to be taken seriously, why is it being cross-posted to sci.math, 
sci.physics, sci.chem, sci.optics, and comp.lang.python?  Such blatant 
disregard for newsgroup etiquette will surely reflect poorly on the poster's 
credibility.  I can only draw the conclusion that he is either a troll or 
very ignorant of what is acceptable.

Carl G. 


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


memory leak

2007-01-26 Thread john g

i have a memory leak issue with extension function that im working on. it
reads data from a binary file into a stl vector then creates a new list to
pass back to the python interface. the function works the first 1021 times
but then gives a segmentation fault (core dumped). heres the business part
of the code:


//read data
   vector data;
   float temp;


   for(int x=0;x-- 
http://mail.python.org/mailman/listinfo/python-list

get pid of a nohup command in Python

2007-02-12 Thread g . willgoose
I'm new to Python and am evaluating moving a project from Tcl/Tk to
Python and am stuck on one issue. How can I nohup (or any detached
task for that matter) a process and get its PID in Python. The obvious
route of (with a trivial example)

os.system("nohup ls > junk &")

returns the status of the command execution (ie. 0). I wish to get the
PID output of the command (e.g. 16617). All the other commands spawn**
also seem to return the execution status not the PID. This is a
showstopper so any help appreciated.

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


Re: dot products

2004-12-20 Thread Alan G Isaac
[Rahul].
> I want to compute dot product of two vectors stored as lists a and b.a
> and b are of the same length

from scipy import dot
ans=dot(a,b)

This times faster than the alternatives I have seen mentioned so far,
given scipy.

Cheers,
Alan Isaac


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


Re: dot products

2004-12-20 Thread Alan G Isaac
"Alan G Isaac" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> This times faster than the alternatives I have seen mentioned so far,
> given scipy.

Actually, since I am new to 'timeit', I probably should check that
I am not overlooking something.  Especially since I see an order
of magnitude difference in performance.  Does the code below
give the right comparisons?

Thanks,
Alan Isaac

#-
import timeit
env1='''
from operator import mul
from itertools import imap
def innerprod(x,y):
 return sum(imap(mul,x,y))
from scipy import rand
x=rand(50); y=rand(50)
'''
env2='''
from operator import mul
from itertools import imap
from scipy import rand
x=rand(50); y=rand(50)
'''
env3='''
from scipy import rand,dot
x=rand(50); y=rand(50)
'''
t1=timeit.Timer("innerprod(x,y)",env1)
t2=timeit.Timer("sum(imap(mul,x,y))",env2)
t3=timeit.Timer("dot(x,y)",env3)
trials=1000
print t1.repeat(2,trials)   #about 0.1 seconds
print t2.repeat(2,trials)   #about 0.1 seconds
print t3.repeat(2,trials)   #about 0.01 seconds



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


Re: Is this a good use for lambda

2004-12-20 Thread Alan G Isaac
I need a clarification of the argument.
Are the opponents saying that I should not be able to:

def compose(list_of_functions): return reduce(lambda f, g: lambda x:
f(g(x)), list_of_functions)

In a nutshell: why?
And may I see the proposed "better" replacement for function composition.

Thanks,
Alan Isaac


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


Re: Is this a good use for lambda

2004-12-21 Thread Alan G Isaac
So as I understand it, so far the "best" proposal for a
replacement of my function-composition function
uses a (compatibility reducing) Python 2.4 feature
that Nick suggests will end up on "Gotcha" lists.

Hmmm: lambda is looking pretty good, I'd say.

The readability issue is valid, of course.  But then,
it has been one of the standard justifications for lambda.

Thanks,
Alan Isaac


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


An interesting python problem using Zope 2.7.3

2005-02-05 Thread ranjith g p
Greetings!!!

I ran the following simple string commands in Linux + Python and the results 
are:

[EMAIL PROTECTED] root]# python
Python 2.2.2 (#1, Feb 24 2003, 19:13:11)
[GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> "A"
'A'
>>> "A/"
'A/'
>>> "A"
'A'
>>>


Now when the same is run from Zope273 + python + Linux or windows,
the results are,

1.  'A'
2.   A/
3.  A
 

respectively. Any suggestions?

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


Re: How to turn a variable name into a string?

2005-03-11 Thread Paolo G. Cantore
Hi Stewart,
what about the other way, string -> var and not var -> string?
My suggestion:
mylist = ["a", "b", "c"]
for my in mylist:
   if locals()[my] == None:
  print "you have a problem with %s" % my
Paolo
Stewart Midwinter wrote:
I'd like to do something like the following:
a = 1; b = 2; c = None
mylist = [a, b, c]
for my in mylist:
if my is None:
print 'you have a problem with %s' % my #this line is problematic

You have a problem with None

What I want to see in the output is:
You have a problem with c

How do I convert a variable name into a string?
thanks!
--
http://mail.python.org/mailman/listinfo/python-list


New to Tkinter...

2005-04-19 Thread Peter G Carswell
Good Morning.
I am new to Tkinter. I have been testing the installation of Tkinter 
through the python web site. The first two test steps give no errors, 
'import _tkinter' and 'import Tkinter'. However, the third step, 
'Tkinter._test', gives the error:
   

Any suggestions?
pete
--
Peter G. Carswell   
The Ohio Supercomputer Center
[EMAIL PROTECTED]
work: 614.292.1091  
fax:  614.292.
"DOC NOTE, I DISSENT. A FAST NEVER PREVENTS A FATNESS. I DIET ON COD."
-Peter Hilton

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


Re: New to Tkinter...

2005-04-19 Thread Peter G Carswell
Eric Brunel wrote:
On Tue, 19 Apr 2005 09:35:03 -0400, Peter G Carswell <[EMAIL PROTECTED]> 
wrote:

Good Morning.
I am new to Tkinter. I have been testing the installation of Tkinter
through the python web site. The first two test steps give no errors,
'import _tkinter' and 'import Tkinter'. However, the third step,
'Tkinter._test', gives the error:


This is not an error. It's just the value of the _test function in the 
Tkinter module. You don't give the URL where you found the 
installation/test instructions, but you probably want:

Tkinter._test()
which *calls* the function. Tkinter._test just returns its value 
(functions are first class objects in Python...)

HTH
Thanks, I realized my beginners' error just after I emailed the 
newgroup. I am sure this won't be my last question.

pete
--
Peter G. Carswell   
The Ohio Supercomputer Center
[EMAIL PROTECTED]
work: 614.292.1091  
fax:  614.292.
"DOC NOTE, I DISSENT. A FAST NEVER PREVENTS A FATNESS. I DIET ON COD."
-Peter Hilton

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


Re: New to Tkinter...

2005-04-19 Thread Peter G Carswell
Eric Brunel wrote:
This is not an error. It's just the value of the _test function in the 
Tkinter module. You don't give the URL where you found the 
installation/test instructions, but you probably want:

Tkinter._test()
which *calls* the function. Tkinter._test just returns its value 
(functions are first class objects in Python...)  
I did get a positive result on my linux desktop. However, on my laptop 
Fedora Core 1,  the Tk window shell popped up with no buttons:

Python 2.2.3 (#1, Oct 15 2003, 23:33:35)
[GCC 3.3.1 20030930 (Red Hat Linux 3.3.1-6)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import _tkinter
>>> import Tkinter
>>> Tkinter._test()
Traceback (most recent call last):
 File "", line 1, in ?
 File "/usr/lib/python2.2/lib-tk/Tkinter.py", line 3118, in _test
   label = Label(root, text=text)
 File "/usr/lib/python2.2/lib-tk/Tkinter.py", line 2285, in __init__
   Widget.__init__(self, master, 'label', cnf, kw)
 File "/usr/lib/python2.2/lib-tk/Tkinter.py", line 1780, in __init__
   self.tk.call(
SystemError: Py_UNICODE and Tcl_UniChar differ in size
>>>
pete
--
Peter G. Carswell   
The Ohio Supercomputer Center
[EMAIL PROTECTED]
work: 614.292.1091  
fax:  614.292.
"DOC NOTE, I DISSENT. A FAST NEVER PREVENTS A FATNESS. I DIET ON COD."
-Peter Hilton

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


Re: Python forum

2005-05-17 Thread Brett g Porter
Jonas Melian wrote:
> Hi,
> 
> I'm going to say a suggestion, why don't you create a forum like the one
> of Ruby (http://www.rubyforums.com/)? for the novices this is a great
> help, better than a mail list
> 
> It's also worth noting that rubyforums.com has nearly no posts (six
> total) because it takes very just a short time working.
> 
> I know that you have python-list, it's both an email and a usenet list.
> But I think that a forum is great for the learning. The test is in
> gentoo's forums. They are a lot of experienced people answering
> questions without any problem and it goes very well
> 
> Thanks

Don't forget that there's also the Tutor list (see 
http://www.python.org/mailman/listinfo/tutor ), targeted to people 
looking to learn the language...


-- 
//  Today's Oblique Strategy (© Brian Eno/Peter Schmidt):
//  Change instrument roles
//  Brett g Porter * [EMAIL PROTECTED]

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


Re: GridCellEditor

2005-05-22 Thread david . g . morgenthaler
On Sun, 22 May 2005 10:29:50 +0300, "gralex" <[EMAIL PROTECTED]> wrote:

>Hi,all!
>
>How i can manually start CellEditor in wxGrid for spicified Cell in grid in 
>my programm:
>
>mygrid.SetGridCursor(2,3)
>mygrid.MakeCellVisible(2,3)
># starting editing... ??
>mygrid.ShowCellEditControl() don't working...
>
>help me, please... 
>
Try:
mygrid..EnableCellEditControl(True)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What are OOP's Jargons and Complexities?

2005-05-23 Thread Thomas G. Marshall
Paul McGuire coughed up:
> Is this supposed to be some sort of wake-up call or call-to-arms to
> all the CS lemmings who have been hoodwinked by Sun into the realm of
> jargon over substance?

...[rip]...

> You certainly seem to have a lot of energy and enthusiasm for these
> topics.  It would be nice if you could find a way to illuminate and
> educate, without falling prey to the urge to pontificate.  If you
> really have some points to make, put away the breathless and profane
> debate style - it just gets in the way of anything you're trying to
> say.  Really, we are *mostly* adults here, and can make up our own
> minds on most things.


Of the many things that bother me about his post is his tendency to voice 
his conclusions as if they would be universally arrived at given his data. 
{shrug}  Paying attention to this guy's post has proven to be a complete 
WOT.


-- 
I've seen this a few times--Don't make this mistake:

Dwight: "This thing is wildly available."
Smedly: "Did you mean wildly, or /widely/ ?"
Dwight: "Both!", said while nodding emphatically.

Dwight was exposed to have made a grammatical
error and tries to cover it up by thinking
fast.  This is so painfully obvious that he
only succeeds in looking worse.


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


Re: What are OOP's Jargons and Complexities?

2005-05-24 Thread Thomas G. Marshall
John W. Kennedy coughed up:
> alex goldman wrote:
>> John W. Kennedy wrote:
>>
>>
>>> Strong
>>> typing has been a feature of mainstream programming languages since
>>> the late 1950's.
>>
>>
>> Is Fortran a strongly typed language? I don't think so. Strong
>> typing has been invented in the 70's, if I'm not mistaken, when ML
>> was invented, but strong typing has never been mainstream.
>
> I begin to believe that I have been reading naughty references, and
> that I should rather have said "statically typed".
>
> I am not familiar with modern Fortran. Surely it at least has argument
> prototyping by now?


There are some fortran advocates that pop into here now and again.  Frankly, 
I'm spooked by how far fortran seems to have come.  There is even OO support 
now.  OI.

I preferred the old days of thinking that fortran sucked "just 'cause".  :)


-- 
Enough is enough.  It is /not/ a requirement that someone must google
relentlessly for an answer before posting in usenet.  Newsgroups are
for discussions.  Discussions do /not/ necessitate prior research.  If
you are bothered by someone asking a question without taking time to
look something up, simply do not respond.


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


Re: What are OOP's Jargons and Complexities?

2005-05-25 Thread Thomas G. Marshall
[EMAIL PROTECTED] coughed up:
> Thomas G. Marshall wrote:
>

*Missattributed* --Thomas G. Marshall (I) did /not/ write the following:

>>> I am not familiar with modern Fortran. Surely it at least has
>>> argument prototyping by now?
>
> Since the 1990 standard, if Fortran subroutines and functions are
> placed in MODULEs, or if INTERFACEs are provided, the compiler checks
> that procedures are called with the right types (int or float, scalar
> or array, etc.) of arguments.
>
>> There are some fortran advocates that pop into here now and again.
>> Frankly, I'm spooked by how far fortran seems to have come.  There
>> is even OO support now.  OI.
>
> Some Fortranners think the language has gotten too big and
> complicated, sounding a bit like C programmers complaining about C++
> (I don't mean that pejoratively).

There are old-poops in every discipline.  :)


-- 
Unix users who vehemently argue that the "ln" command has its arguments
reversed do not understand much about the design of the utilities.  "ln
arg1 arg2" sets the arguments in the same order as "mv arg1 arg2".
Existing file argument to non-existing argument.  And in fact, mv
itself is implemented as a link followed by an unlink.


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


Re: What are OOP's Jargons and Complexities?

2005-05-25 Thread Thomas G. Marshall
Xah Lee coughed up:
> The Rise of "Static" versus "Instance" variables


You are clearly unable to form a proper argument, *AND* you have irritated 
nearly everyone frequently.



Ahthe blessed silence 


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


Re: [Fwd: Re: hex string to hex value]

2005-11-22 Thread Brett g Porter
tim wrote:
> 
> I end up with 66 again, back where I started, a decimal, right?
> I want to end up with 0x42 as being a hex value, not a string, so i can 
> pas it as an argument to a function that needs a hex value.
> (i am trying to replace the 0x42 in the line  midi.note_off(channel=0, 
> note=0x42) with a variable)


As far as Python is concerned, 66 decimal and 42 hex are exactly the 
same thing. There's absolutely no difference in calling

note_off(0x42)
and

note_off(66)

See:

 >>> def f(c):
...print c
...
 >>> f(66)
66
 >>> f(0x42)
66
 >>>



-- 
//  Today's Oblique Strategy (© Brian Eno/Peter Schmidt):
//  Repetition is a form of change
//  Brett g Porter * [EMAIL PROTECTED]

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


Problem cmpiling M2Crypto

2005-11-29 Thread Thomas G. Apostolou
Hello all.

i am trying to make some win32 binaries of M2Crypto 0.15

What I use is:

Python 2.3.3
openssl-0.9.7i
swigwin 1.3.27

I have build the openssl binaries and have installed the Swig binary
python dir is C:\Program Files\Plone 2\Python
openssl dir is c:\openssl
Swig dir is c:\swig

so I have modified the setup.py of m2crypto to :

if os.name == 'nt':
openssl_dir = 'c:\\openssl'
include_dirs = [my_inc, openssl_dir + '/include']
swig_opts_str = '-I"' + openssl_dir + os.sep + 'include"'
library_dirs = [openssl_dir + '\\lib']
libraries = ['ssleay32', 'libeay32']

when i execute python setup.py build from the command prompt i get the
following erros:

C:\Program Files\Plone 2\Python\lib\distutils\extension.py:128: UserWarning:
Unknown Extension options: 'swig_opts'
  warnings.warn(msg)
running build
running build_py
running build_ext
building '__m2crypto' extension
C:\SWIG\swig.exe -python -ISWIG -I"c:\openssl\include" -o SWIG/_m2crypto.c
SWIG/_m2crypto.i
SWIG\_lib.i(527): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_lib.i(528): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_lib.i(529): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_lib.i(530): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_lib.i(531): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_lib.i(532): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_bio.i(17): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_bio.i(18): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_bio.i(19): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_bio.i(20): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_bio.i(21): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_bio.i(22): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_bio.i(24): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_bio.i(25): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_bio.i(26): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_bio.i(27): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_bio.i(28): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_bio.i(29): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_bio.i(30): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_bio.i(31): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_bio.i(33): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_bio.i(34): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_rand.i(7): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_rand.i(8): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_rand.i(9): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_rand.i(10): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_rand.i(11): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_evp.i(26): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_evp.i(27): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_evp.i(28): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_evp.i(29): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_evp.i(31): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_evp.i(32): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_evp.i(33): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_evp.i(34): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_evp.i(35): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_evp.i(36): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_evp.i(37): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_evp.i(38): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_evp.i(39): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_evp.i(40): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_evp.i(41): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_evp.i(42): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_evp.i(43): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_evp.i(44): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_evp.i(45): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_evp.i(46): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_evp.i(53): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_evp.i(54): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_evp.i(55): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_evp.i(56): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_evp.i(63): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_evp.i(64): Warning(121): %name is deprecated.  Use %rename instead.
SWIG\_evp.i(65): Warning(121): %name is deprecated.  Use %rename instead.
S

Re: Problem cmpiling M2Crypto

2005-12-01 Thread Thomas G. Apostolou
Dear friend  Heikki Toivonen,
thank you for replying to my quest...

> C:\Program Files\Plone 2\Python\lib\distutils\extension.py:128:
UserWarning:
> Unknown Extension options: 'swig_opts'

>>Hmm, I don't remember seeing that. But then again, I haven't compiled
>>with the same setup as you either.
I am in a quest to find where this comes from. But it is difficult to me as
i am a newbie to python and totaly new to SWIG... anyway

> Then i open SWIG\_lib.i file and change all %name with %rename

>>You don't need to change those, the name vs rename is just a warning.

> appart from this i can not find Python.h anywhere ni my pc (WinXp)

>>I think that's your real problem. You need the python header(s) etc. to
>>build M2Crypto. Seems like your Python distribution does not contain them.

--
  Heikki Toivonen

After changing all %name to %rename the message about Python.h stoped
appearing.
I also took the steps described in the INSTALL file of m2crypto pack:
"Preparation
~
Read Sebastien Sauvage's webpage:
http://sebsauvage.net/python/mingw.html";

but this is about using mingw32, isn't it?

What i get now is:
1) using "python setup.py build"

C:\Program Files\Plone 2\Python\lib\distutils\extension.py:128: UserWarning:
Unknown Extension options: 'swig_opts'
  warnings.warn(msg)
running build
running build_py
creating build
creating build\lib.win32-2.3
creating build\lib.win32-2.3\M2Crypto
copying M2Crypto\ASN1.py -> build\lib.win32-2.3\M2Crypto
copying M2Crypto\AuthCookie.py -> build\lib.win32-2.3\M2Crypto
.
.
.
copying M2Crypto\_version.py -> build\lib.win32-2.3\M2Crypto
copying M2Crypto\__init__.py -> build\lib.win32-2.3\M2Crypto
creating build\lib.win32-2.3\M2Crypto\SSL
copying M2Crypto\SSL\cb.py -> build\lib.win32-2.3\M2Crypto\SSL
.
.
.
copying M2Crypto\SSL\__init__.py -> build\lib.win32-2.3\M2Crypto\SSL
creating build\lib.win32-2.3\M2Crypto\PGP
copying M2Crypto\PGP\constants.py -> build\lib.win32-2.3\M2Crypto\PGP
.
.
.
copying M2Crypto\PGP\__init__.py -> build\lib.win32-2.3\M2Crypto\PGP
running build_ext
building '__m2crypto' extension
C:\SWIG\swig.exe -python -ISWIG -I"c:\openssl\include" -o SWIG/_m2crypto.c
SWIG/_m2crypto.i
SWIG\_lib.i(527): Error: Syntax error in input(1).
error: command 'swig.exe' failed with exit status 1

2) using "python setup.py build -cmingw32"

C:\Program Files\Plone 2\Python\lib\distutils\extension.py:128: UserWarning:
Unknown Extension options: 'swig_opts'
  warnings.warn(msg)
running build
running build_py
creating build
creating build\lib.win32-2.3
creating build\lib.win32-2.3\M2Crypto
copying M2Crypto\ASN1.py -> build\lib.win32-2.3\M2Crypto
copying M2Crypto\AuthCookie.py -> build\lib.win32-2.3\M2Crypto
.
.
.
copying M2Crypto\PGP\RSA.py -> build\lib.win32-2.3\M2Crypto\PGP
copying M2Crypto\PGP\__init__.py -> build\lib.win32-2.3\M2Crypto\PGP
running build_ext
warning: Python's pyconfig.h doesn't seem to support your compiler. Reason:
couldn't read 'C:\Program Files\Plone 2\Pyth
on\include\pyconfig.h': No such file or directory. Compiling may fail
because of undefined preprocessor macros.
building '__m2crypto' extension
C:\SWIG\swig.exe -python -ISWIG -I"c:\openssl\include" -o SWIG/_m2crypto.c
SWIG/_m2crypto.i
SWIG\_lib.i(527): Error: Syntax error in input(1).
error: command 'swig.exe' failed with exit status 1


any help would be nice.
i would like to buy the 0.13 but the matter is for me to LEARN how to build
those packages, read and write Python, use Plone etc.
thanks to all of you people that have given so much of your time for a FREE
world...


Thomas G. Apostolou



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


Re: Problem cmpiling M2Crypto

2005-12-01 Thread Thomas G. Apostolou

"Fredrik Lundh" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Thomas G. Apostolou wrote:
>
> >> C:\Program Files\Plone 2\Python\lib\distutils\extension.py:128:
> > UserWarning:
> >> Unknown Extension options: 'swig_opts'
> >
> >>>Hmm, I don't remember seeing that. But then again, I haven't compiled
> >>>with the same setup as you either.
> >
> > I am in a quest to find where this comes from.
>
> google can provide a hint, at least:
>
> http://www.mail-archive.com/distutils-sig@python.org/msg00084.html

That was realy some help! Thank you.

I changed %rename back to %name as Heikki Toivonen sujested and changed the
setup.py to read as:

m2crypto = Extension(name = '__m2crypto',
   sources = ['SWIG/_m2crypto.i'],
   include_dirs = include_dirs,
   library_dirs = library_dirs,
   libraries = libraries,
   extra_compile_args = ['-DTHREADING',

'-DSWIG_COBJECT_PYTHON'],
#swig_opts = [swig_opts_str] # only
works for 2.4
   )

What i get now is the warnings about %name is deprecated - witch i think is
better than the errors about "Syntax error in input(1)".
The message about "C:\Program Files\Plone
2\Python\lib\distutils\extension.py:128: UserWarning:
Unknown Extension options: 'swig_opts'" is gone.
I still get the error:
"SWIG/_m2crypto.c(80) : fatal error C1083: Cannot open include file:
'Python.h': No such file or directory
error: command '"C:\Program Files\Microsoft Visual Studio\VC98\BIN\cl.exe"'
failed with exit status 2"

witch is -as Heikki Toivonen told- because of lack of Python.h
I do not hane this file anywhere in my PC.
Could anyone sujest of a package to install that contains Python.h and that
would be of use for me later on?

Thanks in advance
Thomas G. Apostolou


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



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


Re: Problem cmpiling M2Crypto

2005-12-02 Thread Thomas G. Apostolou
"Fredrik Lundh" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Thomas G. Apostolou wrote:
>
> > I still get the error:
> > "SWIG/_m2crypto.c(80) : fatal error C1083: Cannot open include file:
> > 'Python.h': No such file or directory
> > error: command '"C:\Program Files\Microsoft Visual
Studio\VC98\BIN\cl.exe"'
> > failed with exit status 2"
> >
> > witch is -as Heikki Toivonen told- because of lack of Python.h
> > I do not hane this file anywhere in my PC.
> > Could anyone sujest of a package to install that contains Python.h and
that
> > would be of use for me later on?
>
> most standard Python installers come with this file (it's usually in
> ./include relative to the installation directory).
>
> I suggest installing a python.org release:
>
> http://www.python.org/
>
> and using that to build the extensions.
>
> (make sure you get the same version as your Plone uses)
>
> 

So what you say is that the Python installed with Plone doesn't have
Python.h in ./include but Python installers from Python.org do have the
file?
If yes i guess i should install the same version to the same location
(over-writing). Is that so?

Thanks again!



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


Re: Problem cmpiling M2Crypto under Plone

2005-12-02 Thread Thomas G. Apostolou

"Fredrik Lundh" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Thomas G. Apostolou wrote:
>
> > So what you say is that the Python installed with Plone doesn't have
> > Python.h in ./include but Python installers from Python.org do have the
> > file?
>
> that's likely, given building didn't work for you.
>
> after all, Plone's an application that happens to include a Python
interpreter,
> not a Python distribution.
>
> > If yes i guess i should install the same version to the same location
> > (over-writing). Is that so?
>
> to minimize the risk, I'd grab the corresponding python.org version,
install it
> in a separate location, use the python.org version to build the
extensions, and
> finally install them in the Plone tree.
>
> but maybe there's no risk for conflict; maybe someone from the Plone team
> can clarify ?

The above sudgestion is right. Unfortunatelly i found out the problem the
bad way...
After installing the full package of python 2.3.3 on top of the
plone's(2.0.5) python installation, the build and install of m2crypto went
ok but the zope server service was refusing to start...
I thought ok the installation kept a BACKUP directory so i can allways roll
back...
I did unistall it and there was realy a rollback option there witch i
choosed.
But still the service was refusing to start giving me an error witch i could
read at windows EventViewer/Application that was saying :

"Python could not import the service's module
File "C:\Program Files\Plone 2\Data\bin\zopeservice.py", line 100, in ?
from nt_svcutils.service import Service
File "C:\Program Files\Plone 2\Zope\lib\python\nt_svcutils\service.py", line
18, in ?
import win32serviceutil
exceptions.ImportError: No module named win32serviceutil
Python could not import the service's module
File "C:\Program Files\Plone 2\Data\bin\zopeservice.py", line 100, in ?
from nt_svcutils.service import Service
File "C:\Program Files\Plone 2\Zope\lib\python\nt_svcutils\service.py", line
18, in ?
import win32serviceutil
exceptions.ImportError: No module named win32serviceutil"


Good for me i had backups of everything (External Methods, Script(Python),
and DTML-PT). So i unistalled Plone 2.0.5, reistalled it and restored my
site. Of course i was not stupid enough and the problem was encountered in
my development pc instead of the real site pc
Now everithing is ok as i run python setup.py install and it ran ok...

Time for me to learn about how to apply patches (there is one for python
2.3.3 for Connection.py and on for m2crypto named xmlrpclib.py.patch inside
patches directory of mycrypto)

After that i'll start with trying to use the whole thing compiling all this
time...
Thanks to the people imlementing m2crypto and all of you helping me with the
compilation.

PS: After all that strugling for building on windows i am sure that i am
going to use the whole thing on linux box next time i set it up for someone
else


Thomas G. Apostolou



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


Problem patching SimpleXMLRPCServer.py

2005-12-06 Thread Thomas G. Apostolou
Hello all,
I use Python 2.3.3 and try to patch SimpleXMLRPCServer.py with the patch i
got from Python.org.
so after changing to the directory where both SimpleXMLRPCServer.py and
SimpleXMLRPCServer.patch reside i run :
patch -i SimpleXMLRPCServer.patch -b --verbose --dry-run
SimpleXMLRPCServer.py
and i get :
Hmm...patch:  unexpected end of hunk at line 47

The SimpleXMLRPCServer.patch file at lines 24-48 reads like :
--- 107,128 
  import types
  import os

! def resolve_dotted_attribute(obj, attr, allow_dotted_names=True):
  """resolve_dotted_attribute(a, 'b.c.d') => a.b.c.d

  Resolves a dotted attribute name to an object.  Raises
  an AttributeError if any attribute in the chain starts with a '_'.
+
+ If the optional allow_dotted_names argument is false, dots are not
+ supported and this function operates similar to getattr(obj, attr).
  """

! if allow_dotted_names:
! attrs = attr.split('.')
! else:
! attrs = [attr]
!
! for i in attrs:
  if i.startswith('_'):
  raise AttributeError(
  'attempt to access private attribute "%s"' % i
***
*** 156,162 

The SimpleXMLRPCServer.py at lines 107-128 reads like :
import types
import os

def resolve_dotted_attribute(obj, attr):
"""resolve_dotted_attribute(a, 'b.c.d') => a.b.c.d

Resolves a dotted attribute name to an object.  Raises
an AttributeError if any attribute in the chain starts with a '_'.
"""

for i in attr.split('.'):
if i.startswith('_'):
raise AttributeError(
'attempt to access private attribute "%s"' % i
)
else:
obj = getattr(obj,i)
return obj

def list_public_methods(obj):
"""Returns a list of attribute strings, found in the specified
object, which represent callable attributes"""

i am trying to understand what is wrong, trying to change 107-128 to 107-125
but it doesn't seem to work...

any solution or explanation would be helpfull


Thomas G. Apostolou



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


Re: Problem patching SimpleXMLRPCServer.py

2005-12-06 Thread Thomas G. Apostolou
Its ok now,
it seems the problem was that i had saved the file in UTF-8 format ???
I got it again and saved it in Greek(ISO) format and it now goes fine



"Thomas G. Apostolou" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hello all,
> I use Python 2.3.3 and try to patch SimpleXMLRPCServer.py with the patch i
> got from Python.org.
> so after changing to the directory where both SimpleXMLRPCServer.py and
> SimpleXMLRPCServer.patch reside i run :
> patch -i SimpleXMLRPCServer.patch -b --verbose --dry-run
> SimpleXMLRPCServer.py
> and i get :
> Hmm...patch:  unexpected end of hunk at line 47
>
> The SimpleXMLRPCServer.patch file at lines 24-48 reads like :
> --- 107,128 
>   import types
>   import os
>
> ! def resolve_dotted_attribute(obj, attr, allow_dotted_names=True):
>   """resolve_dotted_attribute(a, 'b.c.d') => a.b.c.d
>
>   Resolves a dotted attribute name to an object.  Raises
>   an AttributeError if any attribute in the chain starts with a '_'.
> +
> + If the optional allow_dotted_names argument is false, dots are not
> + supported and this function operates similar to getattr(obj, attr).
>   """
>
> ! if allow_dotted_names:
> ! attrs = attr.split('.')
> ! else:
> ! attrs = [attr]
> !
> ! for i in attrs:
>   if i.startswith('_'):
>   raise AttributeError(
>   'attempt to access private attribute "%s"' % i
> ***
> *** 156,162 
>
> The SimpleXMLRPCServer.py at lines 107-128 reads like :
> import types
> import os
>
> def resolve_dotted_attribute(obj, attr):
> """resolve_dotted_attribute(a, 'b.c.d') => a.b.c.d
>
> Resolves a dotted attribute name to an object.  Raises
> an AttributeError if any attribute in the chain starts with a '_'.
> """
>
> for i in attr.split('.'):
> if i.startswith('_'):
> raise AttributeError(
> 'attempt to access private attribute "%s"' % i
> )
> else:
> obj = getattr(obj,i)
> return obj
>
> def list_public_methods(obj):
> """Returns a list of attribute strings, found in the specified
> object, which represent callable attributes"""
>
> i am trying to understand what is wrong, trying to change 107-128 to
107-125
> but it doesn't seem to work...
>
> any solution or explanation would be helpfull
>
>
> Thomas G. Apostolou
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



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


Question about start using ZServerSSL on win box...

2005-12-07 Thread Thomas G. Apostolou
Hello all,

Dear Ng Pheng Siong,
thank you for your great job with M2Crypto.

I have got and build 0.15 version on a win xp box recently and was reading
your "ZServerSSL HOWTO" document so that i can start using https,
xmlprc-over-https etc.

I have to tell that i have installed from Plone 2.0.5 binary for windows
witch comes with Zope 2.7.0 and Python 2.3.3 (i have patched
SimpleHTTPServer.py as corrected for 2.3.5).

As reading your "ZServerSSL HOWTO" i suppose that the corresponding $ZOPE is
my "C:\Program Files\Plone 2\Zope\lib\python" because only there i can find
$ZOPE/ZServer. Correct me if i am wrong with this...

What i also need to know is that since i have installed so that Zope server
runs as a service what is the corresponding steps for me in the section
where you say :

  1.. Copy $ZSSL/z2s.py into $ZOPE.

  2.. Depending on your operating system, modify $ZOPE/start or
$ZOPE/start.bat to invoke $ZOPE/z2s.py, instead of $ZOPE/z2.py. The files
$ZSSL/starts and $ZSSL/starts.bat serve as examples.

I do not have any $ZOPE/start or $ZOPE/start.bat or $ZOPE/z2.py, i only have
a file named PythonService.exe into "C:\Program Files\Plone 2\Zope\bin"

Do i HAVE to reinstall Plone and set it not to run as service?

Thank you in advance...

Thomas G. Apostolou



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


Re: Mutability of function arguments?

2005-12-07 Thread Brett g Porter
ex_ottoyuhr wrote:
> I'm trying to create a function that can take arguments, say, foo and
> bar, and modify the original copies of foo and bar as well as its local
> versions -- the equivalent of C++ funct(&foo, &bar).
> 
> I've looked around on this newsgroup and elsewhere, and I gather that
> this is a very common concern in Python, but one which is ordinarily
> answered with "No, you can't. Neat, huh?" A few websites, newsgroup
> posts, etc. have recommended that one ask for a more "Pythonic" way of
> doing things; so, is there one, or at least one that doesn't involve
> using objects as wrappers for mutable arguments?
> 
> And, indeed, would that approach work? Would declaring:
> 
> class FooWrapper :
> __init__(fooToLoad) :
> self.foo = fooToLoad
> 
> mean that I could now declare a FooWrapper holding a foo, pass the
> FooWrapper to a function, and have the function conclude with the foo
> within the FooWrapper now modified?

Well, you can test it yourself:

 >>> class wrapper(object):
...def __init__(self, val):
...   self.val = val
...
 >>> w = wrapper(42)
 >>> w.val
42
 >>> def foo(w):
...w.val = 11
...
 >>> foo(w)
 >>> w.val
11
 >>>

> 
> Thanks in advance for everyone's time; I hope I'm comprehensible.

You're comprehensible, but I think that you're also thinking in C++.
The object model that Python follows is very different --  instead of
thinking of assignment meaning
"Stick this value into this named location", you need to switch to 
thinking of assignment as meaning "stick this name onto that object 
until I tell you otherwise".

If you're trying to return multiple values from a function, Python lets 
you do that

 >>> def multiFoo(x, y, z):
...    return x*2, y*2, z*2
...
 >>> x = 1
 >>> y = 2
 >>> z = 3
 >>> x, y, z = multiFoo(x, y, z)
 >>> x
2
 >>> y
4
 >>> z
6
 >>>
-- 
//  Today's Oblique Strategy (© Brian Eno/Peter Schmidt):
//  Repetition is a form of change
//  Brett g Porter * [EMAIL PROTECTED]

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


Re: PHP = Perl Improved

2005-12-09 Thread Thomas G. Marshall
Roedy Green said something like:
> On 9 Dec 2005 11:15:16 -0800, "Xah Lee" <[EMAIL PROTECTED]> wrote, quoted
> or indirectly quoted someone who said :
>
>> recently i got a project that involves the use of php. In 2 days, i
>> read almost the entirety of the php doc. Finding it a breeze because it
>> is roughly based on Perl, of which i have mastery.
>
> that's very lovely, but off topic. Trolling for language flame wars
> belong is comp.lang.java.advocacy.

I had plonked him back in May for this kind of crap.  I suggest you do the 
same.

-- 
If I can ever figure out how, I hope that someday I'll
succeed in my lifetime goal of creating a signature
that ends with the word "blarphoogy".


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


Re: Question about start using ZServerSSL on win box...

2005-12-13 Thread Thomas G. Apostolou
After reading and searching for a while i found that all about running
ZService as service start from C:\Program Files\Plone
2\Data\bin\zopeservice.py
But still i cannot fully understand where the server is called so that i
replace it with z2s.py or what ever needed...
Any ideas?

"Thomas G. Apostolou" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hello all,
>
> Dear Ng Pheng Siong,
> thank you for your great job with M2Crypto.
>
> I have got and build 0.15 version on a win xp box recently and was reading
> your "ZServerSSL HOWTO" document so that i can start using https,
> xmlprc-over-https etc.
>
> I have to tell that i have installed from Plone 2.0.5 binary for windows
> witch comes with Zope 2.7.0 and Python 2.3.3 (i have patched
> SimpleHTTPServer.py as corrected for 2.3.5).
>
> As reading your "ZServerSSL HOWTO" i suppose that the corresponding $ZOPE
is
> my "C:\Program Files\Plone 2\Zope\lib\python" because only there i can
find
> $ZOPE/ZServer. Correct me if i am wrong with this...
>
> What i also need to know is that since i have installed so that Zope
server
> runs as a service what is the corresponding steps for me in the section
> where you say :
>
>   1.. Copy $ZSSL/z2s.py into $ZOPE.
>
>   2.. Depending on your operating system, modify $ZOPE/start or
> $ZOPE/start.bat to invoke $ZOPE/z2s.py, instead of $ZOPE/z2.py. The files
> $ZSSL/starts and $ZSSL/starts.bat serve as examples.
>
> I do not have any $ZOPE/start or $ZOPE/start.bat or $ZOPE/z2.py, i only
have
> a file named PythonService.exe into "C:\Program Files\Plone 2\Zope\bin"
>
> Do i HAVE to reinstall Plone and set it not to run as service?
>
> Thank you in advance...
>
> Thomas G. Apostolou
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



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


Re: Pattern matching with string and list

2005-12-13 Thread Brett g Porter
BartlebyScrivener wrote:
> Even without the marker, can't you do:
> 
> sentence = "the fabric is red"
> colors = ["red", "white", "blue"]
> 
> for color in colors:
> if (sentence.find(color) > 0):
> print color, sentence.find(color)
> 
That depends on whether you're only looking for whole words:

 >>> colors = ['red', 'green', 'blue']
 >>> def findIt(sentence):
...for color in colors:
...   if sentence.find(color) > 0:
...  print color, sentence.find(color)
...
 >>> findIt("This is red")
red 8
 >>> findIt("Fredrik Lundh")
red 1
 >>>

It's easy to see all the cases that this approach will fail for...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Xah's Edu Corner: Examples of Quality Technical Writing

2005-12-18 Thread Thomas G. Marshall
Lars Rune Nøstdal said something like:
> hi,
> everyone thinks youreoay faggot and that youreh stupid .. now go
> fugkght yourselfes
>
> peasse out .. yo!

Idiot.   


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

Re: How to compare files

2005-07-01 Thread Brett g Porter
Lad wrote:
> Hi,
> What is the best method for comparing two files by words?
> I was thinking about reading files by words and compare them but a word
> in one file can be linked with a new line character ( \n)
> and this '\n' will cause that the words will considered to be
> different( eventhough without '\n' are the same)
> 
> Thanks for help.
> LAd.
> 
Have you looked at the difflib module that comes with Python?

http://docs.python.org/lib/module-difflib.html



-- 
//  Today's Oblique Strategy (© Brian Eno/Peter Schmidt):
//  Change instrument roles
//  Brett g Porter * [EMAIL PROTECTED]

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


Re: Defending Python

2005-07-13 Thread Brett g Porter
Jorey Bump wrote:
> 
> Monty Python's Flying Circus used to begin with "It's..." I had read at one 
> time that "It's" was one of the original names proposed for the 
> troupe/show, although I can't seem to find verification.  

"In fact, one of the titles of the show was 'It's', so he must have been 
in there fairly early on. On a list of titles I've got scribbled in a 
notebook was 'It's' and just 'It,' so that's probably where he came from."

   -- Michael Palin (referring to the "It's" man) in _The First 20 Years 
of Monty Python_ by Kim "Howard" Johnson (St. Martin's Press, 1989), p.20


-- 
//  Today's Oblique Strategy (© Brian Eno/Peter Schmidt):
//  Change instrument roles
//  Brett g Porter * [EMAIL PROTECTED]
//  http://bgporter.inknoise.com/JerseyPorkStore
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: URL 'special character' replacements

2006-01-09 Thread Brett g Porter
Claude Henchoz wrote:
> Hi guys
> 
> I have a huge list of URLs. These URLs all have ASCII codes for special
> characters, like "%20" for a space or "%21" for an exclamation mark.
> 
> I've already googled quite some time, but I have not been able to find
> any elegant way on how to replace these with their 'real' counterparts
> (" " and "!").
> 
> Of course, I could just replace(), but that seems to be a lot of work.
> 
> Thanks for any help.
> 
> Cheers, Claude
> 

The standard library module 'urllib' gies you two choices, depending on 
the exact behavior you'd like:

http://www.python.org/doc/2.3.2/lib/module-urllib.html
unquote(string)
 Replace "%xx" escapes by their single-character equivalent.

 Example: unquote('/%7Econnolly/') yields '/~connolly/'.

unquote_plus(string)
 Like unquote(), but also replaces plus signs by spaces, as required 
for unquoting HTML form values.


-- 
//  Today's Oblique Strategy (© Brian Eno/Peter Schmidt):
//  Accretion
//  Brett g Porter * [EMAIL PROTECTED]

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


Re: How to *Search* with google from inside my programme and get the search result?

2006-02-15 Thread Brett g Porter
I V wrote:
> Frank Potter wrote:
>> Does google supply some webservice to programmers? I did see
> 
> Googling for "google api" gets you to:
> 
> http://www.google.com/apis/
> 
> It appears to be a SOAP API, which you can access with python, but I
> think you'll need a third-party library. Googling for "python soap"
> gets you:
> 
> http://www-128.ibm.com/developerworks/library/ws-pyth5/
> 
> which might be a place to start.
> 
Or even easier:
http://pygoogle.sourceforge.net/

SUMMARY
---
This module allows you to access Google's web APIs through SOAP,
to do things like search Google and get the results programmatically.
This API is described here:
   http://www.google.com/apis/

SYSTEM REQUIREMENTS
---
Requires Python 2.0 or later

Requires the SOAPpy library from the Python Web Services project
(http://pywebsvcs.sourceforge.net).  We include an older version, but
its use is now deprecated (and will go away completely in future
releases).  Unfortunately, versions of SOAPpy prior to 0.11.3 will not
work correctly, and thus PyGoogle will fall back on the included
SOAP.py library if an earlier version is found.

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


Re: First Script Problem

2005-09-16 Thread Brett g Porter
Ed Hotchkiss wrote:
> This script should just be writing every possibly IP (yea, there are 
> billions i know blah blah) to a txt file. Instead of just writing the 
> IP, it continues and the number goes past 4 groups. IE: The possible IP 
> keeps getting 3 characters longer every time. And at the end of the last 
> loops do I somehow have to set my mySet to NULL? Any ideas here? 
> 
> -- 
> edward hotchkiss
>  
>  

>  
> 
> 
> # Script to Evaluate every possible IP Address Combo, then write it to a 
> text file
> # 9/15/05
> 
> # ipFileLocation = r"G:\Python\myCode\IPList.txt"
> 
> ipFileLocation = "IPList.txt"
> ipFile = open(ipFileLocation, 'w')
> 
> def findIPs():
>  for num in range(256):
>   mySet = "%03.d" % num

okay -- at this point, on the first iteration of this outer loop, mySet 
is '000'

>   for num in range(256):
>mySet = mySet + "." + "%03.d" % num
and on the first iteration of this first inner loop, mySet is '000.000'

>for num in range(256):
> mySet = mySet + "." + "%03.d" % num
second inner loop, first iteration, mySet is '000.000.000'
> for num in range(256):
>  mySet = mySet + "." + "%03.d" % num
>  ipFile.write(mySet+"\n")

Okay -- this innermost loop will now be executed 256 times (values 
ranging from 0 to 255, and mySet just keeps getting appended to, 
creating the ever-growing output string that you see.

A better way to write this would be something like:

for octet1 in range(256):
for octet2 in range(256):
   for octet3 in range(256):
  for octet4 in range(256):
 ipAddress = '%03.d.%03.d.%03.d.%03.d\n' % (octet1, octet2, 

 octet3, octet4)
 ipFile.write(ipAddress)

...which will generate output like you're looking for:

000.000.000.000
000.000.000.001
000.000.000.002
000.000.000.003
000.000.000.004
000.000.000.005
000.000.000.006
000.000.000.007
000.000.000.008
000.000.000.009
000.000.000.010
000.000.000.011
000.000.000.012
000.000.000.013
000.000.000.014

Also note that growing strings by concatenating with '+' is going to 
create code that runs very slowly as the strings continue to grow -- 
much better to either use string formatting or the idiom of using the 
join method of list objects to create a string in a single pop once a 
list of substrings is all populated.


-- 
//  Today's Oblique Strategy (© Brian Eno/Peter Schmidt):
//  Destroy -nothing -the most important thing
//  Brett g Porter * [EMAIL PROTECTED]
//  http://bgporter.inknoise.com/JerseyPorkStore
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Non-web-based templating system

2006-04-28 Thread Brett g Porter
Diez B. Roggisch wrote:
> [EMAIL PROTECTED] wrote:
> 
> Maybe the built-in string interpolation is sufficient?
> 
> print "Hello %(name)s" % dict(name="Peter Pan")


Or in recent pythons, the built-in string templating system (see 
http://docs.python.org/lib/node109.html)


 >>> from string import Template
 >>> d = dict(name="Barney")
 >>> s = Template("Hello $name")
 >>> s.substitute(d)
'Hello Barney'

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


Re: do design patterns still apply with Python?

2006-03-02 Thread Thomas G. Willis
On 3/2/06, Terry Hancock <[EMAIL PROTECTED]> wrote:
On Thu, 02 Mar 2006 16:38:44 -0500Roy Smith <[EMAIL PROTECTED]> wrote:> In article <[EMAIL PROTECTED]
>,>  John Salerno <[EMAIL PROTECTED]> wrote:> > Since Python does so many things different, especially> > compared to  compiled and statically typed languages, do
> > most of the basic design  patterns still apply when> > writing Python code? If I were to read a  design pattern> > book (such as Head First Design Patterns), could I apply> > their Java examples to Python easily enough, or does
> > Python require a  different perspective when applying> > patterns?> [...]> The basic concepts in the pattern books are worth knowing.>  You just have> to be able to tease apart the concepts from the
> language-specific cruft  that so often obfuscates the> descriptions.This sounds like an article crying out to be written,"(Learning) Design Patterns with Python".Has it been written already?
Cheers,TerryBruce Eckel began writing "Thinking In Python" it was last updated in 2001.He's a busy dude with a lot on his plate, so finishing it or updating it isn't known.
I emailed him once about it and actually got a cordial reply which amounted to,..."I have no time but I'd love to finish it" But, the draft does have some interesting tidbits in it and it's worth a look I think. You def. get the message that patterns apply a lot differently in python as compared to the {...;} languages.
Details here.http://mindview.net/Books/Python/ThinkingInPython.html-- Thomas G. Willis---
http://i-see-sound.comhttp://tomwillis.sonicdiscord.comAmerica, still more rights than North Korea
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: New python.org website

2006-03-08 Thread Thomas G. Willis
I don't necessarily like it, but I think the true test is whether a pointy haired manager type can be convinced that python can be taken seriously as a welcome addition to the programming arsenal. I think the site re-design will aid in that area more so  than  the previous one.
I'm not feeling the new logo though. But it's better than what I can produce in an svg editor/ -- Thomas G. Willis---
http://i-see-sound.comhttp://tomwillis.sonicdiscord.comAmerica, still more rights than North Korea
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: New python.org website

2006-03-08 Thread Thomas G. Willis
On 3/8/06, Robert Boyd <[EMAIL PROTECTED]> wrote:
On 8 Mar 2006 07:47:15 -0800, Michael Tobis <[EMAIL PROTECTED]> wrote:> > No one> > of the complainers and negativists do claim that they could do it much
> > better.>> Indeed, I do not have to be able to write a particular program to> notice it has bugs.>> On the other hand, (since I think the design, while not brilliant, is> good) fixing the logo is something that can be achieved without too
> much fuss.> [snip]While I don't dislike the logo, there has been a lot of grumblingabout it. Dislike has been due to aesthetic reasons, or theresemblance to a cross, or general "it's not as good as x".
So I gave it another close look, and I wondered if this would improve it:Retain the stylized blue snake. Remove the yellow snake, but keep itsbody that's in line horizontally with the blue snake's, and color it
blue. Result: one snake with a horizontal tail that curls up slightlyat the right edge.When I first saw it I thought "twisted" than I thought "is that a cross?"  then I thought maybe it's a messed up yin/yang.
I thought the yin/yang idea might be interesting, and maybe would work but the overall shape needs to be more circular to convey that idea better.But I'm no graphic designer
-- Thomas G. Willis---http://i-see-sound.comhttp://tomwillis.sonicdiscord.com
America, still more rights than North Korea
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: python debugging question

2006-03-08 Thread Thomas G. Willis
On 8 Mar 2006 13:23:44 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
I am a python newbie. I have writen some 500 lines of code. There are 4classes and in all 5 files.
Now, I am trying to run the program. I am getting wrong values for thesimulation results.Is there any debugging facilities in python which would let me go stepby step and check the values of the variables at every step. I have
done something like this in MS Visual Stdio 6.0 sometime back.For python, I am using SPE.what is a good way of debugging such large and iterative programs ? Anytips.Every help is appreciated.
Thanks--http://mail.python.org/mailman/listinfo/python-listThis might help.
http://www.onlamp.com/pub/a/python/2005/09/01/debugger.html-- Thomas G. Willis---http://i-see-sound.com
http://tomwillis.sonicdiscord.comAmerica, still more rights than North Korea
-- 
http://mail.python.org/mailman/listinfo/python-list

  1   2   >