Hidden string formatting bug

2005-10-13 Thread Echo
Hello,
I have been trying to figure out the problem with this string formatting:

sql = 'INSERT INTO tc_themes (name,user_made,hour12,time_loc,background_color_r,' + \
   
'background_color_g,background_color_b,clock_color_r,clock_color_g,' + \
   
'clock_color_b,clock_background_color_r,clock_background_color_g,' + \
   
'clock_background_color_b,clock_points_color_r,clock_points_color_g,' +
\
   
'clock_points_color_b,clock_hour_color_r,clock_hour_color_g,' + \
   
'clock_hour_color_b,clock_min_color_r,clock_min_color_g,' + \
   
'clock_min_color_b,clock_sec_color_r,clock_sec_color_g,' + \
   
'clock_sec_color_b,clock_font_facename,clock_font_size,' + \
   
'clock_font_style,clock_font_underlined,clock_font_weight,' + \
   
'clock_font_color_r,clock_font_color_g,clock_font_color_b,' + \
   
'time_font_facename,time_font_size,time_font_style,' + \
   
'time_font_underlined,time_font_weight,time_font_color_r,' + \
   
'time_font_color_g,time_font_color_b) VALUES (' + \
    "%s,%i,%i,%s,%i," + \
    "%i,%i,%i,%i," + \
    "%i,%i,%i," + \
    "%i,%i,%i," + \
    "%i,%i,%i," + \
    "%i,%i,%i," + \
    "%i,%i,%i," + \
    "%i,%s,%i," + \
    "%i,%i,%i," + \
    "%i,%i,%i," + \
    "%s,%i,%i," + \
    "%i,%i,%i," + \
   
"%i,%i)" % ("'Simple Clock'", 0, 1, "'Top'", 200, 200, 200, 100, 100,
100, 255, 255, 255, 100, 100, 100, 0, 0, 0, 0, 0, 0, 255, 0, 0,
"'Arial'", 18, 90, 0, 90, 0, 0, 0, "'Arial'", 32, 90, 0, 90, 0, 0, 0)

when it executes, I get this error: "inv argument required". I have
checked and rechecked both the string and the tuple. I cant figure out
what the problem is.
After playing around with it, i found out if change the last line to:
"%s,%i) %(... I get a different error. The error is "not all arguments
converted during string formatting".

So I am baffled and confused as of why this wont work. Is anyone able to shed some light on my hidden bug?
Using: Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)]
-- -Echo
-- 
http://mail.python.org/mailman/listinfo/python-list

Help with creating a dict from list and range

2005-10-14 Thread Echo
Hello,Here is what I am trying to do. I am trying to make a dict
that has a key that is the value an element in a list and the value for
the dict to be the index.This is the closest I have been able to get: dict((d[0],i) for d in self.cu.description for i in xrange(len(self.cu.description)-1))

That however does not work. the value for all the dict is 40. Not 1, 2, 3, ... that I was hoping for.

Am I even close at creating the dict that I want? Is there a better way to go about it?-- -Echo 
-- 
http://mail.python.org/mailman/listinfo/python-list

Getting files in a subdirectory in a zip

2005-07-11 Thread Echo
What would the best way to get a list of files in a subdirectory in a zip?

The only thing I can come up with is to extract the zip into a temp
directory and then just grab the list of files in the subdirectory
that I need. This way seems very messy to me and I was wondering if
there are any better ways.

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


Detailed traceback

2005-09-12 Thread Echo
I have been working on handling unhanded exceptions and making a
detailed print out of the traceback after the exception. I found that
traceback.extract_tb worked nice and was quite simple.

During my searching around I found out that it might be possible to
get the variables and their respective values for each frame. I found
this: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52215 to
be extremely helpful.

My only problem with that is that there appears to be no way to get
the line of code for a frame.

So I was wondering if it was possible to get the line of code for a frame.

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


Re: Python component model

2006-10-09 Thread Echo
On 10/9/06, Edward Diener No Spam <[EMAIL PROTECTED]> wrote:
> The definition of a component model I use below is a class which allows
> properties, methods, and events in a structured way which can be
> recognized, usually through some form of introspection outside of that
> class. This structured way allows visual tools to host components, and
> allows programmers to build applications and libraries visually in a RAD
> environment.
>
> The Java language has JavaBeans as its component model which allows Java
> applications to be built in a visual RAD way. Microsoft's .Net has a
> component model built-in to its .Net class libraries as well as
> supported by CLR which allows .Net applications to be built visually
> using components created in any .Net supported language.
>
> With Python things are different. There is no single component model
> which allows Python developers to build components which will be used
> and recognized by the various RAD Python tools on the market. Instead a
> developer must create a slightly different set of Python classes for
> each RAD Python tool. This is the situation despite Python's having
> easily as much functionality, if not much more, as Java or .Net
> languages such as C#, VB, or C++/CLI for creating components, and for
> allowing visual tools to introspect the properties, methods, and events
> of Python classes.
>
> I believe that Python should have a common components model for all RAD
> development environments, as that would allow the Python programmer to
> create a set of classes representing components which would work in any
> environment. I want to immediately point out that components do not
> simply mean visual GUI components but what may be even more important,
> non-visual components. Having used RAD development environments to
> create applications, I have found such environments almost always much
> better than coding complex interactions manually, and I believe that
> visual development environments are almost a necessity in today's world
> of large-scale, multi-tier, and enterprise applications.
>
> Has there ever been, or is there presently anybody, in the Python
> developer community who sees the same need and is working toward that
> goal of a common component model in Python, blessed and encouraged by
> those who maintain the Python language and standard modules themselves ?
> --
> http://mail.python.org/mailman/listinfo/python-list
>


If you are talking about about creating a GUI and having be able to
run using different GUI libraries like Tkinter, wxPython, wxgtk, ect.
You could look into Dabo(http://dabodev.com/). It is designed so that
you can design your GUI and have it run with what ever GUI library you
want(only wxPython is supported at the moment. And I think that
Tkinter works somewhat.)

-- 
"Now that I am a Christian I do not have moods in which the whole
thing looks very improbable: but when I was an atheist I had moods in
which Christianity looked terribly probable."
  -C. S. Lewis

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


Python and CMS

2006-10-22 Thread Echo
I am going to start working on a church website. And since I like
python, I decided to use WSGI. However, I later found out about all
the different CMS's in php. So I wondered if there where any in
python.

Sadly, I only found Plone, skeletonz, and PyLucid (If there is any
more, please let me know). Of those three, only PyLucid supports WSGI
and it didn't look very nice to me.
Both Plone and skeletonz looked very nice. However, they can't be
hosted on a regular web host(at least to my knowledge) since they run
as the web server themselves. So hosting would cost more, at least 2-3
times more from what I've seen.

So I'm thinking of making a python CMS based on WSGI. I'm now trying
to figure out a few things like the best way to store the content and
how to manage/use plugins. For storing the content, the only ways I
know of are as files or in a database. But I'm not sure what would be
better. And as for how to do plugings, I plan on looking at Plone and
skeletonz.

As for working with WSGI, I have found
Colubrid(http://wsgiarea.pocoo.org/colubrid/) and
Paste(http://pythonpaste.org/). I was wondering if anyone knew of any
other libraries that make working with WSGI easier. Also, I wondering
if anyone would like to share their experiences of working with those.


ps. I know that this is a big and complicated project. But no matter
how far I get, it will be fun because its Python:)

-- 
"Now that I am a Christian I do not have moods in which the whole
thing looks very improbable: but when I was an atheist I had moods in
which Christianity looked terribly probable."
  -C. S. Lewis

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


Re: Python and CMS

2006-10-23 Thread Echo
Duncan Booth wrote:
> Just because something like Plone can run as a web server doesn't mean that
> you expose that web server to the outside world, nor do you have to run it
> as a webserver at all. Normally you run Plone behind another web server
> such as Apache.
>
> You can get Plone on shared hosting from various places. I use webfaction
> (www.webfaction.com).
To be able to run Plone on webfaction, I checked them out a few days
ago, you have to get the plan 'shared 4', which is a lot more
expensive than places that offer regular web hosting with pythong
suport (like dreamhost.com).

Bruno Desthuilliers wrote:
> Pylons (www.pylonshq.com). It's a rail-like framework based on Paste.
What I've seen so far, I like. I think I will use Pylons. Thanks.

> > ps. I know that this is a big and complicated project.
>
> Really ? Why so ?
>
> Writing a configurable, extensible, general purpose can be a "big and
> complicated project". But writing a "taylor-made", specific one is not
> that difficult.
Good point.

-- 
"Now that I am a Christian I do not have moods in which the whole
thing looks very improbable: but when I was an atheist I had moods in
which Christianity looked terribly probable."
  -C. S. Lewis

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


Re: editor for Python on Linux

2006-02-20 Thread Echo
On 2/20/06, billie <[EMAIL PROTECTED]> wrote:
> I really think that IDLE is one of the best around in Python source editing.
For me, I find that IDLE is about the worse for editing Python sources.

I used to use Notepad++ before I started using Boa. Sometimes I still
use Notepad++ because I can easly right click on a file to open it up
in Notepad++.

I use the editor that comes with Dabo. It has most features that any
good python editor has. It does CURRENTLY lack many options, however
that will change in the future. All of Dabo is being worked on and
updated a lot, sometimes as much as 10-15 things changed, added and/or
fixed in a day. Although, you will want the svn version for the most
resent changes.

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


Importing and source structure troubles

2005-06-03 Thread Echo
Hello,

I am having trouble with putting the source for a program I am working on in different directories.
I have the directories set up like this:

dir1
  dir2
  dir3

I want the source in dir2 to be able to import from the source in
dir3(is this possible). I get import errors when I tried doing this.

A less preferred structure that I tried was like this:
dir1
  dir3
    dir2

I thought that this way would work. but this way I get even more import
errors. two files in dir2 have a 'from dir3.dir2 import bla' however,
in one of the files, I get an import error. any idea why this is??

What is the best way to structure the program I am working on? I have 3
groups of source files. One has the files that start the program and
some tools. Another group has all the main files. And the last group is
just some misc stuff. How would the best way to accomplish this be?
-- -Echo
-- 
http://mail.python.org/mailman/listinfo/python-list

Having trouble with relative imports

2007-04-09 Thread Echo
Here is my setup:
rpg
-objects
--__init__.py
--gameobject.py
--material.py
-__init__.py
-run_tests.py
-stats.py

the contents of run_test.py is:
import objects as o

the contents of objects/__init__.py is:
from material import *

in objects/material.py I have:
from .gameobject import GameObject
from ..stats import stats

When I try to run run_tests.py, I get this traceback:
(1:30:59 PM) OshEcho: [EMAIL PROTECTED] ~/projects/rpg $ python run_tests.py
Traceback (most recent call last):
  File "run_tests.py", line 4, in 
import objects as o
  File "/home/echo/projects/rpg/objects/__init__.py", line 3, in 
from material import *
  File "/home/echo/projects/rpg/objects/material.py", line 4, in 
from ..stats import stats
ValueError: Attempted relative import beyond toplevel package


Could someone point out to me what I am doing wrong?
I'm running Python 2.5 on Gentoo

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


Re: Having trouble with relative imports

2007-04-10 Thread Echo
On 4/9/07, Echo <[EMAIL PROTECTED]> wrote:
> Here is my setup:
> rpg
> -objects
> --__init__.py
> --gameobject.py
> --material.py
> -__init__.py
> -run_tests.py
> -stats.py
>
> the contents of run_test.py is:
> import objects as o
>
> the contents of objects/__init__.py is:
> from material import *
>
> in objects/material.py I have:
> from .gameobject import GameObject
> from ..stats import stats
>
> When I try to run run_tests.py, I get this traceback:
> (1:30:59 PM) OshEcho: [EMAIL PROTECTED] ~/projects/rpg $ python run_tests.py
> Traceback (most recent call last):
>   File "run_tests.py", line 4, in 
> import objects as o
>   File "/home/echo/projects/rpg/objects/__init__.py", line 3, in 
> from material import *
>   File "/home/echo/projects/rpg/objects/material.py", line 4, in 
> from ..stats import stats
> ValueError: Attempted relative import beyond toplevel package
>
>
> Could someone point out to me what I am doing wrong?
> I'm running Python 2.5 on Gentoo
>
> --
> -Echo
>

Well, since I've gotten no answer and since that Python 2.5 doesn't
play well with some programs on Gentoo, I will be switch back to 2.4
for now.

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


Re: Python Goes Mercurial

2009-04-02 Thread Echo
2009/4/2 Jeremiah Dodds 

> The one thing that makes me want to use git more than any other dvcs is
> that you don't have to create a new directory for branches. This may be
> possible in other dvcs's , but git is the only one I've seen advertise the
> capability.
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
That is the main reason why I switched to git at my work.
As for the git rebase, I don't ever plan on using that 'feature'. Even
though I would rather have had GvR pick git, I think he did a good job
deciding.


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


Re: The Python standard library and PEP8

2009-04-20 Thread Echo
On Mon, Apr 20, 2009 at 9:31 AM, George Sakkis wrote:

> On Apr 19, 6:01 pm, "Martin P. Hellwig"
>
> > Besides, calling Python Object-Orientated is a bit of an insult :-). I
> > would say that Python is Ego-Orientated, it allows me to do what I want.
>
> +1 QOTW
>

So true.

+1 QOTW

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


How is the start of my server monitoring code?

2009-05-04 Thread Echo
I just started a project to monitor servers(load, memory, processes,
etc) via ssh(using paramiko). And I was hoping to get some input on
the design of my project, how pythonic it is, etc. It is quite basic
right now. But it is currently able to get load and memory stats from
any number of servers. I haven't started the logging to a DB or the
GUI for it yet. I also haven't touched on error handling at all
either.

My reasons for making my own server monitoring project:
-It's fun
-Low requirements (only python, paramiko, and pycrypto 1.9+ is required)
-Nothing to install on the servers
-Easy to customize

You can view the code at:
http://github.com/brandonsinger/pywatchlmn/blob/43afb593a891a3d25f3cd9910c5829867bbe229d/monitor.py
The project page is at: http://github.com/brandonsinger/pywatchlmn/tree/master

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


beginer question of list comprehensions

2006-03-23 Thread Echo
Ok, this is the first list comprehension that I have done.
Surprisinly, it works for the most part.
The problem with it is that it returns a list with two lists in it,
instead of just one list. Can anyone tell me what I am doing wrong or
how to fix it.

Here is my code:
[t for t in (__import__(m, globals(), locals(), m).BizObjects() for m
in table_files)]

"table_files" is a list with two module names
"__import__(m, globals(), locals(), m).BizObjects()" is a list of
objects gotten from the module.

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


Re: Web development with Python 3.1

2009-10-26 Thread Echo
bottle (http://bottle.paws.de/) can run on python 3.1 after running
the 2to3 tool on it. It is a very lightweight framework. CherryPy 3.2
also runs on python 3.x

I don't know if there are any others.

On Sun, Oct 25, 2009 at 7:52 PM, Alan Harris-Reid
 wrote:
>
> I am very much new to Python, and one of my first projects is a simple
> data-based website. I am starting with Python 3.1 (I can hear many of you
> shouting "don't - start with 2.6"), but as far as I can see, none of the
> popular python-to-web frameworks (Django, CherryPy, web.py, etc.) are
> Python3 compatible yet.
>
> So, what can I use to start my web programming experience using 3.1?
>
> Any help would be appreciated.
>
> Alan
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



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


how to do draw pattern with python?

2012-09-21 Thread echo . hping
may i know how to shift the bits using only looping and branching??

xx
.x..x.
..xx..
..xx..
.x..x.
xx

xx
..x..x
...xx.
...xx.
..x..x
xx

.xx...
x..x..
xx
xx
x..x..
.xx...

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