Re: Spamming PyPI with stupid packages

2012-01-01 Thread Alexander Kapps
Uh oh, should I really send this? ... Yes. Yes, I should! Sorry, I 
cannot resists.



allow everyone to do import girlfriend



I'm betting on a joke, like antigravity only significantly less
funny and more sexist.


Absolutely not funny. I hope that someday people will understand 
that sexism is just another form of racism.


I was about to write a really harsh reply, but cooled down before I 
got a chance to hit the Send button.


Felinx Lee: Do apologize and rename your package/module or I'm going 
to make a racist comment against Chinese people.

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


Re: Python education survey

2011-12-31 Thread Alexander Kapps

On 31.12.2011 19:23, Roy Smith wrote:


Why do I waste my time reading your pretentious self-important nonsense?


http://xkcd.com/386/

;)


Why ROFLMAO when double-plus funny works just as well?


xkcd/386 has been the excuse for replying to RR for ages and I still 
don't understand why he gets that much advertence. Charity? Sympathy 
for the lone and broken?


FWIW, it undermines all my attempts to block him. Sigh.
--
http://mail.python.org/mailman/listinfo/python-list


Re: .format vs. %

2011-12-31 Thread Alexander Kapps

On 31.12.2011 19:44, davidfx wrote:

Thanks for your response.  I know the following code is not going to be correct 
but I want to show you what I was thinking.

formatter = %r %r %r %r

print formatter % (1, 2, 3, 4)

What is the .format version of this concept?



formatter = {0} {1} {2} {3}
formatter.format(1,2,3,4)


I have to say, I simply hate .format(), and I will be very, very 
upset if classic formatting will really be removed.


I understand that .format() has a lot of advantages for more complex 
formatting, but for the simple stuff I usually do, it's just 
terribly inconvenient (try {} on a German keyboard).

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


Re: python curses wrapper

2011-12-31 Thread Alexander Kapps

On 31.12.2011 20:24, Mag Gam wrote:

Hello,

I have been struggling reseting the terminal when I try to do
KeyboardInterrupt exception therefore I read the documentation for
curses.wrapper and it seems to take care of it for me,
http://docs.python.org/library/curses.html#curses.wrapper.

Can someone please provide a Hello World example with python curses wrapper?

tia


Use atexit.register() to register a cleanup function which is called 
when the program exits:


import atexit
import curses

def cleanup():
curses.nocbreak()
stdscr.keypad(0)
curses.echo()
curses.endwin()

atexit.register(cleanup)

stdscr = curses.initscr()
curses.noecho()
curses.cbreak()
stdscr.keypad(1)

curses.start_color()
curses.init_pair(1, curses.COLOR_GREEN, curses.COLOR_BLUE)
curses.init_pair(2, curses.COLOR_YELLOW, curses.COLOR_BLACK)

stdscr.bkgd(curses.color_pair(1))
stdscr.refresh()

win = curses.newwin(5, 20, 5, 5)
win.bkgd(curses.color_pair(2))
win.box()
win.addstr(2, 2, Hallo, Welt!)
win.refresh()

c = stdscr.getch()

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


Re: python curses wrapper

2011-12-31 Thread Alexander Kapps

On 31.12.2011 20:34, Alexander Kapps wrote:

On 31.12.2011 20:24, Mag Gam wrote:

Hello,

I have been struggling reseting the terminal when I try to do
KeyboardInterrupt exception therefore I read the documentation for
curses.wrapper and it seems to take care of it for me,
http://docs.python.org/library/curses.html#curses.wrapper.

Can someone please provide a Hello World example with python
curses wrapper?

tia


Use atexit.register() to register a cleanup function which is called
when the program exits:


Oh, sorry, I missed the curses.wrapper() part. Here is an example:


import curses

def main(screen):
curses.start_color()
curses.init_pair(1, curses.COLOR_GREEN, curses.COLOR_BLUE)
curses.init_pair(2, curses.COLOR_YELLOW, curses.COLOR_BLACK)

screen.bkgd(curses.color_pair(1))
screen.refresh()

win = curses.newwin(5, 20, 5, 5)
win.bkgd(curses.color_pair(2))
win.box()
win.addstr(2, 2, Hallo, Welt!)
win.refresh()

c = screen.getch()

try:
curses.wrapper(main)
except KeyboardInterrupt:
print Got KeyboardInterrupt exception. Exiting...
exit()

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


Re: Python education survey

2011-12-31 Thread Alexander Kapps

On 01.01.2012 03:36, Grant Edwards wrote:

On 2011-12-31, Alexander Kappsalex.ka...@web.de  wrote:

On 31.12.2011 19:23, Roy Smith wrote:


Why do I waste my time reading your pretentious self-important nonsense?


http://xkcd.com/386/

;)


Why ROFLMAO when double-plus funny works just as well?


xkcd/386 has been the excuse for replying to RR for ages and I still
don't understand why he gets that much advertence. Charity? Sympathy
for the lone and broken?


Sadly, RR's post are often (in the supposed words of Wolfgang Pauli)
not even wrong.



I'm sure, RR is now jumping up high in rapture for being compared to 
high-profile scientist geniuses. Move fuel for his 	 self-affirmation.


I'll give my entire kingdom (or important body-parts, in case my 
kingdom isn't enough) if people would just understand that 
perfection(ists) is/are *the most* dangerous thing possible.

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


Re: Text Processing

2011-12-20 Thread Alexander Kapps

On 20.12.2011 22:04, Nick Dokos wrote:


I have a text file containing such data ;

 ABC
---
-2.0100e-018.000e-028.000e-05
-2.e-010.000e+00   4.800e-04
-1.9900e-014.000e-021.600e-04

But I only need Section B, and I need to change the notation to ;

8.000e-02 = 0.08
0.000e+00 = 0.00
4.000e-02 = 0.04



Does it have to be python? If not, I'd go with something similar to

sed 1,2d foo.data | awk '{printf(%.2f\n, $2);}'



Why sed and awk:

awk 'NR2 {printf(%.2f\n, $2);}' data.txt

And in Python:

f = open(data.txt)
f.readline()# skip header
f.readline()# skip header
for line in f:
print %02s % float(line.split()[1])
--
http://mail.python.org/mailman/listinfo/python-list


Re: Help about Xlib Library in Python

2011-12-17 Thread Alexander Kapps

On 16.12.2011 05:55, 阮铮 wrote:

Hi,

A question about Xlib Library in Python troubled me for several days
and I finally found this email list. I hope someone could answer my
question. I think it is easy for experienced user.

I would like to write a small script to response my mouse click in
root screen and write something in the terminal. My script is like
this, but it does not work in my computer.

from Xlib import X
import Xlib.display

def main():
display = Xlib.display.Display()
root = display.screen().root
root.change_attributes(event_mask=
X.ButtonPressMask |
X.ButtonReleaseMask)
while True:
event = root.display.next_event()
print 1
if __name__ == __main__:
main()


Any hints are welcome
Thank you!

Ruan zheng



You haven't said *how* your script is not working and what 
distro/desktop-environment you use, but I suspect, that your script 
collides with the window manager.


Most window managers occupy the root window for them self, and even 
display another window above the root window (for the wallpaper, the 
desktop icons, etc.), so your clicks never reach the root window, 
but whatever the window manager draws as the background.


If you run your script in a plain and naked X session with nothing 
but an xterm *and no window manager*, your script will probably work.


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


Re: Pragmatics of the standard is() function

2011-11-26 Thread Alexander Kapps

On 26.11.2011 22:20, candide wrote:

You already got answers for the is vs. == difference. I'd like 
to add the following.



In which cases should we use the is() function ?


is is not a function, It's an operator, just like == or +.


is() function makes comparaison of (abstract representation of)
adresses of objects in memory.


That's an implementation detail. CPython (and maybe others) 
implement is in terms of memory addresses. Other implementations 
might use an object ID number or whatever else.

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


Re: What I do and do not know about installing Python on Win 7 with regard to IDLE.

2011-11-25 Thread Alexander Kapps

On 25.11.2011 05:49, Dennis Lee Bieber wrote:

On Fri, 25 Nov 2011 01:32:08 +0100, Alexander Kappsalex.ka...@web.de
declaimed the following in gmane.comp.python.general:



The main difference here is, that Linux makes it easy to seperate
administrative accounts from end-user accounts,


So does Win7... Heck -- I have to answer prompts to OK an installer
even while logged into my admin account!


For Windows, Left-Clicking an OK button to confirm potentionally 
dangerous admin tasks is like linking the acceleration pedal in your 
car to the brake pedal(If the traffic light shows Red/Stop, push the 
acceleration pedal to break)


I mean, seriously, left-clicking an OK button is something *SO* 
unusual to Windows users that you could also just remove that 
barrier altogether.


/sarcasm

Now, OK, I don't really know any  Windows version after XP, so 
things might have changed. But what I see from the casual Win users 
in my environment is that nothing has really changed.


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


Re: What I do and do not know about installing Python on Win 7 with regard to IDLE.

2011-11-24 Thread Alexander Kapps

On 24.11.2011 22:22, W. eWatson wrote:

Whoops, I thought I was replying to Matt Meyers just above you.


Above who? As said by somebody already, most people use a 
mail-client (Thunderbird/Outlook) or a Usenet client to read this 
forum. Google Groups is (In My Opinion at least) just crap (and 
should be blocked/forbidden. It's *the* one spam sender already)

Please always post enough context,

Now, we are talking about Python 3.2.* on Win7, correct? I only have 
Win7 32bit in a VBox VM, but still.


Please paste the following into a python.reg, file, then 
right-click on that file and choose the fist option (the one wihch 
is in bold font, something like install/insert/insert or however 
it's called in your language. In my German versin it's called 
Zusammenführen)


Do you get an Edit with IDLE then?




Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Python.File]
@=Python File

[HKEY_CLASSES_ROOT\Python.File\DefaultIcon]
@=C:\\Python32\\DLLs\\py.ico

[HKEY_CLASSES_ROOT\Python.File\shell]

[HKEY_CLASSES_ROOT\Python.File\shell\Edit with IDLE]

[HKEY_CLASSES_ROOT\Python.File\shell\Edit with IDLE\command]
@=\C:\\Python32\\pythonw.exe\ 
\C:\\Python32\\Lib\\idlelib\\idle.pyw\ -e \%1\


[HKEY_CLASSES_ROOT\Python.File\shell\open]

[HKEY_CLASSES_ROOT\Python.File\shell\open\command]
@=\C:\\Python32\\python.exe\ \%1\ %*


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


Re: What I do and do not know about installing Python on Win 7 with regard to IDLE.

2011-11-24 Thread Alexander Kapps

On 25.11.2011 00:18, Alexander Kapps wrote:


Do you get an Edit with IDLE then?


And even if not. Why are you so obsessive about IDLE? I mean, 
seriously, IDLE is just a bare-level if-nothing-else-is-available 
editor/IDE. It's better than notepad, OK.


I really don't buy it, that your are willing to move to C++ (or even 
just change the language) just because the default editor is not 
available in the context menu.

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


Re: What I do and do not know about installing Python on Win 7 with regard to IDLE.

2011-11-24 Thread Alexander Kapps

On 25.11.2011 01:04, Steven D'Aprano wrote:


So by your reasoning, that's at least 20 ways to infect my Linux system.
I never realised just how insecure Linux must be!


Yes, there are 20+ ways to infect your (and mine) Linux system. 
You cannot trust *any* kind of 3rd party code. Period.


Have you ever added a 3rd party repo (PPA or such). Have you ever 
added some Firefox addon or installed some 3rd-party addition (of 
any kind) to some program)


Where is the protection now?

The main difference here is, that Linux makes it easy to seperate 
administrative accounts from end-user accounts,


The custom addon/cmdlet/whatever I give you has the same dangers on 
Linux as on windows. If you blindly install it, you're owned!



If sharing code is considered to be synonymous with infection, what
does that say about the Free and Open Source Software movement?


Completely besides the topic. It's not about sharing code, but 
about the seperation between normal and administrative user on the 
OS level (which Windows still doesn't have by default).



Linux-users-aren't-the-only-people-allowed-to-write-shell-scripts-ly y'rs,


But-Linux-Users-aren't-root-by-default-ly y'rs.

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


Re: hi can someone help please key bind

2011-10-15 Thread Alexander Kapps

On 15.10.2011 19:30, Gary wrote:

Hi im trying to use key bind on Tkinter to call this function

def Start():
for i in range(60,-1,-1):
ent['text'] = i
time.sleep(1)
root.update()
ent['text'] = 'Time Out!'
root.update()

i know the function is ok as i have assigned a button and i calls
the function as i expect
but
root.bind('a',Start)
gives the following error

Exception in Tkinter callback
Traceback (most recent call last):
File /usr/lib/python2.7/lib-tk/Tkinter.py, line 1413, in __call__
return self.func(*args)
TypeError: Start() takes no arguments (1 given)

Thanks


As the error indicates, the callback function is called with an 
argument, but you don't provide one. That argument is an Event 
instance, so you can get details about the event.


Use

def Start(event):
...

BTW. functions, unlike classes should be all lower-case.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Loop through a dict changing keys

2011-10-15 Thread Alexander Kapps

On 15.10.2011 20:00, Gnarlodious wrote:

What is the best way (Python 3) to loop through dict keys, examine the
string, change them if needed, and save the changes to the same dict?

So for input like this:
{'Mobile': 'string', 'context': 'malicious code', 'order': '7',
'time': 'True'}

I want to booleanize 'True', turn '7' into an integer, escape
'malicious code', and ignore 'string'.

Any elegant Python way to do this?

-- Gnarlie


I think JSON could be of some use, but I've not used it yet, 
otherwise something like this could do it:


#!/usr/bin/python

from cgi import escape

def convert(string):
for conv in (int, lambda x: {'True': True, 'False': False}[x],
 escape):
try:
return conv(string)
except (KeyError, ValueError):
pass
return string


d = {'Mobile': 'string',
 'context': 'malicious code',
 'order': '7',
 'time': 'True'}

print d

for key in d:
d[key] = convert(d[key])

print d


$ ./conv.py
{'Mobile': 'string', 'order': '7', 'context': 'malicious code', 
'time': 'True'}
{'Mobile': 'string', 'order': 7, 'context': 'lt;malicious 
codegt;', 'time': True}

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


Re: Usefulness of the not in operator

2011-10-15 Thread Alexander Kapps

On 10.10.2011 19:29, Nobody wrote:

On Sun, 09 Oct 2011 02:25:27 +0200, Alexander Kapps wrote:


Even if it's off-topic, could you add some similar explanations for
Church numerals (maybe Lambda calculus it isn't too much?)


The Church numeral for N is a function of two arguments which applies its
first argument N times to its second, i.e. (f^N)(x) = f(f(...(f(x))...)).


[SNIP]

Thanks! That's a lot more understandable than Wikipedia. Some 
brain-food for the winter. ;-)

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


Re: Usefulness of the not in operator

2011-10-10 Thread Alexander Kapps

On 08.10.2011 18:08, Steven D'Aprano wrote:


Let's define the boolean values and operators using just two functions:


[SNIP]

Have you just explained Church booleans in an understandable 
language? Awesome. I still have to chew on this, but I think this is 
the first time where I might understand it. Thanks!


Even if it's off-topic, could you add some similar explanations for 
Church numerals (maybe Lambda calculus it isn't too much?)


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


Re: Usefulness of the not in operator

2011-10-08 Thread Alexander Kapps

On 09.10.2011 01:35, Tim Roberts wrote:

Roy Smithr...@panix.com  wrote:

In article4e906108$0$27980$426a3...@news.free.fr,
candidecandide@free.invalid  wrote:


After browsing source code, I realize that parenthesis are not necessary
(not has higher precedence than in).


Here's my take on parenthesis:  If you need to look up whether they're
necessary or not, they are :-)


Amen.  +1


So LISP (Lots of Irritating Superfluous Parentheses) was right all 
the time and is now finally vindicated? ;-)

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


Re: TK + MVC

2011-10-02 Thread Alexander Kapps

On 03.10.2011 00:15, Emeka wrote:

Greg,

Do you have an example where the Controller is connected?


What do you mean? In my example, the Controller *is* connected (to 
both the View and the Model.)

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


Re: TK + MVC

2011-10-02 Thread Alexander Kapps

On 02.10.2011 04:40, Gregory Ewing wrote:

Alexander Kapps wrote:


But I think a simple (and quick 'n' dirty) Tk MVC example can look
like this:


The Controller doesn't seem to add any value in that example.
You might as well connect the Model and Views directly to
each other.



Sure, in that simple example the Controller is just there to show a 
complete MVC pattern with all three parts. There are often examples 
where the View is actually both, the View and the Controller.


That's why I said that I'm not sure if I really understand the MVC 
pattern. There are so many different versions, sometimes strict and 
sometimes less strict, and I think what's the real problem with my 
example is, whether it is really correct to not connect the Model 
and the View directly, but to let the Controller mediate between both.

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


Re: TK + MVC

2011-10-01 Thread Alexander Kapps

On 01.10.2011 14:41, Emeka wrote:

Hello All,

I need a basic example where MVC pattern is used with Python TK.


I'm still not 100% sure if I really understand the MVC pattern. Some 
say the view and the model must not interact directly, some say the 
view must not access the controller (but the controller controls the 
view). Some insist on a certain interface, others just talk about a 
certain data/control flow, etc.


But I think a simple (and quick 'n' dirty) Tk MVC example can look 
like this:



#!/usr/bin/python

import Tkinter as tk

class Model(object):
def __init__(self):
self._data = [foo, bar, baz]
self.controllers = []

def data(self):
return self._data

def add(self, value):
self._data.append(value)
self.changed()

def delete(self, index):
del self._data[index]
self.changed()

def changed(self):
for controller in self.controllers:
controller.update()


class Controller(object):
def __init__(self, model):
self.model = model
self.views = []

def handle_insert(self, value):
self.model.add(value)

def handle_delete(self, index):
self.model.delete(index)

def get_data(self):
return self.model.data()

def update(self):
for view in self.views:
view.update()


class View(object):
def __init__(self, master, controller):
self.controller = controller
self.master = master
self.list = tk.Listbox(self.master)
self.list.pack(expand=1, fill=both)
self.entry = tk.Entry(self.master)
self.entry.pack(fill=x, expand=1)
self.entry.bind(Return, self.enter_handler)
self.list.bind(Delete, self.delete_handler)
self.update()

def enter_handler(self, event):
text = self.entry.get()
self.controller.handle_insert(text)


def delete_handler(self, event):
for index in self.list.curselection():
self.controller.handle_delete(int(index))

def update(self):
self.list.delete(0, end)
for entry in self.controller.get_data():
self.list.insert(end, entry)


def main():
root = tk.Tk()

model = Model()
controller = Controller(model)
view = View(root, controller)

model.controllers.append(controller)
controller.views.append(view)

root.mainloop()

if __name__ == '__main__':
main()
--
http://mail.python.org/mailman/listinfo/python-list


Re: strange results

2011-09-17 Thread Alexander Kapps

On 17.09.2011 01:09, Fig wrote:

I took out all of the color commands that were in the shape functions
and all of the features to the 'draw_house' function showed showed up.
I started putting the color commands back into the shape functions and
have no problems with some of them but when I put the color command
back into others, some of the features start to disappear. As far as I
can see, all of the code is right but I'm just a beginner so I am not
for sure. Can anyone tell me why this is doing what it is.



Just tried your program on Ubuntu 10.04 with Python 2.6.5 and GASP 
0.3.3 and it worked fine. What OS, Python version and GASP version 
are you using?


If you don't get an answer here, try asking on the Launchpad project 
site:


https://launchpad.net/gasp
--
http://mail.python.org/mailman/listinfo/python-list


Re: I think I found 2 undocumented string format codes.

2011-08-24 Thread Alexander Kapps

On 24.08.2011 22:45, Bill wrote:

My google-fu has failed me in finding info on %h and %l string
formatting codes.


'%h' %'hello'

exceptions.ValueError: incomplete format


'%l' %'hello'

exceptions.ValueError: incomplete format

Does anyone know what doing a complete format means?


See

http://docs.python.org/library/stdtypes.html#string-formatting-operations

The formatting codes have been borrowed from the C function 
sprintf(), where l and h are length modifier for integers (%hi, %li, 
...)


The Python docs (link above) say:

A length modifier (h, l, or L) may be present, but is ignored as it 
is not necessary for Python – so e.g. %ld is identical to %d.


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


Re: Linux : create a user if not exists

2011-08-16 Thread Alexander Kapps

On 16.08.2011 16:57, smain kahlouch wrote:

Ok than you. You're right but it doesn't help me :
I replaced it :

  def finduser(user):
... if pwd.getpwnam(user):
... print user, user exists
... return True
... return False
...
  finduser('realuser')
realuser user exists
True
  finduser('blabla')
Traceback (most recent call last):
   File stdin, line 1, in ?
   File stdin, line 2, in finduser
KeyError: 'getpwnam(): name not found: blabla'



Untested:

def finduser(name):
try:
return pwd.getpwnam(name)
except KeyError:
return None

if not finduser(myuser):
print creating user...
else:
print user already exists


Has the advantage that finduser() returns the user details if needed.


(BTW: Please don't top-post)
--
http://mail.python.org/mailman/listinfo/python-list


Re: list comprehension to do os.path.split_all ?

2011-07-29 Thread Alexander Kapps

On 29.07.2011 21:30, Carl Banks wrote:


It's not even fullproof on Unix.

'/home//h1122/bin///ghi/'.split('/')

['','home','','bin','','','ghi','']

The whole point of the os.path functions are to take care of whatever oddities 
there are in the path system.  When you use string manipulation to manipulate 
paths, you bypass all of that and leave yourself open to those oddities, and 
then you find your applications break when a user enters a doubled slash.

So stick to os.path.


Carl Banks


This would also be fixed with normpath() as Dennis Lee Bieber 
suggested. And my solution with list comprehensions handles this too.


Still, there might be other path oddities which would break here. I 
think, that something like a split_all() function should be 
available in the stdlib, no?


Actually, it isn't the first time, where I wonder why 
os.path.split() doesn't do this already. I mean, str.split() doesn't 
only split on the first part, right?

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


Re: list comprehension to do os.path.split_all ?

2011-07-28 Thread Alexander Kapps

On 28.07.2011 22:44, Ian Kelly wrote:

On Thu, Jul 28, 2011 at 2:18 PM, grygeorgeryo...@gmail.com  wrote:

[python 2.7] I have a (linux) pathname that I'd like to split
completely into a list of components, e.g.:
   '/home/gyoung/hacks/pathhack/foo.py'  --['home', 'gyoung',
'hacks', 'pathhack', 'foo.py']

os.path.split gives me a tuple of dirname,basename, but there's no
os.path.split_all function.

I expect I can do this with some simple loop, but I have such faith in
the wonderfulness of list comprehensions, that it seems like there
should be a way to use them for an elegant solution of my problem.
I can't quite work it out.  Any brilliant ideas?   (or other elegant
solutions to the problem?)


path = '/home/gyoung/hacks/pathhack/foo.py'
parts = [part for path, part in iter(lambda: os.path.split(path), ('/', ''))]
parts.reverse()
print parts

But that's horrendously ugly.  Just write a generator with a while
loop or something.



pathname = '/home/gyoung/hacks/pathhack/foo.py'
parts = [part for part in pathname.split(os.path.sep) if part]
print parts

['home', 'gyoung', 'hacks', 'pathhack', 'foo.py']
--
http://mail.python.org/mailman/listinfo/python-list


Re: why the following python program does not face any concurrency problems without synchronize mechanism?

2011-07-09 Thread Alexander Kapps

On 09.07.2011 22:45, smith jack wrote:

from threading import Thread

def calc(start, end):
 total = 0;
 for i in range(start, end + 1):
 total += i;
 print '--result:', total
 return total

t = Thread(target=calc, args=(1,100))
t.start()

I have run this program for many times,and the result is always 5050,
if there is any concurrency problem, the result should not be 5050,
which is never met, anyhow
I mean this program should get the wrong answer at some times, but
this never happens, why?
can concurrency without synchronize mechanism always get the right answer?
any special case in python programming?


Why do you think, that there's a concurrency problem?

All variables are local to the calc() function and all calc() 
invocations run in an own thread. No thread tries to access any 
shared data, so why should there be a concurrency problem?


Concurrency is an issue, when two or more threads/processes try to 
access the same data, but in your program everything is local to the 
calc() function.

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


Re: How can I make a program automatically run once per day?

2011-07-09 Thread Alexander Kapps

On 10.07.2011 02:26, John Salerno wrote:

I have a script that does some stuff that I want to run every day for
maybe a week, or a month. So far I've been good about running it every
night, but is there some way (using Python, of course) that I can make
it automatically run at a set time each night?


Use your operating system's facilities to run timed jobs.

Unix/Linux: Cron jobs
Windows: Scheduled Tasks
Mac: don't know, but probably Cron too
--
http://mail.python.org/mailman/listinfo/python-list


Re: regular expression i'm going crazy

2011-05-16 Thread Alexander Kapps

On 16.05.2011 18:25, Tracubik wrote:

pls help me fixing this:

import re
s = linka la baba
re_s = re.compile(r'(link|l)a' , re.IGNORECASE)

print re_s.findall(s)

output:
['link', 'l']

why?


As the docs say:

If one or more groups are present in the pattern, return a list of 
groups;


http://docs.python.org/library/re.html?highlight=findall#re.findall


i want my re_s to find linka and la, he just find link and l and forget
about the ending a.


Try with non-grouping parentheses:

re_s = re.compile(r'(?:link|l)a' , re.IGNORECASE)
--
http://mail.python.org/mailman/listinfo/python-list


Re: turn monitor off and on

2011-05-14 Thread Alexander Kapps

On 14.05.2011 09:29, harrismh777 wrote:

harrismh777 wrote:


def turnOnMonitor():
SC_MONITORPOWER = 0xF170
win32gui.SendMessage(win32con.HWND_BROADCAST,
win32con.WM_SYSCOMMAND, SC_MONITORPOWER, -1)



Wonder what the equivalent of this is in Linux... ?


Probably xset dpms force {on,off,...}
--
http://mail.python.org/mailman/listinfo/python-list


Re: PyGTK notebook: get current page

2011-05-07 Thread Alexander Kapps

On 07.05.2011 17:04, Tracubik wrote:

Hi all!
I've made a simple PyGTK program.
It's a window with a notebook, the notebook have 2 pages
When changing page, i'ld like to get the id of current page.

I've coded it, but i can get only the previously open page, not the
current one. This is not a big deal if i have only 2 pages, but it could
be with 3 or more pages.

Here's the code:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

# template di finestra in pyGTK

import pygtk
pygtk.require('2.0')
import gtk

class FinestraGTK:

 def pippo(self, widget, event, data=None):
 print current page:  + str(self.nb.get_current_page() )


According to PyGTK docs, the event handler for the switch_page 
signal should look like this:


def pippo(self, notebook, page, page_num, user_data=None):
...

With this method you get the new page number in page_num (or in your 
original method with the misleadingly named data argument)



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


Re: [OT] Disable creation of pyc files in DrPython

2011-04-20 Thread Alexander Kapps

On 20.04.2011 15:21, craf wrote:

Hi.

I wonder if anyone uses Python DrPython as editor.
I need to know if you can disable the creation of
Pyc files created by the program. In the Geany editor you can
add the parameter -B, but not if it can in this editor.


I don't know DrPython, but Python itself checks for the 
$PYTHONDONTWRITEBYTECODE environment variable. Perhaps you can run 
DrPython with a command like:


PYTHONDONTWRITEBYTECODE=1 drpython


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


Re: ipython: Multiple commands on the same line and newlines

2011-04-17 Thread Alexander Kapps

On 17.04.2011 20:40, Phil Winder wrote:

Ok, thanks all. It's a little disappointing, but I guess that you
always have to work in a different way when you move to a new
language. Andrea's %edit method is probably the best compromise, but
this now means that I will have to learn all the (obscure) shortcuts
for vi!


As you can read in Python IDE/text-editor thread. Learning either 
Vim or Emacs will pay off in the long run,


Anyway, IPython honors the $EDITOR environment variable. Just set it 
to whatever editor you prefer.


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


Re: Incompatible _sqlite3.so

2011-03-27 Thread Alexander Kapps

On 27.03.2011 23:24, Tim Johnson wrote:

I have python 2.6.5 on my main workstation with ubuntu 10.04. I am
attempting to set up a temporary test platform on an asus netbook
with slax running from an SD card. I have installed a python 2.7
module on the slax OS. (I can't find a python 2.6.5 module for
slax). For those who don't know, slax is a pocket OS and is very
limited. In the original slax install with python 2.7, there is not
_sqlite3.so available. I copied _sqlite3.so from my workstation and
I am getting the following error message:
... undefined symbol: PyUnicodeUCS4_DecodeUTF8.

I suspect that this is a version problem. I'd like to try
_sqlite3.so for python 2.7 (32-bit). If anyone has one or can tell
me where get one, I would appreciate it. I am reluctant to install
2.7 on my workstation right now.

thanks


Slax is a very modular and flexible pocket OS/Live distro. It's 
everything but limited .There are many additional modules available.


Python 2.6:
http://www.slax.org/modules.php?action=detailid=3118

Several sqlite related packages, you probably need one of the 
pysqlite modules:

http://www.slax.org/modules.php?search=sqlitecategory=

Finally, it's quite easy to build your own Slax modules:
http://www.slax.org/documentation_create_modules.php


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


Re: Incompatible _sqlite3.so

2011-03-27 Thread Alexander Kapps

On 28.03.2011 00:21, Tim Johnson wrote:


Python 2.6:
http://www.slax.org/modules.php?action=detailid=3118


  That module is *not* trusted. See the warning?


It's just not verified by the Slax developers. That doesn't mean 
it's not trusted. It's the same as with Ubuntu packages from the 
Universe repo, or Firefox plugins which haven't been verified by the 
Mozilla team. None of them should be used where security matters, 
but on a testing system, the danger should be rather low.


If you limit yourself to strictly distro developer approved packages 
than I fear it's going to be hard to find one.


If all else fails, you could probably use the _sqlite3.so from 
another distro which has Python 2.7 officially.



  quickest would be the so file itself, maybe from the slack site or
  if someone has one they can send me.


You don't trust an unverified package from the Slax site, but you 
would trust some other stranger on the python-list, to not give you 
a manipulated .so? You're either too paranoid or not paranoid enough ;-)

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


Re: install excel xlwt in ubuntu 9

2011-03-19 Thread Alexander Kapps

On 19.03.2011 07:29, ratna PB wrote:

Hey friends i tried a lot to install excel xlwt in ubuntu 9 but
failed
please help me before i get full fraustrated...


What have you tried and how did it failed?

On 9.10, simply do (you might need to enable the universe repository 
in Synaptic first):


$ sudo apt-get install python-xlwt

Alternatively, install python-setuptools and then use easy_install:

$ sudo apt-get install python-setuptools
$ sudo easy_install xlwt
--
http://mail.python.org/mailman/listinfo/python-list


Re: class error

2011-03-18 Thread Alexander Kapps

On 18.03.2011 21:13, monkeys paw wrote:

I have the following file:

FileInfo.py:

import UserDict


After this import statement, the name UserDict refers to the module.


class FileInfo(UserDict):


Here you are trying to subclass the module. What you need instead is:

class FileInfo(UserDict.UserDict):

Alternatively, import the UserDict class from the UserDict module 
like so:


from UserDict import UserDict

Note, that the UserDict class is obsolete, you can subclass the dict 
type directly:


class FileInfo(dict):
store file metadata
def __init__(self, filename=None):
dict.__init__(self)
self[name] = filename
--
http://mail.python.org/mailman/listinfo/python-list


Re: Reading/Writing files

2011-03-18 Thread Alexander Kapps

On 18.03.2011 22:33, Jon Herman wrote:

Hello all,

I am pretty new to Python and am trying to write data to a file. However, I
seem to be misunderstanding how to do so. For starters, I'm not even sure
where Python is looking for these files or storing them. The directories I
have added to my PYTHONPATH variable (where I import modules from
succesfully) does not appear to be it.

So my question is: How do I tell Python where to look for opening files, and
where to store new files?

Thanks,

Jon





There is no special place where Python looks for normal files 
(PYTHONPATH is just tells where to look for modules.)


If you open a file (for reading and/or writing) and don't give an 
absolute path, then the filename is relative to the CWD (Current 
Working Directory). One can change this directory with os.chdir() 
*but* you shouldn't need to do that. Either start Python in the 
desired directory (your operating system will have a way to do this 
for icons and menu entries) or give an absolute path like:


f = open(/home/alex/test.txt)
f = open(c:/test.txt)

Also check out os.environ, a dict containing the environment 
variables. There you will find variables like $HOME or %USERPROFILE% 
(if that's correct) which tells where your personal files are:


import os

# my home directory is /home/alex
homedir = os.environ[HOME]

# creates the file /home/alex/test.txt
f = open(os.path.join(homedir, test.txt))
--
http://mail.python.org/mailman/listinfo/python-list


Re: os.path.walk() to get full path of all files

2011-03-16 Thread Alexander Kapps

On 16.03.2011 20:41, dude wrote:

My goal is create a list of absolute paths for all files in a given
directory (any number of levels deep).

root
dir1
file1
file2
dir2
file3
dir3
-dir4
--file4
file5

So the above would return:
[root/dir1/file1, root/dir1/file2, root/dir1/dir2/file3, etc...]

I've been trying different ways of using os.path.walk() for that, but
I can't find an elegant way.  Anyone know of something simple to
accomplish that?


Try this:

file_list = []
for root, _, filenames in os.walk(root_path):
for filename in filenames:
file_list.append(os.path.join(root, filename))

for x in file_list:
print x
--
http://mail.python.org/mailman/listinfo/python-list


Re: OT: processes, terminals and file descriptors on *nix

2011-03-16 Thread Alexander Kapps

On 13.03.2011 01:50, Nobody wrote:


I don't have any links. If you want to understand the core Unix API, the
best reference I know of is Stevens (Advanced Programming in the Unix
Environment, by W. Richard Stevens). Unfortunately, it's not cheap.

In spite of the title, it doesn't assume any prior Unix knowledge; the
Advanced mainly refers to the fact that it's the opposite of the Learn
X in Five Minutes books, i.e. it's thorough. That's how it comes to700
pages while only covering the core API (files, processes, and terminals;
no sockets, no X, no I18N, ...).



Thanks, Nobody and Dan. I'll have a look at the book.
--
http://mail.python.org/mailman/listinfo/python-list


Re: os.path.walk() to get full path of all files

2011-03-16 Thread Alexander Kapps

On 16.03.2011 22:00, dude wrote:

awesome, that worked.  I'm not sure how the magic is working with your 
underscores there, but it's doing what I need.  thanks.


The underscore is no magic here. It's just a conventional variable 
name, saying I m unused. One could also write:


for root, UNUSED, filenames in os.walk(root_path):
   ...


BTW. Please quote enough of the posts you reply to. Most people 
access this list/newsgroup per mail client or usenet reader, not per 
a webpage, so without quoting, they might not see the context of our 
post. Thank you.

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


OT: processes, terminals and file descriptors on *nix (was: Re: attach to process by pid?)

2011-03-11 Thread Alexander Kapps

On 11.03.2011 03:18, Nobody wrote:

On Thu, 10 Mar 2011 23:55:51 +0100, Alexander Kapps wrote:


I think he wants to attach to another process's stdin/stdout and
read/write from/to them.
I don't know if this is possible but it would be a great addition for
psutil.


It's not even a meaningful concept, let alone possible.


Unless I misunderstand something,


You do ...


Many thanks for the correction and lesson (to Grand Edwards too)!

I still try to digest your explanations. I thought, that processes 
just do something like dup()'ing the file descriptors of their 
terminal but after some strace experiments, I think that is totally 
wrong.


I'd like to learn more about this (how processes, their controlling 
terminals and the std file descriptors relate)


Do you know any links to deeper material (tried Google but what I've 
found is to shallow)

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


Re: Tk MouseWheel Support

2011-03-10 Thread Alexander Kapps

On 10.03.2011 21:28, Richard Holmes wrote:

I am trying to use the mouse wheel to scroll a list box, but I'm not
getting the event. When I bind Button-1 to the listbox I get the
event and I'm able to scroll using yview_scroll. I've tried binding
MouseWheel andMouseWheel, and I've also triedButton-4 and
Button-5 even though I'm using Windows (XP, if that makes a
difference). None of these works (I'm using print to see if I got to
an event handler, and there's no printout).

TIA for any help!

Dick


Can you post your code please (if it's too long, strip it down to 
the smallest program which still shows the problem.)


On Ubuntu 10.04, Python 2.6.5, the Listbox already recognizes the 
mouse wheel. Listbox aside, the following works here:



import Tkinter as tk

def wheel_up(event):
print wheel_up, event

def wheel_down(event):
print wheel_down, event

root = tk.Tk()
root.bind(Button-4, wheel_up)
root.bind(Button-5, wheel_down)
root.mainloop()
--
http://mail.python.org/mailman/listinfo/python-list


Re: attach to process by pid?

2011-03-10 Thread Alexander Kapps

On 10.03.2011 23:25, Nobody wrote:

On Thu, 10 Mar 2011 20:22:11 +0100, Giampaolo Rodolà wrote:


I think he wants to attach to another process's stdin/stdout and
read/write from/to them.
I don't know if this is possible but it would be a great addition for psutil.


It's not even a meaningful concept, let alone possible.


Unless I misunderstand something, it is possible (at least on Linux):

Two terminal windows:

1:
alex@frittenbude:~$ grep foobar

2:
alex@frittenbude:~$ ps ax|grep 'grep foobar'
13075 pts/4S+ 0:00 grep --color=auto grep foobar
alex@frittenbude:~$ echo foobar  /proc/13075/fd/0

That this is *highly* system dependent, problematic in many regards 
and just terrible hackery is another issue.


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


Re: Python Tutorial on Multithreading

2011-02-21 Thread Alexander Kapps

On 21.02.2011 23:30, KevinSimonson wrote:

I've been teaching myself Python from the tutorial routed at http://
www.tutorialspoint.com/python/index.htm.  It's worked out pretty
well, but when I copied its multithreading example from the bottom of
the page at http://www.tutorialspoint.com/python/
python_multithreading.htm and tried to run it I got the error
messages:

C:\Users\kvnsmnsn\Pythonpython mt.py
Traceback (most recent call last):
   File mt.py, line 38, inmodule
 thread = myThread(threadID, tName, workQueue)
   File mt.py, line 10, in __init__
 self.name = name
   File C:\Python27\lib\threading.py, line 667, in name
 assert self.__initialized, Thread.__init__() not called
AssertionError: Thread.__init__() not called

I don't really understand why it's giving me these messages.
__initialized  gets set toTrue  when__init__()  gets called.
Granted my Python program calls__init__()  with only one parameter,
and the constructor in threading.py takes _seven_ parameters, but
all but one have default values, so a call with just one parameter
should be legal.  Why then is__initialized  getting set toTrue?

My code follows.


That tutorial seems to be wrong.

According to the official docs:

If the subclass overrides the constructor, it must make sure to 
invoke the base class constructor (Thread.__init__()) before doing 
anything else to the thread.


http://docs.python.org/library/threading.html#thread-objects

So, change your __init__ to this:

class myThread (threading.Thread):
def __init__(self, threadID, name, q):
threading.Thread.__init__(self)
self.threadID = threadID
self.name = name
self.q = q


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


Re: Problems of Symbol Congestion in Computer Languages

2011-02-21 Thread Alexander Kapps

On 22.02.2011 00:34, Westley Martínez wrote:

On Mon, 2011-02-21 at 11:28 -0800, rantingrick wrote:



The ascii char i would suffice. However some languages fell it
necessary to create an ongoing tutorial of the language. Sure French
and Latin can sound pretty, however if all you seek is pretty
music then listen to music. Language should be for communication and
nothing more.

Nicely said; you're absolutely right.


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


(Babbling Rick is just an Orwellian Nightmare, try to ignore him)

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


Re: Archiving Modules

2011-02-18 Thread Alexander Kapps

On 18.02.2011 19:51, Westley Martínez wrote:

On Fri, 2011-02-18 at 04:55 -0800, peter wrote:

On Feb 17, 9:55 pm, Jorgen Grahngrahn+n...@snipabacken.se  wrote:



RAR is a proprietary format, which complicates things. For example,
Linux distributions like Debian cannot distribute software which
handles it.  If Python included such a module, they'd be forced to
remove it from their version.


Good point, and one that I did not appreciate.  But there are freeware
applications such as jzip (http://www.jzip.com) which can handle .rar
files, so there must be a way round it.


I wouldn't encourage its use by writing /more/ software which handles
it. IMHO, archives should be widely readable forever, and to be that
they need to be in a widely used, open format.


I agree, but if a file is only available as a rar archive I would like
to be able to extract it without using another 3rd party application.

peter

Freeware is still proprietary software.


While I agree with the general refusal of .rar or other non-free 
archive formats, a useful archiving tool should still be able to 
extract them. Creating them is an other issue.


There is a free (open source) un-rar for Linux which AFAIK can at 
least handle .rar archives below v3.


HTH

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


Re: Best way to gain root privileges

2011-02-18 Thread Alexander Kapps

On 18.02.2011 15:22, Adam Skutt wrote:

On Feb 18, 9:04 am, Ricardo Aráozricar...@gmail.com  wrote:


Many a time I have wanted to allow access to certain privileges to a user but 
*only*
through a program. As far as security is concerned it would be enough
that only root has permission to give the said program running
privileges (privileges different from those of the user that is actually
running it), that only allowed users may modify the program, and that
*other* users may only run it. This would address the issue of someone
modifying the program to gain access to it's privileges. Now, if someone
is able to gain illegal privileges to modify the program, then there
*is* a security hole and the program is not really the problem.


sudo already does this to a limited degree.  If you want more
granularity than sudo, you're looking at mandatory access controls.

Adam



IIUC, than SELinux can also help, since it allows program-specific 
permissions. But I could easily be wrong here since I have yet to 
really learn SElinux.


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


Re: Best way to gain root privileges

2011-02-18 Thread Alexander Kapps

On 18.02.2011 15:42, GSO wrote:


I note that policykit was created by redhat, and that RHEL6 does not
include gksudo in with its gnome for some odd reason.


Don't know if this helps you, but at least for CentOS 5.4, gksudo is 
available in the gksu package from rpmforge.

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


Re: Best way to gain root privileges

2011-02-16 Thread Alexander Kapps

On 16.02.2011 23:02, Ian Kelly wrote:

On Wed, Feb 16, 2011 at 2:29 PM, Daniel Mahoneycatd...@gmail.com  wrote:

On Wed, 16 Feb 2011 21:26:26 +, GSO wrote:


I'm sure this question is as old as time, but what is the best way to
gain root privileges?  (Am using Python 2.6.5, pygtk2 v2.16, Gtk
v2.18.9, on RHEL6.)


Gain root privileges for a script? Write a c wrapper to call the script,
chown it (the wrapper) to root, and set it (the wrapper) suid.


Or for better security, write a shell script that execs the Python
script via sudo.



This is what I occasionally use (in a non security critical 
environment anyway):


#!/bin/sh

SUDO=gksudo
[ -z $DISPLAY ]  SUDO=sudo
[ $(id -u) != 0 ]  exec $SUDO $0 $@

# your_root_privileges_requiring_commands_here


Don't ask me for any security issues. Properly setting up a 
dedicated user group and grant dedicated sudo privileges is probably 
a better way.



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


Re: Best way to gain root privileges

2011-02-16 Thread Alexander Kapps

On 17.02.2011 01:00, GSO wrote:

OK, thanks for the tips.

gksu* does not seem to be included with RHEL6 Desktop (though there is
a package called beesu)


On RHEL try consolehelper/userhelper instead which need additional 
configuration.



The philosophy at the end of the day I think
is do your own thing so a hacker cannot download the code you used.


Nonsense. :-)
Real crackers don't need to download your source and home-brewed 
solutions are almost always the wrong solution for security issues 
(compare: better write your own cryptographic algorithm or use 
existing ones, even those who are open source?)


If public accessible source code would be a security risk, then 
Linux would be *the* most vulnerable OS ever.


Anyway, if you're really that much concerned about security, than 
drop the whole idea and do not let non-admins perform that job. Or, 
see if SElinux can help.



Having said that I'm possibly arriving at the conclusion that a quick
perl script might be the simplest/easiest and most secure option - I
read perl includes code to safely run suid perl scripts - will dig out
my perl tomes.


Not sure, but Perl is just another scripting language (hate that 
term) and you cannot have scripts be SUID.


I have almost no experiences with Perl, but I really doubt, that the 
general problem would be solved with it.


Perhaps explaining your exact situation would help finding a fitting 
solution.



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


Re: file find skips first letter

2011-02-15 Thread Alexander Kapps

On 15.02.2011 19:32, Wanderer wrote:

I'm using code

 def getFiles(self, fileBase):
 return a list of the filenames in a director containing a
base word
 

 allFiles = os.listdir(self.resultDir)
 baseFiles = []
 for f in allFiles:
 if f.find(fileBase)  0:
 baseFiles.append(f)

 return baseFiles

but the code can't find files with fileBase in it if the fileBase
starts the filename.

if the filenames are rnoise##.tif and fileBase is rnoise the file
won't be found. If fileBase is noise the files will be found.


str.find() returns the index to the left-most occurrence or -1 if 
the substring is not found. So, if the file name starts with 
fileBase, find() return 0 which you filter out with your test 
f.find(fileBase) 0.


Either use f.find(fileBase) = 0 or better:

baseFiles = []
for f in allFiles:
if fileBase in f:
baseFiles.append(f)


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


Re: newbie question about PYTHONPATH

2011-02-15 Thread Alexander Kapps

On 15.02.2011 19:12, Panupat Chongstitwattana wrote:

Panupat, please don't top-post, it messes the the natural order of 
the discussion. Thanks.



I think the command line should look something along this line

export PYTHONPATH=$HOME/foo/prog/learning_python/:

with a colon at the end.


Nope, the colon is only needed as a delimiter if you give more than 
one file.



On Wed, Feb 16, 2011 at 12:49 AM, Tim Hansontjhan...@yahoo.com  wrote:

I am to the point in _Learning_Python_  where functions are introduced.

I decided to experiment by putting a function into  a file and importing it
into Idle.  Of course, Idle couldn't find it, so I executed the following
command in Bash:

PYTHONPATH=/home/foo/prog/learning_python
export PYTHONPATH
env | grep PYTHONPATH

~$PYTHONPATH=/home/foo/prog/learning_python

Idle still won't find it.  I'm doing something wrong?


$ export PYTHONPATH=~/src/python/
$ idle

works fine here. Where are you setting PYTHONPATH and from where do 
you run idle? If you set it in a terminal window, but run idle from 
a Desktop menu it won't work as exporting environment variables does 
only affect sub-processes. You might want to set PYTHONPATH in your 
~/.bash_profile and then re-login.


Also, how do you name your file? A Python module must end in .py


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


Re: How to create an entry in the Program menu of Windows?

2011-02-01 Thread Alexander Kapps

On 01.02.2011 22:43, Diesel wrote:


Hi,

I'd like to add menu entry in the Program Menu as part of the
installation of an application. Is it possible to do that from Python?

Any examples or link? I have not been able to find anything with
google...

thanks in advance
s/



AFAIK, the startmenu entries are just .lnk files, placed either in 
the All Users or Some Specific User Startmenu directory. I only 
have a German XP and can't boot it to test at the moment, so I can't 
give more details, but there are surely registry entries to find the 
Startmenu location for the current user or for All Users.


See http://codesnippets.joyent.com/posts/show/529 for an example how 
to place .lnk files. However, for real deployment, you probably want 
to use a real installer framework like NSIS for example.


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


Re: WxPython versus Tkinter.

2011-01-27 Thread Alexander Kapps

On 27.01.2011 19:33, rantingrick wrote:


Please don't use the lower accessibility percentage to prop up the low
Linux percentage in an attempt to win your argument. Because healthy
Linux users ARE NOT equal to handicapped people!


Please don't put words into my mouth, idiot. And read my complete 
post. Nobody compares Linux users with handicapped people. I 
equalize handicapped Linux users with handicapped Windows users. And 
like it or not, the number of Linux users (handicapped or not) is 
raising. Again read my complete post.



And let's just get to the real point of this statement... This
argument stems from me saying that Lunux users should stop complaining
about downloading gtk to use wxPython because they use a non-hand-
holding OS.


Another example of your limited understanding. Do you really believe 
the problem lies in downloading dependencies? Hasn't somebody 
already explained that it's about development dependencies?



And now you attempt to compare yourself to handicapped
people in a veiled way so we feel sorry for you? Well it worked! I DO
feel sorry for you. Congratulations!


I'm entirely sure that you deliberately misunderstood me and now try 
to discredit me with putting this nonsense into my mouth.


You are really a sad, disgusting asshole. Don't bother replying. I 
won't read. (How many more plonks will it take till you consider 
changing your behaviour?)


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


Re: WxPython versus Tkinter.

2011-01-26 Thread Alexander Kapps

On 26.01.2011 18:04, Octavian Rasnita wrote:

From: Littlefield, Tylerty...@tysdomain.com

with JAWS because it is the most used screen reader.

Get off your me soapbox. Jaws is not the most used. NVDA is taking over,
quite fast, and lots of people have totally switched to mac or Vinux


Lots of people means an insignifiant percent of users compared with the percent 
of Windows users.


Please don't use the lower Linux user percentage as an argument 
here. If you follow that path further, you would need to agree that 
it's only an insignificant percent of people who need a screen 
reader, so why bother?


Note carefully: I am *not* saying that one shouldn't bother about 
the minority of people who need accessibility, just that you can't 
use an argument that ignores another minority (Linux user) if you 
fight for your minority (and no, Linux isn't anymore a freak-os. 
Several countries (getting more) have started to migrate 
governmental IT infrastructures to Linux, so if you mean it serious, 
you just need to care for their, possibly impaired, workers too.)



(Also please don't weigh my words to strong; I'm no native english 
speaker and my wording might be clumsy. Try to understand what I 
really wanted to say or ask back.)

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


Re: Return Statement

2011-01-26 Thread Alexander Kapps

On 26.01.2011 21:26, sl33k_ wrote:

How does return True and return False affect the execution of the
calling function?


If only affects the calling function if you use the return value:

def foo():
return True

def bar1():
foo() # nothing difference, whether foo() returns True or False

def bar2()
  if foo():
  print foo returned True or any other non-false value
  else:
  print foo returned False or any other non-True value
--
http://mail.python.org/mailman/listinfo/python-list


Re: WxPython versus Tkinter.

2011-01-24 Thread Alexander Kapps

There are two completely different issues here:

1. Tyler's/Octavian's very valid (but AFAICT now somewhat 
over-expressed) point that Tk/Tkinter isn't accessible.


I accept this, but don't see any point against Tk(inter) in this per 
se. Tk(inter) could be advanced to support screen readers and such.


2. RR's aggressive, insulting, self-praising war against Tk(inter) 
(which, IIRC, he ones praised)


I *really* don't understand why RR gets so much attention. He has 
(massively!) insulted everybody around, has shown his low knowledge 
and understanding, his selfish and arrogant behaviour, etc.


As I see it, please don't fall trap when RR now supports the 
accessible issue. I'm quite sure, that he just misuses that.




Now that Godwin has been called, let me say also this:

Check some earlier posts of RR (especially unicode related, but also 
his whole command structure, leader, one for all, etc stuff) 
and it should be clear who is the izan. (*)



Wake me, if RR is chased out of town and we can start a real 
discussion about the future of Python GUIs and accessibility.




(*)
I'm German and I just *KNOW* what to think about people who accuse 
random opponents as aniz. Our politicians do that quite regularly 
and the *ONLY* aim behind this is plain and simply to discredit the 
opponent when the arguments run out.

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


Re: Short circuting

2011-01-21 Thread Alexander Kapps

On 22.01.2011 00:33, Ed Connell wrote:

Hi,

Consider the following please:  (re_section, re_name, etc are
previously compiled patterns)

result1 = re_section.search(line);
result2 = re_name.search(line);
result3 = re_data1.search(line);
result4 = re_data2.search(line);

if result1:
last_section = result1.group()[18:-5]
elif result2:
last_name = result2.group(0)[6:-1]
elif result3:
data[last_section] = {last_name:
result3.group()[13:-5]}
elif result4:
data[last_section] = {last_name:
result4.group()[17:-5]}

It gets my goat to have to obtain all resultx when I just want the
first that is not None.  (In theory, the number of results can be
much longer.)  I can think of alternatives (raising exceptions), but
they all use deep indenting.

Ideas?

Ed




Maybe something like this (totally untested and probably wrong, I'm 
already quite tired):



for pattern in (re_section, re_name, re_data1, re_data2):
result = pattern.search(line):
if result:
if pattern == re_section:
last_section = result1.group()[18:-5]
elif pattern == re_name:
last_name = result2.group(0)[6:-1]
elif pattern == re_data1:
data[last_section] = {last_name: result3.group()[13:-5]}
elif pattern == re_data2:
data[last_section] = {last_name: result4.group()[17:-5]}


Also, if you have long if/elif ladders, look if you can apply the 
dictionary dispatch pattern.

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


Re: Short circuting

2011-01-21 Thread Alexander Kapps

On 22.01.2011 01:10, Alexander Kapps wrote:

On 22.01.2011 00:33, Ed Connell wrote:

Hi,

Consider the following please: (re_section, re_name, etc are
previously compiled patterns)

result1 = re_section.search(line);
result2 = re_name.search(line);
result3 = re_data1.search(line);
result4 = re_data2.search(line);

if result1:
last_section = result1.group()[18:-5]
elif result2:
last_name = result2.group(0)[6:-1]
elif result3:
data[last_section] = {last_name:
result3.group()[13:-5]}
elif result4:
data[last_section] = {last_name:
result4.group()[17:-5]}

It gets my goat to have to obtain all resultx when I just want the
first that is not None. (In theory, the number of results can be
much longer.) I can think of alternatives (raising exceptions), but
they all use deep indenting.

Ideas?

Ed




Maybe something like this (totally untested and probably wrong, I'm
already quite tired):


for pattern in (re_section, re_name, re_data1, re_data2):
result = pattern.search(line):
if result:
if pattern == re_section:
last_section = result1.group()[18:-5]
elif pattern == re_name:
last_name = result2.group(0)[6:-1]
elif pattern == re_data1:
data[last_section] = {last_name: result3.group()[13:-5]}
elif pattern == re_data2:
data[last_section] = {last_name: result4.group()[17:-5]}


Also, if you have long if/elif ladders, look if you can apply the
dictionary dispatch pattern.


Correction. Of course you need to break out of the loop as soon as a 
not None result is found:


if result:
if pattern == re_section:
last_section = result1.group()[18:-5]
...
break
...
--
http://mail.python.org/mailman/listinfo/python-list


Re: Tkinter: The good, the bad, and the ugly!

2011-01-18 Thread Alexander Kapps

On 18.01.2011 09:58, Octavian Rasnita wrote:
 From: Alexander Kapps alex.ka...@web.de
 On 17.01.2011 21:04, Octavian Rasnita wrote:
 I say probably not considering the availability of 3rd party
 downloads. What say you, Python community?

 Available as 3rd party downloads:

 XML,HTML,...
 HTTP,FTP,SMTP,POP,IMAP/...
 MD5,SHA,...
 zip,bzip,...

 and so on and so on and so on.

 Remove them all just because they are available as 3rd party
 downloads?

 No, they should not be removed because they don't cause any damage,
 very bad damage as Tkinter does.


Tkinter causes damage? Very bad damage? What are you talking about?

 The Batteries included of Python is just *great* and I vote for
 *more* not less batteries!

 Well, in that case, why don't you agree to also include WxPython in
 the Python package?

Well, I don't like wx that much and others have already highlighted 
some of the problems with it. I think that adding redundancy is bad 
and I really want a GUI toolkit that makes it easy to quickly write 
a simple GUI, so I do not want wx to replace Tkinter. But yes, I 
wouldn't mind the inclusion of a large GUI package.


 And one more thing. Not all the Python programmers create desktop
 apps so a GUI lib is useless. Some of them use Python only for
 web programming or only for system administration.

 Not all Python programmers do web programming, so please remove
 the useless HTML junk too.

 Why do you call it html junk?

You said a GUI lib is useless because not all programmers write 
GUIs. so I say an HTML lib is useless because not all programmers 
write web stuff. Got it? Both are useful and I'm absolutely against 
any attempt to remove either from the stdlib. *That* would cause damage.


 Almost every beginner wants to do GUIs or at least some graphic
 stuff. Removing the GUI module from the stdlib would be plain
 wrong IMHO. But I don't understand the whole issue anyway. It
 isn't that you need to fire up your torrent client and wait 48
 hours for the Python download to complete. Why remove useful (to
 many, not most) stuff from the lib?

 Yes it can be useful for some people, but why promote it instead of
 promoting a better library for beginners?

Which one? That's the whole point. There currently is no better GUI 
lib than Tkinter which allows quick and easy GUI programming and 
still has a large widget set, is pythonic and so on. PyGUI might be 
in the future. If you care that much go on and help making it happen.


I have absolutely no problem with a better GUI lib, I just don't 
care much and those who seem to care enough to start a war over and 
over again seem to be unwilling to really do anything.


 Octavian


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


Re: Tkinter: The good, the bad, and the ugly!

2011-01-18 Thread Alexander Kapps

On 18.01.2011 21:23, Octavian Rasnita wrote:

From: Alexander Kappsalex.ka...@web.de

Tkinter causes damage? Very bad damage? What are you talking about?


I am talking about the fact that Python promotes Tkinter, and many beginners 
will start using it, and they will start creating applications with it, and 
they will learn to use it better than WxPython, and they will start believing 
that Tkinter is better because it is easier to use than WxPython, so they will 
start convincing others that Tkinter is the best, and they will start finding 
many reasons that show that Tkinter is better. And after this, they will say 
that they don't care about the real problems generated by GUIs like Tk.
And a very big problem is that the applications that use Tk/GTK are not 
accessible for screen readers, so those applications will be just blank for 
people with visual impairments which need to use a screen reader.

Those applications won't be less nice, or just a little harder to use. They 
won't be accessible at all and they will help the discrimination of the blind 
people, and not because of technical problems, because those problems can be 
solved with a better interface like Wx, which is not perfectly accessible 
either, but it is much better. That discrimination appears just because some 
people say that they don't care.


Well, I don't like wx that much and others have already highlighted
some of the problems with it. I think that adding redundancy is bad


It is a redundancy for you, but have you imagined that for some people the 
display is the redundant part of the computer?


I was talking about redundancy as in duplication of already existing 
parts. However, for some people, networking is superfluous. That's 
not a reason to remove the networking modules from the stdlib.


Anyway, If you think duplicating functionality is a good approach 
here, go on, I don't mind. Just remember to stop somewhen and don't 
include 10 GUI toolkits and 20 HTML parsers just because some people 
don't like the already existing ones.



You said a GUI lib is useless because not all programmers write
GUIs. so I say an HTML lib is useless because not all programmers
write web stuff. Got it? Both are useful and I'm absolutely against
any attempt to remove either from the stdlib. *That* would cause damage.


I didn't say that a GUI lib is useless. The GUIS that create discrimination by 
offering access only for some users (when there are other GUIS that can offer 
access to everyone) create damage and they should be avoided, and for avoiding 
them, the beginners need to understand this. But Python promotes that bad GUI 
lib by including it in the default package instead of promoting a better lib.


Please read your previous post. Anyway *which* GUI offers access to 
everyone?



Which one? That's the whole point. There currently is no better GUI
lib than Tkinter which allows quick and easy GUI programming and


Are you a beginner? A good programmer is not interested only to create an 
application with 10 lines of code, no matter the results.


I'm neither a beginner, nor really a professional programmer. I 
occasionally do paid coding and that often includes small tools and 
helper utilities and one thing I can tell you: In approx 90% of 
those cases, people want a GUI. It hasn't to be fancy, they just 
don't want no command line tools.


Tkinter is just great for quickly hacking together a GUI or for 
prototyping if somebody wants something more advanced.



The application need to have a good quality and to be accessible by everyone if 
the technology allows it.
Why do we like the portable GUIS and don't really like the native interfaces 
that don't work on other platforms?
Because we want our programs to be usable by as many people as possible. Well, some 
platforms render the output as sound and Tkinter are not portable on those 
platforms (screen readers).


I have absolutely no problem with a better GUI lib, I just don't care


Well, I was sure that you are one of those who don't care...


You make that sound as if I should feel guilty now.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Tkinter: The good, the bad, and the ugly!

2011-01-17 Thread Alexander Kapps

On 17.01.2011 21:04, Octavian Rasnita wrote:

I say probably not considering the availability of 3rd party
downloads. What say you, Python community?


Available as 3rd party downloads:

XML,HTML,...
HTTP,FTP,SMTP,POP,IMAP/...
MD5,SHA,...
zip,bzip,...

and so on and so on and so on.

Remove them all just because they are available as 3rd party downloads?

The Batteries included of Python is just *great* and I vote for 
*more* not less batteries!



And one more thing. Not all the Python programmers create desktop apps so a GUI 
lib is useless. Some of them use Python only for web programming or only for 
system administration.


Not all Python programmers do web programming, so please remove the 
useless HTML junk too.



Almost every beginner wants to do GUIs or at least some graphic 
stuff. Removing the GUI module from the stdlib would be plain wrong 
IMHO. But I don't understand the whole issue anyway. It isn't that 
you need to fire up your torrent client and wait 48 hours for the 
Python download to complete. Why remove useful (to many, not most) 
stuff from the lib?

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


Re: UTF-8 question from Dive into Python 3

2011-01-17 Thread Alexander Kapps

On 17.01.2011 23:19, carlo wrote:


Is it true UTF-8 does not have any big-endian/little-endian issue
because of its encoding method? And if it is true, why Mark (and
everyone does) writes about UTF-8 with and without BOM some chapters
later? What would be the BOM purpose then?


Can't answer your other questions, but the UTF-8 BOM is simply a 
marker saying This is a UTF-8 text file, not an ASCII text file


If I'm not wrong, this was a Microsoft invention and surely one of 
their brightest ideas. I really wish, that this had been done for 
ANSI some decades ago. Determining the encoding for text files is 
hard to impossible because such a mark was never introduced.

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


Re: Tkinter: The good, the bad, and the ugly!

2010-12-29 Thread Alexander Kapps

On 30.12.2010 00:58, rantingrick preached:


Tkinter: The good, the bad, and the ugly!
-
An expose by rantingrick


You are seriously starting to sound like Xah Lee.



our beloved dictator (Mr. Van Rossum) had the foresight to include a simplistic 
GUI toolkit that we call Tkinter
into the stdlib. And he saw that it was great, and that it was good, and so he 
rested.


For a technocrat (and that's an insult, in my book), you have a 
really annoying bible-style type of speech (or do you just play too 
much WoW?).


Would you please stop to consider your own, what 4 or 5, years of 
programming experience to be enough to judge on such reasons?


Some thought-food for you: What other GUI toolkit even just *could* 
had been included by Pan, Jesus, Mohammed, Budda, or God herself? 
(it's *your* wording that makes me include such names)




The answer is simple. We need a 100% Python GUI.


How many times did you say that now? Have you done anything to 
archive that goal? Have you even tried to support existing projects? 
I'm going to bet my right arm, that you haven't.



Then and only then will Python be truly what GvR intended.


I must admit, you keep true with yourself and even advance on that. 
Now you not only claim to speech for the whole Python community, but 
for Guide himself.


Sorry, but how megalomaniac are you?

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


Re: stuck with Pexpect script need help!!

2010-12-12 Thread Alexander Kapps

On 12.12.2010 17:06, Emile van Sebille wrote:

On 12/10/2010 10:02 PM Darshak Bavishi said...
snip

Pexpect is intended for UNIX-like operating systems.)

snip


Can we use pexpect from windows host machine ?!



I expect not...

Emile



According to [1] you might get it working with the Cygwin port of 
Python. Alternatively try WinPexpect [2]


[1] http://www.noah.org/wiki/Pexpect#Python
[2] http://bitbucket.org/geertj/winpexpect/wiki/Home
--
http://mail.python.org/mailman/listinfo/python-list


Re: python-parser running Beautiful Soup needs to be reviewed

2010-12-11 Thread Alexander Kapps

On 11.12.2010 22:38, Stef Mientki wrote:

On 11-12-2010 17:24, Martin Kaspar wrote:

Hello commnity

i am new to Python and to Beatiful Soup also!
It is told to be a great tool to parse and extract content. So here i
am...:

I want to take the content of atd-tag of a table in a html
document. For example, i have this table

table class=bp_ergebnis_tab_info
 tr
 td
  This is a sample text
 /td

 td
  This is the second sample text
 /td
 /tr
/table

How can i use beautifulsoup to take the text This is a sample text?

Should i make use
soup.findAll('table' ,attrs={'class':'bp_ergebnis_tab_info'}) to get
the whole table.

See the target 
http://www.schulministerium.nrw.de/BP/SchuleSuchen?action=799.601437941842SchulAdresseMapDO=142323

Well - what have we to do first:

The first thing is t o find the table:

i do this with Using find rather than findall returns the first item
in the list
(rather than returning a list of all finds - in which case we'd have
to add an extra [0]
to take the first element of the list):


table = soup.find('table' ,attrs={'class':'bp_ergebnis_tab_info'})

Then use find again to find the first td:

first_td = soup.find('td')

Then we have to use renderContents() to extract the textual contents:

text = first_td.renderContents()

... and the job is done (though we may also want to use strip() to
remove leading and trailing spaces:

trimmed_text = text.strip()

This should give us:


print trimmed_text
This is a sample text

as desired.


What do you think about the code? I love to hear from you!?

I've no opinion.
I'm just struggling with BeautifulSoup myself, finding it one of the toughest 
libs I've seen ;-)


Really? While I'm by no means an expert, I find it very easy to work 
with. It's very well structured IMHO.



So the simplest solution I came up with:

Text = 
table class=bp_ergebnis_tab_info
 tr
 td
  This is a sample text
 /td

 td
  This is the second sample text
 /td
 /tr
/table

Content = BeautifulSoup ( Text )
print Content.find('td').contents[0].strip()

This is a sample text


And now I wonder how to get the next contents !!


Content = BeautifulSoup ( Text )
for td in Content.findAll('td'):
print td.string.strip() # or td.renderContents().strip()
--
http://mail.python.org/mailman/listinfo/python-list


Re: Program, Application, and Software

2010-11-18 Thread Alexander Kapps

On 19.11.2010 01:26, MRAB wrote:

On 19/11/2010 00:07, Steven D'Aprano wrote:

On Thu, 18 Nov 2010 14:21:47 +, Martin Gregorie wrote:


I use 'script' to refer to programs written in languages that don't have
a separate compile phase which must be run before the program can be
executed. IOW Python and Perl programs are scripts aloing with programs
written as awk, Javascript and bash scripts.


You're mistaken then about Python, because it does have a separate
compilation phase that runs before the program can be executed. Where do
you think the .pyc files come from, and what did you think the compile()
function did? It just happens automatically, rather than manually.


[snip]
I think what he means is that you don't need explicitly to compile and
then run.


What difference does it make? Is 'print Hello' a program or a 
script? Are you saying, that it depends on whether you have to 
manually call some compiler?

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


Re: Is Unladen Swallow dead?

2010-11-17 Thread Alexander Kapps

On 17.11.2010 23:09, John Nagle wrote:

On 11/17/2010 12:49 PM, John Ladasky wrote:

On Nov 16, 2:30 pm, laspilorena.aspi...@gmail.com wrote:

Is Unladen Swallow dead?


No, it's just resting.


For those who don't get that, The Monty Python reference:
http://www.mtholyoke.edu/~ebarnes/python/dead-parrot.htm;


Thank you John for making my light enough Wallet even lighter, now I 
have to go and buy the original English version. Seems the German 
translation sucks (misses a lot) and my copy lacks the original dub.


Damned.

:-)

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


Re: Program, Application, and Software

2010-11-17 Thread Alexander Kapps

On 17.11.2010 19:38, Boštjan Mejak wrote:

What is the difference between a program, an application, and software?


Program: A sequence of one or more instructions (even 'print 
hello' is a valid Python program)


Application: Usually a large(er), complex program

Software: The parts of a computer that you *can't* kick.

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


Re: Raw Unicode docstring

2010-11-17 Thread Alexander Kapps

On 17.11.2010 06:14, John Machin wrote:

On Nov 17, 9:34 am, Alexander Kappsalex.ka...@web.de  wrote:


urScheißt\nderBär\nim Wald?


Nicht ohne eine Genehmigung von der Umwelt Erhaltung Abteilung.


The typical response around here is Ja, aber nur wenn er Klopapier 
dabei hat.


:-D

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


Re: Raw Unicode docstring

2010-11-16 Thread Alexander Kapps

On 16.11.2010 22:56, Boštjan Mejak wrote:

Hello,

how does one write a raw unicode docstring? If I have backslashes in
the docstring, I must tuck an 'r' in front of it, like this:
rThis is a raw docstring.

If I have foreign letters in the docstring, I must tuck a 'u' in front
of it, like this:
uThis is a Unicode docstring.

What if I have foreign characters *and* backslashes in my docstring?
How to write the docstring then?
ruMy raw unicode docstring.
or
urMy unicode docstring.

Please answer my question, although it may sound like a noobish one. Thanks.


One of Python's main strength is it's brilliant interactive mode, 
where you can easily try things out (Hint: Try ipython for an even 
better interactive experience)


Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3] on linux2
Type help, copyright, credits or license for more information.
 ruScheißt\nderBär\nim Wald?
  File stdin, line 1
ruScheißt\nderBär\nim Wald?
 ^
SyntaxError: invalid syntax
 urScheißt\nderBär\nim Wald?
u'Schei\xdft\\nderB\xe4r\\nim Wald?'


Looks like ur works fine.

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


Re: pylint -- should I just ignore it sometimes?

2010-10-19 Thread Alexander Kapps

On 19.10.2010 21:57, Seebs wrote:

So, I'm messing around with pylint.  Quite a lot of what it says
is quite reasonable, makes sense to me, and all that.

There's a few exceptions.

One:  I am a big, big, fan of idiomatic short names where appropriate.
For instance:
catchsomething, e:
I don't want a long, verbose, name -- e is about as much in need of
a long and descriptive name as the stereotypical i one would use as
a loop index (in a language without iterators).  Should I just ignore
that, or is it really more Pythonic to say something like:
catch KeyError, 
exception_resulting_from_the_use_of_a_key_not_defined_for_the_dictionary_in_which_it_was_looked_up:


catch KeyError, exc
catch KeyError, exception


Secondly:  I am getting a couple of hits on things like Too many instance
attributes (8/7) or Too many branches (14/12).  In the cases in question,
it doesn't seem to me that the number of instance attributes is particularly
devastatingly complicated, because the instances in question are, by design,
sort of data stores; they carry a handful of precomputed results that are
then reused to populate templates.

So am I going to be laughed out of the room if I just let a class have
eight instance attributes, or use a short name for a caught exception?

-s


Pylint gives *hints* about *possible* problems or bad style. I 
personally think it's good practice to take care of all of them and 
carefully think if you or pylint is right. Once you decided that you 
are right, you can configure pylint to not complain about certain 
aspects. See man pylint for more.

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


Re: pylint -- should I just ignore it sometimes?

2010-10-19 Thread Alexander Kapps

On 20.10.2010 00:36, Seebs wrote:

On 2010-10-19, Martin P. Hellwigmartin.hell...@dcuktec.org  wrote:

Well, as with all styles IMHO, if there is a _good_ reason to break it,
then by all means do, but you might want to consider putting in a
comment why you did that and add the #pylint: disable-msg=message_id
on that line. If that is overkill, why not just comply to the standard
and avoid all the fuzz?


Well, part of what I'm trying to understand is why the standard in question
says what it says.  I'm pretty much mystified by a claim that something with
seven instance attributes is too complicated.  For instance, I've got a
class which represents (approximately) a C function, for use in writing
various wrappers related to it.  It has name, return type, args, default
values, a list of arguments which need various modifications, a default
return value, and so on... And it ends up with, apparently, 10 instance
attributes.

I can't tell whether there's actually a general consensus that classes
should never be nearly that complicated, or whether pylint is being a little
dogmatic here -- I haven't seen enough other Python to be sure.  I'm
used to having objects with anywhere from two or three to a dozen or more
attributes, depending on what kind of thing they model.  It seems like a
very odd measure of complexity; is it really that unusual for objects to have
more than seven meaningful attributes?

-s


The general idea is, that modules, classes, methods, and functions 
should be small so they are better reusable, manageable and 
understandable. If you have a huge class or function with many 
attributes or local variables, it's often a sign, that your 
class/function does to much and you better refactor this into 
smaller pieces. There isn't and there can't be a general consensus 
about /how/ small some part should be.


If pylint complains about too many variables or such, take it as a 
hint to rethink your design. If you say, my design is good, then 
feel free to ignore the warning.


If your classes wrap some existing datastructure and pyling 
complains, take it as a hint (just a hint, not more) that maybe your 
underlying datastructure is to complex.


But there are no general rules. In the end you (the programmer) has 
to decide how the code or the data is structured, pylint can only 
give you hints, that there *may* be a problem.


I don't know why the standard (what standard?) says what it says, 
but I guess, it's the result of long time experiences and analysis 
of existing code. Trust them, unless you are sure to know better.

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


Re: Help with paths

2010-10-18 Thread Alexander Kapps

On 18.10.2010 23:24, Devin M wrote:

Hello, I am using os.path to get the absolute paths of a few
directories that some python files are in.
FIlePath = os.path.dirname(os.path.realpath(__file__))
which returns a path similar to /home/devinm/project/files
Now I want to get the directory above this one. (/home/devinm/
project/) Is there a simple way to do this? I was considering spliting
apart the path and then reconstructing it with the last folder left
off. Hope theres a better way to do this.

Regards,
Devin M


os.path.split() is designed for this

In [4]: path=/home/devinm/project/files

In [5]: import os.path

In [6]: os.path.split(path)[0]
Out[6]: '/home/devinm/project'
--
http://mail.python.org/mailman/listinfo/python-list


Re: accessing a text file

2010-09-05 Thread Alexander Kapps

Baba wrote:

level: beginner

how can i access the contents of a text file in Python?

i would like to compare a string (word) with the content of a text
file (word_list). i want to see if word is in word_list. let's assume
the TXT file is stored in the same directory as the PY file.

def is_valid_word(word, word_list)


thanks
Baba



Completely untested:

def is_valid_word(word, filename):
for line in open(filename):
if word in line.split():
return True
return False
--
http://mail.python.org/mailman/listinfo/python-list


Re: Fw: sendmail error

2010-08-31 Thread Alexander Kapps

sandric ionut wrote:
  Three things:  When quoting code, do it exactly, and without wordwrap 
in your mail program.  There are so many typos in that code sample that 
it's useless, presumably because you didn't use copy/paste
 
The code was COPY and PASTE - presume wrong


   When quoting an error message, get it all.  Since you omit the 
stacktrace part, we can't tell what line might be giving you that error
 
That is all the error code!!!


Once you've noticed which line, just examine the types of each of 
the elements you're combining.  If you're using the + operator, and the 
left operand is a string, then the right one must also be string.  
Figure out why it's not and you have your own answer
 
Do you really think that I didn't do it? What a... response. This + or , 
is really USELESS. Please don't bother to send useless replays
This is the line where I get the error: smtpObj.sendmail(fromEmail, 
toEmail, mesaj.as_string())



Indeed, what a response. But from you. Do you always attack people 
who tried to help you?


Dave Angel, gave you a very useful hint on how to debug such errors. 
 In particular, he asked you to paste the *full* traceback.


And if your mail/news client messes up the code so heavily, it's 
probably time to move to a better client.


And the mention of + is not useless. If you would have tried a 
little harder, you would probably find, that concatenating a string 
and an exception object, gives exactly the error you got.




So, the problem is probably here:

print eroare:  + smtplib.SMTPException

Instead you want something like:

except smtplib.SMTPException, msg
print eroare:  + msg


If you are sure, that's not the line which gave the error, again, 
post the *full* traceback.


Next time, show a little more civility and follow the advices you 
got. Help us, to help you. is the word.


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


Re: Fw: sendmail error

2010-08-31 Thread Alexander Kapps

Chris Withers wrote:

Alexander Kapps wrote:

Instead you want something like:

except smtplib.SMTPException, msg
print eroare:  + msg


Err, that's still concatenating a string and an exception object.


OUCH! What a stupid error. Thanks for correction. :-)


What *would* work is:

except smtplib.SMTPException, msg
 print eroare:  + str(msg)

...not that it's particularly good coding style, what with hiding the 
traceback and all...


Full Ack.


cheers,

Chris



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


Re: Python libs on Windows ME

2010-08-31 Thread Alexander Kapps

Thomas Jollans wrote:


I would use another os like Linux or Windows 2000, but this particular
computer can't even seem to handle even the most minimal graphical
Linux distributions.


Really? I'm sure you can get Linux on there somehow. It might not be trivial, 
but it should definitely be possible. Out of interest: what distros did you 
try?


In my experiences, getting /some/ Linux on a usual, say, post-1995 
PC is almost trivial, even with GUI. It's just a matter of choosing 
the right distro (and desktop environment).


If the OP would post the exact hardware specs, I'm almost sure, that 
we can find a distro that works without much hassle.

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


Re: Python libs on Windows ME

2010-08-31 Thread Alexander Kapps

hexusne...@gmail.com wrote:

On Aug 31, 2:04 pm, Thomas Jollans tho...@jollybox.de wrote:

On Tuesday 31 August 2010, it occurred to hexusne...@gmail.com to exclaim:


I'm not guessing that this is a problem on Windows 98, but on Windows
ME modules in /Lib don't seem to load.  Examples include site.py and
os.py which are both located in the top level Lib directory.  The same
thing happens with Python 2.3, 2.4, and 2.5.  I can't get IDLE to load
and the Python interpreter always complains that it can't load the
site module even if Python is run from the same directory as the
module (note: this does not happen if a module is loaded from the
current working directory while in the interpreter).

What is sys.path set to ?

python.exe -c import sys; print(sys.path)

It sounds like the stdlib directory is not on sys.path. Couldn't say why
though...




I would use another os like Linux or Windows 2000, but this particular
computer can't even seem to handle even the most minimal graphical
Linux distributions.

Really? I'm sure you can get Linux on there somehow. It might not be trivial,
but it should definitely be possible. Out of interest: what distros did you
try?


I think Puppy Linux might work, but I'd need GTK for wxPython, and I
assume that means version 2 of GTK which I'm not sure comes with Puppy
Linux and I've experienced problems in the past compiling GTK with './
configure  make' and so on.


Well, just try. AFAIK, Puppy has GTK2 (actually, it would surprise 
me if not)

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


Re: String substitution VS proper mysql escaping

2010-08-30 Thread Alexander Kapps

Nik the Greek wrote:


cursor.execute(''' SELECT hits FROM counters WHERE page = %s and
date = %s and host = %s ''' , a_tuple )

and

cursor.execute(''' SELECT hits FROM counters WHERE page = %s and
date = %s and host = %s ''' , (a_tuple) )

are both syntactically correct right?

buw what about

cursor.execute(''' SELECT hits FROM counters WHERE page = %s and
date = %s and host = %s ''' , (a_tuple,) )


Python has a wonderful interactive mode which is perfect for trying 
this out:


 a_tuple = 1,2,3
 a_tuple
(1, 2, 3)
 (a_tuple)
(1, 2, 3)
 (a_tuple,)
((1, 2, 3),)



First note, that tuples are not created with parentheses, but with 
the comma. So, the first two are the same. The parens are only 
needed to remove ambiguity in certain situations, but are 
meaningless here.


The third case is a tuple containing a_tuple as its only element.
--
http://mail.python.org/mailman/listinfo/python-list


Re: split string into multi-character letters

2010-08-25 Thread Alexander Kapps

Jed wrote:

Hi, I'm seeking help with a fairly simple string processing task.
I've simplified what I'm actually doing into a hypothetical
equivalent.
Suppose I want to take a word in Spanish, and divide it into
individual letters.  The problem is that there are a few 2-character
combinations that are considered single letters in Spanish - for
example 'ch', 'll', 'rr'.
Suppose I have:

alphabet = ['a','b','c','ch','d','u','r','rr','o'] #this would include
the whole alphabet but I shortened it here
theword = 'churro'

I would like to split the string 'churro' into a list containing:

'ch','u','rr','o'

So at each letter I want to look ahead and see if it can be combined
with the next letter to make a single 'letter' of the Spanish
alphabet.  I think this could be done with a regular expression
passing the list called alphabet to re.match() for example, but I'm
not sure how to use the contents of a whole list as a search string in
a regular expression, or if it's even possible.  My real application
is a bit more complex than the Spanish alphabet so I'm looking for a
fairly general solution.
Thanks,
Jed


I don't know the Spanish alphabet, and you didn't say in what way 
your real application is more complex, but maybe something like this 
could be a starter:


In [13]: import re

In [14]: theword = 'churro'

In [15]: two_chars=[ch, rr]

In [16]: re.findall('|'.join(two_chars)+|[a-z], theword)
Out[16]: ['ch', 'u', 'rr', 'o']

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


Re: Overload print

2010-08-25 Thread Alexander Kapps

Ross Williamson wrote:

Hi All

Is there anyway in a class to overload the print function?


In Python = 2.x print is a statement and thus can't be 
overloaded. That's exactly the reason, why Python 3 has turned 
print into a function.



class foo_class():
def __print__(self):
  print hello



cc = foo_class()
print cc


Gives:

hello


Hmm, on what Python version are you? To my knowledge there is no 
__print__ special method. Did you mean __str__ or __repr__ ?



I'm looking at finding nice way to print variables in a class just by
asking to print it


In Python3 you *can* overload print(), but still, you better define 
__str__() on your class to return a string, representing what ever 
you want:


In [11]: class Foo(object):
   : def __str__(self):
   : return foo
   :
   :

In [12]: f = Foo()

In [13]: print f
foo

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


Re: simple python deployment tool

2010-07-08 Thread Alexander Kapps

King wrote:

Hi,

I am writing a python package deployment tool for linux based
platforms. I have tried various existing
tool sets but none of them is up to the mark and they have their own
issues. Initially I'll start with simple approach.


I'm sorry, but your approach is not going to work. The Right Way(tm) 
is to not ship any external libraries, but let the user install the 
dependencies with the distro's package manager. And to not try to 
build custom packages, but to let the package maintainers  of the 
different distros package your application for you.



1. Find all the modules/packages and copy to lib directory.
2. Find python's *.so dependencies(system libs) and copy them to
syslib


That would include all the way down to libc, your archive is going 
to be huge, but the actual problem is, what if the libc isn't 
compatible with the kernel, what if the WX, GTK, X11, etc libraries 
aren't compatible with the running Xserver?


End of the story is, you would need to package a minimal (but almost 
complete) Linux system into your package, which of course is not 
want you want.



3. Copy python(executable) and libpython2.6.so.1.0 into dist
directory.
4. Set up temp environment
5. Run main script using python main script.py

The idea is to produce a cleaner directory structure. Neither I am
creating a boot loader nor I am converting main script
file into executable. It's plain vanilla stuff.


It's not vanilla stuff, but a very hard problem. In fact you are 
fighting against the whole system structure.


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


Re: simple python deployment tool

2010-07-08 Thread Alexander Kapps

King wrote:

On Jul 8, 2:21 pm, Alexander Kapps alex.ka...@web.de wrote:

King wrote:

Hi,
I am writing a python package deployment tool for linux based
platforms. I have tried various existing
tool sets but none of them is up to the mark and they have their own
issues. Initially I'll start with simple approach.

I'm sorry, but your approach is not going to work. The Right Way(tm)
is to not ship any external libraries, but let the user install the
dependencies with the distro's package manager. And to not try to
build custom packages, but to let the package maintainers  of the
different distros package your application for you.


Yes, you an do this by creating a .deb package that will take care of
installing the required libraries.
It may possible that either required version is not available in the
distro's repository or the one available is
older one then required.


Yes, that may happen.


So best deal would be to ship at least all
the python's libs along with your package.


No, IMHO, the best way to cope with this, is to be a little 
conservative on what library versions you use. Don't use the most 
cutting edge versions, but those who are most wildly available.


Even if you must use the most recent versions, you should leave the 
packaging to the distro maintainers. They know their distro a lot 
better and know how to maintain compatiblity with the rest of the 
system.




1. Find all the modules/packages and copy to lib directory.
2. Find python's *.so dependencies(system libs) and copy them to
syslib

That would include all the way down to libc, your archive is going
to be huge, but the actual problem is, what if the libc isn't
compatible with the kernel, what if the WX, GTK, X11, etc libraries
aren't compatible with the running Xserver?


You are right here. It seems there is no standard definition of system
libraries on linux. To over come the problem of binary
compatibility, I am using ubuntu (hardy) which is on glibc 2.7. Every
other external python library including python is compiled on
hardy. This is would give you maximum chances that libs would be
compatible in case if you run on any other distro which is using glibc

=2.7


Just because any other disto is based on glibc 2.7 doesn't ensure, 
that the other parts (like gtk libs vs. X11) are compatible.


Actually by doing so, you are limiting your package to Hardy only. 
Any compatiblity with other Ubuntu versions or other distros would 
be purely by accident.



End of the story is, you would need to package a minimal (but almost
complete) Linux system into your package, which of course is not
want you want.


3. Copy python(executable) and libpython2.6.so.1.0 into dist
directory.
4. Set up temp environment
5. Run main script using python main script.py
The idea is to produce a cleaner directory structure. Neither I am
creating a boot loader nor I am converting main script
file into executable. It's plain vanilla stuff.

It's not vanilla stuff, but a very hard problem. In fact you are
fighting against the whole system structure.


Ok, forget about system libs(libX*.* etc.), I don't know why it sounds
too complicated. I am hoping it should work and eventually it's easier
then tools that create an executable using bootloader. The problem is
in setting the correct python environment.


It sounds complicated, because it is complicated. :-)

Now, imagine, everybody would do this. There would be dozens, maybe 
hundreds of redundant copies of Python, libXYZ, etc.


I don't know what you mean by create an executable using 
bootloader, but really, the correct way is to leave the dependency 
management to the distro and it's package manager.




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


Re: Python 2.7 released

2010-07-05 Thread Alexander Kapps

Martineau wrote:


Perhaps it's hidden somewhere, but I couldn't find the .chm help file
in the python-2.7.msi file using 7-zip, nor saw anything that looked
like a Doc folder embedded within it -- so I doubt installing it on a
Windows machine would work any better.


I don't know much about the .msi format or how 7-Zip handles it, but 
on my XP box, 7-Zip lists a python sub-archive (a 7-Zip 
compound). Within is the python27.chm

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


Re: Python dynamic attribute creation

2010-06-28 Thread Alexander Kapps

Bruno Desthuilliers wrote:

Alexander Kapps a écrit :
(snip)
While I personally don't agree with this proposal (but I understand 
why some people might want it), I can see a reason.


When disallowing direct attribute creation, those typos that seem to 
catch newcommers won't happen anymore. What I mean is this:


class Foo(object):
def __init__(self):
self.somearg = 0

f = Foo()
f.soemarg = 42

---^ There, typo, but still working

It's something like a custom __setattr__ that errors out when trying 
to assign to an attribute that doesn't exists,


Chicken and egg problem, really :  f.__dict__['somearg'] doesn't exists 
until self.somearg = 0 is executed.


The problem is that Python's methods are only thin wrapper around 
functions (cf http://wiki.python.org/moin/FromFunctionToMethod) so 
there's no difference between self.somearg = 0 in Foo.__init__ and 
f.somearg = 42.


IOW, there's no way to implement this proposal without completely 
changing Python's object model.


I must be missing something. Can you please explain why the whole 
object model would need to change?


This seems to work quite well:

class TypoProtection(object):
def __init__(self):
self.foo = 42
self.bar = 24

def _setattr(self, name, value):
if name in self.__dict__:
self.__dict__[name] = value
else:
raise AttributeError, %s has no '%s' attribute \
  % (self.__class__, name)


self.__class__.__setattr__ = _setattr


t = TypoProtection()

t.foo = spam
t.bar = ham
t.parrot = dead



Traceback (most recent call last):
  File typo.py, line 20, in module
t.parrot = dead
  File typo.py, line 10, in _setattr
raise AttributeError, %s has no '%s' attribute % 
(self.__class__, name
AttributeError: class '__main__.TypoProtection' has no 'parrot' 
attribute



So, IIUC, all what would need to be done is to add an implicit 
__setattr__ at the end of __init__ .


(Just want to understand, still not advocating this proposal)

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


Re: Python dynamic attribute creation

2010-06-28 Thread Alexander Kapps

Alexander Kapps wrote:

Bruno Desthuilliers wrote:

Alexander Kapps a écrit :
(snip)
While I personally don't agree with this proposal (but I understand 
why some people might want it), I can see a reason.


When disallowing direct attribute creation, those typos that seem to 
catch newcommers won't happen anymore. What I mean is this:


class Foo(object):
def __init__(self):
self.somearg = 0

f = Foo()
f.soemarg = 42

---^ There, typo, but still working

It's something like a custom __setattr__ that errors out when trying 
to assign to an attribute that doesn't exists,


Chicken and egg problem, really :  f.__dict__['somearg'] doesn't 
exists until self.somearg = 0 is executed.


The problem is that Python's methods are only thin wrapper around 
functions (cf http://wiki.python.org/moin/FromFunctionToMethod) so 
there's no difference between self.somearg = 0 in Foo.__init__ and 
f.somearg = 42.


IOW, there's no way to implement this proposal without completely 
changing Python's object model.


I must be missing something. Can you please explain why the whole object 
model would need to change?


UHHM! Forget it. This of course doesn't work with setattr too. My 
stupidness. :-(




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


[OT] Football was: Python dynamic attribute creation

2010-06-28 Thread Alexander Kapps

Mark Lawrence wrote:

On 28/06/2010 20:23, Alexander Kapps wrote:

UHHM! Forget it. This of course doesn't work with setattr too. My
stupidness. :-(

Don't worry too much, looks like your nation's football is much better 
than your settattr knowledge. 


I very much appreciate your attempt to make me feel better, but 
please realize that not every German (or UK citizen) is a football 
fan(atic). FWIW, I don't give a dime (very, very much less actually) 
who wins what there.


And I surely know a lot more about setattr, than about the Abseits 
(aside, offside, or such) rule (even if my setattr knowledge is 
plain zero)


Having that said, I wish you all luck for your team! :-)

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


Re: Python dynamic attribute creation

2010-06-26 Thread Alexander Kapps

Ixokai wrote:


In what possible way is:

setattr(foo, 'new_attr', 'blah')
getattr(foo, 'new_attr')
delattr(foo, 'new_attr')

Better then:

foo.new_attr = 'blah'
foo.new_attr
del foo.new_attr

I don't understand what your argument is or problem is with the regular 
syntax, if you want to allow the former (all of which is currently 
possible in Python if you prefer this style) but not the latter (all of 
which also works, it just uses normal syntax as everyone would expect).


Do you think it should be somehow tricky or more difficult to 
dynamically modify an instance at runtime? For that to hold, you have to 
provide some pretty compelling reasoning why dynamically modifying an 
instance at runtime is Not Good. Only then is there a good reason to 
make it more difficult. (Since Python doesn't really restrict things, 
just makes certain rare things that are undesirable a little harder to do)


--Stephen



While I personally don't agree with this proposal (but I understand 
why some people might want it), I can see a reason.


When disallowing direct attribute creation, those typos that seem to 
catch newcommers won't happen anymore. What I mean is this:


class Foo(object):
def __init__(self):
self.somearg = 0

f = Foo()
f.soemarg = 42

---^ There, typo, but still working

It's something like a custom __setattr__ that errors out when trying 
to assign to an attribute that doesn't exists, just as default behavior.


Sure, unittest are the Right Way(tm) to handle this, but there is a 
learning curve for new programmers wrt unittest. And disallowing 
this, doesn't take away any dynamism since setattr and friends are 
still there.


Anyway, since I do a lot interactive programming I don't want it. It 
would hinder me a lot.

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


Re: Python dynamic attribute creation

2010-06-26 Thread Alexander Kapps

Stephen Hansen wrote:

On 6/26/10 9:01 AM, Alexander Kapps wrote:

While I personally don't agree with this proposal (but I understand why
some people might want it), I can see a reason.

When disallowing direct attribute creation, those typos that seem to
catch newcommers won't happen anymore. What I mean is this:


I get where you're coming from, but I don't see why attributes should 
get such special typo-protection when locals and any other names shouldn't.


Well, I would sympathize with an attempt to add some kind of typo 
protection. Not build into the language, but I dream about a command 
line switch that invokes a test like pylint/PyChecker. I wish any of 
those would enter the standard distribution.


I see it as an extension of Special cases aren't special enough to 
break the rules. -- and here I think the OP and I disagree most strongly.


This characterization of adding attributes to an object as something 
else, some special kind of activity called metaprogramming I think I 
reject outright, whereas I believe -- though I do not claim to speak for 
him/her -- the OP's position is that using 'syntax' to add attributes is 
actually a special case/activity.


I consider it the standard, normal behavior.

If this is how I create a local variable:
x = 1

And to read that variable, I simply refer to it as x, and if to read a 
defined attribute from an object I do:

a.x

Then, to me, the way in which I would set a new variable on that object 
is clearly:

a.x = 1

I don't see why Python should special case setting an attribute on an 
object to be so wildly different then setting a local variable (or 
global, or anything else) as to require a special function call. The 
activity of adding an attribute to an object is no more special, IMHO, 
then adding a variable to the local scope.


I fully agree with everything so far. As I said, i don't support 
this proposal, just that I can see a reason why some people might 
want this. I do this type of dynamic attribute addition (both data 
and methods) all day in my interactive sessions, which are a large 
part of my Python activity.


Now, true: I fully acknowledge that if you're in an OOP-mindset and 
you're choosing to use a certain style of programming (and one I 
frequently indulge in), then you may /choose/ to treat certain objects 
as special, as being more firmly structured, as having a formal definition.


In that situation, certainly: adding an attribute on the fly to that 
formal definition seems entirely strange and special of an activity. But 
that's only because you *chose* to *see* and *use* the object that way. 
The specialness of the activity is entirely in your head, and to 
Python, its an entirely normal event.


That was an interesting insight, thank you for this. While I 
actually know all this, I indeed still seem to sometimes treat 
objects as fixed-once-defined-and-created entities. I just grep'ed 
all my code repository and found that I almost never do any 
on-the-fly attribute addition (totally contrary to my interactive work)


You may have just opened the door the my next level of Python OO 
understanding. Thank you! :-)


Python lets you associate significance with normal events so you can get 
things done. But its just plodding along not really drinking whatever 
kool-aid you are, though its happy you like your flavor and is entirely 
content with letting you think its playing ball with you on that.


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


Python eCommerce, small webshop

2010-03-12 Thread Alexander Kapps

Hello everybody!

I have to set up a small webshop for used books, CDs, DVD, and stuff 
 and did't find anything realy usefull on google.


I'm pretty skilled with Python and would strongly prefer a Python 
based Shop but all I've found are in early stage, unmaintained or 
too limited.


I've looked around and found many PHP based shops (currently I'm 
playing with OpenCart but their code is so messy, I don't think this 
is going to work) and some Ruby based ones (I don't know Ruby at all)


I there really no decent, up-to-date, activily maintained and post 
beta stage Python webshop?


What I need is:

- full german support (ie. translation, shipping models, payment 
models, etc)

- secure (code, SQL, full SSL, etc)
- themable without getting into all gory details of modern HTML/CSS 
(a bit is OK)

- customizable by people with good Python and basic SQL knowledge
- finally (after being setup) usable by people without any 
programming skills at all.




Thanks for any tips.

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


Python eCommerce, small webshop

2010-03-12 Thread Alexander Kapps

Hello everybody!

I have to set up a small webshop for used books, CDs, DVD, and stuff 
 and did't find anything realy usefull on google.


I'm pretty skilled with Python and would strongly prefer a Python 
based Shop but all I've found are in early stage, unmaintained or 
too limited.


I've looked around and found many PHP based shops (currently I'm 
playing with OpenCart but their code is so messy, I don't think this 
is going to work) and some Ruby based ones (I don't know Ruby at all)


I there really no decent, up-to-date, activily maintained and post 
beta stage Python webshop?


What I need is:

- full german support (ie. translation, shipping models, payment 
models, etc)

- secure (code, SQL, full SSL, etc)
- themable without getting into all gory details of modern HTML/CSS 
(a bit is OK)

- customizable by people with good Python and basic SQL knowledge
- finally (after being setup) usable by people without any 
programming skills at all.




Thanks for any tips.

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


Re: Python eCommerce, small webshop

2010-03-12 Thread Alexander Kapps
Sorry, Emile for the private post, one beer too much and the wrong 
button... ;-)


Emile van Sebille wrote:

 On 3/12/2010 5:02 PM Alexander Kapps said...
 Hello everybody!

 I have to set up a small webshop for used books, CDs, DVD, and 
stuff and

 did't find anything realy usefull on google.

 Have you checked the current status of Satchmo?

Sort of. I checked their site and feature list which looks 
promising. Then I searched for a forum. I have quite some objections 
 against projects who only have a google group with a reaction time 
measured in days.


But since you mentioned it, I'll have a closer look.

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