Re: sed to python: replace Q

2008-04-30 Thread happyriding
On Apr 29, 11:27 pm, Raymond <[EMAIL PROTECTED]> wrote:
> For some reason I'm unable to grok Python's string.replace() function.

line = "abc"
line = line.replace("a", "x")
print line

--output:--
xbc

line = "abc"
line = line.replace("[apq]", "x")
print line

--output:--
abc


Does the 5 character substring "[apq]" exist anywhere in the original
string?
--
http://mail.python.org/mailman/listinfo/python-list


Re: computing with characters

2008-04-30 Thread Kam-Hung Soh

On Wed, 30 Apr 2008 16:13:17 +1000, SL <[EMAIL PROTECTED]> wrote:


How can I compute with the integer values of characters in python?
Like 'a' + 1 equals 'b' etc


Try: ord('a')

See also: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65117

--
Kam-Hung Soh http://kamhungsoh.com/blog";>Software Salariman
--
http://mail.python.org/mailman/listinfo/python-list


Re: sed to python: replace Q

2008-04-30 Thread Robert Bossy

Raymond wrote:

For some reason I'm unable to grok Python's string.replace() function.
Just trying to parse a simple IP address, wrapped in square brackets,
from Postfix logs. In sed this is straightforward given:

line = "date process text [ip] more text"

  sed -e 's/^.*\[//' -e 's/].*$//'
  

alternatively:
 sed -e 's/.*\[\(.*\)].*/\1/'


yet the following Python code does nothing:

  line = line.replace('^.*\[', '', 1)
  line = line.replace('].*$', '')

Is there a decent description of string.replace() somewhere?
  

In python shell:
   help(str.replace)

Online:
   http://docs.python.org/lib/string-methods.html#l2h-255

But what you are probably looking for is re.sub():
   http://docs.python.org/lib/node46.html#l2h-405


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


Re: sed to python: replace Q

2008-04-30 Thread Kam-Hung Soh

On Wed, 30 Apr 2008 15:27:36 +1000, Raymond <[EMAIL PROTECTED]> wrote:


For some reason I'm unable to grok Python's string.replace() function.
Just trying to parse a simple IP address, wrapped in square brackets,
from Postfix logs. In sed this is straightforward given:

line = "date process text [ip] more text"

  sed -e 's/^.*\[//' -e 's/].*$//'

yet the following Python code does nothing:

  line = line.replace('^.*\[', '', 1)
  line = line.replace('].*$', '')


str.replace() doesn't support regular expressions.

Try:

import re
p = re.compile("^.*\[")
q = re.compile("].*$")
q.sub('',p.sub('', line))



Is there a decent description of string.replace() somewhere?

Raymond


Section 3.6.1 String Functions

--
Kam-Hung Soh http://kamhungsoh.com/blog";>Software Salariman
--
http://mail.python.org/mailman/listinfo/python-list


Re: py2exe Icon Resources

2008-04-30 Thread Thomas Heller
[EMAIL PROTECTED] schrieb:
> I have created an app using python and then converting it to an exe
> using py2exe, and have the following code:
> 
> "icon_resources": [(1, "appFavicon.ico"), (2, "dataFavicon.ico")]
> 
> in my py2exe setup file, the appFavicon works fine and it sets that as
> the app icon thats fine, but the program creates data files (like
> documents) and i wanted them to have a different icon...
> 
> I package my apps using Inno Setup 5, and it registers the file type
> fine so that it loads on double click, what i cant do is set the icon
> for the file.
> 
> as you can see i have packaged two different icons with py2exe but
> when i set DefaultIcon in the registry to "C:\pathtoapp\myapp.exe,2"
> it doesnt work, nor does it work with a 1 or a %1 or indeed with
> passing a path to the icon itself, nothing seems to work!!
> 
> how do you access the other icons generated from py2exe, or how do you
> set the registry up so that i looks for the icon correctly,
> 

There was a problem in the icon resources code in py2exe which was
recently fixed in CVS but there is not yet a binary release of this code.
Maybe it solves your problem...

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


Re: computing with characters

2008-04-30 Thread SL


"Lutz Horn" <[EMAIL PROTECTED]> schreef in bericht 
news:[EMAIL PROTECTED]

Hi,

2008/4/30 Gary Herron <[EMAIL PROTECTED]>:

SL wrote:
> How can I compute with the integer values of characters in python?
> Like 'a' + 1 equals 'b' etc

 You can get an integer value from a character with the ord() function.


So just for completion, the solution is:


chr(ord('a') + 1)

'b'


thanks :) I'm a beginner and I was expecting this to be a member of string 
so I couldnt find it anywhere in the docs. 


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


Re: computing with characters

2008-04-30 Thread Gabriel Genellina

En Wed, 30 Apr 2008 04:19:22 -0300, SL <[EMAIL PROTECTED]> escribió:

"Lutz Horn" <[EMAIL PROTECTED]> schreef in bericht  
news:[EMAIL PROTECTED]


So just for completion, the solution is:


chr(ord('a') + 1)

'b'


thanks :) I'm a beginner and I was expecting this to be a member of  
string so I couldnt find it anywhere in the docs.


And that's a very reasonable place to search; I think chr and ord are  
builtin functions (and not str methods) just by an historical accident.  
(Or is there any other reason? what's wrong with "a".ord() or  
str.from_ordinal(65))?


--
Gabriel Genellina

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


Re: Problem with variables assigned to variables???

2008-04-30 Thread n00m
for listmember in mylist:
print listmember + ".shp", eval(listmember)
--
http://mail.python.org/mailman/listinfo/python-list


Re: computing with characters

2008-04-30 Thread Arnaud Delobelle
"Gabriel Genellina" <[EMAIL PROTECTED]> writes:

> En Wed, 30 Apr 2008 04:19:22 -0300, SL <[EMAIL PROTECTED]> escribió:
>
>> "Lutz Horn" <[EMAIL PROTECTED]> schreef in bericht
>> news:[EMAIL PROTECTED]
>>>
>>> So just for completion, the solution is:
>>>
>> chr(ord('a') + 1)
>>> 'b'
>>
>> thanks :) I'm a beginner and I was expecting this to be a member of
>> string so I couldnt find it anywhere in the docs.
>
> And that's a very reasonable place to search; I think chr and ord are
> builtin functions (and not str methods) just by an historical
> accident.  (Or is there any other reason? what's wrong with "a".ord()
> or  str.from_ordinal(65))?


Not a reason, but doesn't ord() word with unicode as well?

-- 
Arnaud

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


Re: computing with characters

2008-04-30 Thread SL


"Arnaud Delobelle" <[EMAIL PROTECTED]> schreef in bericht 
news:[EMAIL PROTECTED]

"Gabriel Genellina" <[EMAIL PROTECTED]> writes:


En Wed, 30 Apr 2008 04:19:22 -0300, SL <[EMAIL PROTECTED]> escribió:


"Lutz Horn" <[EMAIL PROTECTED]> schreef in bericht
news:[EMAIL PROTECTED]


So just for completion, the solution is:


chr(ord('a') + 1)

'b'


thanks :) I'm a beginner and I was expecting this to be a member of
string so I couldnt find it anywhere in the docs.


And that's a very reasonable place to search; I think chr and ord are
builtin functions (and not str methods) just by an historical
accident.  (Or is there any other reason? what's wrong with "a".ord()
or  str.from_ordinal(65))?



Not a reason, but doesn't ord() word with unicode as well?


yes it does, I just read the documentation on it :)




--
Arnaud



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


Re: Simple TK Question - refreshing the canvas when not in focus

2008-04-30 Thread Eric Brunel

On Tue, 29 Apr 2008 17:09:18 +0200, blaine <[EMAIL PROTECTED]> wrote:
[snip]

I'll try the update() again.  I would want to use that on the canvas
itself right? Not the root window?


Well, in fact, there is no difference at all... In tcl/tk, update is a  
function, and isn't applied to a particular widget. Any call to the update  
method on any widget should refresh the whole GUI.


HTH
--
python -c "print ''.join([chr(154 - ord(c)) for c in  
'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])"

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


Re: list.reverse()

2008-04-30 Thread Gabriel Genellina

En Tue, 29 Apr 2008 10:32:46 -0300, Roy Smith <[EMAIL PROTECTED]> escribió:


What you want to do is look at the reversed() function.  Not only does it
return something (other than Null), but it is much faster because it
doesn't have to store the reversed list anywhere.  What it returns is an
iterator which walks the list in reverse order.  
Same with list.sort() vs. the global sorted().


No, sorted() returns a -newly created- true list, not an iterator. Its  
argument may be any iterable, but the result is always a list.


--
Gabriel Genellina

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


Free YouTube Video Downloader Software

2008-04-30 Thread GoodieMan
Friends,

Here is an absolutely free tool to download any video from YouTube.
SmoothTube downloads videos from YouTube and converts them to MPEG
format, which is supported by almost all media players and devices. It
also post processes videos, smoothing out some of the compression
artifacts often introduced by YouTube's file size requirements.

http://freeware4.blogspot.com/2008/04/smoothtube-youtube-video-downloader.html
--
http://mail.python.org/mailman/listinfo/python-list


Re: computing with characters

2008-04-30 Thread SL


"Gabriel Genellina" <[EMAIL PROTECTED]> schreef in bericht 
news:[EMAIL PROTECTED]

En Wed, 30 Apr 2008 04:19:22 -0300, SL <[EMAIL PROTECTED]> escribió:
And that's a very reasonable place to search; I think chr and ord are 
builtin functions (and not str methods) just by an historical accident. 
(Or is there any other reason? what's wrong with "a".ord() or 
str.from_ordinal(65))?


yes when you know other OO languages you expect this. Anyone know why 
builtins were chosen? Just curious


--
Gabriel Genellina



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


Re: Who makes up these rules, anyway?

2008-04-30 Thread Gabriel Genellina
En Tue, 29 Apr 2008 13:15:33 -0300, Roel Schroeven  
<[EMAIL PROTECTED]> escribió:

Cameron Laird schreef:

In article <[EMAIL PROTECTED]>,
Gabriel Genellina <[EMAIL PROTECTED]> wrote:



   Explicit variable declaration for functions:
   
http://groups.google.com/group/comp.lang.python/browse_thread/thread/6c4a508edd2fbe04/

.
A reader notes that this thread actually lived during 2004 (!) [...]


I assumed it was a mix-up with the recent thread with the same name:  
http://groups.google.com/group/comp.lang.python/browse_thread/thread/f3832259c6da530


Yes, sorry! The worst part is that I *did* notice it was an old thread,  
but somehow I messed the links at the end.


--
Gabriel Genellina

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


Re: @classmethod question

2008-04-30 Thread Bruno Desthuilliers

Scott SA a écrit :

On 4/24/08, Bruno Desthuilliers ([EMAIL PROTECTED]) wrote:


It is a series of convenience methods, in this case I'm interacting
with a database via an ORM (object-relational model).

out of curiosity : which one ?


I'm rapidly becoming a "django junkie"^TM



(snip)

Then if you want some "table-level" operations on your models, you 
should put them in a custom manager. You'll find relevant stuff here:


http://www.b-list.org/weblog/2008/feb/25/managers/
http://www.djangoproject.com/documentation/model-api/#managers
--
http://mail.python.org/mailman/listinfo/python-list


Re: computing with characters

2008-04-30 Thread Torsten Bronger
Hallöchen!

SL writes:

> "Gabriel Genellina" <[EMAIL PROTECTED]> schreef in bericht
> news:[EMAIL PROTECTED]
>
>> En Wed, 30 Apr 2008 04:19:22 -0300, SL <[EMAIL PROTECTED]> escribió: And
>> that's a very reasonable place to search; I think chr and ord are
>> builtin functions (and not str methods) just by an historical
>> accident. (Or is there any other reason? what's wrong with
>> "a".ord() or str.from_ordinal(65))?
>
> yes when you know other OO languages you expect this. Anyone know
> why builtins were chosen? Just curious

*Maybe* for aesthetical reasons.  I find ord(c) more pleasent for
the eye.  YMMV.

The biggest ugliness though is ",".join().  No idea why this should
be better than join(list, separator=" ").  Besides, ",".join(u"x")
yields an unicode object.  This is confusing (but will probably go
away with Python 3).

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
  Jabber ID: [EMAIL PROTECTED]
   (See http://ime.webhop.org for further contact info.)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Sending Cntrl-C ??

2008-04-30 Thread Gabriel Genellina
En Tue, 29 Apr 2008 20:48:42 -0300, Christian Heimes <[EMAIL PROTECTED]>  
escribió:



gamename schrieb:

Thanks, Christian.  Would that work on win32 as well?


No, Windows doesn't support the same, rich set of signal as Unix OSes.


True but irrelevant to the question.
To the OP: you can download the pywin32 package from sourceforge, and use
win32api.GenerateConsoleCtrlEvent(win32con.CTRL_C_EVENT, pgid)
or call the same function using ctypes.
See http://msdn.microsoft.com/en-us/library/ms683155(VS.85).aspx for some  
important remarks.


--
Gabriel Genellina

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


Re: Simple TK Question - refreshing the canvas when not in focus

2008-04-30 Thread Robert.Spilleboudt

blaine wrote:

Hey everyone!
  I'm not very good with Tk, and I am using a very simple canvas to
draw some pictures (this relates to that nokia screen emulator I had a
post about a few days ago).

Anyway, all is well, except one thing.  When I am not in the program,
and the program receives a draw command (from a FIFO pipe), the canvas
does not refresh until I click into the program. How do I force it to
refresh, or force the window to gain focus?  It seems like pretty
common behavior, but a few things that I've tried have not worked.

Class screen():
def __init__(self):
self.root = Tkinter.Tk()
self.root.title('Nokia Canvas')
self.canvas = Tkinter.Canvas(self.root, width =130,
height=130)
self.canvas.pack()
self.root.mainloop()

Then somewhere a long the line I do:
self.canvas.create_line(args[0], args[1], args[2],
args[3], fill=color)
self.canvas.pack()

I've tried self.root.set_focus(), self.root.force_focus(),
self.canvas.update(), etc. but I can't get it.
Thanks!
Blaine
When you read the pipe,  do you generate an event? Probably not , and Tk 
is event-driven and should never update the canvas if there is no event.

This is how I understand Tk.

I have a Tk program who reads a audio signal (from an RC transmitter) . 
I generate a event every 100 msec , and "process" refresh the canvas.

Starting the sequence:
id = root.after(100,process)  will call "process" after 100 msec
At the end of "process", repeat:
id = root.after(100,process)
Robert
--
http://mail.python.org/mailman/listinfo/python-list


Re: computing with characters

2008-04-30 Thread Gabriel Genellina
En Wed, 30 Apr 2008 05:00:26 -0300, Arnaud Delobelle  
<[EMAIL PROTECTED]> escribió:



"Gabriel Genellina" <[EMAIL PROTECTED]> writes:


En Wed, 30 Apr 2008 04:19:22 -0300, SL <[EMAIL PROTECTED]> escribió:


"Lutz Horn" <[EMAIL PROTECTED]> schreef in bericht
news:[EMAIL PROTECTED]


So just for completion, the solution is:


chr(ord('a') + 1)

'b'


thanks :) I'm a beginner and I was expecting this to be a member of
string so I couldnt find it anywhere in the docs.


And that's a very reasonable place to search; I think chr and ord are
builtin functions (and not str methods) just by an historical
accident.  (Or is there any other reason? what's wrong with "a".ord()
or  str.from_ordinal(65))?



Not a reason, but doesn't ord() word with unicode as well?


Yes, so ord() could be an instance method of both str and unicode, like  
upper(), strip(), and all of them...

And str.from_ordinal(n)==chr(n), unicode.from_ordinal(n)==unichr(n)

--
Gabriel Genellina

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


Re: Code/test ratio wrt static vs dynamic typing [was: Re: Python Success stories]

2008-04-30 Thread cokofreedom
>
> A rather off-topic and perhaps naive question, but isn't a 1:4
> production/test ratio a bit too much ? Is there a guesstimate of what
> percentage of this test code tests for things that you would get for
> free in a statically typed language ? I'm just curious whether this
> argument against dynamic typing - that you end up doing the job of a
> static compiler in test code - holds in practice.
>
> George

To me it seems like more of an argument for a (more) concise Test
Framework for Python, or at least a fully fledge IDE beyond pyDev.
--
http://mail.python.org/mailman/listinfo/python-list


help: Question regarding parallel communication using python

2008-04-30 Thread pramod sridhar
Hello,

I would like from my Python application to control 2 (or more devices) using
the existing port's interface in my PC,like serial (COM1) or Parallel port
(lpt) or any other like PCI...etc.
The control mechanism usually involves sending messages to the connected
devices in parallel.
For instance, I would like to send a command to a target connected on COM
port and at the same time would like to read the value of a Digital
multimeter over other COM port ( or may be via USB with some adapter)

My Question is:
- Is it possible to achieve the above in Python ?
- Do we need to use any kind of Parallel processing to achieve this ?
- If so, Which of the available packages (like pypar or Pydusa..etc) suits
best ?

Please suggest.

Thank you very much in advance,

With Regards,
Pramod
--
http://mail.python.org/mailman/listinfo/python-list

Re: Problem with variables assigned to variables???

2008-04-30 Thread M.-A. Lemburg

On 2008-04-30 07:25, [EMAIL PROTECTED] wrote:

I have a simple line of code that requires the following inputs - an
input file, output file and a SQL expression.  the code needs to be
run with several different SQL expressions to produce multiple output
files.  To do this I first created a list of a portion of the output
filename:
mylist = ('name1', 'name2', 'name3')

I also assigned variables for each SQL expression:
name1 = "\"field_a\" LIKE '021'"
name2 = "\"field_a\" LIKE '031'"
name3 = "\"field_a\" LIKE '041'"

Notice the variable names are the same as the listmember strings, that
is intentional, but obviously doesn't work.

the loop:
for listmember in mylist:
print listmember + ".shp", listmember

my intended output is:
name1.shp "field_a LIKE '021'
name2.shp "field_a LIKE '031'
name3.shp "field_a LIKE '041'

but, of course, the variable listmember returns the name of the
listmember which makes perfect sense to me:
name1.shp name1

So how can I iterate not only the filenames but the SQL expressions as
well?


The Python way to do this would be to take two lists, one
with the filenames and one with the SQL, and then iterate
over them in parallel:

for filename, sql_snippet in zip(filenames, sql_snippets):
...

(there are also a couple of ways to use iterators to do the
same)

If you just want to get you code to work, use this:

for listmember in mylist:
print listmember + ".shp", locals()[listmember]


--
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Apr 30 2008)
>>> Python/Zope Consulting and Support ...http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/


 Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! 


   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611
--
http://mail.python.org/mailman/listinfo/python-list


Re: File IO Issues, help :(

2008-04-30 Thread Peter Otten
Dennis Lee Bieber wrote:

> On Tue, 29 Apr 2008 08:35:46 +0200, Peter Otten <[EMAIL PROTECTED]>
> declaimed the following in comp.lang.python:
> 
> 
>> jsfile.truncate(0)
>> jsfile.seek(0)
>>
> I'd suggest first doing the seek to start, then do the truncate

I usually overwrite the file, and that shows. Is there a usecase where
truncate() with an argument actually makes sense?

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


Re: __getattr__ and recursion ?

2008-04-30 Thread Peter Otten
Stef Mientki wrote:

> hello,
> 
> I tried to find an easy way to add properties (attributes) to a number
> of different components.
> So I wrote a class, from which all these components are derived.
> By trial and error I created the code below, which now works, but
> there is one thing I don't understand:
> in the line indicated with "<<== 1" I'm not allowed to use
> 
> for item in self.extra_getters :
> 
> because it will result in an infinite recursion.
> But in the line indicated with "<<== 2" , I am allowed ...
> ... why is this allowed ??

When the instance is created 

self.extra_setters = {} 

in the __init__() method triggers

self.__setattr__("extra_setters", {})

which executes

for item in self.extra_setters:
   # ...

in the __setattr__() method. Because at that point there is no extra_setters
attribute 

self.__dict__["extra_setters"] 

fails and self.__getattr__("extra_setters") is used as a fallback. Now as
__getattr__() contains a self.extra_getters attribute access and that
attribute doesn't exist either this again triggers 

self.__getattr__("extra_getters") -- ad infinitum.

By the way, looping over a dictionary destroys its key advantage, O(1)
lookup. Use

# untested
if attr in self.extra_setters:
self.extra_setters[attr](value)
else:
self.__dict__[attr] = value

and something similar in __getattr__().

Peter

> 
> thanks,
> Stef Mientki
> 
> 
> # ***
> # ***
> class _add_attribs ( object ) :
> def __init__ ( self ) :
> self.extra_setters = {}
> self.extra_getters = {}
> 
> def _add_attrib ( self, text, setter = None, getter = None ) :
> if setter :
> self.extra_setters [ text ] = setter
> if getter :
> self.extra_getters [ text ] = getter
> 
> # *
> # always called instead of the normal mechanism
> # *
> def __setattr__ ( self, attr, value ) :
> for item in self.extra_setters :
> if item == attr :
> self.extra_setters [ item ] ( value )
> break
> else :
> self.__dict__[attr] = value
> 
> # *
> # only called when not found with the normal mechanism
> # *
> def __getattr__ ( self, attr ) :
> try :
> for item in self.__dict__['extra_getters'] :<<== 1
> if item == attr :
> return self.extra_getters [ item ] ( )  <<== 2
>   except :
>   return []
> # ***

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


crack the sims 2 hm stuff

2008-04-30 Thread urquhart . nak
crack the sims 2 hm stuff

















http://crack.cracksofts.com

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


call of duty modern warfare keygen

2008-04-30 Thread meisnernel73884
call of duty modern warfare keygen







http://crack.cracksofts.com

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


soul patch

2008-04-30 Thread meisnernel73884
soul patch







http://crack.cracksofts.com

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


Re: xml.dom.minidom weirdness: bug?

2008-04-30 Thread Gabriel Genellina

En Tue, 29 Apr 2008 23:51:14 -0300, JYA <[EMAIL PROTECTED]> escribió:

What I'm doing, is read an xml file, create another dom object and copy  
the element from one to the other.


At no time do I ever modify the original dom object, yet it gets  
modified.


for y in x.getElementsByTagName('display-name'):
elem.appendChild(y)
tv_xml.appendChild(elem)


You'll note that at no time do I modify the content of docxml, yet it  
gets modified.


The weirdness disappear if I change the line
channellist = docxml.getElementsByTagName('channel')
to
channellist = copy.deepcopy(docxml.getElementsByTagName('channel'))

However, my understanding is that it shouldn't be necessary.


I think that any element can have only a single parent. If you get an  
element from one document and insert it onto another document, it gets  
removed from the first.


--
Gabriel Genellina

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


Re: Where to get BeautifulSoup--www.crummy.com appears to be down.

2008-04-30 Thread Florian Diesch
John Nagle <[EMAIL PROTECTED]> wrote:

>Perl has CPAN, which is reasonably comprehensive and presents modules
> in a uniform way.  If you need a common Perl module that's not in the
> Perl distro, it's probably in CPAN. "Installing a new module can be as
> simple as typing perl -MCPAN -e 'install Chocolate::Belgian'."
> So Perl has exactly that.
>
>Python's Cheese Shop is just a list of links to packages
> elsewhere.  There's no uniformity, no standard installation, no
> standard uninstallation, and no standard version control.

Python has easy_install


   Florian
-- 

---
**  Hi! I'm a signature virus! Copy me into your signature, please!  **
---
--
http://mail.python.org/mailman/listinfo/python-list


Re: DO YOU KNOW ANY THING ABOUT ISLAM???

2008-04-30 Thread ABDULLAH
On Apr 27, 1:52 pm, Lie <[EMAIL PROTECTED]> wrote:
> On Apr 24, 1:40 pm, ABDULLAH <[EMAIL PROTECTED]> wrote:
>
> > What you are about to read might sound unusual but it could be very
> > enlightened. So I would be thankful if you give my article 5 minute
> > of
> > your value time. THANK YOU
>
> No, it is not unusual at all, it's very normal. The only thing that's
> unusual is that you misposted this in a programming language mailing
> list instead of religion list.

sorry if you did not like this topic I thougth it will be intresting
for someone but ok as you like I will stop writing about these stuffs
in this group
--
http://mail.python.org/mailman/listinfo/python-list


Re: Problem with variables assigned to variables???

2008-04-30 Thread Bruno Desthuilliers

n00m a écrit :

for listmember in mylist:
print listmember + ".shp", eval(listmember)


eval and exec are almost always the wrong solution. The right solution 
very often implies a dict or attribute lookup, either on custom dict or 
on one of the available namespaces (globals(), locals(), or a module, 
class or instance).


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


wep key crack

2008-04-30 Thread meisnernel73884
wep key crack







http://crack.cracksofts.com

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


wep key crack

2008-04-30 Thread meisnernel73884
wep key crack







http://crack.cracksofts.com

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


microsoft office 2007 crack

2008-04-30 Thread urquhart . nak
microsoft office 2007 crack

















http://crack.cracksofts.com

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


Re: Python's doc problems: sort

2008-04-30 Thread John Thingstad
PÃ¥ Wed, 30 Apr 2008 06:26:31 +0200, skrev George Sakkis  
<[EMAIL PROTECTED]>:



On Apr 29, 11:13 pm, Jürgen Exner <[EMAIL PROTECTED]> wrote:


"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:

Is this self-promoting maniac still going at it?

>Although i disliked Perl very much [...]

Then why on earth do you bother polluting this NG?

Back into the killfile you go

jue


   \|||/
 (o o)
,ooO--(_)---.
| Please|
|   don't feed the  |
| TROLL's ! |
'--Ooo--'
|__|__|
 || ||
ooO Ooo


Doesn't copying Rainer Joswig's troll warning constitute a copywright  
infrigment :)


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


free fiction

2008-04-30 Thread mickey333





http://www.authspot.com/Short-Stories/Sunfish.107015
--
http://mail.python.org/mailman/listinfo/python-list


call of duty modern warfare keygen

2008-04-30 Thread meisnernel73884
call of duty modern warfare keygen







http://crack.cracksofts.com

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


vws crack

2008-04-30 Thread meisnernel73884
vws crack







http://crack.cracksofts.com

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


crack cream

2008-04-30 Thread urquhart . nak
crack cream

















http://crack.cracksofts.com

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


cracks and keygens

2008-04-30 Thread meisnernel73884
cracks and keygens







http://crack.cracksofts.com

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


soul patch

2008-04-30 Thread meisnernel73884
soul patch







http://crack.cracksofts.com

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


avg crack

2008-04-30 Thread urquhart . nak
avg crack

















http://crack.cracksofts.com

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


patch management

2008-04-30 Thread urquhart . nak
patch management

















http://crack.cracksofts.com

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


cracks and keygens

2008-04-30 Thread meisnernel73884
cracks and keygens







http://crack.cracksofts.com

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


rar password crack

2008-04-30 Thread meisnernel73884
rar password crack







http://crack.cracksofts.com

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


rar password crack

2008-04-30 Thread meisnernel73884
rar password crack







http://crack.cracksofts.com

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


autocad 2005 cracks and cheats

2008-04-30 Thread meisnernel73884
autocad 2005 cracks and cheats







http://crack.cracksofts.com

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


fifa manager 08 crack

2008-04-30 Thread meisnernel73884
fifa manager 08 crack







http://crack.cracksofts.com

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


Re: computing with characters

2008-04-30 Thread Duncan Booth
Torsten Bronger <[EMAIL PROTECTED]> wrote:

> The biggest ugliness though is ",".join().  No idea why this should
> be better than join(list, separator=" ").  Besides, ",".join(u"x")
> yields an unicode object.  This is confusing (but will probably go
> away with Python 3).

It is only ugly because you aren't used to seeing method calls on string 
literals. Here are some arguably less-ugly alternatives:

print str.join(", ", sequence)

or:

comma_separated = ", ".join

will let you use:

print comma_separated(sequence)

or even just:

SEPARATOR = ", "

followed by:

SEPARATOR.join(sequence)

is no more ugly than any other method call.

It would make perfect sense for join to be a method on stringlike objects 
if it simply returned an object of the same type as the object it is called 
on. As you point out, where it breaks down is a str separator can return a 
unicode result and that is confusing: if you want a unicode result perhaps 
you should be required to use a unicode separator but that isn't going to 
happen (at least not in Python 2.x).

What definitely wouldn't make sense would be to make join a method of the 
list type (as it is in some other languages).
--
http://mail.python.org/mailman/listinfo/python-list


Re: ssh

2008-04-30 Thread gert

Eric Wertman wrote:
>
>from popen2 import Popen3
>
>def ssh(host,command) :
>''' Wraps ssh commands '''
>ssh_exec = ['/usr/bin/ssh -qnx -F ssh_config', host, command]
>cmd = ' '.join(ssh_exec)
>output,errors,status = process(cmd)
>return output,errors,status
>
>def process(cmd) :
>proc = Popen3(cmd,-1)
>output = proc.fromchild.readlines()
>errors = proc.childerr.readlines()
>status = proc.poll()
>return output,errors,status

thanks, what happens with the ssh connection after def process(cmd) is
done

Do i not need to remove the 'else' for it to work ?
Also can i execute multiple commands at once ?

import os, time

def ssh(user, rhost, pw, cmd):
pid, fd = os.forkpty()
if pid == 0:
os.execv("/bin/ssh", ["/bin/ssh", "-l", user, rhost] +
cmd)
time.sleep(0.2)
os.read(fd, 1000)
time.sleep(0.2)
os.write(fd, pw + "\n")
time.sleep(0.2)
res = ''
s = os.read(fd, 1)
while s:
res += s
s = os.read(fd, 1)
return res

print ssh('username', 'serverdomain.com', 'Password', ['ls -l'])
--
http://mail.python.org/mailman/listinfo/python-list


Re: best way to host a membership site

2008-04-30 Thread Bruno Desthuilliers

Magdoll a écrit :

Hi,
  I know this is potentially off-topic, but because python is the
language I'm most comfortable with and I've previously had experiences
with plone, I'd as much advice as possible on this.

I want to host a site where people can register to become a user. They
should be able to maintain their own "showroom", where they can show
blog entries (maybe just by linking to their own blogs on some other
blog/album-hosting site like Xanga), put up pictures (again, I'm not
thinking about actually hosting these data, since there are already
plenty of places to put your pictures and blogs). The most important
thing is they will be able to build up a "profile" where I can store
in a DB. The profile will include membership information - for now,
think of it as "member X owns item A,B,C and gave comments on A such
and such, also member X is a male white caucasian between his 20-30
who likes outdoors". Eventually, I want this to be a simple social-
networking site where people can share a very particular hobby (I'm
doing it for comsetics and for a very targeted group that are active
bloggers, so they'll be somewhat web-salient) and the backend can
collect enough data (while maintaining privacy) to build up a
recommendation system similar to Netflix's movie recommendations, or
Match.com if you will.


You may want to have a look at o'reilly's "Programming Collective 
Intelligence"

http://www.oreilly.com/catalog/9780596529321/

The code examples are alas very very poorly coded, but at least they are 
in Python.



I want to know that given I know python best and I abhor C#/ASP, what
is the best thing to use. A friend recommended Ruby on Rails - not to
instigate war here, but I'd welcome comments on that (I don't know
Ruby, but I'll learn).


Ruby by itself is a nice language, but really on the same "niche" as 
Python. Rails is a nice framework too, but there are real problems wrt/ 
perfs and scalability - nothing that can't be solved given enough 
efforts and hardware, but depending on the expected load, this might be 
something you want to take into account (or just don't care).



I've used PLONE before, but back then I
remembered the site ran incredably slow (or it could just be the
server), and there were issues with upgrades.


Plone is indeed a 8-pounds behemoth, and (from working experience) 
is certainly one of the worst possible solution for anything else than 
pure content management.



I want to minimze time
on trying to learn how to write an interface for users to register and
manage their own space. Also I want an infrastructure that's not too
rigid so if in the future I want to add more apps it's not to hard.

I've also heard about django, but not enough to know how far it'll get
me. I'm open to all sorts of suggestions. Thanks!


We're about to start a couple somewhat similar projects here, and while 
our chief engineer is a definitive Ruby/Rails addict, we finally settled 
on Django. While it's not my own personal favorite Python MVC framework, 
it's still a very good one, and probably the more mature and stable so 
far. wrt/ the "add more apps in the future" concern, you may want to 
read this:

http://www.b-list.org/weblog/2007/nov/29/django-blog/

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


Essentio CS5110 the first produced desktop from asus

2008-04-30 Thread speedman2010

When I search web as every day I was surprised when I readied  that
ASUA company announced about it is new Essentio CS5110 desktop and I
Saied " cool ASUS enter to the world of desktop manufactories "
because ASUS produced good product and have a good Reputation On
computer market  and I waited for this step a long time
To read more go to http://computerworld4y.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: computing with characters

2008-04-30 Thread Torsten Bronger
Hallöchen!

Duncan Booth writes:

> Torsten Bronger <[EMAIL PROTECTED]> wrote:
>
>> The biggest ugliness though is ",".join().  No idea why this should
>> be better than join(list, separator=" ").  Besides, ",".join(u"x")
>> yields an unicode object.  This is confusing (but will probably go
>> away with Python 3).
>
> It is only ugly because you aren't used to seeing method calls on
> string literals.

I am used to it.  Programming very much with unicode, I use .encode
and .decode very often and I like them.  I consider en/decoding to
be an intrinsic feature of strings, but not ord(), which is an
"external", rather administrative operation on strings (and actually
not even this, but on characters) for my taste.

However, join() is really bizarre.  The list rather than the
separator should be the leading actor.

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
  Jabber ID: [EMAIL PROTECTED]
   (See http://ime.webhop.org for further contact info.)
--
http://mail.python.org/mailman/listinfo/python-list


crack rock cooking

2008-04-30 Thread meisnernel73884
crack rock cooking







http://crack.cracksofts.com

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


vws crack

2008-04-30 Thread meisnernel73884
vws crack







http://crack.cracksofts.com

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


the sims 2 crack

2008-04-30 Thread soray6034rao
the sims 2 crack







http://crack.cracksofts.com

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


daylight savings time patch

2008-04-30 Thread soray6034rao
daylight savings time patch







http://crack.cracksofts.com

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


ulead video studio 8 serial crack

2008-04-30 Thread soray6034rao
ulead video studio 8 serial crack







http://crack.cracksofts.com

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


microsoft office word 2007 keygen download

2008-04-30 Thread soray6034rao
microsoft office word 2007 keygen download







http://crack.cracksofts.com

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


age of empires 3 crack serial

2008-04-30 Thread soray6034rao
age of empires 3 crack serial







http://crack.cracksofts.com

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


Re: computing with characters

2008-04-30 Thread Marco Mariani

Torsten Bronger wrote:


However, join() is really bizarre.  The list rather than the
separator should be the leading actor.


No, because join must work with _any sequence_, and there is no 
"sequence" type to put the join method on.

This semantic certainly sets python apart from many other languages.

>>> '-'.join(c for c in 'hello')
'h-e-l-l-o'
>>>
--
http://mail.python.org/mailman/listinfo/python-list


Re: computing with characters

2008-04-30 Thread Marc 'BlackJack' Rintsch
On Wed, 30 Apr 2008 13:12:05 +0200, Torsten Bronger wrote:

> However, join() is really bizarre.  The list rather than the
> separator should be the leading actor.

You mean any iterable should be the leading actor, bacause `str.join()`
works with any iterable.  And that's why it is implemented *once* on
string and unicode objects.  Okay that's twice.  :-)

Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list


Re: computing with characters

2008-04-30 Thread Torsten Bronger
Hallöchen!

Marco Mariani writes:

> Torsten Bronger wrote:
>
>> However, join() is really bizarre.  The list rather than the
>> separator should be the leading actor.
>
> No, because join must work with _any sequence_, and there is no
> "sequence" type to put the join method on.

No, but for the sake of aesthetics (that's what we're talking here
after all), it would be better to have it as the first argument in a
build-in function.

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
  Jabber ID: [EMAIL PROTECTED]
   (See http://ime.webhop.org for further contact info.)
--
http://mail.python.org/mailman/listinfo/python-list


Re: computing with characters

2008-04-30 Thread Duncan Booth
Torsten Bronger <[EMAIL PROTECTED]> wrote:

> However, join() is really bizarre.  The list rather than the
> separator should be the leading actor.

Do you mean the list, or do you mean the list/the tuple/the dict/the 
generator/the file and anything else which just happens to be an iterable 
sequence of strings?

join is a factory method for creating a string from a separator string and 
a sequence of strings, any sequence of strings. It doesn't make sense to 
either limit it to specific sequence types, or to require it as part of the 
iterator protocol.

Having it as a function would make sense, but if it is going to be a method 
then it should be a method on the string types not on the sequence types.
--
http://mail.python.org/mailman/listinfo/python-list


Re: how to convert a multiline string to an anonymous function?

2008-04-30 Thread Scott David Daniels

Matimus wrote:

On Apr 29, 3:39 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:

Danny Shevitz schrieb:

Simple question here: ...
str = '''
def f(state):
  print state
  return True
'''
but return an anonmyous version of it, a la 'return f' so I can assign it
independently. The body is multiline so lambda doesn't work

The "stupid" thing is that you can pass your own dictionary as globals
to exec. Then you can get a reference to the function under the name "f"
in the globals, and store that under whatever name you need
Diez

...

Or, you can even  more simply do:
text = '''
def f(state):
print state
return True
'''
lcl = {}
exec text in globals(), lcl
and lcl will be a dictionary with a single item: {'f' : }
so you could return lcl.values()[0]

-Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list


Re: xml.dom.minidom weirdness: bug?

2008-04-30 Thread Marc Christiansen
JYA <[EMAIL PROTECTED]> wrote:
>for y in x.getElementsByTagName('display-name'):
>elem.appendChild(y)

Like Gabriel wrote, nodes can only have one parent. Use 
  elem.appendChild(y.cloneNode(True))
instead. Or y.cloneNode(False), if you want a shallow copy (i.e. without
any of the children, e.g. text content).

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


relative import broken?

2008-04-30 Thread test

basic noob question here.

i am trying to reference a package, i have the structure:

mypack/
   __init__.py
   test.py
   subdir1/
   __init__.py
   mod1.py
   subdir2/
   __init__.py
   mod2.py

can someone please tell me why the statement:

from mypack.subdir1.mod1 import *

does NOT work from mod2.py nor from test.py?

instead, if i use:

from subdir1.mod1 import *

it works perfectly from test.py.

?

thank you,

aj.


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


Re: Python(2.5) reads an input file FASTER than pure C(Mingw)

2008-04-30 Thread n00m
>>> a = ['zzz', 'aaa']
>>> id(a[0]), id(a[1])
(12258848, 12259296)
>>> a.sort()
>>> id(a[0]), id(a[1])
(12259296, 12258848)
>>>
--
http://mail.python.org/mailman/listinfo/python-list


Re: Simple TK Question - refreshing the canvas when not in focus

2008-04-30 Thread Eric Brunel
On Wed, 30 Apr 2008 10:58:06 +0200, Robert.Spilleboudt   
<[EMAIL PROTECTED]> wrote:



blaine wrote:

Hey everyone!
  I'm not very good with Tk, and I am using a very simple canvas to
draw some pictures (this relates to that nokia screen emulator I had a
post about a few days ago).
 Anyway, all is well, except one thing.  When I am not in the program,
and the program receives a draw command (from a FIFO pipe), the canvas
does not refresh until I click into the program. How do I force it to
refresh, or force the window to gain focus?  It seems like pretty
common behavior, but a few things that I've tried have not worked.
 Class screen():
def __init__(self):
self.root = Tkinter.Tk()
self.root.title('Nokia Canvas')
self.canvas = Tkinter.Canvas(self.root, width =130,
height=130)
self.canvas.pack()
self.root.mainloop()
 Then somewhere a long the line I do:
self.canvas.create_line(args[0], args[1], args[2],
args[3], fill=color)
self.canvas.pack()
 I've tried self.root.set_focus(), self.root.force_focus(),
self.canvas.update(), etc. but I can't get it.
Thanks!
Blaine
When you read the pipe,  do you generate an event? Probably not , and Tk  
is event-driven and should never update the canvas if there is no event.

This is how I understand Tk.

I have a Tk program who reads a audio signal (from an RC transmitter) .  
I generate a event every 100 msec , and "process" refresh the canvas.

Starting the sequence:
id = root.after(100,process)  will call "process" after 100 msec
At the end of "process", repeat:
id = root.after(100,process)
Robert


Your method actually works and is in fact even clearer: you explicitely  
give back the control to the main event loop by sending the event. But the  
call to 'update' should also work, since it also gives back the control to  
the main event loop, implicitely however. BTW, the pending events *are*  
treated by a call to update, which can cause some surprises...

--
python -c "print ''.join([chr(154 - ord(c)) for c in  
'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])"

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


Stream I/O to a java applet (os.popen?)

2008-04-30 Thread Cody Woolaver
Hello,
I have designed a script (in java) that allows me to input a command like "Move 
325 642" and the mouse cursor will move to that x,y position. The way that the 
java program works is when it initializes it runs in a constant loop reading 
the input each time something is sent to it... Here is an example of how i run 
the script from the terminal:
 
[code]
[EMAIL PROTECTED]:~/Workspace/Mouse/mouse/>java MouseMove
Move 500 500
Click Left 1 1
Move 400 400
Click Right 1 1
Move 250 50
Click Left 2 2
Exit
[EMAIL PROTECTED]:~/Workspace/Mouse/mouse/>
[/code]
 
Here is what happens:[quote]
I typed: "Move 500 500" then hit enter
The code: Moved the mouse to pos x,y. Then waited for more input
I typed: "Click Left 1 1" then hit enter
The code: Left Clicked at the current position once, with one ms of wait. Then 
waited for more input
I typed: "Move 400 400" then hit enter
The code: Moved the mouse to pos x,y. Then waited for more input
I typed: "Click Right 1 1" then hit enter
The code: Right Clicked at the current position once, with one ms of wait. Then 
waited for more input
I typed: "Move 500 500" then hit enter
The code: Moved the mouse to pos x,y. Then waited for more input
I typed: "Click Left 2 2" then hit enter
The code: Left Clicked at the current position twice (double click), with two 
ms of wait between each click. Then waited for More input
I typed: "Exit" then hit enter
The code: Quit the program[/quote]
 
This is all done at the terminal though and i need to have it done through a 
python file. I'm aware that i will have to use os.popen but am unfamiliar with 
how it works.
 
As an example could someone show me how to do this all in one "main.py" file.
 
[code]
import os #I know this will be needed
class JavaClass():
   def start():
   #Start the java program
   def move(x,y):
   #move the mouse (Inputs "Move x y")
   def click(button, times, delay):
   #click the mouse (Inputs "Click button times delay")
   def close():
   #Sends "Exit" to the program, ending it safely
JavaFile = New JavaClass()
JavaFile.start()  #Will open up the java file, then waits for input
JavaFile.move(500,500)   #Input the following (exact same 
as above)
JavaFile.click("Left", 1, 1) #Input the following (exact same as above)
JavaFile.move(400,400)   #Input the following (exact same 
as above)
JavaFile.click("Right", 1, 1)   #Input the following (exact same as above)
JavaFile.move(250,50) #Input the following (exact same as above)
JavaFile.click("Left", 2, 2) #Input the following (exact same as above)
JavaFile.close() #Will send "Exit" to the program closing it
[/code]
 
Thank you very much for any help you are able to give me
~Cody Woolaver
--
http://mail.python.org/mailman/listinfo/python-list

I messed up my wxPython install (Eclipse Configuration Issue)

2008-04-30 Thread blaine
The wxPython group is a bit stale compared to this group, so I'll give
it a shot :)

(READ: Originally when I started htis post, Python 2.5 at the shell
did not work (identical behavior to eclipse).  I'm not sure why, but
it has since worked fine with no problems.  Not sure whats going on
there... I didn't change anything.  Anyways...)

Ok so I am having this problem.  I am using OS X 10.4.  I use
MacPython and installed wxPython a few months back, and it worked
great.  Well I haven't done any wx development lately, and now that
I'm getting back into it I can't get wx to work properly.  I'm using
Eclipse, too.

Python 2.5 at Shell: works just fine
$ python
>>> import wx

OLD projects in Eclipse: import wx works fine
NEW projects in Eclipse (since I have started working wx again after a
few months):
import wx
/Users/frikk/Documents/workspace/Bili_UI/src/wx.py:3:
DeprecationWarning: The wxPython compatibility package is no longer
automatically generated or actively maintained.  Please switch to the
wx package as soon as possible.
  from wxPython.wx import *
Traceback (most recent call last):
  File "/Users/frikk/Documents/workspace/Bili_UI/src/nokia_fkscrn.py",
line 37, in 
import wx
  File "/Users/frikk/Documents/workspace/Bili_UI/src/wx.py", line 3,
in 
from wxPython.wx import *
  File "//Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/wx-2.8-mac-ansi/wxPython/__init__.py", line
15, in 
import _wx
  File "//Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/wx-2.8-mac-ansi/wxPython/_wx.py", line 3, in

from _core import *
  File "//Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/wx-2.8-mac-ansi/wxPython/_core.py", line 15,
in 
import wx._core
ImportError: No module named _core

I feel like this may be a path issue? Any ideas on what else to look
for? Both sys.path statements are the same, and I'm not sure what else
I could be causing it - some configuration perhaps in Eclipse that is
not being set correctly for newer projects? I also choose 'Python 2.5'
from in eclipse - and it points to the same location for both
projects.. Path:
>>> import sys
>>> sys.path

['', '/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
site-packages/setuptools-0.6c8-py2.5.egg', '/Library/Frameworks/
Python.framework/Versions/2.5/lib/python2.5/site-packages/
Pygments-0.9-
py2.5.egg', '/Library/Frameworks/Python.framework/Versions/2.5/lib/
python25.zip', '/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5', '/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/plat-darwin', '/Library/Frameworks/Python.framework/
Versions/
2.5/lib/python2.5/plat-mac', '/Library/Frameworks/Python.framework/
Versions/2.5/lib/python2.5/plat-mac/lib-scriptpackages', '/Library/
Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-tk', '/
Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-
dynload', '/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages', '/Library/Frameworks/Python.framework/
Versions/2.5/lib/python2.5/site-packages/wx-2.8-mac-ansi']

Any suggestions would be great - its probably something pretty
minor... Thanks!

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


Re: Tremendous slowdown due to garbage collection

2008-04-30 Thread s0suk3
On Apr 12, 11:11 am, [EMAIL PROTECTED] wrote:
> I should have been more specific about possible fixes.
>
> > > python2.5 -m timeit 'gc.disable();l=[(i,) for i in range(200)]'
>
> > 10 loops, best of 3: 662 msec per loop
>
> > > python2.5 -m timeit 'gc.enable();l=[(i,) for i in range(200)]'
>
> > 10 loops, best of 3: 15.2 sec per loop
>
> > In the latter case, thegarbagecollector apparently consumes about
> > 97% of the overall time.
>
> In a related thread onhttp://bugs.python.org/issue2607
> Amaury Forgeot d'Arc suggested a setting of the GC
> thresholds that actually solves the problem for me:
>
> > Disabling the gc may not be a good idea in a real application; I suggest
> > you to play with the gc.set_threshold function and set larger values, at
> > least while building the dictionary. (700, 1000, 10) seems to yield good
> > results.
> > python2.5 -m timeit 'gc.set_threshold(700,1000,10);l=[(i,) for i in 
> > range(200)]'
>
> 10 loops, best of 3: 658 msec per loop
>
> which made me suggest to use these as defaults, but then
> Martin v. Löwis wrote that
>
> > No, the defaults are correct for typical applications.
>
> At that point I felt lost and as the general wish in that thread was
> to move
> discussion to comp.lang.python, I brought it up here, in a modified
> and simplified form.
>
> > I would suggest to configure the default behaviour of thegarbage
> > collector in such a way that this squared complexity is avoided
> > without requiring specific knowledge and intervention by the user. Not
> > being an expert in these details I would like to ask the gurus how
> > this could be done.
> > I hope this should be at least technically possible, whether it is
> > really desirable or important for a default installation of Python
> > could then be discussed once the disadvantages of such a setting would
> > be apparent.
>
> I still don't see what is so good about defaults that lead to O(N*N)
> computation for a O(N) problem, and I like Amaury's suggestion a lot,
> so I would like to see comments on its disadvantages. Please don't
> tell me that O(N*N) is good enough. For N>1E7 it isn't.
>
> About some other remarks made here:
>
> > I think the linguists of the world should write better automated
> > translation systems. Not being an expert in these details I would like
> > to ask the gurus how it could be done.
>
> I fully agree, and that is why I (as someone involved with MT) would
> prefer to focus on MT and not on memory allocation issues, and by the
> way, this is why I normally prefer to work in Python, as it normally
> lets me focus on the problem instead of the tool.
>
> > There are going to be pathological cases in any memory allocation
> > scheme. The fact that you have apparently located one calls for you to
> > change your approach, not for the finely-tuned well-conceivedgarbage
> > collection scheme to be abandoned for your convenience.
>
> I do not agree at all. Having to deal with N>1E7 objects is IMHO not
> pathological, it is just daily practice in data-oriented work (we're
> talking about deriving models from Gigawords, not about toy systems).
>
> > If you had made a definite proposal that could have been evaluated you
> > request would perhaps have seemed a little more approachable.
>
> I feel it is ok to describe a generic problem without having found
> the answer yet.
> (If you disagree: Where are your definite proposals wrt. MT ? ;-)
> But I admit, I should have brought up Amaury's definite proposal
> right away.
>
> > A question often asked ... of people who are creating
> > very large data structures in Python is "Why are you doing that?"
> > That is, you should consider whether some kind of database solution
> > would be better.  You mention lots of dicts--it sounds like some
> > balanced B-trees with disk loading on demand could be a good choice.
>
> I do it because I have to count frequencies of pairs of things that
> appear in real data. Extremely simple stuff, only interesting because
> of the size of the data set. After Amaury's hint to switch GC
> temporarily
> off I can count 100M pairs tokens (18M pair types) in about 15
> minutes,
> which is very cool, and I can do it in only a few lines of code, which
> is even cooler.
> Any approach that would touch the disk would be too slow for me, and
> bringing in complicated datastructures by myself would distract me
> too much from what I need to do. That's exactly why I use Python;
> it has lots of highly fine-tuned complicated stuff behind the scenes,
> that is just doing the right thing, so I should not have to (and I
> could
> not) re-invent this myself.
>
> Thanks for the helpful comments,
> Andreas

In the issue at bugs.python.org, why do you say "Do I have to switch
to Perl or C to get this done???", as if Perl and C were similar
languages? If we were to look at Python, Perl, and C together, Python
and Perl would be similar languages, and C would be quite something
different, *specially* regarding the discussed is

Re: relative import broken?

2008-04-30 Thread Peter Otten
test wrote:

> basic noob question here.
> 
> i am trying to reference a package, i have the structure:
> 
> mypack/
> __init__.py
> test.py
> subdir1/
> __init__.py
> mod1.py
> subdir2/
> __init__.py
> mod2.py
> 
> can someone please tell me why the statement:
> 
> from mypack.subdir1.mod1 import *
> 
> does NOT work from mod2.py nor from test.py?
> 
> instead, if i use:
> 
> from subdir1.mod1 import *
> 
> it works perfectly from test.py.
> 
> ?

The parent directory of mypack must be in the module search path, see

http://docs.python.org/tut/node8.html#l2h-19

The least intrusive way to achieve this is to move test.py one level up in
the directory hierarchy.

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


Python Search Engine powered by Google

2008-04-30 Thread Giovanni Giorgi
Hi all, I am working on a customized python search engine:
http://blog.objectsroot.com/python/
It is done using a special feature of Google, and it is focused on
python
I'd like to have the contribution of other guys out of there to fine
tuning it.
Feel free to use it and give me your feedback.
You can leave a comment on my blog.
Bye bye
--
http://mail.python.org/mailman/listinfo/python-list


PIL and IPTC

2008-04-30 Thread Jumping Arne
I'm completely new to PIL and I'm trying to read IPTC info, I understand that 
it's possible but I can't find out how (and for once Google doesn't seem to 
be able to help). Does anyone have an example of how it's done?

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


Re: Simple TK Question - refreshing the canvas when not in focus

2008-04-30 Thread blaine
Still doesn't work.  I'm looking into using wx instead...

This is the full code - does it work for anyone else? Just do a echo
'line 0 0 10 10' > dev.file


import sys, os, time, Tkinter, threading

class nokia_fkscrn(Tkinter.Toplevel):
fp=None
def __init__(self, file):
self.fname = file
# Create the FIFO pipe (hopefully /dev/screen or similar)
if not os.path.exists(self.fname): os.mkfifo(self.fname)
self.readthread = threading.Thread(target=self.read)
self.readthread.start()
self.init_canvas()

def init_canvas(self):
# Set up our canvas
self.root = Tkinter.Tk()
self.root.title('Nokia Canvas')
self.canvas = Tkinter.Canvas(self.root, width =130,
height=130)

self.canvas.pack()
self.root.mainloop()


def read(self):
while 1:
self.fp = open(self.fname, 'r')
while 1:
st = self.fp.readline()
if st == '': break
self.process(st)
self.fp.close()

def process(self, line):
cmd = line.split()
if cmd[0] == 'line':
# Draw Line
args = map(int, cmd[1:])
try:
color=args[4]
except:
color='black'
if self.canvas:
print 'Drawing Line:', args
self.canvas.create_line(args[0], args[1], args[2],
args[3], fill=color)
self.canvas.update()
self.canvas.focus_force()

nokia = nokia_fkscrn('dev.file')
--
http://mail.python.org/mailman/listinfo/python-list


Re: list.reverse()

2008-04-30 Thread blaine
On Apr 29, 8:51 pm, Roy Smith <[EMAIL PROTECTED]> wrote:
> In article
> <[EMAIL PROTECTED]>,
>
>  blaine <[EMAIL PROTECTED]> wrote:
> > Check out this cool little trick I recently learned:
> > >>> x=range(5)
> > >>> x.reverse() or x
> > [4, 3, 2, 1, 0]
>
> > Useful for returning lists that you need to sort or reverse without
> > wasting that precious extra line :)
>
> > What it does: x.reverse() does the reverse and returns None.  or is
> > bitwise, so it sees that 'None' is not 'True' and then continues to
> > process the next operand, x.  x or'd with None will always be x (and x
> > has just been changed by the reverse()).  So you get the new value of
> > x :)
>
> Please don't do that in any code I have to read and understand.  Cool
> little tricks have no place in good code.
>
> >>> x = range(5)
> >>> x.reverse()
> >>> x
>
> [4, 3, 2, 1, 0]
>
> does the same thing, and it a lot easier to understand.  I buy my newlines
> in the big box at Costo, so I don't mind using a few extra ones here or
> there.

haha true - i usually don't use shortcuts, it kind of defeats the
purpose of the readability of python :)
--
http://mail.python.org/mailman/listinfo/python-list


Re: how to convert a multiline string to an anonymous function?

2008-04-30 Thread Danny Shevitz
Thanks All!

you've solved my problem.

D

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


Re: best way to host a membership site

2008-04-30 Thread Aaron Watters

> We're about to start a couple somewhat similar projects here, and while
> our chief engineer is a definitive Ruby/Rails addict, we finally settled
> on Django. While it's not my own personal favorite Python MVC framework,
> it's still a very good one, and probably the more mature and stable so
> far. wrt/ the "add more apps in the future" concern, you may want to
> read this:http://www.b-list.org/weblog/2007/nov/29/django-blog/

Interesting link.  Django does seem to be a well designed
modular approach -- and I think if it had existed back in
'97 the history of web development would have been much
different.

I can't help feeling that it would be nice to have a
collection of tools that was even more orthogonal
and flexible, and WSGI
seems to possibly offer a nice base platform for constructing
tools like these.  Also I think it remains devilishly difficult
to implement ajaxy functionalities like smart data pickers,
in-form validation, partial form saving, "chatty interfaces" etc.

What are some good paradigms or
methodologies or ideas out there that the Python community
should steal? :)

warning: It's very possible that my understanding of Django is not
deep enough and that the answer is "Django".
   -- Aaron Watters
===
http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=you+may+cheat
--
http://mail.python.org/mailman/listinfo/python-list


Re: List all files using FTP

2008-04-30 Thread Giampaolo Rodola'
On 6 Mar, 18:46, Anders Eriksson <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I need to list all the files on myFTPaccount (multiple subdirectories). I
> don't have shell access to the account.
>
> anyone that has a program that will do this?
>
> // Anders
> --
> English is not my first, or second, language
> so anything strange, or insulting, is due to
> the translation.
> Please correct me so I may improve my English!

If you mean listing ALL files including those contained in sub
directories if the server supports globbing you can issue a "STAT *"
command and receive the list of all files on the command channel in an
"ls -lR *"-like form.
Not tested:

>>> import ftplib
>>> f = ftplib.FTP()
>>> f.connect('ftpserver.domain', 21)
>>> f.login()
>>> f.sendcmd('STAT *')
an "ls -lR *" is expected to come
--
http://mail.python.org/mailman/listinfo/python-list


Re: best way to host a membership site

2008-04-30 Thread Jeroen Ruigrok van der Werven
-On [20080430 02:16], Magdoll ([EMAIL PROTECTED]) wrote:
>Also I want an infrastructure that's not too rigid so if in the future I
>want to add more apps it's not to hard.

Not to belittle Django, but for what I wanted to do with it, it was too
restraining.

I instead went with a combination of:

Werkzeug - http://werkzeug.pocoo.org/
SQLAlchemy - http://www.sqlalchemy.org/
Genshi - http://genshi.edgewall.org/ (although some people might prefer
 Jinja is they like Django's templating - http://jinja.pocoo.org/)
Babel - http://babel.edgewall.org/

This provided me with a lot of flexibility, more than Django could've
provided me with (but hey, welcome to the general limitation of frameworks).

-- 
Jeroen Ruigrok van der Werven  / asmodai
イェルーン ラウフロック ヴァン デル ウェルヴェン
http://www.in-nomine.org/ | http://www.rangaku.org/ | GPG: 2EAC625B
The human race is challenged more than ever before to demonstrate our
mastery -- not over nature but of ourselves...
--
http://mail.python.org/mailman/listinfo/python-list

Re: Simple TK Question - refreshing the canvas when not in focus

2008-04-30 Thread Peter Otten
blaine wrote:

> Still doesn't work.  I'm looking into using wx instead...
> 
> This is the full code - does it work for anyone else? Just do a echo
> 'line 0 0 10 10' > dev.file

Haven't tried it, but I think that the problem is that you are updating the
UI from the "readthread". A good example to model your app after is here:

http://effbot.org/zone/tkinter-threads.htm

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


new free fiction

2008-04-30 Thread mickey333



http://www.authspot.com/Short-Stories/Gossip.110935
--
http://mail.python.org/mailman/listinfo/python-list


Re: computing with characters

2008-04-30 Thread Diez B. Roggisch

However, join() is really bizarre.  The list rather than the
separator should be the leading actor.


Certainly *not*! This would be the way ruby does it, and IMHO it does 
not make sense to add join as a string-processing related 
method/functionality to a general purpose sequence type. And as others 
have pointed out, this would also mean that e.g.


def sgen():
for i in xrange(100):
   yield str(i)

sgen.join(":")

wouldn't work or even further spread the join-functionality over even 
more objects.


An argument for the original ord/chr debate btw is orthogonality: if you 
want ord to be part of a string, you'd want chr to be part of ints - 
which leads to ugly code due to parsing problems:


(100).chr()



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


Re: I messed up my wxPython install (Eclipse Configuration Issue)

2008-04-30 Thread Peter Otten
blaine wrote:

> The wxPython group is a bit stale compared to this group, so I'll give
> it a shot :)
> 
> (READ: Originally when I started htis post, Python 2.5 at the shell
> did not work (identical behavior to eclipse).  I'm not sure why, but
> it has since worked fine with no problems.  Not sure whats going on
> there... I didn't change anything.  Anyways...)
> 
> Ok so I am having this problem.  I am using OS X 10.4.  I use
> MacPython and installed wxPython a few months back, and it worked
> great.  Well I haven't done any wx development lately, and now that
> I'm getting back into it I can't get wx to work properly.  I'm using
> Eclipse, too.
> 
> Python 2.5 at Shell: works just fine
> $ python
 import wx
> 
> OLD projects in Eclipse: import wx works fine
> NEW projects in Eclipse (since I have started working wx again after a
> few months):
> import wx
> /Users/frikk/Documents/workspace/Bili_UI/src/wx.py:3:

Rename your script wx.py to something that doesn't clash with the installed
modules, e.g. my_wx.py. And don't forget to remove

/Users/frikk/Documents/workspace/Bili_UI/src/wx.pyc # note the .pyc suffix

too.

Peter

> DeprecationWarning: The wxPython compatibility package is no longer
> automatically generated or actively maintained.  Please switch to the
> wx package as soon as possible.
>   from wxPython.wx import *
> Traceback (most recent call last):
>   File "/Users/frikk/Documents/workspace/Bili_UI/src/nokia_fkscrn.py",
> line 37, in 
> import wx
>   File "/Users/frikk/Documents/workspace/Bili_UI/src/wx.py", line 3,
> in 
> from wxPython.wx import *
>   File "//Library/Frameworks/Python.framework/Versions/2.5/lib/
> python2.5/site-packages/wx-2.8-mac-ansi/wxPython/__init__.py", line
> 15, in 
> import _wx
>   File "//Library/Frameworks/Python.framework/Versions/2.5/lib/
> python2.5/site-packages/wx-2.8-mac-ansi/wxPython/_wx.py", line 3, in
> 
> from _core import *
>   File "//Library/Frameworks/Python.framework/Versions/2.5/lib/
> python2.5/site-packages/wx-2.8-mac-ansi/wxPython/_core.py", line 15,
> in 
> import wx._core
> ImportError: No module named _core
> 
> I feel like this may be a path issue? Any ideas on what else to look
> for? Both sys.path statements are the same, and I'm not sure what else
> I could be causing it - some configuration perhaps in Eclipse that is
> not being set correctly for newer projects? I also choose 'Python 2.5'
> from in eclipse - and it points to the same location for both
> projects.. Path:
 import sys
 sys.path
> 
> ['', '/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
> site-packages/setuptools-0.6c8-py2.5.egg', '/Library/Frameworks/
> Python.framework/Versions/2.5/lib/python2.5/site-packages/
> Pygments-0.9-
> py2.5.egg', '/Library/Frameworks/Python.framework/Versions/2.5/lib/
> python25.zip', '/Library/Frameworks/Python.framework/Versions/2.5/lib/
> python2.5', '/Library/Frameworks/Python.framework/Versions/2.5/lib/
> python2.5/plat-darwin', '/Library/Frameworks/Python.framework/
> Versions/
> 2.5/lib/python2.5/plat-mac', '/Library/Frameworks/Python.framework/
> Versions/2.5/lib/python2.5/plat-mac/lib-scriptpackages', '/Library/
> Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-tk', '/
> Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-
> dynload', '/Library/Frameworks/Python.framework/Versions/2.5/lib/
> python2.5/site-packages', '/Library/Frameworks/Python.framework/
> Versions/2.5/lib/python2.5/site-packages/wx-2.8-mac-ansi']
> 
> Any suggestions would be great - its probably something pretty
> minor... Thanks!
> 
> Blaine

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


Re: Code/test ratio wrt static vs dynamic typing [was: Re: Python Success stories]

2008-04-30 Thread MRAB
On Apr 30, 10:47 am, [EMAIL PROTECTED] wrote:
> > A rather off-topic and perhaps naive question, but isn't a 1:4
> > production/test ratio a bit too much ? Is there a guesstimate of what
> > percentage of this test code tests for things that you would get for
> > free in a statically typed language ? I'm just curious whether this
> > argument against dynamic typing - that you end up doing the job of a
> > static compiler in test code - holds in practice.
>
> > George
>
> To me it seems like more of an argument for a (more) concise Test
> Framework for Python, or at least a fully fledge IDE beyond pyDev.

You could just as easily argue that it shows the power of Python:
something that contains so much functionality that it requires 120 000
lines to test completely needs only 30 000 lines to implement! :-)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Issue with regular expressions

2008-04-30 Thread Gerard Flanagan
On Apr 29, 3:46 pm, Julien <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm fairly new in Python and I haven't used the regular expressions
> enough to be able to achieve what I want.
> I'd like to select terms in a string, so I can then do a search in my
> database.
>
> query = '   "  some words"  with and "withoutquotes   "  '
> p = re.compile(magic_regular_expression)   $ <--- the magic happens
> m = p.match(query)
>
> I'd like m.groups() to return:
> ('some words', 'with', 'and', 'without quotes')
>
> Is that achievable with a single regular expression, and if so, what
> would it be?
>
> Any help would be much appreciated.
>

With simpleparse:

--

from simpleparse.parser import Parser
from simpleparse.common import strings
from simpleparse.dispatchprocessor import DispatchProcessor, getString


grammar = '''
text := (quoted / unquoted / ws)+
quoted   := string
unquoted := -ws+
ws   := [ \t\r\n]+
'''

class MyProcessor(DispatchProcessor):

def __init__(self, groups):
self.groups = groups

def quoted(self, val, buffer):
self.groups.append(' '.join(getString(val, buffer)
[1:-1].split()))

def unquoted(self, val, buffer):
self.groups.append(getString(val, buffer))

def ws(self, val, buffer):
pass

groups = []
parser = Parser(grammar, 'text')
proc = MyProcessor(groups)
parser.parse(TESTS[1][1][0], processor=proc)

print groups
--

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


printing inside and outside of main() module

2008-04-30 Thread korean_dave
This allows me to see output:

---begin of try.py
print "Hello World"
--end of try.py

This DOESN'T though...

--begin of try2.py
def main():
 return "Hello"
--end of try2.py

Can someone explain why???
--
http://mail.python.org/mailman/listinfo/python-list


Re: printing inside and outside of main() module

2008-04-30 Thread Peter Otten
korean_dave wrote:

> This allows me to see output:
> 
> ---begin of try.py
> print "Hello World"
> --end of try.py
> 
> This DOESN'T though...
> 
> --begin of try2.py
> def main():
>  return "Hello"
main() # add this
> --end of try2.py
> 
> Can someone explain why???

Python doesn't call the main() function; you have to invoke it explicitly.

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


Re: simple chemistry in python

2008-04-30 Thread Brian Blais




baoilleach wrote:


If you are familiar with parsing XML, much of the data you need is
stored in the following file:
http://bodr.svn.sourceforge.net/viewvc/*checkout*/bodr/trunk/bodr/ 
elements/elements.xml?revision=34&content-type=text%2Fplain



Here's a quick BeautifulSoup script to read it into a python dict.   
It misses anything not a scalar, but you can easily modify it to  
include arrays, etc... in the xml.



hope it's useful.  certainly a neat site!

bb

--
Brian Blais
[EMAIL PROTECTED]
http://web.bryant.edu/~bblais


from __future__ import with_statement
from BeautifulSoup import BeautifulSoup

with open('elements.xml') as fid:
soup=BeautifulSoup(fid)


all_atoms=soup('atom')

element=soup('atom',{'id':'H'})[0]

elements={}
for atom in all_atoms:

info={}
id=atom['id']

scalars=atom('scalar')

for s in scalars:
dictref=s['dictref']  # seems to have a bo at the beginning
datatype=s['datatype'] # seems to have a xsd: at the beginning

contents=s.contents[0]

if datatype=='xsd:Integer':
value=int(contents)
elif datatype=='xsd:int':
value=int(contents)
elif datatype=='xsd:float':
value=float(contents)
else:
value=contents


key=dictref[3:]

info[key]=value



elements[id]=info


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

Re: computing with characters

2008-04-30 Thread Torsten Bronger
Hallöchen!

Diez B. Roggisch writes:

>> However, join() is really bizarre.  The list rather than the
>> separator should be the leading actor.
>
> Certainly *not*! This would be the way ruby does it, and IMHO it
> does not make sense to add join as a string-processing related
> method/functionality to a general purpose sequence type.

Okay, my wording was unfortunate.  However, I've already twice
(before and after the above posting of mine) said what I mean,
namely join(list, separator), possibly with a default value for
"separator".

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
  Jabber ID: [EMAIL PROTECTED]
   (See http://ime.webhop.org for further contact info.)
--
http://mail.python.org/mailman/listinfo/python-list


Re: best way to host a membership site

2008-04-30 Thread Aaron Watters
On Apr 30, 10:43 am, Jeroen Ruigrok van der Werven <[EMAIL PROTECTED]
nomine.org> wrote:
>
> Werkzeug -http://werkzeug.pocoo.org/ 

Wow.  An initial glance looks great!  I need help with pronunciation,
though :(.
(also, I'm a little disappointed because I made some notes that looked
a little
like this...)
   -- Aaron Watters
===
http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=slip+nibble
--
http://mail.python.org/mailman/listinfo/python-list


Re: Colors for Rows

2008-04-30 Thread Victor Subervi
Thank you all. You helped clean up my code. The stupid mistake was in where
I set the initial value of the variable z.
Victor

On Tue, Apr 29, 2008 at 3:20 PM, J. Cliff Dyer <[EMAIL PROTECTED]> wrote:

> On Tue, 2008-04-29 at 15:39 -0400, D'Arcy J.M. Cain wrote:
> > On Tue, 29 Apr 2008 15:03:23 -0400
> > "J. Cliff Dyer" <[EMAIL PROTECTED]> wrote:
> > > Or, if you aren't sure how many colors you'll be using, try the more
> > > robust:
> > >
> > > bg[z % len(bg)]
> >
> > Good point although I would have calculated the length once at the
> > start rather than each time through the loop.
> >
>
> Good catch.  Thanks.  What's that they say about eyes and bugs?
>
> Cheers,
> Cliff
>
>
>
--
http://mail.python.org/mailman/listinfo/python-list

Re: calling variable function name ?

2008-04-30 Thread TkNeo
On Apr 8, 7:51 pm, George Sakkis <[EMAIL PROTECTED]> wrote:
> On Apr 8, 3:52 pm,TkNeo<[EMAIL PROTECTED]> wrote:
>
> > I don't know the exact terminology in python, but this is something i
> > am trying to do
>
> > i have 3 functions lets say
> > FA(param1,param2)
> > FB(param1,param2)
> > FC(param1,param2)
>
> > temp = "B" #something entered by user. now i want to call FB. I don't
> > want to do an if else because if have way too many methods like
> > this...
>
> > var = "F" + temp
> > var(param1, param2)
>
> Try this:
>
> func = globals()["F" + temp]
> func(param1, param2)
>
> HTH,
> George



George - Thanks for your reply but what you suggested is not working:

def FA(param1,param2):
print "FA" + param1 + " " + param2
def FA(param1,param2):
print "FB" + param1 + " " + param2
def FA(param1,param2):
print "FC" + param1 + " " + param2

temp = sys.argv[1]

func = globals()["F" + temp]
func("Hello", "World")


I ran the script with first parameter as B and i get the following
message
KeyError: 'FB'

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


Re: Colors for Rows

2008-04-30 Thread D'Arcy J.M. Cain
On Wed, 30 Apr 2008 10:57:44 -0500
"Victor Subervi" <[EMAIL PROTECTED]> wrote:
> Thank you all. You helped clean up my code. The stupid mistake was in where
> I set the initial value of the variable z.

Really?  I thought that it was odd to start in the middle of your
colour list but it didn't seem like it was an error.  What do you think
was wrong with it?

-- 
D'Arcy J.M. Cain <[EMAIL PROTECTED]> |  Democracy is three wolves
http://www.druid.net/darcy/|  and a sheep voting on
+1 416 425 1212 (DoD#0082)(eNTP)   |  what's for dinner.
--
http://mail.python.org/mailman/listinfo/python-list


Custom Classes?

2008-04-30 Thread Victor Subervi
 Hi;
I have the following code which produces a file every time I need to display
an image from MySQL. What garbage! Surely, python is capable of better than
this, but the last time I asked for help on it, I got no responses. Is this
only possible with custom classes? Please, give me some guidance here!

try:

  w += 1

  getpic = "getpic" + str(w) + ".py"

  try:

os.remove(getpic)

  except:

pass

  code = """

#!/usr/local/bin/python

import cgitb; cgitb.enable()

import MySQLdb

import cgi

import sys,os

sys.path.append(os.getcwd())

from login import login

user, passwd, db, host = login()

form = cgi.FieldStorage()

picid = int(form["id"].value)

x = int(form["x"].value)

pics =
{1:'pic1',2:'pic1_thumb',3:'pic2',4:'pic2_thumb',5:'pic3',6:'pic3_thumb',7:'pic4',8:'pic4_thumb',\

9:'pic5',10:'pic5_thumb',11:'pic6',12:'pic6_thumb'}

pic = pics[x]

print 'Content-Type: text/html'

db = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db)

cursor= db.cursor()

sql = "select " + pic + " from products where id='" + str(picid) + "';"

cursor.execute(sql)

content = cursor.fetchall()[0][0].tostring()

cursor.close()

print 'Content-Type: image/jpeg'

print

print content

"""

  script = open(getpic, "w")

  script.write(code)

  print '' % pic

  print '\n' % (getpic, d, y)

TIA,

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

Re: Colors for Rows

2008-04-30 Thread Victor Subervi
The problem was that z was not incrementing. It kept getting reset to 3,
then incremented to 4 immediately, and reset back to 3. Stupid :/

On Wed, Apr 30, 2008 at 11:01 AM, D'Arcy J.M. Cain <[EMAIL PROTECTED]> wrote:

> On Wed, 30 Apr 2008 10:57:44 -0500
> "Victor Subervi" <[EMAIL PROTECTED]> wrote:
> > Thank you all. You helped clean up my code. The stupid mistake was in
> where
> > I set the initial value of the variable z.
>
> Really?  I thought that it was odd to start in the middle of your
> colour list but it didn't seem like it was an error.  What do you think
> was wrong with it?
>
> --
> D'Arcy J.M. Cain <[EMAIL PROTECTED]> |  Democracy is three wolves
> http://www.druid.net/darcy/|  and a sheep voting on
> +1 416 425 1212 (DoD#0082)(eNTP)   |  what's for dinner.
>
--
http://mail.python.org/mailman/listinfo/python-list

Re: calling variable function name ?

2008-04-30 Thread Arnaud Delobelle
TkNeo <[EMAIL PROTECTED]> writes:

>
> George - Thanks for your reply but what you suggested is not working:
>
> def FA(param1,param2):
> print "FA" + param1 + " " + param2
> def FA(param1,param2):
> print "FB" + param1 + " " + param2
> def FA(param1,param2):
> print "FC" + param1 + " " + param2
>
> temp = sys.argv[1]
>
> func = globals()["F" + temp]
> func("Hello", "World")
>
>
> I ran the script with first parameter as B and i get the following
> message
> KeyError: 'FB'

Perhaps if you call your three function FA, FB, FC instead of FA, FA,
FA it'll help?

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


Re: Colors for Rows

2008-04-30 Thread D'Arcy J.M. Cain
On Wed, 30 Apr 2008 11:03:34 -0500
"Victor Subervi" <[EMAIL PROTECTED]> wrote:
> The problem was that z was not incrementing. It kept getting reset to 3,
> then incremented to 4 immediately, and reset back to 3. Stupid :/

Not in the code you actually posted.  As I said earlier, create the
script that shows the error, run it and then cut and paste the actual
code into the message.  That might have saved a bunch of people a lot
of time in trying to help you.  Next time people may not want to spend
much time on your problem.

I'm not trying to rag on you.  I'm just trying to help you get the most
out of the list.  Have you read
http://catb.org/~esr/faqs/smart-questions.html yet?

-- 
D'Arcy J.M. Cain <[EMAIL PROTECTED]> |  Democracy is three wolves
http://www.druid.net/darcy/|  and a sheep voting on
+1 416 425 1212 (DoD#0082)(eNTP)   |  what's for dinner.
--
http://mail.python.org/mailman/listinfo/python-list


  1   2   >