Re: how to split text into lines?

2008-07-31 Thread Chris
On Jul 31, 7:26 am, alex23 <[EMAIL PROTECTED]> wrote: > kj wrote: > > Sorry, I should have googled this first.  I just found splitlines()... > > > Still, for my own edification, is there a way to achieve the same > > effect using re.split? > > re.split(os.linesep, ) works the same as .splitlines()

Re: Newbie Python questions

2008-07-31 Thread Tim Roberts
LessPaul <[EMAIL PROTECTED]> wrote: > >...My >question is in regard to GUI platforms. My primary target would be >Windows, but I would also like be able to support Linux and Mac >versions if possible. I'm also interested in using a system that also >has support for pure C++ applications. As such, a

Re: Optimizing size of very large dictionaries

2008-07-31 Thread Raymond Hettinger
> > Are there any techniques I can use to strip a dictionary data > > structure down to the smallest memory overhead possible? Sure. You can build your own version of a dict using UserDict.DictMixin. The underlying structure can be as space efficient as you want. FWIW, dictionaries automaticall

Re: How can I check nbr of cores of computer?

2008-07-31 Thread Duncan Booth
Steven D'Aprano <[EMAIL PROTECTED]> wrote: > I don't expect that Python will have a built-in core-counting function. > You would probably need to ask the operating system. On Linux, you could > do this: > > import os > text = os.popen('cat /proc/cpuinfo').read() > > > How you would do it in W

Re: win32com ChartObject pythonwin vs idle

2008-07-31 Thread Tim Golden
sterling wrote: I'm curious as to why the difference between IDLE and pythonWin when using win32com. opening an excel file, i've attempted to grab the chart information out of the file. commands like co = ChartObjects(1) works in pythonWin but doesn't work in IDLE. however, on both co = charto

Re: New CMS in Python

2008-07-31 Thread Martin Sand Christensen
> :-) <[EMAIL PROTECTED]> writes: [...] > Please send me how U expect your new CMS would be? I don't mean to be disparaging, but I'd like to point out a few things that I'm not entirely sure you've thought through. Firstly, there is currently no shortage in CMS', and especially not in half-

Re: Change PC to Win or Windows

2008-07-31 Thread Ross Ridge
Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > It gets even worse... No Windows-based "PC" has ever used the >"PowerPC" processor -- which had been a staple of the Macintosh before >they went Intel... Actually the were personal computers sold using PowerPC processors that ran Windows NT. I

hosting on djangodomain.com

2008-07-31 Thread Łowik
Hi! Did anyone used this hosting or heard about it? It's good or not? what can you talk about it? -- http://mail.python.org/mailman/listinfo/python-list

Re: Python parsing iTunes XML/COM

2008-07-31 Thread John Machin
On Jul 31, 12:58 am, william tanksley <[EMAIL PROTECTED]> wrote: > Thank you for the response. Here's some more info, including a little > that you didn't ask me for but which might be useful. > > John Machin <[EMAIL PROTECTED]> wrote: > > william tanksley <[EMAIL PROTECTED]> wrote: > > > To ask an

Re: Possible to have multiple loop variables?

2008-07-31 Thread Alan Franzoni
laredotornado was kind enough to say: > How would I set up the ms1 array such that I can use three items per > object? Use tuples. But that should depend on which values make up the key for your mapping. E.g. ms1 = {('managed1':7019):8020, ('managed2':7020):8021} ms2 = {'managed1':(7019:8020), '

Re: interpreter vs. compiled

2008-07-31 Thread Bob Martin
in 76135 20080731 090911 Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: >On Thu, 31 Jul 2008 06:17:59 GMT, Tim Roberts <[EMAIL PROTECTED]> declaimed >the following in comp.lang.python: > > >> And again, I never said that it did. CPython is an interpreter. the >

Re: interpreter vs. compiled

2008-07-31 Thread Duncan Booth
Terry Reedy <[EMAIL PROTECTED]> wrote: > 1. Portability: The Microsoft C# JIT compiler runs under Windows .NET > on x86/amd64 and maybe it64 and what else? Just porting .NET to run > 0n Linux on the same processors was/is a bit task. Does MONO have a > JIT also? Technically there is no such th

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-31 Thread Iain King
On Jul 31, 7:08 am, "Russ P." <[EMAIL PROTECTED]> wrote: > On Jul 30, 10:43 pm, Erik Max Francis <[EMAIL PROTECTED]> wrote: > > > > > Russ P. wrote: > > > On Jul 30, 9:27 pm, Erik Max Francis <[EMAIL PROTECTED]> wrote: > > >> You're sure going on about a distinction without a difference for a guy >

working pylint anyone?

2008-07-31 Thread Diez B. Roggisch
Hi, until yesterday I was a happy user of pylint. Then I upgraded to ubuntu hardy heron - and the trouble began. The packaged version of pylint (0.13.2) fails with this error (last line): logilab.common.configuration.UnsupportedAction: callback The same error happens if I use easy_install-2.5

Re: working pylint anyone?

2008-07-31 Thread Stefan Rank
on 31.07.2008 11:29 Diez B. Roggisch said the following: The packaged version of pylint (0.13.2) fails with this error (last line): So - anybody out here having an actually working pylint config and can tell me what versions work together? I've become pretty dependend on it to be honest...

Re: SVN access with pysvn under Cygwin (Installation problems)

2008-07-31 Thread Andy Dingley
On 30 Jul, 20:30, Jason Tishler <[EMAIL PROTECTED]> wrote: > You need to build (and install) pysvn under Cygwin.  The pre-built > Windows version will not work under Cygwin. Thanks. Presumably this same problem would affect anything that uses a .pyd under Cygwin? -- http://mail.python.org/mailman

Re: Optimizing size of very large dictionaries

2008-07-31 Thread M.-A. Lemburg
On 2008-07-31 02:29, [EMAIL PROTECTED] wrote: Are there any techniques I can use to strip a dictionary data structure down to the smallest memory overhead possible? I'm working on a project where my available RAM is limited to 2G and I would like to use very large dictionaries vs. a traditional

Re: Interbase

2008-07-31 Thread M.-A. Lemburg
On 2008-07-30 18:49, Mike Hjorleifsson wrote: Has anyone gotten python working with Interbase database platform ? I need to query some info from an interbase database on another server need a lil help getting started. You could try the EasySoft ODBC driver for InterBase: http://www.easysoft.

Difference between type and class

2008-07-31 Thread Nikolaus Rath
Hello, Can someone explain to me the difference between a type and a class? After reading http://www.cafepy.com/article/python_types_and_objects/ it seems to me that classes and types are actually the same thing: - both are instances of a metaclass, and the same metaclass ('type') can instant

Re: Is it possible to consume UTF8 XML documents using xml.dom.pulldom?

2008-07-31 Thread Paul Boddie
On 30 Jul, 20:15, Peter Otten <[EMAIL PROTECTED]> wrote: > Paul Boddie wrote: > > Who wants to be first to submit a patch? ;-) > > And where? The sourceforge page says > > "PyXML is no longer maintained." The minidom code is in the standard library: http://svn.python.org/view/python/trunk/Lib/xml

Re: ANN: Google custom search engine for Python

2008-07-31 Thread Gerard flanagan
Gerard flanagan wrote: What is it? --- A Google custom search engine which targets only the following sites: + `The Hazel Tree `__ + `The Python standard library docs `__ + `The Python wiki `__ + `Python Packag

Case tagging and python

2008-07-31 Thread Fred Mangusta
Hi, I'm relatively new to programming in general, and totally new to python, and I've been told that this language is particularly good for what I need to do. Let me explain. I have a large corpus of English text, in the form of several files. First of all I would like to scan each file. Then, f

How smart is the Python interpreter?

2008-07-31 Thread ssecorp
def str_sort(string): s = "" for a in sorted(string): s+=a return s if i instead do: def str_sort(string): s = "" so = sorted(string) for a in so: s+=a return s will that be faster or the interpreter can fi

Re: Case tagging and python

2008-07-31 Thread bearophileHUGS
Fred Mangusta: > Could I use the join function to reform the string? You can write a function to split the words, for example taking in account the points too, etc. > And, regarding the casetest() function, what do you suggest to do? Python strings have isupper, islower, istitle methods, they m

Re: Tkinter- Possibly a basic question

2008-07-31 Thread joshdw4
On Jul 30, 6:48 pm, "Guilherme Polo" <[EMAIL PROTECTED]> wrote: > On Wed, Jul 30, 2008 at 6:33 PM,  <[EMAIL PROTECTED]> wrote: > >... > > ... > > The second option is to not create the root there, instead, make App > inherit Tk. I rarely see people doing this, but it works too. Here you > won't nee

Re: Difference between type and class

2008-07-31 Thread oj
On Jul 31, 11:37 am, Nikolaus Rath <[EMAIL PROTECTED]> wrote: > So why does Python distinguish between e.g. the type 'int' and the > class 'myclass'? Why can't I say that 'int' is a class and 'myclass' > is a type? I might be wrong here, but I think the point is that there is no distinction. A cla

Re: How smart is the Python interpreter?

2008-07-31 Thread Ulrich Eckhardt
ssecorp wrote: > def str_sort(string): > s = "" > for a in sorted(string): > s+=a > return s > > > if i instead do: > > def str_sort(string): > s = "" > so = sorted(string) > for a in so: > s+=a > return s > > will that be faster or the interpreter can figure out that it o

Re: Difference between type and class

2008-07-31 Thread Thomas Troeger
Can someone explain to me the difference between a type and a class? If your confusion is of a more general nature I suggest reading the introduction of `Design Patterns' (ISBN-10: 0201633612), under `Specifying Object Interfaces'. In short: A type denotes a certain interface, i.e. a set of

Re: working pylint anyone?

2008-07-31 Thread [EMAIL PROTECTED]
On Jul 31, 11:29 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > Hi, > > until yesterday I was a happy user of pylint. Then I upgraded to ubuntu > hardy heron - and the trouble began. > > The packaged version of pylint (0.13.2) fails with this error (last line): > > logilab.common.configuration

Re: How smart is the Python interpreter?

2008-07-31 Thread Heiko Wundram
Am Donnerstag, 31. Juli 2008 13:09:57 schrieb ssecorp: > def str_sort(string): > s = "" > for a in sorted(string): > s+=a > return s > > > if i instead do: > > def str_sort(string): > s = "" > so = sorted(string) > for a in so: > s+=

Re: Terminate a python script from linux shell / bash script

2008-07-31 Thread Nigel Rantor
Gros Bedo wrote: Thank you guys for your help. My problem is that I project to use this command to terminate a script when uninstalling the software, so I can't store the PID. This command will be integrated in the spec file of the RPM package. Here's the script I'll use, it may help someone e

Re: How smart is the Python interpreter?

2008-07-31 Thread Diez B. Roggisch
ssecorp wrote: > def str_sort(string): > s = "" > for a in sorted(string): > s+=a > return s > > > if i instead do: > > def str_sort(string): > s = "" > so = sorted(string) > for a in so: > s+=a > return s > > > will that be faster or the interpreter can figure out that it only has >

Python Contractor needed

2008-07-31 Thread Rakesh Thakrar
Hi All, An opportunity for a talented Python Software Engineer has arisen to join a company which is currently going through a phase of rapid expansion. Candidates must have excellent software development skills to join an established team within this small company with offices in the U.K. and

Re: Continuous integration for Python projects

2008-07-31 Thread Leonid Shalupov
Hello, Hussein B wrote: Please correct my if I'm wrong but it seems to me that the major continuous integration servers (Hudson, CruiseControl, TeamCity ..) don't support Python based application. It seems they mainly support Java, .NET and Ruby. Can I use one of the previous listed servers for

Re: working pylint anyone?

2008-07-31 Thread Diez B. Roggisch
Stefan Rank wrote: > on 31.07.2008 11:29 Diez B. Roggisch said the following: > >> >> The packaged version of pylint (0.13.2) fails with this error (last >> line): >> > >> >> So - anybody out here having an actually working pylint config and can >> tell me what versions work together? I've be

Re: SVN access with pysvn under Cygwin (Installation problems)

2008-07-31 Thread Jason Tishler
Andy, On Thu, Jul 31, 2008 at 03:10:26AM -0700, Andy Dingley wrote: > On 30 Jul, 20:30, Jason Tishler <[EMAIL PROTECTED]> wrote: > > You need to build (and install) pysvn under Cygwin. The pre-built > > Windows version will not work under Cygwin. > > Thanks. Presumably this same problem would aff

Re: Difference between type and class

2008-07-31 Thread Nikolaus Rath
Thomas Troeger <[EMAIL PROTECTED]> writes: >> Can someone explain to me the difference between a type and a class? > > If your confusion is of a more general nature I suggest reading the > introduction of `Design Patterns' (ISBN-10: 0201633612), under > Specifying Object Interfaces'. > > In short:

Re: Difference between type and class

2008-07-31 Thread Nikolaus Rath
oj <[EMAIL PROTECTED]> writes: > On Jul 31, 11:37 am, Nikolaus Rath <[EMAIL PROTECTED]> wrote: >> So why does Python distinguish between e.g. the type 'int' and the >> class 'myclass'? Why can't I say that 'int' is a class and 'myclass' >> is a type? > > I might be wrong here, but I think the point

Re: working pylint anyone?

2008-07-31 Thread Diez B. Roggisch
> Which version of python-logilab-common and python-logilab-astng are > installed on your machine ? By now, pylint 0.14 with logilab.common 0.27 and astng 0.17.2 I was able to track down the problem as being related to a custom init-hook. See the attached .pylintrc + hook. They don't actually *d

Re: Difference between type and class

2008-07-31 Thread Maric Michaud
Le Thursday 31 July 2008 14:30:19 Nikolaus Rath, vous avez écrit : > oj <[EMAIL PROTECTED]> writes: > > On Jul 31, 11:37 am, Nikolaus Rath <[EMAIL PROTECTED]> wrote: > >> So why does Python distinguish between e.g. the type 'int' and the > >> class 'myclass'? Why can't I say that 'int' is a class a

Re: working pylint anyone?

2008-07-31 Thread Mike Driscoll
On Jul 31, 4:29 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > Hi, > > until yesterday I was a happy user of pylint. Then I upgraded to ubuntu > hardy heron - and the trouble began. > > The packaged version of pylint (0.13.2) fails with this error (last line): > > logilab.common.configuration.

Re: Difference between type and class

2008-07-31 Thread Maric Michaud
Le Thursday 31 July 2008 13:32:39 Thomas Troeger, vous avez écrit : > De : > Thomas Troeger <[EMAIL PROTECTED]>  (Aioe.org NNTP Server) > À : > python-list@python.org > Date : > Aujourd'hui 13:32:39 >   > > > Can someone explain to me the difference between a type and a class? > > If your con

Re: Difference between type and class

2008-07-31 Thread Thomas Troeger
That would imply that I cannot create instances of a type, only of a class that implements the type, wouldn't it? But Python denotes 'int' as a type *and* I can instantiate it. Now I start getting confused also ;-) >>> a=5 >>> a.__class__ >>> a.__class__.__class__ >>> dir(a) ['__abs__', '__a

current week / weeks in year - best practice

2008-07-31 Thread Aljosa Mohorovic
i use this to find out current week and total number of weeks for current year: now = datetime.now() weeks_in_year = int(date(now.year, 12, 31).strftime("%W")) current_week = int(date(now.year, now.month, now.day).strftime("%W")) is this the best way or is there a better way? Aljosa Mohorovic --

problem when reading file

2008-07-31 Thread shrimpy
hi every one, i am new to python, and coz i want to write a handy command for my linux machine, to find a word in all the files which are under the current folder. the code is half done, but when i run it, it complain, and i don`t know why??? can anyone help me have a look at it? here is the me

Re: Python parsing iTunes XML/COM

2008-07-31 Thread william tanksley
Stefan Behnel <[EMAIL PROTECTED]> wrote: > william tanksley wrote: > > Okay, my answer is that ElementTree (in Python 2.5) is simply > > deranged when it comes to Unicode. It assumes everything's ASCII. > It does not "assume" that. It *requires* byte strings to be ASCII. You can't encode Unicode

Python Contractor needed

2008-07-31 Thread Rakesh Thakrar
Hi All, An opportunity for a talented Python Software Engineer has arisen to join a company which is currently going through a phase of rapid expansion. Candidates must have excellent software development skills to join an established team within this small company with offices in the U.K. and

Re: problem when reading file

2008-07-31 Thread Heiko Wundram
Am Donnerstag, 31. Juli 2008 15:44:33 schrieb shrimpy: > hi every one, i am new to python, > and coz i want to write a handy command for my linux machine, to find > a word in all the files which are under the current folder. What about grep -R "myword" . ? Even works on regular expression (with

Function References

2008-07-31 Thread [EMAIL PROTECTED]
Greetings, I'm trying to wrap a function in a C library as a compiled C Python module. Everything is going great, but I've hit a snag. There's a function in the form of this: First the typedef: typedef void(*FPtr_DeviceMessageHandler) (const DeviceMessage, const char*); Then the actual function

Re: Python parsing iTunes XML/COM

2008-07-31 Thread william tanksley
John Machin <[EMAIL PROTECTED]> wrote: > william tanksley <[EMAIL PROTECTED]> wrote: > > "Buffett Time - Annual Shareholders\xc2\xa0L.mp3" > > 1. This isn't Unicode; it's missing the u"" (I printed using repr). > > 2. It's got the UTF-8 bytes there in the middle. > > In addition to the above result

Debugging of a long running process under Windows

2008-07-31 Thread Propad
Hello, I know this issue pops up once in a while, but I haven't found a good answer to it. I need to debug a long running application under windows. The application is a combined java/python framework for testing ECUs in the automotive industry. Basically, the Java GUI (Eclipse-based) starts test-c

Re: current week / weeks in year - best practice

2008-07-31 Thread Diez B. Roggisch
Aljosa Mohorovic wrote: > i use this to find out current week and total number of weeks for > current year: > now = datetime.now() > weeks_in_year = int(date(now.year, 12, 31).strftime("%W")) > current_week = int(date(now.year, now.month, now.day).strftime("%W")) > > is this the best way or is th

Re: Function References

2008-07-31 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: > Greetings, > > I'm trying to wrap a function in a C library as a compiled C Python > module. Everything is going great, but I've hit a snag. There's a > function in the form of this: > > First the typedef: > typedef void(*FPtr_DeviceMessageHandler) (const DeviceMessage

Re: Function References

2008-07-31 Thread [EMAIL PROTECTED]
Hello Diez. > May I suggest you move to ctypes for wrapping? It's easier, pure python and > callbacks are already built-in. I'm pretty new to extending Python in C, I don't understand what you're saying. Are there any examples or a brief explanation/URL you could point me to? -- http://mail.pyth

Re: Function References

2008-07-31 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: > Hello Diez. > >> May I suggest you move to ctypes for wrapping? It's easier, pure python >> and callbacks are already built-in. > > I'm pretty new to extending Python in C, I don't understand what > you're saying. Are there any examples or a brief explanation/URL you >

Re: working pylint anyone?

2008-07-31 Thread [EMAIL PROTECTED]
On Jul 31, 2:39 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > > Which version of python-logilab-common and python-logilab-astng are > > installed on your machine ? > > By now, pylint 0.14 with logilab.common 0.27 and astng 0.17.2 > > I was able to track down the problem as being related to a

Re: Function References

2008-07-31 Thread [EMAIL PROTECTED]
> Ctypes is a since python2.5 built-in module that allows to declare > interfaces to C-libraries in pure python. You declare datatypes and > function prototypes, load a DLL/SO and then happily work with it. No C, no > compiler, no refcounts, no nothing. > > And you can pass python-functions as call

Re: Need help in writing up a Python Syntax checker

2008-07-31 Thread [EMAIL PROTECTED]
On Jul 14, 8:22 am, Kinokunya <[EMAIL PROTECTED]> wrote: > Hi guys, > > My group and I will be working on our final year project, the scope to > do a program/web-based application similar areas of functionalities > like thePyLintand PyChecker; a Python syntax checker. We have no > Python background

Re: Function References

2008-07-31 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: >> Ctypes is a since python2.5 built-in module that allows to declare >> interfaces to C-libraries in pure python. You declare datatypes and >> function prototypes, load a DLL/SO and then happily work with it. No C, >> no compiler, no refcounts, no nothing. >> >> And you c

Re: Function References

2008-07-31 Thread Diez B. Roggisch
Diez B. Roggisch wrote: > [EMAIL PROTECTED] wrote: > >>> Ctypes is a since python2.5 built-in module that allows to declare >>> interfaces to C-libraries in pure python. You declare datatypes and >>> function prototypes, load a DLL/SO and then happily work with it. No C, >>> no compiler, no refco

Re: Function References

2008-07-31 Thread [EMAIL PROTECTED]
> How much more liberal can it get than MIT-licensed? Again, the licensing issue is everything to do with the original library distributor, NOT ctypes. > But then, if you insist, go down the hard road. Irrelevant and unnecessary. If you don't want to help, don't please don't reply. -- http://mai

Re: Difference between type and class

2008-07-31 Thread Nikolaus Rath
Maric Michaud <[EMAIL PROTECTED]> writes: >> > Can someone explain to me the difference between a type and a class? >> >> If your confusion is of a more general nature I suggest reading the >> introduction of `Design Patterns' (ISBN-10: 0201633612), under >> `Specifying Object Interfaces'. >> >> In

Re: Function References

2008-07-31 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: >> How much more liberal can it get than MIT-licensed? > > Again, the licensing issue is everything to do with the original > library distributor, NOT ctypes. I read library distributor as "ctypes-library distributor" because it is 3rd-party under 2.4. Which was the reas

HELP - Attribute Error, no matter what I do on PAMIE...

2008-07-31 Thread frankrentef
Greetings all. I'm new to PAMIE and I've watched / followed to PAMIE videos on Show me Do. I've tried to duplicate the "scriptWrite" function in an attempt to automate the forms process... without success. Can someone PLEASE Assist!? I'm using the following code from cPAMIE import PAMIE #I

Re: Difference between type and class

2008-07-31 Thread Maric Michaud
Le Thursday 31 July 2008 16:46:28 Nikolaus Rath, vous avez écrit : > Maric Michaud <[EMAIL PROTECTED]> writes: > >> > Can someone explain to me the difference between a type and a class? > >> > >> If your confusion is of a more general nature I suggest reading the > >> introduction of `Design Patte

Re: Difference between type and class

2008-07-31 Thread Nikolaus Rath
Maric Michaud <[EMAIL PROTECTED]> writes: > Le Thursday 31 July 2008 14:30:19 Nikolaus Rath, vous avez écrit : >> oj <[EMAIL PROTECTED]> writes: >> > On Jul 31, 11:37 am, Nikolaus Rath <[EMAIL PROTECTED]> wrote: >> >> So why does Python distinguish between e.g. the type 'int' and the >> >> class 'm

Re: win32com ChartObject pythonwin vs idle

2008-07-31 Thread sterling
On Jul 31, 4:28 am, Tim Golden <[EMAIL PROTECTED]> wrote: > sterling wrote: > > I'm curious as to why the difference between IDLE and pythonWin when > > using win32com. > > opening an excel file, i've attempted to grab the chart information > > out of the file. > > > commands like co = ChartObjects

Re: Swap memory in Python ? - three questions

2008-07-31 Thread John Nagle
Robert LaMarca wrote: Hi, I am using numpy and wish to create very large arrays. My system is AMD 64 x 2 Ubuntu 8.04. Ubuntu should be 64 bit. I have 3gb RAM and a 15 GB swap drive. Does a full 64-bit version of CPython, one where all pointers and sizes are 64 bits, even exist?

Re: Function References

2008-07-31 Thread [EMAIL PROTECTED]
On Jul 31, 10:47 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > I take the freedom to do so as I see fit - this is usenet... Fine, then keep beating a dead horse by replying to this thread with things that do nobody any good. It seems like there are a lot better way to waste time, though. Th

Re: Difference between type and class

2008-07-31 Thread Nikolaus Rath
Maric Michaud <[EMAIL PROTECTED]> writes: > Le Thursday 31 July 2008 16:46:28 Nikolaus Rath, vous avez écrit : >> Maric Michaud <[EMAIL PROTECTED]> writes: >> >> > Can someone explain to me the difference between a type and a class? >> >> >> >> If your confusion is of a more general nature I sugges

Re: undo a dictionary

2008-07-31 Thread mmm
Gabriel, I meant the latter, so this helps > Or, do you mean you already have those names and values, perhaps mixed   > with a lot more names, and want to extract only those starting with "x"   > and following with a number? > > result = {} > for name, value in vars(): # or locals().items(), or g

Re: Difference between type and class

2008-07-31 Thread Maric Michaud
Le Thursday 31 July 2008 17:00:51 Nikolaus Rath, vous avez écrit : > > There are some confusion about the terms here. > > > > Classes are instances of type 'type', > > Could you please clarify what you mean with 'instance of type X'? I > guess you mean that 'y is an instance of type X' iif y is con

Re: Newbie Python questions

2008-07-31 Thread binaryjesus
One great open source GUI package that you left out is GTK ie. pygtk. i cant compare it with wx as i have never used it but isay its much better than QT. Anyway for ur q if u want to compair qt n wx. QT should be faster coz it has a better documentation. and welcome to the python family! kind re

Re: current week / weeks in year - best practice

2008-07-31 Thread Aljosa Mohorovic
On Jul 31, 3:58 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > Instead of datetime.now() use date.today(), which removes a lot of > boilerplate. > > int(date.today().strftime("%W")) > > Apart from that, I think it's the way to go. what if i know current context week = 20 (example), what would

Re: Newbie Python questions

2008-07-31 Thread Mike Driscoll
On Jul 29, 12:28 pm, LessPaul <[EMAIL PROTECTED]> wrote: > I recently discovered Python and see it as a great language to use for > personal projects (and more). I made my living for over a decade as a > coder in C, C++, ADA, Fortran, and Assembly before moving to systems > engineering. > > I'm now

Re: current week / weeks in year - best practice

2008-07-31 Thread Aljosa Mohorovic
On Jul 31, 5:42 pm, Aljosa Mohorovic <[EMAIL PROTECTED]> wrote: > what if i know current context week = 20 (example), what would be the > best way to get datetime objects for first and last day of current > context week? > by "current context week" i don't mean current week for current year > but c

Re: How smart is the Python interpreter?

2008-07-31 Thread Gary Herron
ssecorp wrote: def str_sort(string): s = "" for a in sorted(string): s+=a return s if i instead do: def str_sort(string): s = "" so = sorted(string) for a in so: s+=a return s will that be faster or the i

Re: Function References

2008-07-31 Thread Matthew Woodcraft
>> Ctypes is a since python2.5 built-in module that allows to declare >> interfaces to C-libraries in pure python. You declare datatypes and >> function prototypes, load a DLL/SO and then happily work with it. No C, no >> compiler, no refcounts, no nothing. >> >> And you can pass python-functions a

Re: Non Continuous Subsequences

2008-07-31 Thread Bruce Frederiksen
On Wed, 30 Jul 2008 09:32:25 -0700, bearophileHUGS wrote: > This post is not about practical stuff, so if you have little time, > you may ignore it. > > This is a task of the rosettacode.org site: > http://www.rosettacode.org/wiki/Non_Continuous_Subsequences > > A subsequence contains some subse

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-31 Thread Chris Mellon
On Tue, Jul 29, 2008 at 3:37 AM, Carl Banks <[EMAIL PROTECTED]> wrote: > On Jul 28, 8:15 pm, Steven D'Aprano <[EMAIL PROTECTED] > cybersource.com.au> wrote: >> On Mon, 28 Jul 2008 13:22:37 -0700, Carl Banks wrote: >> > On Jul 28, 10:00 am, Steven D'Aprano <[EMAIL PROTECTED] >> > cybersource.com.au>

Re: problem when reading file

2008-07-31 Thread Bruce Frederiksen
On Thu, 31 Jul 2008 23:44:33 +1000, shrimpy wrote: > hi every one, i am new to python, > and coz i want to write a handy command for my linux machine, to find > a word in all the files which are under the current folder. > > the code is half done, but when i run it, it complain, and i don`t know

Re: Function References

2008-07-31 Thread Carsten Haese
[EMAIL PROTECTED] wrote: Greetings, I'm trying to wrap a function in a C library as a compiled C Python module. Everything is going great, but I've hit a snag. There's a function in the form of this: First the typedef: typedef void(*FPtr_DeviceMessageHandler) (const DeviceMessage, const char*);

Re: Function References

2008-07-31 Thread Chris Mellon
On Thu, Jul 31, 2008 at 10:27 AM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > On Jul 31, 10:47 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: >> I take the freedom to do so as I see fit - this is usenet... > > Fine, then keep beating a dead horse by replying to this thread with > things that

Re: Non Continuous Subsequences

2008-07-31 Thread bearophileHUGS
Bruce Frederiksen: Your solution is a bit different from what I was thinking about (I was thinking about a generator function, with yield), but it works. This line: > return itertools.chain( >itertools.imap(lambda ys: x + ys, ncsub(xs, s + p1)), >nc

Re: Non Continuous Subsequences

2008-07-31 Thread Mensanator
On Jul 30, 11:32 am, [EMAIL PROTECTED] wrote: > This post is not about practical stuff, so if you have little time, > you may ignore it. > > This is a task of the rosettacode.org > site:http://www.rosettacode.org/wiki/Non_Continuous_Subsequences > > A subsequence contains some subset of the elemen

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-31 Thread Matthew Fitzgibbons
Steven D'Aprano wrote: On Wed, 30 Jul 2008 09:23:05 -0600, Matthew Fitzgibbons wrote: If you're expecting a list (and only a list) then your point makes sense. 'if x' can get you into trouble if you _don't_ want its polymorphism. "if x" is hardly unique in that way. If you're expecting a list

Re: Python parsing iTunes XML/COM

2008-07-31 Thread Stefan Behnel
william tanksley wrote: > I didn't > pass a string. I passed a file. It didn't error out; instead, it > produced bytestring-encoded output (not Unicode). >From my experience (and from the source code I have seen so far), ElementTree does not return UTF-8 encoded strings at the API level. Can you p

Re: Difference between type and class

2008-07-31 Thread Nikolaus Rath
Maric Michaud <[EMAIL PROTECTED]> writes: >>> What the means is that int is not a user type but a >>> builtin type, instances of int are not types (or classes) but common >>> objects, so its nature is the same as any classes. >>> >>> The way it prints doesn't matter, it's just the __repr__ of any

Hobbyist - Python vs. other languages

2008-07-31 Thread fprintf
I have been playing with computers since I first learned to program moving shapes on an Atari 800XL in BASIC. After many years of dabbling in programming languages as a hobbyist (I am not a computer scientist or other IT professional), I have never found a way to stick with a language far enough to

Re: Hobbyist - Python vs. other languages

2008-07-31 Thread Mike Driscoll
On Jul 31, 1:32 pm, fprintf <[EMAIL PROTECTED]> wrote: > I have been playing with computers since I first learned to program > moving shapes on an Atari 800XL in BASIC. After many years of dabbling > in programming languages as a hobbyist (I am not a computer scientist > or other IT professional),

Re: Hobbyist - Python vs. other languages

2008-07-31 Thread Serdar Tumgoren
>From this noob's perspective, I'd say take a look at Magnus Lie Hetland's Beginning Pythonbook. It covers the core syntax (which it sounds like you're familiar with already) and then includes a bunch of projects, from text p

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-31 Thread Matthew Fitzgibbons
Steven D'Aprano wrote: On Wed, 30 Jul 2008 09:23:05 -0600, Matthew Fitzgibbons wrote: If you're expecting a list (and only a list) then your point makes sense. 'if x' can get you into trouble if you _don't_ want its polymorphism. "if x" is hardly unique in that way. If you're expecting a list

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-31 Thread Matthew Fitzgibbons
Matthew Fitzgibbons wrote: Steven D'Aprano wrote: On Wed, 30 Jul 2008 09:23:05 -0600, Matthew Fitzgibbons wrote: If you're expecting a list (and only a list) then your point makes sense. 'if x' can get you into trouble if you _don't_ want its polymorphism. "if x" is hardly unique in that way

simple problem with lists I am just forgetting

2008-07-31 Thread Alexnb
Lets say we have this list: funlist = ['a', 'b', 'c'] and lets say I do this: if funlist[4]: print funlist[4] I will get the exception "list index out of range" How can I test if the list item is empty without getting that exception? -- View this message in context: http://www.nabble.co

Re: simple problem with lists I am just forgetting

2008-07-31 Thread bearophileHUGS
Alexnb: > How can I test if the list item is empty without getting that exception? In Python such list cell isn't empty, it's absent. So you can use len(somelist) to see how much long the list is before accessing its items. Often you can iterate on the list with a for, so you don't need to care of

Re: Hobbyist - Python vs. other languages

2008-07-31 Thread bearophileHUGS
fprintf: > and yet they all end at the point where a person has enough > knowledge of the syntax, but not really enough to do anything. A programming language is a tool to solve problems, so first of all: do you have problems to solve? You can create some visualizations, some program with GUI, som

find and replace with regular expressions

2008-07-31 Thread chrispoliquin
I am using regular expressions to search a string (always full sentences, maybe more than one sentence) for common abbreviations and remove the periods. I need to break the string into different sentences but split('.') doesn't solve the whole problem because of possible periods in the middle of a

Re: Case tagging and python

2008-07-31 Thread Fred Mangusta
Hi, I came up with the following procedure ALLCAPS = "|ALLCAPS" NOCAPS = "|NOCAPS" MIDCAPS = "|MIDCAPS" CAPS = "|CAPS" DIGIT = "|DIGIT" def test_case(w): w_out = '' if w.isalpha(): #se la virgola non ci entra if w.isupper(): w_out = w.lower() + ALLCAPS r

Re: Case tagging and python

2008-07-31 Thread chrispoliquin
I second the idea of just using the islower(), isupper(), and istitle() methods. So, you could have a function - let's call it checkCase() - that returns a string with the tag you want... def checkCase(word): if word.islower(): tag = 'nocap' elif word.isupper(): tag = 'al

Re: Hobbyist - Python vs. other languages

2008-07-31 Thread Matthew Fitzgibbons
fprintf wrote: I have been playing with computers since I first learned to program moving shapes on an Atari 800XL in BASIC. After many years of dabbling in programming languages as a hobbyist (I am not a computer scientist or other IT professional), I have never found a way to stick with a langu

  1   2   >