On 28/08/2010 14:41, Peter Otten wrote:
BTW, I didn't expect it but I get different results on different
runs.
Clever code. I will give it a go soonest. Elec off for the next 24 hours
in my neck of the woods. Urgh. Python can't "import electricity" just yet :)
\d
--
http://mail.python.org/mail
On 28/08/2010 12:03, Peter Otten wrote:
But be warned that if you set the limit too high instead of giving you a
RuntimeError your program will segfault.
Silly question: is there any way to tell the future in this case? I
mean, ask for X recursion limit, and catch an error (or something) if
tha
On 28/08/2010 11:17, Carl Banks wrote:
It's simple. Copy the object to flatten onto your stack. Pop one item
off the stack. If the item you popped is a list, push each item of
that list onto the stack. Otherwise yield the value. Loop until stack
is empty.
Nice. The reversed thing was throwing me,
On 28/08/2010 09:21, Arnaud Delobelle wrote:
This flattens the list in the flatwalk method (which IMHO it should
do given its name!):
Heh, I often name things ahead of my actual capacity to implement them!
el is child.flatwalk():
Ah, I see what you mean. I think 'is' is 'in', but I kind of g
On 28/08/2010 08:43, Peter Otten wrote:
If you call functions within functions (or methods, it doesn't matter) they
consume stack space
Right, got it. Darn, but at least there's that setrecursionlimit call.
Thanks,
\e
--
http://mail.python.org/mailman/listinfo/python-list
This is all about walking trees, recursion and generators. None of which
fit my brain at all!
From an XML tree (an SVG file) I build a bunch of Tag objects.
[I use lxml, but I am combining multiple svg files into a 'forest' of
trees, so I can't use the lxml walking methods because they all sto
On 04/08/2010 20:09, Dotan Cohen wrote:
Don't forget that the Euro symbol is outside the Greek character set.
I could make some kind of economic joke here, but I'm also broke :D
\d
--
http://mail.python.org/mailman/listinfo/python-list
On 02/08/2010 17:35, Mark Lawrence wrote:
aka the colon. :)
Ha. This is a case of the colon being the appendix!
\d
--
http://mail.python.org/mailman/listinfo/python-list
On 10/07/2010 13:05, Dani Valverde wrote:
It could be a solution. But I am used to work with gEdit using the R
statistical programming language plugin, and I am able to send the code
to console instead of typing it in.
To run your code, save it to a file 'mycode.py' (or whatever), then open
a co
On 21/03/2010 09:23, Ren Wenshan wrote:
I have been learning Panda3D, an open source 3D engine,
Ask on the Panda3D forums, you will get good help there.
\d
--
http://mail.python.org/mailman/listinfo/python-list
On 10/02/2010 20:36, pyt...@bdurham.com wrote:
def picture(s, pic, placeholder='@'):
nextchar=iter(s).next
return ''.join(nextchar() if i == placeholder else i for i in pic)
Hell's teeth - even I understood that! Amazing solution.
\d
--
Fonty Python and Things! -- http://otherwise.re
No one uses pyClutter?
I have some code, it does not work, but maybe this will start to help
solve the problem:
import clutter
from clutter import cogl
x,y=0,0
def boo(tl,frame,obj):#,evt):
global x,y
obj.set_position(x, y)
def xy(obj,evt):
global x,y
x,y = ev
Hi, this is a little bit of a cross-post. I posted to the clutter list,
but there's little activity there.
I am trying to make sense of pyClutter 1.0. Could anyone point me to an
example (or post one) that shows clipping from a path applied to child
objects?
For example: A star shape that conta
On Saturday 02 January 2010 00:02:36 Dan Stromberg wrote:
> I put together a page about significant whitespace (and the lack thereof).
The only thing about Python's style that worries me is that it can't be
compressed like javascript can*, and perhaps that will prevent it becoming a
browser-side
On Thursday 17 December 2009 19:46:41 Terry Reedy wrote:
> His idea was for a document rather than
> app centric plain.
These days I find the notion of monolithic apps to be a pita.
The concept of many small black boxes (but open source) that each do a single
job and pipe in/out is so much more
On Thursday 17 December 2009 10:54:59 David Roberts wrote:
> Have you seen Eagle Mode[1]?
>
Yes. It's a strange beast. Good start I think; but addicted to zooming, to the
detriment of the managing aspects I think. Still, here I sit writing no code
and pontificating!
\d
--
\/\/ave: donn.in...@g
On Wednesday 16 December 2009 07:03:19 David Roberts wrote:
> It involves scaling an image to various resolutions, and partitioning
> them into fixed-size tiles. It's roughly the same technique used by
> Google Maps/Earth.
Thanks. That gives me something to go on. Wikipedia didn't like my search
t
On Wednesday 16 December 2009 09:42:14 David Roberts wrote:
> PyZUI 0.1 has been released:
Magic! Grabbed a tarball yesterday.
\d
--
\/\/ave: donn.in...@googlewave.com
home: http://otherwise.relics.co.za/
2D vector animation : https://savannah.nongnu.org/projects/things/
Font manager : https://s
On Tuesday 15 December 2009 11:12:21 Martijn Arts wrote:
> You could do some really awesome stuff with that! I love the webpage
> example where you zoom in on the exclamation mark and there's a new page.
>
It is very cool, but I would inject a note of caution here: I'd a hate a zui
to become a c
On Tuesday 15 December 2009 04:29:39 David Roberts wrote:
> Yes, the toolkit used is PyQt.
\me makes note to start learning PyQt asap.
> and employs pyramidal tiling for efficiency
\me ... time to hit Wikipedia :)
> (I haven't used any Qt/KDE voodoo in this regard).
Imho, your code should *becom
On Tuesday 15 December 2009 01:43:52 David Boddie wrote:
> I managed to catch his address and sent him a message saying that people
> were discussing PyZUI in this thread.
>
Oooh. Sits,fidgets and waits. I want my socks back! (OP) :D
\d
--
\/\/ave: donn.in...@googlewave.com
home: http://otherwis
On Monday 14 December 2009 00:10:52 David Boddie wrote:
> Doesn't the author give his e-mail address at the end of the video?
> (Maybe I'm thinking of a different video.)
>
Yes, in a quick and garbled way :) I have yet to try to contact the author or
the youtube poster -- been too busy.
I was ho
On Friday 11 December 2009 12:38:46 Daniel Fetchinson wrote:
> Youtube has a link 'Send message' on the profile of users, maybe
> sending a message to the person who uploaded the video will give you a
> useful response.
>
I'm a Tube-tard so that never crossed my mind. Will give it a go.
\d
--
ht
Hi,
I happened upon this youtube link:
http://www.youtube.com/watch?v=57nWm984wdY
It fairly blew my socks off. In it a fellow by the name of David Roberts demos
a zui written in Python. Aside from the zooming (which is impressive enough)
it show embedding of images, pdf files, web pages and text.
On Saturday 14 November 2009 22:23:40 Paul Rubin wrote:
> they'll have to call it Go2
Lol.
Or we could fork it and call it Gosub ... and never return!
\d
--
http://mail.python.org/mailman/listinfo/python-list
> > def ...(...(:
> > ...
> > class ...(...(:
> I disagree. It looks like one smiley is drooling into the other smiley's
> mouth. Two smileys, one function? Yuk!
That *def*initely has no *class* ... :P
\d
--
http://mail.python.org/mailman/listinfo/python-list
On Friday 16 October 2009 13:08:38 Niklas Norrthon wrote:
> that made me think I understand
>
Lol, I know the feeling! :D I have read that page a few times, and I always
emerge thinking 'now I've got it'. Then a week passes...
\d
--
http://mail.python.org/mailman/listinfo/python-list
On Friday 16 October 2009 01:59:43 Stephen Hansen wrote:
>
Just to say, thanks for that post. I am an old ascii dog and this notion of
encoding and decoding is taking such a lng time to penetrate my thick
skull. Little snippets like your post are valuable insights. I have made a
gnote of it!
On Wednesday 14 October 2009 14:23:11 vicky wrote:
> I just want to know that, due to any reason if a script exits, is
> their some way to release all the resources acquired by the script
> during execution ?
Python cleans-up after itself so I would not worry about that until you are an
expert and
On Monday 12 October 2009 00:53:42 Someone Something wrote:
> 1) What should I start programming (project that takes 1-2 months, not very
> short term)?
> 2) Whtat are some good open source projects I can start coding for?
These kinds of questions amaze me. Surely you are a kid in a candy shop when
On Monday 05 October 2009 18:09:46 Manowar wrote:
> just need to know if i can manipulate the bones in
> realtime with python.
If you are looking for some kind of "from awesome import Bones", then I really
don't know of anything. You should look at the various 3D toolkits (like Panda
3D, python-
Great description - wish the Python docs could be as clear. Thanks.
\d
--
http://mail.python.org/mailman/listinfo/python-list
On Thursday 01 October 2009 01:08:28 Patrick Sabin wrote:
> Thanks for the tip. Got it work, although it was a bit tricky, as
> resizing doesn't seem to be supported by python-rsvg and
> cairo.ImageSurface.create_from_png doesn't allow StringIO or
My best suggestions are to visit the Cairo website
On Wednesday 30 September 2009 18:01:50 Patrick Sabin wrote:
> I would like to open svg files with PIL, but svg doesn't seem to be
> supported. Does anyone know about a svg decoder for the PIL?
Have a look at Cairo (python-cairo) in conjunction with librsvg (python-rsvg)
-- that'll fix you up. You
On Friday 25 September 2009 08:15:18 Olof Bjarnason wrote:
> Does anyone have any hint on a more economic way of creating
> single-file distribution packages
You could use distutils (setup.py) and include a readme that explains what
apt-get commands to use to install pygame, etc. Generally it's be
On Thursday 24 September 2009 05:05:45 MacRules wrote:
> s="1234abcd"
print s[0:4]
should do it. Not sure it's a function though.
\d
--
home: http://otherwise.relics.co.za/
2D vector animation : https://savannah.nongnu.org/projects/things/
Font manager : https://savannah.nongnu.org/projects/fon
On Wednesday 23 September 2009 22:12:24 Ethan Furman wrote:
> Works great if you want 4,999,999 elements. ;-) Omit the '1' if you
> want all five million.
Yes. Fenceposts always get me :)
And I was just reminded that one can:
l=range(500)
\d
--
home: http://otherwise.relics.co.za/
2D vector
On Wednesday 23 September 2009 19:14:20 Rudolf wrote:
> I want to allocate an array and then populate it
> using a for loop.
You don't need to allocate anything, just use the list or dictionary types.
l=[] #empty list
for x in range(1,500):
l.append(x)
\d
--
http://mail.python.org/mailman/
On Wednesday 23 September 2009 18:51:29 volcano wrote:
> exit_code = !$
I think it's $? to get the code.
\d
--
home: http://otherwise.relics.co.za/
2D vector animation : https://savannah.nongnu.org/projects/things/
Font manager : https://savannah.nongnu.org/projects/fontypython/
--
http://mail.py
On Monday 21 September 2009 22:49:50 daggerdvm wrote:
> you brain needs error checking!
try:
return response()
except Troll,e:
raise dontFeed(anymore=True)
\d
--
home: http://otherwise.relics.co.za/
2D vector animation : https://savannah.nongnu.org/projects/things/
Font manager : https://savann
print "a"+"b"
\d
--
http://mail.python.org/mailman/listinfo/python-list
On Saturday 12 September 2009 17:30:19 garabik-
news-2005...@kassiopeia.juls.savba.sk wrote:
> apt-get install unicode
> unicode 0100..
Nice tip, thanks.
> if you see a lot of accented letters (and not squares or question marks),
> you can be sure
I see the accented chars -- so now I am more cert
On Saturday 12 September 2009 07:55:14 Lie Ryan wrote:
> > f=ImageFont.truetype("FGTshgyo.TTF",1,encoding="utf-8")
> > print f.font.family
> > '?s'
> Are you sure that your terminal (Command Prompt/bash/IDLE/etc) supports
> utf-8 and that it is properly set up to display utf-8?
Fairly sure.
Python 2.6
PIL Version: 1.1.6-3ubuntu1
libfreetype6 Version: 2.3.9-4ubuntu0.1
Hello,
I have a feeling I've asked this in the distant past, but it's recently
emerged as a bug in my app so can anyone point me in the right direction?
In Fonty Python, when I draw the family name of a f
On Friday 11 September 2009 09:30:42 Kermit Mei wrote:
Do this:
class Test(object):
> t1 = Test
And this:
t1 = Test()
That makes an instance and runs the __init__
\d
--
home: http://otherwise.relics.co.za/
2D vector animation : https://savannah.nongnu.org/projects/things/
Font manager : https://
ket, dict, whatever?
A sort of generic solution might be to follow str's behavior
with respect to '__str__', extending it to fall back to repr()
whatever goes wrong.
def xtr(a):
try:
return str(a)
except:
return repr(a)
...
hey are not better known'
If English isn't your 1st language, you deserve a lot of credit for your
mastery of it, but you need a better dictionary.
Donn Cave, [EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
27;t imagine how you could be
convinced of this. Changes to Python in 3.0 won't satisfy
the continuing "need" for change thereafter.
Donn Cave, [EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
ation is a lot more fun in some ways,
but I think if you were to apply a sort of conspiracy analysis
to the situation - "who benefits from language change" - this
would be a couple items down on the list of motivations.
Donn Cave, [EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
ome of the maintenance issues, since at least you can upgrade on
your own schedule, but of course it has its costs too. Anyone who
might be thinking about using Python for an application should
seriously think about this.
Donn Cave, [EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
tify the backup
error unit, if the command line parameter option isn't available
for some reason.
Donn Cave, [EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
ed pipe. When you read from one,
you get end of file, i.e., a normal return with 0 bytes.
When you test it, make sure to try a configuration with more
than one child process. Since the parent holds the write end
of the pipe, subsequently forked child processes could easily
inherit it, and they
t does support "asynchronous, blocking" with
aio -- as VAX/VMS did (and presumably still does), with event
flags.
Donn Cave, [EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
rony because there's no way to know when the data is
ready, and 3rd rate I/O because afterwards you still have the
copying to do. I don't see even this much in asyncore.py, but
I just gave it a glance.
thanks,
Donn Cave, [EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
uld cheerfully accept this,
given the meager and clumsy support for static typing in languages
like C++, but today, it makes me appreciate Haskell's potential
for complex projects.
Donn Cave, [EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
oard interrupt?
You might try posix.setsid(), from the child fork.
The object is to get the child fork out of the foreground
process group for the Berkeley terminal driver. This defines
who gets signals, when they originate in terminal control keys.
Donn Cave, [EMAIL PROTECTED]
--
http://ma
Nick Craig-Wood wrote:
> This iterates over the lines of all files listed in sys.argv[1:],
> defaulting to sys.stdin if the list is empty. If a filename is '-', it
> is also replaced by sys.stdin. To specify an alternative list of
> filenames, pass it as the first argument to input(). A single fil
Hexamorph wrote:
> It's a bit clumsy, but seems to do what I guess you want.
Hey, thanks for that! I will have a go.
\d
--
http://mail.python.org/mailman/listinfo/python-list
Andrew,
Thanks for your tips. I managed to get a working script going. I am sure there
will be stdin 'issues' to come, but I hope not.
If anyone wants to have a look, it's on the cheese shop at:
http://pypi.python.org/pypi/fui
\d
--
"You know, I've gone to a lot of psychics, and they've told me
Thanks for the tips, I'll decode and try 'em all out.
> Ah yes, Groo. Ever wonder who would win if Groo and Forrest Gump fought
> each other?
Heh ;) I reckon they'd both die laughing. Be fun to watch -- if anyone else
survived!
\d
--
"A computer without Windows is like chocolate cake without
> wget -i -
> it doesn't do anything, just waits for your input. Your applications
> probably should behave the same.
Okay, that works for me.
> Paddy wrote:
> > ls *.a | ./fui.py -f - *.b
> It doesn't seem to me that -f parameter is necessary for your
> application.
Yes and no, I have another op
Paddy wrote:
> fileinput is set to process each file a line at a time unfortunately.
Wow. So there seems to be no solution to my OP. I'm amazed, I would have
thought a simple list of strings, one from stdin and one from the args,
would be easy to get.
I *really* don't want to open each file, that
Paddy wrote:
> ls *.a | ./fui.py -f - *.b
To be sure I grok this: I am seeing the single dash as a placeholder for
where all the piped filenames will go, so *.b happens after *.a has been
expanded and they all get fed to -f, right?
I'm also guessing you mean that I should detect the single dash an
> Try the fileinput module.
I did give the fileinput module a go, but I can't find much info on it and
the help is ... well, it's python help ;)
> in goes to its stdin where it is processed if it has an argument of -
> fileinput works that way
Okay, I did think of the dash, but did not know how to
Hi,
(Gnu/Linux - Python 2.4/5)
Given these two examples:
1.
./fui.py *.py
2.
ls *.py | ./fui.py
How can I capture a list of the arguments?
I need to get all the strings (file or dir names) passed via the normal
command line and any that may come from a pipe.
There is a third case:
3.
ls *.jpg |
> You get the full locale name with locale.setlocale(category) (i.e.
> without the second argument)
Ah. Can one call it after the full call has been done:
locale.setlocale(locale.LC_ALL,'')
locale.setlocale(locale.LC_ALL)
Without any issues?
> > I need that two-letter code that's hidden in a
> > t
Given that getlocale() is not to be used, what's the best way to get the
locale later in the app? I need that two-letter code that's hidden in a
typical locale like en_ZA.utf8 -- I want that 'en' part.
BTW - things are hanging-together much better now, thanks to your info. I have
it running in
> Can you please type
> paf = ['/home/donn/.fontypython/M\xc3\x96gul.pog']
> f = open(paf, "r")
I think I was getting a ghost error from another try somewhere higher up. You
are correct, this does open the file - no matter what the locale is.
I have decided to kee
> Now you are mixing two important concepts - the *contents*
> of the file with the *name* of the file.
Then I suspect the error may be due to the contents having been written in
utf8 from previous runs. Phew!
It's bedtime on my end, so I'll try it again when I get a chance during the
week.
Th
Well, that didn't take me long... Can you help with this situation?
I have a file named "MÖgul.pog" in this directory:
/home/donn/.fontypython/
I set my LANG=C
Now, I want to open that file from Python, and I create a path with
os.path.join() and an os.listdir() which resul
Martin,
I want to thank you for your patience, you have been sterling. I have an
overview this evening that I did not have this morning. I have started fixing
my code and the repairs may not be that extreme after all.
I'll hack-on and get it done. I *might* bug you again, but I'll resist at all
> No. It may use replacement characters (i.e. a question mark, or an empty
> square box), but if you don't see such characters, then the terminal has
> successfully decoded the file names. Whether it also correctly decoded
> them is something for you to check (i.e. do they look right?)
Okay.
So, t
> If you can all ls them, and if the file names come out right, then
> they'll have the same encoding.
Could it not be that the app doing the output (say konsole) could be
displaying a filename as best as it can (doing the ignore/replace) trick and
using whatever fonts it can reach) and this woul
> So on *your* system, today: what encoding are the filenames encoded in?
> We are not talking about arbitrary files, right, but about font files?
> What *actual* file names do these font files have?
>
> On my system, all font files have ASCII-only file names, even if they
> are for non-ASCII chara
Martin,
> Yes. It does so when it fails to decode the byte string according to the
> file system encoding (which, in turn, bases on the locale).
That's at least one way I can weed-out filenames that are going to give me
trouble; if Python itself can't figure out how to decode it, then I can also
Martin,
Thanks, food for thought indeed.
> On Unix, yes. On Windows, NTFS and VFAT represent file names as Unicode
> strings always, independent of locale. POSIX file names are byte
> strings, and there isn't any good support for recording what their
> encoding is.
I get my filenames from two sour
Martin,
I really appreciate your reply. I have been working in a vacuum on this and
without any experience. I hope you don't mind if I ask you a bunch of
questions. If I can get over some conceptual 'humps' then I'm sure I can
produce a better app.
> That's a bug in the app. It shouldn't assume
Hello,
I hope someone can illuminate this situation for me.
Here's the nutshell:
1. On start I call locale.setlocale(locale.LC_ALL,''), the getlocale.
2. If this returns "C" or anything without 'utf8' in it, then things start
to go downhill:
2a. The app assumes unicode objects internally. i.e.
Thorsten Kampe wrote:
> gettext.textdomain('optparse')
> gettext.install('script', unicode = True)
They speak of a 'global' domain in the docs, but (as is my usual beef with
the Python docs -- see PHP docs for sterling help) there is no clarity.
It *sounds* like there can be a .mo file for *eve
Is there a group better suited to gettext/i18n questions of this sort? Just
wondering because I have little time left to finish my "December" project!
> How does one 'merge' gettext.translations objects together? Or is that
> insane?
>
> What's the best way to handle a project with multiple domai
Thanks for taking the time to post those links. I have read most of them
before. They don't seem to cover the basic issue in my OP, but i18n on
Python is a dark art and maybe there's something I missed.
\d
--
http://mail.python.org/mailman/listinfo/python-list
Hi,
A soon-to-be happy new year to everyone!
I'm 100% new to this i18n lark and my approach so far has been to create
a .mo file per module in my app.
My thinking was, why load one huge .mo file when a single module only needs
a few strings? Since then, it seems, I have made the wrong decision.
> Which is even more correct than I hoped for -- in Norwegian, aa is
> pronounced the same as å (which is the 29th letter in the Norwegian
> alphabet) and is sorted according to pronunciation.
Much appreciated bjorn.
\d
--
http://mail.python.org/mailman/listinfo/python-list
In follow-up: I think this should work:
# -*- coding: utf8 -*-
import locale
locale.setlocale( locale.LC_ALL, "" )
class Test(object):
def __init__(self,nam):
self.name = nam
def __cmp__(self, other):
return cmp(self.name, other.name)
l = [ Test("ABILENE.ttf"), Te
Hi,
Well, I'm beat. I can't wrap my head around this stuff.
I need to create a list that will contain objects sorted by a "name"
property that is in the alphabetical order of the user's locale.
I used to have a simple list that I got from os.listdir and I could do this:
l = os.listdir(".")
l.so
> You guess. When fisrt imported, the module's source is executed, a
> module object is created and stored in sys.modules, and the needed names
> are inserted into the importing module's namespace. Next times the
> module is "served" directly from sys.modules.
Peachy, thanks.
\d
--
http://mail.
Chris wrote:
> print cli.os.environ['HOME']
I was really confused by your reply until I saw the cli.os part. Okay, I see
what you mean.
\d
--
http://mail.python.org/mailman/listinfo/python-list
> would be a VeryBadThing(tm).
:)
> Having explicits imports in each module is good wrt/ readability.
Okay, I can accept that. I worry that it's opening the module file over and
over again - or does it open it once and kind of re-point to it when it
hits a second import of the same thing?
> pac
> I've now uploaded a new release of the desktop module which is now, in
> fact, a package:
Thanks Paul, I saw it via the cheese shop rss. I have been too busy to read
this list for a week. I will have a look in due course.
\d
--
http://mail.python.org/mailman/listinfo/python-list
Hi, I'm sure this is a FAQ, but I have just not found clarity on the
web/docs.
(using monospaced type to show the tree)
trunk:$ tree
.
fp
|-- fontypython
| |-- __init__.py
| |-- cli.py
| |-- config.py
(I start it all with ./fp)
fp says:
import cli
cli.py says:
import os
import config
con
> As far as I can tell, you have a bit more code in boo, and somewhere in
> that code (after the print statement), you rebind the name 'kills'.
Okay, yes:
def boo()
kills += 1
print kills
> the absence of a global declaration, this makes this name a local
> variable.
I think I see what you mean
Thanks Bruno, I had to keep coding, so I used the long form
[Object.subobject.property = blah] anyway. It's long-winded, but
unambiguous.
\d
--
http://mail.python.org/mailman/listinfo/python-list
> Please refer me to some basic Python code for animation like that .
You are in for a wild ride! Depending on your platform you can use dozens of
different tools. Try wxPython, pyCairo, pyGTK and PIL (Python Imaging
Library) for the most capable.
Basically you are looking at a fairly complex thin
> class Key(object):
> def __init__self):
> self.__dict__['props'] = KeyProps()
Okay - that's weird. Is there another way to spin this?
> def __setattr__(self,var,val):
> setattr(self.props,var,val)
Perhaps by changing this one?
\d
--
http://mail.python.org/mailman/listinfo/python-list
Hi,
I have two modules, the second is imported by the first.
Let's call them one.py and two.py (two being my API)
In the first I register a function into the second.
[in one.py]
def boo(): ...
...
two.register( boo )
two.startLoop()
In two.py it starts a loop (GTK timeout), so processing remains
> Define a __repr__ or __str__ method for the class
Yes, then I could include the code John Machin suggested in there:
for attr, value in sorted(self.__dict__.iteritems()): blah
That will do nicely. Thanks all.
\d
--
http://mail.python.org/mailman/listinfo/python-list
> So you might want to describe your use-case.
Um.. I wanted an object with Key to hold other data. I wanted a way to set
that *other* data within Key without having to specify the "object
in-between" everytime.
k1.x = "ni!"
should perform:
k1.props.x = "ni!"
and
print k1.x
should perform:
print
> AFAIK you have to roll your own. Here is a very rudimentary example:
Very cool, thanks.
\d
--
http://mail.python.org/mailman/listinfo/python-list
Hi,
Here's some code, it's broken:
class Key( object ):
def __init__(self):
self.props = KeyProps()
def __getattr__(self, v):
return getattr( self.props,v )
def __setattr__(self,var,val):
object.__setattr__(self.props,var,val)
class KeyProps(object):
Hi,
Is there a way to get a dump of the insides of an object? I thought pprint
would do it. If I had a class like this:
class t:
def __init__(self):
self.x=1
self.y=2
self.obj = SomeOtherObj()
Then it could display it as:
t,
x,1,
y,2,
obj,
Or something like that -- a complete output
1 - 100 of 444 matches
Mail list logo