Re: What YAML engine do you use?

2005-01-21 Thread A.M. Kuchling
On Fri, 21 Jan 2005 18:54:50 +0100, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > judging from http://yaml.org/spec/current.html (750k), the YAML designers are > clearly insane. that's the most absurd software specification I've ever > seen. they > need help, not users. IMHO that's a bit

Re: Funny Python error messages

2005-01-21 Thread Hans Nowak
Will Stuyvesant wrote: Add your funny or surprising Python error messages to this thread. A requirement is that you should also show (minimal) code that produces the message. Put the code below, so people can think about how to generate the message first, a little puzzle if you like. Perhaps this

Re: What YAML engine do you use?

2005-01-21 Thread Reinhold Birkenfeld
A.M. Kuchling wrote: > On Fri, 21 Jan 2005 18:54:50 +0100, > Fredrik Lundh <[EMAIL PROTECTED]> wrote: >> judging from http://yaml.org/spec/current.html (750k), the YAML designers are >> clearly insane. that's the most absurd software specification I've ever >> seen. they >> need help, not

Re: Print a string in binary format

2005-01-21 Thread Steven Bethard
Stephen Thorne wrote: On Fri, 21 Jan 2005 01:54:34 GMT, Kartic <[EMAIL PROTECTED]> wrote: Aha..I guess I posted too soon. You might want to take a look at this cookbook entry: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/219300 Defines lambdas to convert integer to binary. The one you pr

Re: Unbinding multiple variables

2005-01-21 Thread Steven Bethard
Johnny Lin wrote: my understanding about locals() from the nutshell book was that i should treat that dictionary as read-only. is it safe to use it to delete entries? No it's not: py> def f(): ... x = 1 ... del locals()['x'] ... print x ... py> f() 1 py> def f(): ... x = 1 ...

make install with python

2005-01-21 Thread Uwe Mayer
Hi, I am writing a Python application and use the GNU auto-tools to compile what needs compilation (i.e. Qt's .ui files). However, I don't know how to write an automake file that installs the main file (lmc.py) and some library files (i.e. ClassA.py, ClassB.py) into the appropriate directories.

Re: problems with duplicating and slicing an array

2005-01-21 Thread Steven Bethard
py> import numarray as na py> a = na.array([[1,2,3],[4,5,6]]) Yun Mao wrote: Thanks for the help. numarray doesn't provide what I look for either. e.g. a = array( [[1,2,3],[4,5,6]] ) I sometimes what this: a[ [1,0], :], py> a[[1,0]] array([[4, 5, 6], [1, 2, 3]]) or even a[ [1,0], [0,1] ]

Re: Zen of Python

2005-01-21 Thread Tim Peters
[Paul Rubin] >> You snipped out the examples I gave, like [x*x for x in range(5)] >> leaving unnecessary residue in the name space. Was it not >> obvious from the beginning that that was a kludge? If it was >> obviously a kludge, was it not obvious that there would be >> reason to want to fix it

Re: make install with python

2005-01-21 Thread Reinhold Birkenfeld
Uwe Mayer wrote: > Hi, > > I am writing a Python application and use the GNU auto-tools to compile what > needs compilation (i.e. Qt's .ui files). > However, I don't know how to write an automake file that installs the main > file (lmc.py) and some library files (i.e. ClassA.py, ClassB.py) into th

Re: Configuring Python for Tk on Mac

2005-01-21 Thread Jim Sizelove
Martyn Quick wrote: On my desk here at work I have a Mac G4 running Mac OS X v10.2.8. When I go into a terminal and type "python" up comes a nice python interface and all seems great. However when I type "import Tkinter" I'm greeted by the following error. import Tkinter Traceback (most recent ca

Re: Simple (newbie) regular expression question

2005-01-21 Thread John Machin
André Roberge wrote: > Sorry for the simple question, but I find regular > expressions rather intimidating. And I've never > needed them before ... > > How would I go about to 'define' a regular expression that > would identify strings like > __alphanumerical__ as in __init__ > (Just to spell th

Re: What YAML engine do you use?

2005-01-21 Thread Fredrik Lundh
A.M. Kuchling wrote: > IMHO that's a bit extreme. Specifications are written to be detailed, so > consequently they're torture to read. Seen the ReStructured Text spec > lately? I've read many specs; YAML (both the spec and the format) is easily among the worst ten-or-so specs I've ever seen.

Re: Graph and Table implementation

2005-01-21 Thread John Hunter
> "Jan" == Jan Rienyer Gadil <[EMAIL PROTECTED]> writes: Jan> could anyone please help me! what and how is the best Jan> implementation of creating a table based on data coming from Jan> the serial port ? and also how would i be able to create Jan> graphs (2D) based on these d

Re: What YAML engine do you use?

2005-01-21 Thread Daniel Bickett
Istvan Albert wrote: > XML with elementtree is what makes me never have think about XML again. I second that. I heard about yaml and I read into it, but when I tried to use it I didn't seem to get in touch with all of the glory surrounding it. The yaml module -- when I tried to use it -- was very

Re: Xah Lee's Unixism

2005-01-21 Thread Pfhreak
Patrick, I maintain the web page that Rupert mentions in responce to your message about Nextstep and Mach. (http://www.macos.utah.edu/Documentation/MacOSXClasses/macosxone/unix.html) I'm curious to learn more about the development of Mach and its use in Nextstep. Can you point me to your source

Re: Is there a library to parse Mozilla "mork" documents?

2005-01-21 Thread John Reese
On Thu, 20 Jan 2005 23:48:34 -0800, Tim Roberts <[EMAIL PROTECTED]> wrote: > John Reese <[EMAIL PROTECTED]> wrote: >> >>Mozilla, Firefox, Thunderbird, and so forth use this awful format >>called MORK to store all kinds of things: which messages you've read >>in a newsgroup, headers and indexes into

Re: Simple (newbie) regular expression question

2005-01-21 Thread André Roberge
John Machin wrote: André Roberge wrote: Sorry for the simple question, but I find regular expressions rather intimidating. And I've never needed them before ... How would I go about to 'define' a regular expression that would identify strings like __alphanumerical__ as in __init__ (Just to spell

Tuple size and memory allocation for embedded Python

2005-01-21 Thread Jinming Xu
Hi Folks, Python seems unstable, when allocating big memory. For example, the following C++ code creates a tuple of tuples: PyObject* arCoord = PyTuple_New(n); double d = 1.5; for(int i=0; i When the n is small, say 100, the code works fine. when n is big, say 10,000, Python has trouble all

Python 2.4 on FreeBSD 5.3 and ncurses

2005-01-21 Thread Maximillian Dornseif
Hello, I just installed a new FreeBSD 5.3-RELEASE System (Base System) and the first additional Packet I wanted to install was Python. While configuring I gon an error about (n)curses.h and was asked to report this to the Python list: configure: WARNING: ncurses.h: present but cannot be compile

Re: why am I getting a segmentation fault?

2005-01-21 Thread Paul McGuire
"Jay donnell" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I have a short multi-threaded script that checks web images to make > sure they are still there. I get a segmentation fault everytime I run > it and I can't figure out why. Writing threaded scripts is new to me so > I may b

Re: Tuple size and memory allocation for embedded Python

2005-01-21 Thread Craig Ringer
On Fri, 2005-01-21 at 16:03 -0600, Jinming Xu wrote: > Hi Folks, > > Python seems unstable, when allocating big memory. For example, the > following C++ code creates a tuple of tuples: > > PyObject* arCoord = PyTuple_New(n); > double d = 1.5; > for(int i=0; i { > PyObject* coord

Re: Tuple size and memory allocation for embedded Python

2005-01-21 Thread Steve Holden
Jinming Xu wrote: Hi Folks, Python seems unstable, when allocating big memory. For example, the following C++ code creates a tuple of tuples: PyObject* arCoord = PyTuple_New(n); double d = 1.5; for(int i=0; i When the n is small, say 100, the code works fine. when n is big, say 10,000, Pyth

Re: Tuple size and memory allocation for embedded Python

2005-01-21 Thread Craig Ringer
On Fri, 2005-01-21 at 17:20 -0500, Steve Holden wrote: > Jinming Xu wrote: > > > Hi Folks, > > > > Python seems unstable, when allocating big memory. For example, the > > following C++ code creates a tuple of tuples: > > > > PyObject* arCoord = PyTuple_New(n); > > double d = 1.5; > > for(in

Re: why am I getting a segmentation fault?

2005-01-21 Thread Jeff Shannon
Paul McGuire wrote: 4. filename=r[7].split('/')[-1] is not terribly portable. See if there is a standard module for parsing filespecs (I'll bet there is). Indeed there is -- os.path. In particular, os.path.basename() seems to do exactly that snippet is intending, in a much more robust (and read

Re: Tuple size and memory allocation for embedded Python

2005-01-21 Thread Tim Peters
[Jinming Xu] >> Python seems unstable, when allocating big memory. For >> example, the following C++ code creates a tuple of tuples: >> >> PyObject* arCoord = PyTuple_New(n); >> double d = 1.5; >> for(int i=0; i> { >> PyObject* coord = PyTuple_New(2); >> PyTuple_SetItem(coord

PyXML problem between python 2.3 and python 2.4

2005-01-21 Thread PyStarbuck
Hi All, Has anybody had an issue with compatiblity between XML files between python 2.3 and python 2.4. I have PyXML 0.8.3 installed in ClearCase and it is shared between Solaris and Windows. Here is an example on my system: ActivePython 2.3.4 Build 233 (ActiveState Corp.) based on Python 2.3.4

Re: Zen of Python

2005-01-21 Thread Alex Martelli
Timothy Fitz <[EMAIL PROTECTED]> wrote: ... > Perhaps Tim Peters is far too > concise for my feeble mind It's Zen, it's beyond Mind. Let it speak to your True Self! Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Tuple size and memory allocation for embedded Python

2005-01-21 Thread Jinming Xu
From: Tim Peters <[EMAIL PROTECTED]> Reply-To: Tim Peters <[EMAIL PROTECTED]> To: python-list@python.org Subject: Re: Tuple size and memory allocation for embedded Python Date: Fri, 21 Jan 2005 17:51:21 -0500 [Jinming Xu] >> Python seems unstable, when allocating big memory. For >> example, the fo

Re: Configuring Python for Tk on Mac

2005-01-21 Thread Alex Martelli
Craig Ringer <[EMAIL PROTECTED]> wrote: ... > I've just checked the OSX 10.3 machine here, and it fails to import > tkinter there too. I'd say Apple just don't build Python with Tk > support. No idea about any 10.2, sorry, but on 10.3 that's not the problem: Tk support is there alright, it's Tc

default value in a list

2005-01-21 Thread TB
Hi, Is there an elegant way to assign to a list from a list of unknown size? For example, how could you do something like: >>> a, b, c = (line.split(':')) if line could have less than three fields? Thanks, TB -- http://mail.python.org/mailman/listinfo/python-list

Re: Unbinding multiple variables

2005-01-21 Thread Alex Martelli
Johnny Lin <[EMAIL PROTECTED]> wrote: ... > my understanding about locals() from the nutshell book was that i > should treat that dictionary as read-only. is it safe to use it to > delete entries? Speaking as the Nutshell author: it's "safe", it just doesn't DO anything. I _hoped_ locals() wo

Re: default value in a list

2005-01-21 Thread Larry Bates
What do you want put into the "missing" variables? I'll assume None. Something like following works: values=line.split(':') try: a=values.pop(0) except IndexError: a=None try: b=values.pop(0) except IndexError: b=None try: c=values.pop(0) except IndexError: c=None Larry Bates TB wrote: Hi, Is the

Re: default value in a list

2005-01-21 Thread Steve Holden
TB wrote: Hi, Is there an elegant way to assign to a list from a list of unknown size? For example, how could you do something like: a, b, c = (line.split(':')) if line could have less than three fields? l = line.split(':') l is a list, whose length will be one more than the number of colons in

Re: default value in a list

2005-01-21 Thread Paul McGuire
"TB" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > > Is there an elegant way to assign to a list from a list of unknown > size? For example, how could you do something like: > > >>> a, b, c = (line.split(':')) > if line could have less than three fields? > > Thanks, > TB > I

Re: why am I getting a segmentation fault?

2005-01-21 Thread John Machin
Jay donnell wrote: > I have a short multi-threaded script that checks web images to make > sure they are still there. I get a segmentation fault everytime I run > it and I can't figure out why. Writing threaded scripts is new to me so > I may be doing something wrong that should be obvious :( >

finding name of instances created

2005-01-21 Thread André
Short version of what I am looking for: Given a class "public_class" which is instantiated a few times e.g. a = public_class() b = public_class() c = public_class() I would like to find out the name of the instances so that I could create a list of them e.g. ['a', 'b', 'c'] I've read the Python

Re: finding name of instances created

2005-01-21 Thread Craig Ringer
On Fri, 2005-01-21 at 16:13 -0800, Andrà wrote: > Short version of what I am looking for: > > Given a class "public_class" which is instantiated a few times e.g. > > a = public_class() > b = public_class() > c = public_class() > > I would like to find out the name of the instances so that I coul

Re: Class introspection and dynamically determining function arguments

2005-01-21 Thread Bengt Richter
On Thu, 20 Jan 2005 11:24:12 -, "Mark English" <[EMAIL PROTECTED]> wrote: >I'd like to write a Tkinter app which, given a class, pops up a >window(s) with fields for each "attribute" of that class. The user could >enter values for the attributes and on closing the window would be >returned an

Re: default value in a list

2005-01-21 Thread Steven Bethard
Paul McGuire wrote: expand = lambda lst,default,minlen : (lst + [default]*minlen)[0:minlen] Or if you're afraid of lambda like me: def expand(lst,default,minlen):return (lst + [default]*minlen)[0:minlen] or perhaps more readably: def expand(lst, default, minlen): return (lst + [default]*minlen)

Re: Unbinding multiple variables

2005-01-21 Thread Steven Bethard
Alex Martelli wrote: Nevertheless, any modifications to locals() are utterly futile (within a function). Evil hack that makes modifications to locals() not quite as futile: py> import sys py> import ctypes py> def f(): ... x = 1 ... locals()['x'] = 2 ... ctypes.pythonapi.PyFrame_LocalsT

Re: finding name of instances created

2005-01-21 Thread Steven Bethard
André wrote: Given the statement a = public_class() I would like to generate my_dict['a'] = private_class() so that one could write a.apparently_simple_method() and that, behind the scene, I could translate that as my_dict['a'].not_so_simple_method() as well as do things like for name in my_dict:

Re: xml parsing escape characters

2005-01-21 Thread "Martin v. LÃwis"
Luis P. Mendes wrote: From your experience, do you think that if this wrong XML code could be meant to be read only by somekind of Microsoft parser, the error will not occur? This is very unlikely. MSXML would never do this incorrectly. Regards, Martin -- http://mail.python.org/mailman/listinfo/py

Re: make install with python

2005-01-21 Thread Uwe Mayer
Friday 21 January 2005 20:47 pm Reinhold Birkenfeld wrote: [...] > The regular way is to use distutils and a setup.py file (google for > documentation). Ok, thanks. The document described just what I was looking for. Any suggestions how I handle

Re: default value in a list

2005-01-21 Thread Jeff Shannon
TB wrote: Hi, Is there an elegant way to assign to a list from a list of unknown size? For example, how could you do something like: a, b, c = (line.split(':')) if line could have less than three fields? (Note that you're actually assigning to a group of local variables, via tuple unpacking, not

Re: finding name of instances created

2005-01-21 Thread Andrà Roberge
Craig Ringer wrote: On Fri, 2005-01-21 at 16:13 -0800, Andrà wrote: Short version of what I am looking for: Given a class "public_class" which is instantiated a few times e.g. a = public_class() b = public_class() c = public_class() I would like to find out the name of the instances so that I could

Re: rotor replacement

2005-01-21 Thread "Martin v. LÃwis"
[EMAIL PROTECTED] wrote: Do you know this for a fact? I'm going by newsgroup messages from around the time that I was proposing to put together a standard block cipher module for Python. Ah, newsgroup messages. Anybody could respond, whether they have insight or not. The PSF does comply with the

Re: why am I getting a segmentation fault?

2005-01-21 Thread Jay donnell
Thank you. I made all the changes you recommended and everything seems to be working. -- http://mail.python.org/mailman/listinfo/python-list

Re: why am I getting a segmentation fault?

2005-01-21 Thread Jay donnell
>### Have you looked in your database to see if the >script has actually >updated item.goodImage? Do you have a test plan? Thank you for the help. Sorry for the messy code. I was under time constraints. I had class, and I was rushing to get this working before class. I should waited a day and read

Re: Class introspection and dynamically determining function arguments

2005-01-21 Thread Mike C. Fletcher
On Thu, 20 Jan 2005 11:24:12 -, "Mark English" <[EMAIL PROTECTED]> wrote: I'd like to write a Tkinter app which, given a class, pops up a window(s) with fields for each "attribute" of that class. The user could enter values for the attributes and on closing the window would be returned an i

Re: What YAML engine do you use?

2005-01-21 Thread Bengt Richter
On Fri, 21 Jan 2005 12:04:10 -0600, "A.M. Kuchling" <[EMAIL PROTECTED]> wrote: >On Fri, 21 Jan 2005 18:30:47 +0100, > rm <[EMAIL PROTECTED]> wrote: >> Nowadays, people are trying to create binary XML, XML databases, >> graphics in XML (btw, I'm quite impressed by SVG), you have XSLT, you

Re: What YAML engine do you use?

2005-01-21 Thread Peter Hansen
A.M. Kuchling wrote: On Fri, 21 Jan 2005 18:54:50 +0100, Fredrik Lundh <[EMAIL PROTECTED]> wrote: judging from http://yaml.org/spec/current.html (750k), the YAML designers are clearly insane. that's the most absurd software specification I've ever seen. they need help, not users. IMHO that's a

getting file size

2005-01-21 Thread Bob Smith
Are these the same: 1. f_size = os.path.getsize(file_name) 2. fp1 = file(file_name, 'r') data = fp1.readlines() last_byte = fp1.tell() I always get the same value when doing 1. or 2. Is there a reason I should do both? When reading to the end of a file, won't tell() be just as accurate as o

specifying constants for a function (WAS: generator expressions: performance anomaly?)

2005-01-21 Thread Steven Bethard
I wrote: > If you really want locals that don't contribute to arguments, I'd be > much happier with something like a decorator, e.g.[1]: > > @with_consts(i=1, deftime=time.ctime()) > def foo(x, y=123, *args, **kw): >return x*y, kw.get('which_time')=='now' and time.ctime() or deftime > > Then yo

Re: finding name of instances created

2005-01-21 Thread André
Using the method suggested by Steven Bethard, I *almost* got it working the way I would like. Here's my program: === .class PrivateClass(object): .dict = {} .def not_so_simple_method(self): .for name in PrivateClass.dict.keys(): .if PrivateClass.dict[name] == self: .

pure python code to do modular-arithmetic unit conversions?

2005-01-21 Thread Dan Stromberg
Is there already a pure python module that can do modular-arithmetic unit conversions, like converting a huge number of seconds into months, weeks... or a bandwidth measure into megabits/s or gigabits/s or megabytes/s or gigabytes/s, whatever's the most useful (ala df -h)? Thanks! -- http://mai

Re: finding name of instances created

2005-01-21 Thread Steven Bethard
André wrote: Using the method suggested by Steven Bethard, I *almost* got it working the way I would like. Here's my program: === .class PrivateClass(object): .dict = {} .def not_so_simple_method(self): .for name in PrivateClass.dict.keys(): .if PrivateClass.dict[name] =

Re: how to write a tutorial

2005-01-21 Thread Jeffrey Cunningham
On Fri, 21 Jan 2005 03:08:50 -0800, Xah Lee wrote: > i've started to read python tutorial recently. > http://python.org/doc/2.3.4/tut/tut.html > (snip rest of misleading filler) > > http://xahlee.org/PageTwo_dir/more.html The first line is solipsistic (..like..'so what?'). But I think its all m

Re: finding name of instances created

2005-01-21 Thread André
Steven Bethard wrote: > André wrote: > > Using the method suggested by Steven Bethard, I *almost* got it working > > the way I would like. [snip] > > It looks like you want PrivateClass.dict updated every time that > globals() is updated. yes, that is what I would like to do. >You can just use g

Re: hash patent by AltNet; Python is prior art?

2005-01-21 Thread JanC
Tim Churches schreef: > And I agree 100% with Alex Martelli - Europe and other countries must > reject software, algorithmic and business method patents and thus create > a powerhouse of innovation. let the US and fellow-travellers stew in > their own juice - they will become powerhouses of lit

Re: nntplib: abstraction of threads

2005-01-21 Thread JanC
Steve Holden schreef: > Better still, do a Google search on "mail threading algorithm", > implement the algorithm described in > >http://www.jwz.org/doc/threading.html > > and post your implementation back to the newsgroup :-)

Re: finding name of instances created

2005-01-21 Thread Steven Bethard
Andrà Roberge wrote: Behind the scene, I have something like: robot_dict = { 'robot' = CreateRobot( ..., name = 'robot') } and have mapped move() to correspond to robot_dict['robot'].move() (which does lots of stuff behind the scene.) I have tested robot_dict[] with more than one robot (each with i

Re: finding name of instances created

2005-01-21 Thread Steven Bethard
André wrote: Steven Bethard wrote: André wrote: Using the method suggested by Steven Bethard, I *almost* got it working the way I would like. [snip] It looks like you want PrivateClass.dict updated every time that globals() is updated. yes, that is what I would like to do. You can just use global

Re: finding name of instances created

2005-01-21 Thread André
Steven Bethard wrote: > André Roberge wrote: > > Behind the scene, I have something like: > > robot_dict = { 'robot' = CreateRobot( ..., name = 'robot') } > > and have mapped move() to correspond to > > robot_dict['robot'].move() > > (which does lots of stuff behind the scene.) > > > > I have test

Re: finding name of instances created

2005-01-21 Thread Steven Bethard
Andrà Roberge wrote: Behind the scene, I have something like: robot_dict = { 'robot' = CreateRobot( ..., name = 'robot') } and have mapped move() to correspond to robot_dict['robot'].move() (which does lots of stuff behind the scene.) I have tested robot_dict[] with more than one robot (each with i

Re: Free NNTP (was Re: how to stop google from messing Python code)

2005-01-21 Thread JanC
Paul Boddie schreef: > JanC wrote: >> Aahz schreef: >> >>> You also have access to the free netnews server >>> http://news.cis.dfn.de/ >> >> That address is now for DFN internal use only. >> >> Their public service moved to . > > To me, that seems to be the genera

Re: pure python code to do modular-arithmetic unit conversions?

2005-01-21 Thread Dan Bishop
Dan Stromberg wrote: > Is there already a pure python module that can do modular-arithmetic unit > conversions, like converting a huge number of seconds into months, > weeks... Use the divmod function. SECONDS_PER_MONTH = 2629746 # 1/4800 of 400 Gregorian years def convert_seconds(seconds): "R

Re: Determining if a client PC has an Internet connection

2005-01-21 Thread torment
Have you tried just parsing the output from the command "ipconfig"? It's pretty obvious from the output that might give you if a connection is availible. I hope it helps. -Matt Dave Brueck wrote: > Cliff Wells wrote: > > I'm writing an application that needs to know if an Internet connection > >

list unpack trick?

2005-01-21 Thread aurora
I find that I use some list unpacking construct very often: name, value = s.split('=',1) So that 'a=1' unpack as name='a' and value='1' and 'a=b=c' unpack as name='a' and value='b=c'. The only issue is when s does not contain the character '=', let's say it is 'xyz', the result list ha

Re: rotor replacement

2005-01-21 Thread JanC
Robin Becker schreef: > well since rotor is a german (1930's) invention And AES is a Belgian invention... ;-) > it is a bit late for > Amricans (Hollywood notwithstanding) to be worried about its export -- JanC "Be strict when sending and tolerant when receiving." RFC 1958 - Architectural

Re: Print a string in binary format

2005-01-21 Thread Bengt Richter
On Sat, 22 Jan 2005 00:45:19 +1000, Nick Coghlan <[EMAIL PROTECTED]> wrote: >neutrino wrote: >> Greetings to the Python gurus, >> >> I have a binary file and wish to see the "raw" content of it. So I open >> it in binary mode, and read one byte at a time to a variable, which >> will be of the str

Re: pure python code to do modular-arithmetic unit conversions?

2005-01-21 Thread Michael Spencer
Dan Stromberg wrote: Is there already a pure python module that can do modular-arithmetic unit conversions, like converting a huge number of seconds into months, weeks... or a bandwidth measure into megabits/s or gigabits/s or megabytes/s or gigabytes/s, whatever's the most useful (ala df -h)? Than

Re: finding name of instances created

2005-01-21 Thread Jeremy Bowers
On Fri, 21 Jan 2005 21:01:00 -0400, Andrà Roberge wrote: > etc. Since I want the user to learn Python's syntax, I don't want to > require him/her to write > alex = CreateRobot(name = 'alex') > to then be able to do > alex.move() This is just my opinion, but I've been involved with teaching new pro

Re: list unpack trick?

2005-01-21 Thread Siegmund Fuehringer
On Fri, Jan 21, 2005 at 08:02:38PM -0800, aurora wrote: > I find that I use some list unpacking construct very often: > > name, value = s.split('=',1) > > So that 'a=1' unpack as name='a' and value='1' and 'a=b=c' unpack as > name='a' and value='b=c'. > > The only issue is when s does no

Reload Tricks

2005-01-21 Thread Kamilche
I want my program to be able to reload its code dynamically. I have a large hierarchy of objects in memory. The inheritance hierarchy of these objects are scattered over several files. I find that after reloading the appropriate files, and overwriting the __class__ of object instances, one more th

Re: Zen of Python

2005-01-21 Thread Paul Rubin
Tim Peters <[EMAIL PROTECTED]> writes: > But at that time, Python didn't have lexical scoping, and it wasn't > clear that it ever would. So what's the bigger wart? Making > listcomps exactly equivalent to an easily-explained Python for-loop > nest, or introducing a notion of lexical scope unique

Re: why am I getting a segmentation fault?

2005-01-21 Thread John Machin
Jay donnell wrote: > >### Have you looked in your database to see if the >script has > actually > >updated item.goodImage? Do you have a test plan? > > Thank you for the help. Sorry for the messy code. I was under time > constraints. I had class, and I was rushing to get this working before > cla

Re: rotor replacement

2005-01-21 Thread Paul Rubin
"Martin v. Löwis" <[EMAIL PROTECTED]> writes: > > I'm going by newsgroup messages from around the time that I was > > proposing to put together a standard block cipher module for Python. > > Ah, newsgroup messages. Anybody could respond, whether they have insight > or not. Here's the message I h

Re: need help on need help on generator...

2005-01-21 Thread Nick Coghlan
Francis Girard wrote: In particular, I don't know what Python constructs does generate a generator. I know this is now the case for reading lines in a file or with the new "iterator" package. But what else ? Does Craig Ringer answer mean that list comprehensions are lazy ? Where can I find a com

Re: getting file size

2005-01-21 Thread John Machin
Bob Smith wrote: > Are these the same: > > 1. f_size = os.path.getsize(file_name) > > 2. fp1 = file(file_name, 'r') > data = fp1.readlines() > last_byte = fp1.tell() > > I always get the same value when doing 1. or 2. Is there a reason I > should do both? When reading to the end of a file,

Re: Reload Tricks

2005-01-21 Thread Michael Spencer
Kamilche wrote: I want my program to be able to reload its code dynamically. I have a large hierarchy of objects in memory. The inheritance hierarchy of these objects are scattered over several files. I find that after reloading the appropriate files, and overwriting the __class__ of object instanc

Re: Print a string in binary format

2005-01-21 Thread Nick Coghlan
Bengt Richter wrote: On Sat, 22 Jan 2005 00:45:19 +1000, Nick Coghlan <[EMAIL PROTECTED]> wrote: Here's an interesting twiddle, though (there's probably already something along these lines in the cookbook): Looks like you also played with this problem, after Alex posted a request for alternative

Re: Reload Tricks

2005-01-21 Thread Kamilche
That's a powerful advantage - not having to track class instances. Thanks for the tip! I just got done doing it 'my way' though, now I'll have to change it. It took me all day! :-D -- http://mail.python.org/mailman/listinfo/python-list

Re: Reload Tricks

2005-01-21 Thread Kamilche
Would it be possible to just not copy any attribute that starts and ends with '__'? Or are there some important attributes being copied? -- http://mail.python.org/mailman/listinfo/python-list

Re: specifying constants for a function (WAS: generator expressions: performance anomaly?)

2005-01-21 Thread Nick Coghlan
Steven Bethard wrote: I wrote: > If you really want locals that don't contribute to arguments, I'd be > much happier with something like a decorator, e.g.[1]: > > @with_consts(i=1, deftime=time.ctime()) > def foo(x, y=123, *args, **kw): >return x*y, kw.get('which_time')=='now' and time.ct

Re: Zen of Python

2005-01-21 Thread Dave Benjamin
Paul Rubin wrote: Tim Peters <[EMAIL PROTECTED]> writes: But at that time, Python didn't have lexical scoping, and it wasn't clear that it ever would. So what's the bigger wart? Making listcomps exactly equivalent to an easily-explained Python for-loop nest, or introducing a notion of lexical sco

Re: list unpack trick?

2005-01-21 Thread Fredrik Lundh
"aurora" wrote: > The only issue is when s does not contain the character '=', let's say it is > 'xyz', the result > list has a len of 1 and the unpacking would fail. Is there some really handy > trick to pack the > result list into len of 2 so that it unpack as name='xyz' and value=''? do

Re: default value in a list

2005-01-21 Thread Fredrik Lundh
Paul McGuire wrote: > I asked a very similar question a few weeks ago, and from the various > suggestions, I came up with this: > > expand = lambda lst,default,minlen : (lst + [default]*minlen)[0:minlen] I wouldn't trust whoever suggested that. if you want a function, use a function: def e

Re: Event details changed: Bangalore Python January Meetup

2005-01-21 Thread Premshree Pillai
On Fri, 21 Jan 2005 09:13:06 -0800 (PST), Swaroop C H <[EMAIL PROTECTED]> wrote: > > Read Anand's email!! Especially the part about 'well-known Python community > members' ... ha ha, I can't stop laughing ;) :) Hey, in case I forget (I have a terrible memory), message me! :) > > --- Anand Pilla

<    1   2