Re: newbie help

2005-03-24 Thread Marc 'BlackJack' Rintsch
uffer: %s" % buffer return buffer In your code, no matter if index equals 1 or 2, a list with 512 `None`s is created, printed and then returned. It would be really better if you describe *what* you want to achieve, not *how*. And in words please, not in code snippets. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Cpickle module... not in Lib installs

2005-03-25 Thread Marc 'BlackJack' Rintsch
;> import cPickle >>> cPickle.__file__ '/usr/lib/python2.4/lib-dynload/cPickle.so' Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: ossaudiodev full duplex

2005-03-26 Thread Marc 'BlackJack' Rintsch
elect all other sources except the line-in or microphone input because some soundcards can mix several input sources when recording. The `ossaudiodev` module has an `openmixer()` function but it may be easier to use one of the graphical mixer programs like `kmix` or `alsamixergui`. Ciao, M

Re: putting the output of a print statement into a string

2005-03-27 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Jon Perez wrote: > Question: > > Is there a way to somehow put the output of 'print exc_obj' into > a string? There are ways to do even that, but maybe ``str(exc_obj)`` is enough for your needs!? Ciao, Marc 'BlackJack' Rint

Re: Performance issue

2005-04-02 Thread Marc 'BlackJack' Rintsch
t results in moving all remaining elements one index down. Better iterate over the words in a for loop:: for word in words: # use `word` instead of `word[0]` in the loop body. ... Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Performance issue

2005-04-02 Thread Marc 'BlackJack' Rintsch
ne characters at the end of each line while `str.splitlines()` removes them. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Performance issue

2005-04-02 Thread Marc 'BlackJack' Rintsch
ak try: print anagram_map[''.join(sorted(list(word.strip().lower(] except KeyError: print 'No anagrams found for %r' % word # # Print all anagrams sorted by number of anagrams. # print '\n'.join(map(str, sorted(anagram

Re: Changing TEXT color from python

2005-04-04 Thread Marc 'BlackJack' Rintsch
ows, Google for ANSI.SYS and read up on Escape Sequences, or check > out the curses for Windows implementation that's floating around somewhere on > the net, I don't know the URL. At least under Linux the ANSI color escapes should work too. Out of the box. Ciao, Marc

Re: Overwrite just one line? Am I a n00b or is this impossible? Both? :D

2005-04-06 Thread Marc 'BlackJack' Rintsch
= open('test.dat') In [74]: a = f.read() In [75]: f.close() In [76]: a Out[76]: '\x00\x00\x00\x00\x00\x00\x00\00<...>hello If you want to open an existing file without overwriting it you have to use mode "w+" or "a". Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Are circular dependencies possible in Python?

2005-04-09 Thread Marc 'BlackJack' Rintsch
ap both definitions without problems. 3. Function A is actually called and *must* exist at this point. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Directory in Windows

2005-04-30 Thread Marc 'BlackJack' Rintsch
lf.path.get()), listFiles, None) > print filelist > === Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Copy polygonal subset of an image

2015-08-28 Thread Marc Camacho Cateura
Hi all, For a project, I need to copy a polygonal subset of an image. I have eight points of panoramic image, and I want to copy this subset onto another panoramic image. I find ways to do this with PIL but only with a box mask. And I need a polygonal subset from the eight points... I'm new i

Amateur question on class definitions...

2011-11-29 Thread J. Marc Edwards
yntax? set_of_workflows = list(a_workflow) Is this how a pro would do this? Regards, Marc -- J. Marc Edwards Lead Architect - Semiconductor Design Portals Nimbis Services, Inc. Skype: (919) 747-3775 Cell: (919) 345-1021 Fax: (919) 882-8602 marc.edwa...@nimbisservices.com www.nimbisservic

RE: Awsome Python - chained exceptions

2013-02-20 Thread J. Marc Edwards
ronic application. Regards, Marc J. Marc Edwards, Lead Architect Semiconductor Design Portals Nimbis Services, Inc. Cell - (919) 345-1021 Fax - (919) 882-8602 Skype - (919) 747-3775 jmarcedwa...@gmail.com marc.edwa...@nimbisservices.com -Original Message- From: Python

Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-13 Thread Marc 'BlackJack' Rintsch
which is a bit uglier than parenthesis (IMHO). And you want to trade occasional parenthesis for mandatory curly braces? I guess it leads to much more braces or other explicit end markers for suits than the few "unneccessary" parenthesis one has to use to group long expressions. Ciao, Marc 'BlackJack' Rintsch. -- http://mail.python.org/mailman/listinfo/python-list

Re: lambda (and reduce) are valuable

2005-12-14 Thread Marc 'BlackJack' Rintsch
tter complicated_list.sort(key=itemgetter(3)) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: reading files

2005-12-20 Thread Marc 'BlackJack' Rintsch
th the memory. It makes clear you're done with the *name* since that's what ``del`` deletes from the namespace, not the object. I know that you know this but many people seem to think ``del`` get's rid of the object like a call to `free()` in C. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: csv.Sniffer: wrong detection of the end of line delimiter

2005-12-29 Thread Marc 'BlackJack' Rintsch
x27;b' flag on platforms where that makes a difference. I guess the reason is the same as for "text" pickle format: If you don't use binary mode the file is not platform independend anymore because some OSes "manipulate" the data in text mode. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: compare dictionary values

2005-12-30 Thread Marc 'BlackJack' Rintsch
list() for (key, value) in new: try: if old[key] != value: result.append(key) except KeyError: result.append(key) return result Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Get path of a class

2006-01-10 Thread Marc 'BlackJack' Rintsch
[33]: import inspect, zipfile In [34]: inspect.getsourcefile(zipfile.ZipInfo) Out[34]: '/usr/lib/python2.4/zipfile.py' Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Marshal Obj is String or Binary?

2006-01-13 Thread Marc 'BlackJack' Rintsch
is string > anyways. So, why does O'reilly's Python Cookbook is insisting in saving > it as a binary file and BLOB type? > > Am I missing out something? Yes, that a string is *binary* data. But only a subset of strings is safe to use as `TEXT` in databases. Do you see all th

Re: Arithmetic sequences in Python

2006-01-16 Thread Marc 'BlackJack' Rintsch
ded=True). > > How about... > > for i in (0..x]: > blah That would break most editors "highlight matching brace" functionality. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: hash of hashes

2006-07-11 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, sfo wrote: > how do i create a hash of hash similar to perl using dict in python > $x{$y}{z}=$z Just put dictionaries as values into a dictionary. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: uTidylib question..

2006-07-11 Thread Marc 'BlackJack' Rintsch
ntents of the object. If this means it prints out what you want as a string… > my question, can the "document object" be turned/translated into a string > var? …then yes: ``str(s)`` Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Accessors in Python (getters and setters)

2006-07-13 Thread Marc 'BlackJack' Rintsch
find those trivial getters and setters because we have properties if the access might become a bit more complex in the future. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Byte array question

2006-07-14 Thread Marc 'BlackJack' Rintsch
eserializing: : > {'hostname': '', 'faultData': faultData at -1216226708>: {'exception': None, 'message': 'Found > character data inside an array element while deserializing'}}> In the Java snippet from your initial post the `c

Re: math symbols not displaying

2006-07-15 Thread Marc 'BlackJack' Rintsch
ng Gnome > under Ubuntu 6.06. The glyphs have to be present in the font that is used. Fonts that should contain almost all mathematical characters are in the `latex-xft-fonts` package. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: reading specific lines of a file

2006-07-15 Thread Marc 'BlackJack' Rintsch
the standard library is implemented but you might have a look at it. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Commercial Programming

2006-07-16 Thread Marc 'BlackJack' Rintsch
using and spreading the software without permission from you. The only secure way is to put the software on a server under your control and offer your program as web service. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: instantiate all subclasses of a class

2006-07-16 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Daniel Nogradi wrote: > More precisely I have a module m with some content: > > # m.py > class A: > pass > class x( A ): > pass > class y( A ): > pass > # all kinds of other objects follow > # end of m.py > > and then in another module I have currently: > > #

Re: Recursive function returning a list

2006-07-17 Thread Marc 'BlackJack' Rintsch
't > think of another possibility. > > Do you have any ideas? def get_all_children(self, accumulator=None): if accumulator is None: accumulator = list() accumulator.extend(self.children) for child in self.children: child.get_all_ch

Re: compiling 2.3.5 on ubuntu

2006-07-17 Thread Marc 'BlackJack' Rintsch
7;t imagine there's anything older on Ubuntu 6.06. There's a `python2.3` package with version 2.3.5 and a `python2.2` with version 2.2.3 in it. All of them can be installed side by side. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: range() is not the best way to check range?

2006-07-18 Thread Marc 'BlackJack' Rintsch
tyle of and'ing two comparisons together to emphasize the fact it is > god's chosen way of doing this ;-) Pete doesn't like to be called god in public. ;-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Partial classes

2006-07-19 Thread Marc 'BlackJack' Rintsch
planned in future releases of Python. Can you flesh out your use case a little bit and tell why you can't solve the problem with inheritance or a meta class? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Coding style

2006-07-19 Thread Marc 'BlackJack' Rintsch
e presence of ambiguity, refuse the temptation to guess". > > OTOH, my favorite there would be > > list(True) is [None] Wow it even gets better, the list containing one `None` object should be a singleton too. Argh. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Regular expression issue

2006-07-19 Thread Marc 'BlackJack' Rintsch
und\) You need the flags re.MULTILINE and re.DOTALL when compiling the regular expression. You'll have to check the 'baro' and 'na' groups to decide if it matched a numerical value or 'N/A'. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Coding style

2006-07-19 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Boris Borcic wrote: >> And I don't find `list(False)` to return an empty list be very obvious. > > What would be your choice ? ``list()`` or ``[]`` for empty lists and a `TypeError` for ``list(False)``. Just like it is right now. Ciao, M

Re: Retrieve ext. variables in python program

2006-07-19 Thread Marc 'BlackJack' Rintsch
e 1, in ? > [wsadmin] ImportError: no module named cfgparse Well, the message is quite descriptive. There is no module named `cfgparse`. Diez suggestet the `ConfigParser` modul. You notice the difference? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Accessors in Python (getters and setters)

2006-07-19 Thread Marc 'BlackJack' Rintsch
rash my system by changing Robust's > state arbitrarily. Because in the real world when your program is buggy, > you get bug reports, nasty emails among other forms of ridicule. And > your supposed solution to my problem is me saying, "but...but...I told > you not change is_

Re: Semantics of propagated exceptions

2006-07-21 Thread Marc 'BlackJack' Rintsch
not an ordinary `E` but one that has a special, well defined meaning if raised by `f` itself according to your protocol. Put the original exception as an attribute to the new one and/or subclass the new exception type from `E`. This way calling code can choose to to handle both types as `E` if the

Re: Is it possible to get image size before/without downloading?

2006-07-22 Thread Marc 'BlackJack' Rintsch
is header. Depends on the image format how much of the file has to be read and how the information is encoded. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: How to test if object is sequence, or iterable?

2006-07-22 Thread Marc 'BlackJack' Rintsch
cover most cases. What about objects that just implement an apropriate `__getitem__()` method? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Type signature

2006-07-22 Thread Marc 'BlackJack' Rintsch
`this functions takes an iterable as input` then `iterable` isn't a specific type but an object that implements the behavior of an iterable. You can't check that reliable without actually trying to iterate over it. Search for "duck typing". Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: [Newbie] List from a generator function

2006-07-23 Thread Marc 'BlackJack' Rintsch
I missing something? What is `length`? Do you want unique elements from `possible_notes`? Then you could use `random.sample()`. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: easy questions from python newbie

2006-07-23 Thread Marc 'BlackJack' Rintsch
t example: import csv from itertools import groupby in_file = open('test.csv', 'rb') data = list(csv.reader(in_file)) in_file.close() data.sort() out_file = open('test2.csv', 'wb') writer = csv.writer(out_file) for row, identical_rows in groupby(data): row.append(le

Re: BeautifulSoup to get string inner 'p' and 'a' tags

2006-07-24 Thread Marc 'BlackJack' Rintsch
;> ' >> tree = BeautifulSoup(s) > >> print tree.first('p') > FOO > > So if I run 'print tree.first('p').string' to get the 'FOO' string it > shows Null value because it's the 'a' tag: > >> print t

Re: Type signature

2006-07-24 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, paul kölle wrote: > Marc 'BlackJack' Rintsch wrote: >> In <[EMAIL PROTECTED]>, Yacao Wang >> wrote: >> >>> However, type signatures are not only a kind of information provided for >>> the compiler, but also

Re: Python Stripped CSS Background Image Calls

2006-07-24 Thread Marc 'BlackJack' Rintsch
are doing? Python doesn't know about CSS and it's illegal syntax to just write CSS into Python programs. I guess there's a web framework involved? Or CGI? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: prob with struct and byte order

2006-07-24 Thread Marc 'BlackJack' Rintsch
bers in front is 47 bytes so there's a 5 byte difference. You have to look at some more messages to get an idea how the length corresponds to the actual payloads length. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: dicts vs classes

2006-07-25 Thread Marc 'BlackJack' Rintsch
nt of view? If you really have a memory problem read the documentation about `__slots__`. But I would only consider this if `a lot of` is several 100k or millions of objects and the memory consumption really is a problem. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: csv file or sqlite ?

2006-07-25 Thread Marc 'BlackJack' Rintsch
that blacklist and just query a few of them per program run, say in a CGI script, then a database will become faster than linear searching through a csv file. Just try both and measure to know for sure. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: MySql

2006-07-27 Thread Marc 'BlackJack' Rintsch
2|32 > 6|47 > > please tell me what i am doing wrong. thanks. Where's the problem? Do you mind that the third entry has a 6 as unique `auto` value? Doesn't `AUTO_INCREMENT` just guarantee unique values? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: function to convert degree (hour), minute, seconds string to integer

2006-07-27 Thread Marc 'BlackJack' Rintsch
; "23h59m59s", that would have to be handled separately. Looking at the subject I would expect to be able to give 76°04'54" as argument. Hm, but degrees don't map directly to hours!? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Zipping Files to user defined Directory

2006-07-27 Thread Marc 'BlackJack' Rintsch
rectory and then deliver that archive to the user. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie Q: Class Privacy (or lack of)

2006-07-28 Thread Marc 'BlackJack' Rintsch
e > safety, but I don't hear much. > > It looks pretty good as long as it is used by a small > group, especially for a small project. (Or Python is meant just for such > projects?) Please prove that the safety is sacrificed to the extent that you fear. This "if you don't have `private`, everything starts to fall apart and explodes right in your face if the project starts to get bigger" arguments aren't backed by empirical data either but often seems to be just learned by heart in Java and C++ courses. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie Q: Class Privacy (or lack of)

2006-07-28 Thread Marc 'BlackJack' Rintsch
_not_defined_in_the_class = 456 > ==> > AttributeError: 'MyClass' object has no attribute > 'instance_var_not_defined_in_the_class' > > x.func = 789 > ==> > AttributeError: 'MyClass' object attribute 'func' is read-only > > Only the

Re: War chest for writing web apps in Python?

2006-07-29 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Rob Sinclar wrote: > Synaptic is using aptitude as back-end (this is serious). Why can I deinstall aptitude without deinstalling synaptic then!? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: War chest for writing web apps in Python?

2006-07-29 Thread Marc 'BlackJack' Rintsch
t is very useful to users working on linux machines without > X server installed. I know what aptitude is… > Synaptic is the interface which leads the underlying application. …but I ask why I can deinstall it and still use synaptic if it's using aptitude as back-end as you seriously cla

Re: system programign

2006-07-29 Thread Marc 'BlackJack' Rintsch
n('old.txt', 'r') out_file = open('new.txt', 'w') for line in in_file: out_file.write(line) in_file.close() out_file.close() how do you do ? I'm fine, thanks. ;-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Math package

2006-07-29 Thread Marc 'BlackJack' Rintsch
l in that array: You have: (1 billion)^2 bytes You want: terabyte * 100 / 1e-06 Hope you have enough memory. ;-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Pygame Help

2006-07-29 Thread Marc 'BlackJack' Rintsch
structure with lists of lists is the simplest solution. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Html character entity conversion

2006-07-30 Thread Marc 'BlackJack' Rintsch
t; > How can I translate this using standard Python libraries?? Have you tried a more recent version of BeautifulSoup? IIRC current versions always decode text to unicode objects before returning them. Ciao, Marc -- http://mail.python.org/mailman/listinfo/python-list

Re: BCD List to HEX List

2006-07-30 Thread Marc 'BlackJack' Rintsch
6, 7, 8] l2 = func(l1) print l2 And now please describe you problem a little better. ;-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: BCD List to HEX List

2006-07-30 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Philippe Martin wrote: > Marc 'BlackJack' Rintsch wrote: > >> And now please describe you problem a little better. ;-) > > I'll try. > > first of all python is not going to be used for my purpose (sigh) > > I have de

Re: Pickle vs XML for file I/O

2006-07-31 Thread Marc 'BlackJack' Rintsch
27;s in the standard library and ready to use for serialization. To get an XML solution you must either write your own serialization code or use a 3rd party library. What are the problems you fear when using `shelve` by the way? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Pickle vs XML for file I/O

2006-08-01 Thread Marc 'BlackJack' Rintsch
ry that maps strings to objects. So if you want to save a party of characters and load them back together than pickle a list with those characters. If you want a database of many characters the player can choose from than you might want to store them in a `shelve`. Ciao, Marc '

Re: Newbie Q: Class Privacy (or lack of)

2006-08-02 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Antoon Pardon wrote: > On 2006-07-28, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >> This avoids the problem but you get others in return. And it's an >> abuse of `__slots__` which is meant as a way to save memory if yo

Re: ElementTree and Unicode

2006-08-02 Thread Marc 'BlackJack' Rintsch
suggest a way to do it ? Encode it in UTF-8 and then Base64. AFAIK the only reliable way to put an arbitrary string into XML and get exactly the same string back again. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Pickle vs XML for file I/O

2006-08-02 Thread Marc 'BlackJack' Rintsch
char1, char2, char3] > file = open("partyfile.dat", "w") > pickle.dump(party, file) Yes that would work. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Datetime question

2006-08-03 Thread Marc 'BlackJack' Rintsch
, 609000) In [19]: a + datetime.timedelta(days=8, hours=20) Out[19]: datetime.datetime(2006, 8, 12, 10, 13, 56, 609000) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: format a number for output

2006-08-07 Thread Marc 'BlackJack' Rintsch
rt locale In [24]: locale.setlocale(locale.LC_ALL, '') Out[24]: 'en_US.UTF-8' In [25]: locale.format('%d', 1890284, True) Out[25]: '1,890,284' It's not always commas but whatever character is used to group thousands in the active locale. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: semi-Newbie question

2006-08-11 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, len wrote: > mycode = "TagToSQL['mySQLfieldname'] = Tagfile['Value']" > exec mycode Why do you use ``exec`` here? Why not simply:: TagToSQL['mySQLfieldname'] = Tagfile['Value'] Ciao, Marc 'Bl

Re: Python checking for None/Null values

2006-08-11 Thread Marc 'BlackJack' Rintsch
line 326, in ? > if historyRep[8]==None: IndexError: list index out of range `historyRep` seems to be shorter than you think it is. Try printing it too see what it actually contains. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: What's the cleanest way to compare 2 dictionary?

2006-08-11 Thread Marc 'BlackJack' Rintsch
ressions in 2.3. Turn it into a list comprehension:: common_eq = set([k for k in _common if a[k] == b[k]]) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Read a file with open command

2006-08-11 Thread Marc 'BlackJack' Rintsch
y data into memory it's better to use:: file_obj = open('D:/Mes documents/ADB Anna.ods', 'rb') data = file_obj.read() file_obj.close() Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Python/Tk not working in Linux

2006-08-12 Thread Marc 'BlackJack' Rintsch
g the version from your distribution? I would suspect you get an `ImportError` on `Tkinter` there. Some distributions move the `Tkinter` stuff into an own package. Search for a package called `python-tk` or `python-tkinter` or similar. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: unbound methods

2006-08-12 Thread Marc 'BlackJack' Rintsch
as first argument (got nothing instead). Any suggestions > would be greatly appreciated. Thanks! I'd suggest that you post some actual code plus traceback so we don't have to guess. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: trouble with replace

2006-08-12 Thread Marc 'BlackJack' Rintsch
e()` does not work in place. You have to bind the result to a name like:: xdata = xdata.replace('abcdef', 'highway') Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Python/Tk not working in Linux

2006-08-13 Thread Marc 'BlackJack' Rintsch
t packages for your installed Tcl/Tk and compile the Python sources. Unless you really want to compile everything yourself. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: TypeError: 'module' object is not callable (newby question)

2006-08-14 Thread Marc 'BlackJack' Rintsch
' object is not callable Don't call your file `glob.py` because then you import this module and not the `glob` module from the standard library. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Memory problem

2006-08-14 Thread Marc 'BlackJack' Rintsch
nto memory? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: TypeError: 'module' object is not callable (newby question)

2006-08-15 Thread Marc 'BlackJack' Rintsch
I can't find any comprehensive index. Here's the index of the reference manual: http://docs.python.org/ref/genindex.html Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: file object and eof

2006-08-15 Thread Marc 'BlackJack' Rintsch
ing. If the empty string is returned you are at the end of the file. Or write a function that uses `os.path.filesize()` and the `tell()` method of the file. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: file object and eof

2006-08-15 Thread Marc 'BlackJack' Rintsch
sh >> your goal, but you're going to have to tell us what it is. >> > > how about?!: > > def eof(fileobj): >curloc = fileobj.tell() >ofloc = fileobj.seek(0,2) >fileobj.seek(curloc, 0) >if ofloc >= curloc: > return True &

Re: Very weird behavior that's driving me crazy

2006-08-16 Thread Marc 'BlackJack' Rintsch
ssion and you forgot to reload the module after making changes to it? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: what is the keyword "is" for?

2006-08-16 Thread Marc 'BlackJack' Rintsch
In [14]: a is b Out[14]: True In [15]: a == b Out[15]: False In [16]: a Out[16]: nan On my platform the division results in "Not A Number". Two NaNs compared are always `False`. You could argue that this is the very same NaN but to get this effect the interpreter has to take care that eve

Re: using python at the bash shell?

2006-08-16 Thread Marc 'BlackJack' Rintsch
n front of ``cd`` this is what happens. Just leave out the ``!``. IPython has it's own built-in ``cd`` command. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Optimization of __len__() in cgi.py

2006-08-16 Thread Marc 'BlackJack' Rintsch
rn the length of `self.list` directly without the need to create an intermediate list that's thrown away immediately. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Adding a char inside path string

2006-08-16 Thread Marc 'BlackJack' Rintsch
ting path something like > > ('\\serverName\c$:\FolderName1\FolderName2\example.exe',) > > How on the earth I can remove those paranthesis? Well, don't convert the tuple to a string but get the string out of the tuple instead. for row in rows: path = row[0].replace('C:', 'C$') print path Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: write eof without closing

2006-08-19 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, cage wrote: > can i write a eof to a file descriptor without closing it? > like: > fd.write(EOF) > or something What do you expect this to to? Writing a byte to the file and you don't know which value this byte has? Ciao, Marc '

Re: How to get the ascii code of Chinese characters?

2006-08-19 Thread Marc 'BlackJack' Rintsch
ontain Chinese characters. http://en.wikipedia.org/wiki/ASCII Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: [NEWB]: List with random numbers

2006-08-19 Thread Marc 'BlackJack' Rintsch
e(random_list) In [6]: random_list Out[6]: [1, 4, 6, 2, 5, 0, 3] Same effect but more efficient than your approach. Ciao, Marc 'BlackJack' -- http://mail.python.org/mailman/listinfo/python-list

Re: Text parsing

2006-08-20 Thread Marc 'BlackJack' Rintsch
'test3\ntest4\ntest5\ntest6', 'test7\ntest8', > 'test9', '\n'] > > What happened to "test10"? It seems to be gone unless I add two > linebreaks at the end of the file. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: sum and strings

2006-08-20 Thread Marc 'BlackJack' Rintsch
r side effects. The above one-liner builds a list of `None`\s of length ``len(deep)`` for no reason just to throw them away. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: What do you want in a new web framework?

2006-08-20 Thread Marc 'BlackJack' Rintsch
eb > framework(Easy use of Database, Easy use of XML, GUI Designer, etc...)? > > I'm wating your answers. Thank you for all answers...! Don't think that yet another Python web framework is really needed. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: istep() addition to itertool? (Was: Re: Printing n elements per line in a list)

2006-08-20 Thread Marc 'BlackJack' Rintsch
` is a stream of events, then your function always needs to "receive" `step` events before the caller can do anything else with the events. In Rhamphoryncus' function the caller can react on the event as soon as it's "delivered" by `iterable`. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Python and STL efficiency

2006-08-21 Thread Marc 'BlackJack' Rintsch
IDLE, respectively. I had expected C++ to be > way faster. However, while the python code gave the result almost > instantly, the C++ code took several seconds to run! Can somebody > explain this to me? Or is there something wrong with my code? There's a difference in data structur

Re: Questions on exceptions

2006-08-21 Thread Marc 'BlackJack' Rintsch
terested in the new (Python 2.5) ``with`` statement too: http://docs.python.org/dev/ref/with.html And the style guide: http://www.python.org/dev/peps/pep-0008/ (because you used Java naming conventions) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Python and STL efficiency

2006-08-21 Thread Marc 'BlackJack' Rintsch
``gcc`` prints deprecation warnings if you write the names with '.h'. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: How to decode a string

2006-08-21 Thread Marc 'BlackJack' Rintsch
t decode byte 0xc3 in position 3: > ordinal > not in range(128) > > Can you please suggest the solution? Do you get this from converting the value from the database or from trying to print the unicode string? Can you give us the output of print repr(RealName) Ciao, Marc &#

<    1   2   3   4   5   6   7   8   9   10   >