Re: Organizing Code - Packages

2007-09-08 Thread Marc 'BlackJack' Rintsch
ease post actual code and actual tracebacks you get. And `MyModule` is a bad name for a package. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Python syntax wart

2007-09-08 Thread Marc 'BlackJack' Rintsch
ot;]}), > Link["from_episode"] > ) > ) > #end for What do you mean by not possible!? This compiles fine for me. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Python syntax wart

2007-09-10 Thread Marc 'BlackJack' Rintsch
ThisCh >= '0' and ThisCh <= '9' > or > ThisCh == '_' > or > ThisCh == '.' > ) > ... I still down see the second dimension. If you say 2D I think of something like a table with two columns and not a sequential condition spread over several lines. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: How to insert in a string @ a index

2007-09-10 Thread Marc 'BlackJack' Rintsch
return match.group(0) > > re.sub(keyword, matchHandler, t1) This doesn't work because according to the OP not all 'hello's are keywords. It seems to depend on the position if it's a keyword or not. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Python syntax wart

2007-09-10 Thread Marc 'BlackJack' Rintsch
On Mon, 10 Sep 2007 19:54:49 +1200, Lawrence D'Oliveiro wrote: > In message <[EMAIL PROTECTED]>, Marc 'BlackJack' Rintsch > wrote: > >> On Mon, 10 Sep 2007 15:02:58 +1200, Lawrence D'Oliveiro wrote: >> >>> In message <[EMAIL PRO

Re: concise code (beginner)

2007-09-10 Thread Marc 'BlackJack' Rintsch
ct that a text read from top to bottom follows time from earliest to latest. And as most here don't top post, a conversation with a top poster starts to get mixed and even harder to follow. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Python syntax wart

2007-09-10 Thread Marc 'BlackJack' Rintsch
On Mon, 10 Sep 2007 20:19:08 +1200, Lawrence D'Oliveiro wrote: > In message <[EMAIL PROTECTED]>, Marc 'BlackJack' Rintsch > wrote: > >> I see a tree structure here ... > > Good, you're improving. Thanks. >> ... but still no table. > &

Re: Using a time duration to print out data where every 2 seconds is a pixel

2007-09-10 Thread Marc 'BlackJack' Rintsch
On Mon, 10 Sep 2007 15:48:44 +0200, A.T.Hofkamp wrote: > (I have seen references to a module called datetime, but I have never used > such > a module so no idea what it is or where to get it). It's just an import away -- in the standard library. :-) Ciao, Marc '

Re: How do I read and write to the same CSV file

2007-09-10 Thread Marc 'BlackJack' Rintsch
rename the temporary file to the source file's name afterward. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: memcpy

2007-09-10 Thread Marc 'BlackJack' Rintsch
a Python object. You can't use arbitrary Python objects with `ctypes`. `memcpy` expects a pointer not an object. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: printing list containing unicode string

2007-09-10 Thread Marc 'BlackJack' Rintsch
char set. The mentioning of above as a "convenient property" > is inane. You are being silly here. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: IOError - list of all Errno numbers and their meanings?

2007-09-11 Thread Marc 'BlackJack' Rintsch
rerror()` function. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: memcpy

2007-09-11 Thread Marc 'BlackJack' Rintsch
On Tue, 11 Sep 2007 05:09:58 -0700, Tim wrote: > On Sep 10, 3:31 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >> On Mon, 10 Sep 2007 11:38:50 -0700, Tim wrote: >> > How do I memcpy from a pointer to an array of floats in python? >> >> >

Re: memcpy

2007-09-11 Thread Marc 'BlackJack' Rintsch
;pointer" object to the name `shared_memory_pointer`. > shared_memory_pointer = > windll.kernel32.MapViewOfFile(hMapObject, FILE_MAP_ALL_ACCESS, > 0, 0, TABLE_SHMEMSIZE) And here you bind a different object to that name, so the first binding has no effect. Ciao,

Re: Car-ac-systems

2007-09-11 Thread Marc 'BlackJack' Rintsch
has to scroll back and forth to keep track of the discussion. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Problem

2007-09-12 Thread Marc 'BlackJack' Rintsch
oject: http://pyenchant.sourceforge.net/ So there is either an extra package for SuSE or the OP has to build it himself. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Implementing a fixed size stack for an RPN Calculator

2007-09-12 Thread Marc 'BlackJack' Rintsch
can I define a formal way of transforming the non computable > expression to computable one. > > My RPN only implements: + - x % Why does this homework assignment limit the stack so severely!? ;-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: python & osgi

2007-09-13 Thread Marc 'BlackJack' Rintsch
it's possible to unload them again. But is code really a memory problem? I've never thought "OMG memory is getting low, I wish I could unload a module to get some space." In my experience it's always data that eats my RAM. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 3K or Python 2.9?

2007-09-13 Thread Marc 'BlackJack' Rintsch
od and the class docstring. > I think static typing helps in trying to deduce what code is doing, > particularly when you are looking at function definitions. You don't > have to work to find out what type of variables it takes. This should either be obvious or in the docstring. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Perl and Python, a practical side-by-side example.

2007-03-03 Thread Marc 'BlackJack' Rintsch
are *many* other objects that can be used in a boolean context of an ``if`` statement for testing "trueness" and "falseness". Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Sort with extra variables

2007-03-03 Thread Marc 'BlackJack' Rintsch
;> Did you check how much the slowdown is? > > Yes, the lambda adds 50% Compared to what? Compared to a sort that doesn't do what you want? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: pop method question

2007-03-04 Thread Marc 'BlackJack' Rintsch
expect different behaviour from both. I expect the ``+`` operator to return either an immutable or entirely new object, while `add()` can be something on containers that mutates the object. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: multiple content-types break cgi.py

2007-03-04 Thread Marc 'BlackJack' Rintsch
d be "this is an iOrange" of course. ;-) SCNR, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Building a dictionary from a tuple of variable length

2007-03-05 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, bg_ie wrote: > Therefore, how do I build the tuple of Falses to reflect the length of > my t tuple? In [1]: dict.fromkeys(('one', 'two', 'three'), False) Out[1]: {'three': False, 'two': False,

Re: Dictionary of Dictionaries

2007-03-05 Thread Marc 'BlackJack' Rintsch
19]: {'two': {}, 'one': {}} In [20]: a['one']['x'] = 42 In [21]: a Out[21]: {'two': {'x': 42}, 'one': {'x': 42}} In [22]: a['one'] is a['two'] Out[22]: True Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: catching exceptions from an except: block

2007-03-07 Thread Marc 'BlackJack' Rintsch
ept: > continue > raise CantDoIt > -- Why do you think this is an abuse? I think it's a perfectly valid use of a loop. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: catching exceptions from an except: block

2007-03-07 Thread Marc 'BlackJack' Rintsch
tion is signaled by a `StopIteration` exception. Looks like flow control to me. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: splitting common functions into a sepperate module

2007-03-08 Thread Marc 'BlackJack' Rintsch
ted concept. Why? I thought combining state/data and related functions into one object is a key concept of OOP. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: heapq.heappush and pop to use key

2007-03-08 Thread Marc 'BlackJack' Rintsch
rm (weight, obj) with the original `heapq` module. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: number generator

2007-03-09 Thread Marc 'BlackJack' Rintsch
and the problem to generate (N-1) random numbers that add up to (M-X). You have to think a little bit about the "suitable range" part though. The necessary functions to draw random numbers are in the `random` module. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Is this right? Multiple imports of same module.

2007-03-09 Thread Marc 'BlackJack' Rintsch
the module name (mod1 and mod2) and the alias MM (mod3). Is > that right? Yes, that's correct. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Need help with a string plz! (newbie)

2007-03-09 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, israphelr wrote: > So I created a program, that gets a string from a user and then prints > the string in reverse order. In [57]: 'reversed string'[::-1] Out[57]: 'gnirts desrever' Ciao, Marc 'BlackJack' Rintsch -- http

Re: UTF-8 output problems

2007-03-10 Thread Marc 'BlackJack' Rintsch
ts. At least in most cases. But there is no way to tell what encoding a file or pipe should have. So Python refuses to guess. If an encoding could be determined the `sys.stdout.encoding` attribute is set to the name, otherwise it's `None`. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: number generator

2007-03-10 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Raymond Hettinger wrote: > On Mar 9, 7:32 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >> In <[EMAIL PROTECTED]>, cesco wrote: >> > Given two positive integers, N and M with N < M, I have to generate N &

Re: File locking

2007-03-12 Thread Marc 'BlackJack' Rintsch
hat is not only dependent on the operating system but also on the file system in use. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Grep Equivalent for Python

2007-03-14 Thread Marc 'BlackJack' Rintsch
dlines(): for line in open('/proc/meminfo'): >> if line.startswith("Memtotal:"): >> name, amt, unit = line.split() >> print name, amt, unit >> break Of course it's cleaner to assign the file object to a name and close the fi

Re: question about class methods

2007-03-14 Thread Marc 'BlackJack' Rintsch
"not self" is True, how can self have attributes? Attributes are independent from the "truth" value of an object. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: most complete xml package for Python?

2007-03-14 Thread Marc 'BlackJack' Rintsch
s when embedding Dojo Rich Text Editors. So those editors have some problem with XML. I'm not impressed by such code. ;-) It's like complaining about: In [100]: '\x61' Out[100]: 'a' It's the same information, just a different representation. Both are withi

Re: what are Python equivalent to MATLAB persistent or C++ static?

2007-03-15 Thread Marc 'BlackJack' Rintsch
ct): i_am_a_class_attribute = 42 def __init__(self): self.i_am_an_instance_attribute = 'Viking' And C++static local variables don't exist in Python. There are ways to emulate them with mutable default arguments, but that's at least debatable. Use a class instead. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Pickle Problem

2007-03-15 Thread Marc 'BlackJack' Rintsch
object at 0xb5a3fd4c> In [44]: x() Out[44]: <__main__.DemoClass object at 0xb5a3fc2c> You have to call the class object and the method to see any effects. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: dict.items() vs dict.iteritems and similar questions

2007-03-15 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, skip wrote: > Are you sure? There's no guarantee that an iterator will terminate: > > len(list(itertools.cycle(range(10 You have infinite memory? ;-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: right-format of integer output as text

2007-03-15 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, dmitrey wrote: > how can I implement this one in the simpliest way? > Thank you in advance, In [45]: '%10d' % 1 Out[45]: ' 1' In [46]: '%10d' % 42 Out[46]: '42' In [47]: '%10d' % 1

Re: To count number of quadruplets with sum = 0

2007-03-16 Thread Marc 'BlackJack' Rintsch
it's faster to use that iterator instead of `int`. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Mastering Python

2007-03-16 Thread Marc 'BlackJack' Rintsch
hon: http://www.diveintopython.org/ Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Webcams and python

2007-03-18 Thread Marc 'BlackJack' Rintsch
gorithm to lower the cpu load? Just throw a small `time.sleep()` into the loop. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: list comprehension help

2007-03-18 Thread Marc 'BlackJack' Rintsch
`maxsplit` argument to avoid splitting the line at *every* space character. And if the names give the right hints `db.sync()` may be a potentially expensive operation. Try to call it at a lower frequency if possible. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: list comprehension help

2007-03-18 Thread Marc 'BlackJack' Rintsch
ut that doesn't have a sync method. Shelves (`shelve` module) have this API. And syncing forces the changes to be written to disks, so all caching and buffering of the operating system is prevented. So this may slow down the program considerably. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: check if files are the same on Windows

2007-03-19 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Beliavsky wrote: > […] How should one check that files are the same in Python? The files > are plain text. Take a look at the `filecmp` module. Pay attention to the shallow argument of `filecmp.cmp()` and the default value! Ciao, Marc 'B

Re: How to copy a ClassObject?

2007-03-20 Thread Marc 'BlackJack' Rintsch
but I'd rather make a copy than a subclass. Why? Python isn't a prototype based programming language. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: replace illegal xml characters

2007-03-21 Thread Marc 'BlackJack' Rintsch
cuments? What exactly is your problem? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: How to set SA_RESTART flag in Python

2007-03-21 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Marco wrote: > I want to set SA_RESTART flag to restart a system-call. How to do > this in Python? You question seems to lack a little bit context. Are you talking about system calls into the Linux kernel? Ciao, Marc 'BlackJack&

Re: how to abort on syntax errors

2007-03-26 Thread Marc 'BlackJack' Rintsch
ceptions they shouldn't swallow. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: shutil.copy Problem

2007-03-26 Thread Marc 'BlackJack' Rintsch
exceptions.UnicodeDecodeError > 'ascii' codec can't decode byte 0xd6 in position 26: ordinal not in > range(128)] > > What could the possible cause of this be? Shouldn't shutil simply be > reading and writing the bytes and not character decoding them? Do you

Re: Fortran vs Python - Newbie Question

2007-03-27 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Mark Morss wrote: > Well, the discussion was about Python vs. Fortran, and Pyrex, as I > understand it, is a tool for linking C to Python. I think it's more than that. It's more a subset of Python with a little static typing. Ciao, Ma

Re: Problem with class variables

2007-03-29 Thread Marc 'BlackJack' Rintsch
self.b = list(self.a) BTW this is about instance variable, not class variables. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Best way to wait for string input

2007-03-29 Thread Marc 'BlackJack' Rintsch
nput using msvcrt.kbhit( ) and msvcrt.getch( ). Is there > something equivalent to wait for string inputs? The builtin `raw_input()`? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: encoding confusions

2007-03-29 Thread Marc 'BlackJack' Rintsch
ings to unicode objects and you *encode* unicode objects to strings. It doesn't make sense to encode a string in 'latin-1' because it must be decoded first and the "automatic" decoding assumes ASCII and barfs if there's something non-ascii in the string. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Game programming for kids: looking for open source 2D game development kit

2007-03-30 Thread Marc 'BlackJack' Rintsch
cts and attach behaviour to them. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: New to Python - Easy way to open a text file

2007-03-30 Thread Marc 'BlackJack' Rintsch
rue: > line = f.readline() > if not line: break > # do something with the line of text such as print it. > > f.close() f = open(r'pathToFile) for line in f: # do something with the line of text such as print it. f.close() Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Inserting '-' character in front of all numbers in a string

2007-03-30 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, kevinliu23 wrote: > "2a 3ab" into "-2a -3ab". In [8]: '-' + ' -'.join('2a 3ab 4xy'.split()) Out[8]: '-2a -3ab -4xy' Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Clean "Durty" strings

2007-04-02 Thread Marc 'BlackJack' Rintsch
pletely without regular expressions: def main(): soup = BeautifulSoup(source, convertEntities=BeautifulSoup.HTML_ENTITIES) print ' '.join(''.join(soup(text=True)).split()) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Parsing Problems

2007-04-03 Thread Marc 'BlackJack' Rintsch
{forget the numericals matching}.As you can see there > are single quotes around numericals ,which is not desired .I think the > problem lies in me using a list for storing and later printing out > values. It's not that you store them in the list but that you simply print the

Re: raw_input just continues anyway?

2007-04-03 Thread Marc 'BlackJack' Rintsch
would this cause a > linebreak? Yes of course. `raw_input()` is reading from `stdin` so the very first line you pipe in will be assigned to `bucket_name`. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: How can I time how much each thread takes?

2007-04-03 Thread Marc 'BlackJack' Rintsch
> I have read example of timeit.Timer() funcion, but I don' t know how > can i use it in a multiple thread program? If you want wall time then use `time.time()` in the `run()` method of the threads to calculate the difference between start and end and set an attribute with the

Re: Storing of folder structure in SQL DB

2007-04-05 Thread Marc 'BlackJack' Rintsch
t;> id+=1 >> >> […] > > use os.sep instead of '/' ! Or even better `os.path.join()` instead of building the strings with ``+``. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: subprocess.Popen output to file?

2007-04-07 Thread Marc 'BlackJack' Rintsch
. I think it is documented, that's what the `stderr` and `stdout` arguments are used for. Untested: f = open('dump.txt', 'wb') p = Popen(('mysqldump', '--option', '--another-option'), stdout=f) r = p.wait() Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Database in memory

2007-04-09 Thread Marc 'BlackJack' Rintsch
p. Or build indexes with dictionaries. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Managing a file buffer

2007-04-09 Thread Marc 'BlackJack' Rintsch
a from the head of a file. At least not without moving all following data "down", but then the file pointer within `gstreamer` is wrong. Can't `gstreamer` be fed through a pipe? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: menu drop down icons (inactive) look horrible in Windows Classic Theme

2007-04-10 Thread Marc 'BlackJack' Rintsch
roblem with python rewriting "shotty" inactive icons in > the Windows Classic Theme? > > ANY help appreciated. What the heck are you talking about? Tkinter? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: No zlib in Python 2.4.4

2007-04-11 Thread Marc 'BlackJack' Rintsch
he zlib-dev or zlib-devel package installed? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: tuples, index method, Python's design

2007-04-11 Thread Marc 'BlackJack' Rintsch
table can have completely different types but the values in a row, represented as a Python tuple, of course belong together. The homogeneous objects in lists must not be of the same type but share some behavior so it makes sense to apply some operation on all the elements. For example get the length

Re: sqlite3 question

2007-04-12 Thread Marc 'BlackJack' Rintsch
; are restored in advance. This should not work because `r` should not be a `Cursor` object. The `execute()`-Method returns an integer with the number of "affected rows". Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: reading from sys.stdin

2007-04-13 Thread Marc 'BlackJack' Rintsch
the read after the loop doesn't read anything because the file content is in the buffer of the iterator. If the test file has more lines, I tested it with 1000, the output looks like this: 0 xx >xx 151 xx 152 x< Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: reading from sys.stdin

2007-04-14 Thread Marc 'BlackJack' Rintsch
rt. Is that about right? Not the whole file is read but a block of it. If you type in enough to fill the buffer the iteration can start without an EOF on `sys.stdin`. See the second example in <[EMAIL PROTECTED]> which demonstrates that not the whole file is read at once by the itera

Re: Python Feature Request: Allow changing base of member indices to 1

2007-04-14 Thread Marc 'BlackJack' Rintsch
modules > only as and when they are called. Modules are parsed when they are imported. And some modules are already imported before your module is imported because they are built-in or loaded to be able to import your module in the first place. And what about modules that are written in C? C

Re: Python editor/IDE on Linux?

2007-04-15 Thread Marc 'BlackJack' Rintsch
n plug-in to spare myself too much typing and limit typing errors in long names. Along with the editor there's always a terminal with IPython running to test and explore my own code and libraries. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: how to strip the domain name in python?

2007-04-15 Thread Marc 'BlackJack' Rintsch
ttern, line) >> >> if (match): >> >> s1, s2 = match[0] >> >> print s2 > > Can anyone please help me with my problem? I still can't solve it. > > Basically, I want to strip out the text after the first '.' in url > address: > > http://www.cnn.com -> cnn.com from urlparse import urlsplit def get_domain(url): net_location = urlsplit(url)[1] return '.'.join(net_location.rsplit('.', 2)[-2:]) def main(): print get_domain('http://www.cnn.com') Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: How to initialize a table of months.

2007-04-15 Thread Marc 'BlackJack' Rintsch
n mons[mon] You've already got some answers, I just want to point out that the ``global`` is unnecessary here and that `mons` as a constant should be spelled in capital letters by convention. And maybe it's better to write `MONTHS` instead the abbreviation. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: sqlite3 question

2007-04-15 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Gabriel Genellina wrote: > En Thu, 12 Apr 2007 08:43:49 -0300, Marc 'BlackJack' Rintsch > <[EMAIL PROTECTED]> escribió: > >> In <[EMAIL PROTECTED]>, Jorgen Bodde >> wrote: >> >>>>&g

Re: pyparsing Catch-22

2007-04-16 Thread Marc 'BlackJack' Rintsch
of allowed character sets. Defined with string containing all allowed initial characters, an optional string containing allowed body characters (if omitted, defaults to the initial character set), and an optional minimum, maximum, and/or exact length. Ciao, Marc 'Blac

Re: How to generate a continuous string

2007-04-16 Thread Marc 'BlackJack' Rintsch
asier: multiply the string by a number. In [12]: 'a' * 5 Out[12]: 'a' Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: file resume

2007-04-16 Thread Marc 'BlackJack' Rintsch
now if i need to open it again and append other binary data how can i > proceed? Just open it in append mode: ``open('blablal', 'ab')`` Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Syntax error

2007-04-17 Thread Marc 'BlackJack' Rintsch
> > Any clue ? There was once a bug in Python that lead to such "errors" if an encoding comment was used. So your costumer might check his Python version and maybe he should update. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: recursion

2007-09-14 Thread Marc 'BlackJack' Rintsch
3, 2, 1] > i dont get all this > > >>> def f(l): > if l == []: > print l > return [] > else: > return f(l[1:]) + l[:1] > > >>> f([1,2,3]) > [] > [3, 2, 1] # how this come here? how python save variables from each > r

Re: recursion

2007-09-14 Thread Marc 'BlackJack' Rintsch
: r4 f(0): return 1 The 1 is returned to the previus call: r3 f(1): return 1 * 1 This can be evaluated now and is returned to its caller: r2 f(2): return 2 * 1 Again this is evaluated and returned to its caller: r1 f(3): return 3 * 2 And here we have the final result that is returned from

Re: int('\x23') != 0x23 (a.k.a convert char to integer of its byte representation)

2007-09-15 Thread Marc 'BlackJack' Rintsch
looking for the `struct` module in the standard library instead of doing this yourself. :-) If you insist on doing it yourself take a look at the built-in `ord()` function. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: how to join array of integers?

2007-09-15 Thread Marc 'BlackJack' Rintsch
,".join() ? but then it must take > a list of strings... not integers... > > any fast method? Convert them to strings before joining: In [145]: foo = [1, 2, 3] In [146]: ','.join(map(str, foo)) Out[146]: '1,2,3' Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: string questions

2007-09-15 Thread Marc 'BlackJack' Rintsch
be the best > function to use. However, when I use > string.replace(s1, "a", " ") in python to replace a with an empty space, > it doesn't work...I just get spam back when I print s1. Any ideas? Yes, read the documentation to find out that `replace()` does not

Re: Needless copying in iterations?

2007-09-15 Thread Marc 'BlackJack' Rintsch
his copy really is "needless". `whatever()` may change `stuff[i]` where `i` is in `x:y` and this may lead to different results wether it iterates over a copy or the original. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Needless copying in iterations?

2007-09-15 Thread Marc 'BlackJack' Rintsch
On Sun, 16 Sep 2007 00:40:13 +, Steven D'Aprano wrote: > On Sun, 16 Sep 2007 00:05:58 +0000, Marc 'BlackJack' Rintsch wrote: > > In *general* the compiler can't tell, but in specific cases it could. A > (hypothetical) optimizing compiler would tell the diff

Re: Needless copying in iterations?

2007-09-16 Thread Marc 'BlackJack' Rintsch
ses", no side effects, no duck typing. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Needless copying in iterations?

2007-09-16 Thread Marc 'BlackJack' Rintsch
On Sun, 16 Sep 2007 13:31:57 +, Steven D'Aprano wrote: > On Sun, 16 Sep 2007 10:58:07 +0000, Marc 'BlackJack' Rintsch wrote: > >> On Sun, 16 Sep 2007 09:50:39 +, Steven D'Aprano wrote: >> >>> The point is rather moot, since CPytho

Re: We need PIGs :)

2007-09-16 Thread Marc 'BlackJack' Rintsch
On Sun, 16 Sep 2007 10:17:18 -0400, Colin J. Williams wrote: > Marc 'BlackJack' Rintsch wrote: > >> `getFoo()` is discouraged by PEP 8. […] > > Perhaps PEP 8 needs rethinking. I prefer getFoo(). Yeah, *your* preference is a very good reason to rethink PEP 8… ;-) C

Re: where are the .pyc files?

2007-09-16 Thread Marc 'BlackJack' Rintsch
e in my folder even if i turn the "show hidden file" to on. The `*.pyc` files are usually only created when you import a module, not when a module is run directly. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: where are the .pyc files?

2007-09-17 Thread Marc 'BlackJack' Rintsch
On Mon, 17 Sep 2007 01:23:20 +, Summercool wrote: > On Sep 16, 10:36 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >> >> The `*.pyc` files are usually only created when you import a module, not >> when a module is run directly. > > how com

Re: Memory Problem

2007-09-18 Thread Marc 'BlackJack' Rintsch
)) > self.nRows += 1 > > Maybe somebody can help me. If you need, I can give more implementation > details. IMHO That's not enough code and/or description of the data structure(s). And you also left out some information like the number of rows/columns and the size of the data. Have you already thought about using a database? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: How do you limit the # of lines Read?

2007-09-18 Thread Marc 'BlackJack' Rintsch
arenthesis of the readline() function? > > t = string.readline() # Limit this somehow? Do you want to limit how much of *one* line is read or the number of lines!? The latter can be done with `itertools.islice()`. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Deserializing specific objects from a file

2007-09-18 Thread Marc 'BlackJack' Rintsch
lve`-Module. Another option might be pickling to individual files and store them in a ZIP archive. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: lambda-funcs problem

2007-09-19 Thread Marc 'BlackJack' Rintsch
t because those are evaluated at definition time of functions:: F.append(lambda x, i=i: x + i) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Sets in Python

2007-09-20 Thread Marc 'BlackJack' Rintsch
expect d.keys() to return after a key of d has been modified? > > In the new model, it should be the value at the time of addition. > That is [1,2] (not [1,2,3]). This does mean a copy of key in > maintained internally in the dict. A copy!? That has to be a deep copy. Which would make `dict`\s alot slower and use more memory. Plus you can't store objects that can't be copied anymore. That doesn't sound like a good trade off to me. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

<    5   6   7   8   9   10   11   12   13   14   >