Hi
It would help if you could describe the purpose you have in mind for doing
this. There is a cute way of doing what you want:
===file: a.py===
# module a.py
test = 'first'
class aclass:
def __init__(self, mod, value):
mod.test = value# Is there another way to refe
Olivier
If you consider using the ctypes module, you can write a dll (windows) or
a shared object (linux) using anything that can make one of those.
For example, I have successfully used FreePascal to make a dynamic library
on both windows and linux and use that library within python on both
Steven, thanks for your help once again :)
so you could write the code like:
test = 'first'
class aclass:
def __init__(self, value):
mod = __import__(__name__)
mod.test = value
This is sweet. I really like this technique for manipulating module-scope
identifiers (from with
Hi Alex
Assuming you have a file called "data.txt":
***
f = open('data.txt','r')
lines = f.readlines()
f.close()
for line in lines:
print line
***
Will print each line of the file.
You can make a huge investment by setting 2 or 3 hours aside to go through
the Python tutorial, which gets insta
Peter
Yes, you can even write
f = open("data.txt")
for line in f:
# do stuff with line
f.close()
This has the additional benefit of not slurping in the entire file at
once.
Is there disk access on every iteration? I'm guessing yes? It shouldn't
be an issue in the vast majority of cases,
Olivier
But the problem is about modules thats are developped from others with
distutils...
Yes, sorry, I reread your original post and now realise that you were
referring to other people's modules. And with your comments there, I
agree with you -> MSVC as a requirement is unfortunate.
thx
Ca
Gurpreet
You can manage the namespace more formally. Or to put it another way,
"global" gives me the heebie-jeebies. I recently worked on a project
replacing a legacy reactor model in FORTRAN, and between COMMON blocks,
and GOTO statements, I didn't know up from down.
How about this:
***
cl
Hi Doug
Not only was Kylix a letdown, there is talk also of it being
discontinued. To be fair though, it is easy to see the difficulty for
Borland to deploy a Linux IDE of the same quality as Delphi when so much
in different Linux distributions is variable, the widget set being a prime
ex
Chris
> 1. get arbitrary numerical data (typically large data sets in columnar
> format or even via COM from other packages. I generally have to deal with
> one or more sets of X,Y data)
> 2. manipulate the data (scaling, least squares fitting, means, peaks,
> add/subtract one XY set from another
You really owe it to yourself to try the PyParsing package, if you have to
do this kind of thing with any frequency.
The syntactic difference between PyParsing and regular expressions is
greater than the syntactic difference between Python and C.
thx
Caleb
On Tue, 19 Jul 2005 13:35:02 +0200,
Wow, I didn't know about enumerate.
Many thanks
Caleb
On Wed, 20 Jul 2005 15:19:50 +0200, Simon Brunning
<[EMAIL PROTECTED]> wrote:
> On 7/20/05, Mage <[EMAIL PROTECTED]> wrote:
>> Or is there better way?
>>
>> for (i, url) in [(i,links[i]) for i in range(len(links))]:
>
> for i, url in enumer
Terry
Yes, I must agree with you that it is something I should know. I do try
to keep with things but there are always some things that slip through the
cracks, like enumerate, in this case. That is why I am extremely grateful
the for the activity, generosity and pure knowledge on this new
Probably, the best place for learning how to build GUI's for Windows, in
general, is to get hold the personal edition of Delphi from the Borland
website. If you want something more specific to Python, it is likely to
be much tougher. You would, for example, have to decide which widget
too
> Since you are on this topic, do you (or anyone else) have any type of
> "code-completion" mode for python in emacs?
>
> Thanks
> -george
For what its worth, Vim has a generic type of "code-completion" that uses
the file being edited to check for completion options within a word. It's
not
Peter
To my mind, this kind of setup (interface class, or abstact class) is more
usually used in static languages to benefit polymorphism - but python is
dynamically typed, so in which situations would this setup be useful in a
python program? You see, I expected your post to say that it wo
You know, for several years I was one of those people who simply ignored
posts like this about Vi/Vim because I happened to come across it once on
a sparc machine and thought it was ridiculous that I couldn't figure out
how to type a simple note. I thought that Vi (Vim) was some kind of
w
York
Short answer: yes
We use python and R at work, and in general you will find python syntax a
little cleaner for functionality they have in common. R is better for
some of the more hard-wired stats stuff, though.
On Mon, 19 Sep 2005 20:04:37 +0200, York <[EMAIL PROTECTED]> wrote:
> Hi,
The other thing (and this is always true) is that "better" needs
definition. On purely technical grounds, on average, MSOffice is better
than OO. However, holistically, OO is probably better (no lock-in, open
standards, multiplatform and so on). Those soft issues do matter.
On Mon, 19 Sep
Very interesting that sudoku solving appears on the python group - there
is a programming competition at mathschallenge.net (euler) where one of
the puzzles is developing a sudoku solving algorithm...
Actually the python entrants are giving the C guys a good run!
On Mon, 19 Sep 2005 09:12:54
Hi Anthony
Here is some stuff to get you started (this is from memory, I'm not
checking it, but should be mostly helpful):
***
import os
os.chdir('C:\My Documents') # Can use this to jump around to different
folders
fileNames = os.listdir('.') # Checks the now current folder
namesToMatch = [
I would be interested to see an example of code that is more concise but
yet as *clear* as the one you already have. I can actually read and
understand what you've got there. That's cool :)
On 6 Feb 2005 11:28:37 -0800, <[EMAIL PROTECTED]> wrote:
I wrote this little piece of code to get a l
Hi Philip
C++ to Python is a steep 'unlearning' curve...
That's worthy of QOTW. I decided not to reply to this thread earlier, but
you just convinced me otherwise :)
I work in Delphi a lot, which is in a lot of respects very similar to C.
I have come to the conclusion that function overloadi
Hi Surfunbear
I don't know about the stuff regarding jobs, resumes, etc, but I will tell
you the same thing I tell everyone I meet regarding python:
Set aside a morning, and work through the python tutorial that comes with
the documentation. People like me are going to tell you this and that,
Sure Steve
Lemme see ... (indentation changed so comments associate with correct bits)
Out of curiosity, do you find:
filenames = [os.path.join(dirpath, filename)
# This is cool
for dirpath, _, filenames in os.walk('.')
# This is getting tricky, whats
Wow, Steve, thanks, you went to some effort here.
I prefer to give names to the values produced by os.walk -- I think it
makes the usage much clearer. However, since I don't use 'dirnames', I
use '_' to indicate this:
Actually, I feel silly for not recognising this - I read about the Python3
Sure, Nick, I agree with you completely.
I generally try to make sure that my classes are limited in what they
do/provide, so it is not often a problem that a class may need to be
instantiated in several very different ways.
But your point is well taken.
Thanks
Caleb
--
http://mail.python.org/
Peter, that was very clear, thanks.
> So not only is
>
> for line in file(...):
># do stuff
>
> the most elegant, it is also the fastest. file.readlines() comes
close, but
> is only viable for "small" files.
--
http://mail.python.org/mailman/listinfo/python-list
Hi all
I saw it on a webpage a few days ago, can't seem to find it again. Tried
a google search for
"pypy needed translate C modules"
but that didn't turn up what I was looking for. Anyone have that page
ref handy listing the C modules that the pypy team need translated into
python?
than
Hi m
Speed is a contentious issue here. Point is, if you really need raw
speed, why stop only at Perl and Python? There are plenty of statically
compiled languages that will produce native binaries.
The relative difference in speed between Perl and Python, whatever it is,
is completely was
is it possible to write python code without any indentation?
Xah
You can, of course, write a silly little inline script without
any control structures that will all line up at the left
margain. So what?
John Roth
I agree, John, I don't get it. The vast majority of programmers (albiet
from my l
Jim
Someone on this list (SteveB) helped me quite a bit with a list
comprehension on a recent thread. Roy said it can be hard to read, and I
agree in part because I always thought they were hard to read, when in
actual fact I had just never bothered to learn properly. Here is a
mini-tutor
Jean, Paddy
I use "pym" to extract bits of pascal out of delphi code for documentation
purposes. You have to add some stuff to the delphi code (in your case, C
header), but these are added within comment blocks, and the interesting
thing is that you add python code(!) as a kind of dynamic ma
Marc
I don't know how it is handled, but I expect also that there is an implied
close().
thanks
Caleb
When you read a file with that method, is there an implied close() call
on the file? I assume there is, but how is that handled?
--
http://mail.python.org/mailman/listinfo/python-list
Alexander
PowerOfGenerator=TakeFromSensor()
if PowerOfGenerator>xxx:
RecalcPower(PowerOfGenerator)
PutToTheDatabase(PowerOfGenerator)
Here, python will not help you. The worst thing is that in such
calculations
you often receive plausible results.
(I think PyChecker has co
Stephen
You're gonna have to help me here.what is the effective difference?
Thanks
Caleb
'>>> a = []
'>>> for b in range(4):
'>>> for i in range(3):
'>>> a.append(i*2*b)
There is a subtle error in this explanation. The equivilence actually
looks like:
'> a = []
'> l1 = range(4)
'> l
Jeff
I fully agree. As I stated in a message to alexander, it is quick and
easy even to write a simple project-specific tool for checking that only
allowed variable names exist in all the project files.
Compared to having to work with tons of effectively useless variable
declarations foreve
Hi Adam
Thanks for your comments.
> I think the expression you seek is "comparing virtue among whores."
Sure, that's what I was saying, but not quite in as colourfil a manner
:)
> >
> > The problem domains in which I do most of my work (chemical process
> > modelling and simulation) really do
Hi Fredrik
*sigh* I think I will stop writing mini-tutorials :)
You are, of course, correct. And I really like your method of
explaining how to mentally juggle the LC into explicit loops.
I shudder to think how mnay people I confused with my incorrect
examples - I really should have tested the
uld give it some more thought anyways.
Thanks again
Caleb
On Wed, 09 Feb 2005 12:38:37 -0500, Joe Francia
<[EMAIL PROTECTED]> wrote:
Caleb Hattingh wrote:
As you might imagine, I think about this constantly. However, there
are many other issues that make it complicated, such as having to w
Carl
What is the ultimate version control tool for Python if you are working
in a
Windows environment?
We use JEDI VCS (open source, free). To be fair, JEDI VCS actually
integrates into the Delphi IDE, which is what we use mostly. However, the
standard installation also installs a standalon
Roy
How about the Yoda version:
do:
statement
do not do:
statement
The Yoda version actually goes
statement
:do
statement
:not do
Caleb
--
http://mail.python.org/mailman/listinfo/python-list
Brent
Google "python ctypes". ctypes is cool :)
keep well
Caleb
On Wed, 9 Feb 2005 13:44:44 -0700, Brent W. Hughes
<[EMAIL PROTECTED]> wrote:
I have a third-party DLL and it's associated .h file. The DLL was
written
in C. I have neither the associated .c files nor the .obj files for the
DL
http://www.python.org
On Tue, 15 Feb 2005 13:16:53 -0500, samar bazied <[EMAIL PROTECTED]>
wrote:
Hi..
plz
can u help me??
I am very new in python and I have some qustions about it.
can u give me design process of python and their related langauges?
and I will be very habby if u give me small ev
I have had good success with pygnuplot.
On Tue, 8 Mar 2005 20:45:22 +0200, ionel <[EMAIL PROTECTED]> wrote:
i need some pointers.
so far i've tryed matplotlib ...
--
http://mail.python.org/mailman/listinfo/python-list
Here's hoping effbot is around :)
I have a really simple situation where I have 2 png images, and open them
so:
'>>> iconBallImage =
Image.open('sampleTextures/iconBall.png').resize(DimensionSize)
'>>> iconShieldImage =
Image.open('sampleTextures/iconShield.png').resize(DimensionSize)
The 2
I'm going to assume the following is self-explanatory - type the commands
in yourself.
'>>> a = 'hello my name is caleb'
'>>> b = a.split()
'>>> b
['hello', 'my', 'name', 'is', 'caleb']
'>>> b[0]
'hello'
'>>> b[1]
'my'
'>>> b[0:1]
['hello']
'>>> b[0:2]
['hello', 'my']
'>>> b[-1]
'caleb'
'>>> b[:
I heartily support something like this, but alas I have not the time to
help out with it. I like the Enthought python distribution because it
installs several packages in one shot. A pity there isn't a similar thing
for python addons in Linux (or is there?).
Something apt-get-like would be
m Hanks <[EMAIL PROTECTED]>
wrote:
"Caleb Hattingh" <[EMAIL PROTECTED]> wrote in message
news:<[EMAIL PROTECTED]>...
>>> iconBallImage.paste(iconShieldImage,
Hi
I can't help you directly, but I am also finding im.putpixel to be
extremely slow - as the docs recommend, can you try using the
pixel-placing method of Draw? This is what I am going to try for my
application (resampling algorithms).
Thx
Caleb
On 30 Nov 2004 11:18:40 -0800, irond_will <[
Obviously, Peter and Jorge are hardcore, but below is what a beginner like
me hacked up:
My point, I guess, is that it is possible to quickly get a solution to a
specific problem like this without being a total expert. The code below
was typed out once, and with only one minor correction be
Hi all
I hadn't checked PythonForDelphi in a while, and decided to again today.
All I can say is *wow*. Those guys are doing a terrific job. For those
of you with a pascal background (and a Delphi/Kylix licence), you may want
to check it out. In particular, the creation of binary addons/m
Hi
You could just parse the model file. Off the top of my head
***
f = open('ModuleYouWantToExamine.py','r')
for i in f:
if i.find('def ') > -1:
print 'Found a function!: '+i.replace('def ','')
f.close()
***
You would have to build this up for a more complete examination. Of
course,
Hi It's me
a = 3
y = "a"
print eval(y)
To get 'a' to be 4 here, you would say
a = 4
I am not sure why you would want to do otherwise? Perhaps you could
sketch out a little more about what you are trying to do? That would help
a lot. Are you aiming for something like point
Andy
thx for that. I had a file called 'tktest.py' lying around, and I did:
'>>> a = compiler.parseFile('tktest.py')
And "a" looks something like this:
***
Stmt([Import([('Tkinter', None)]), Function(None, 'add_rows', ['w',
'titles', 'rows'], [], 0, None, Stmt([Discard(CallFunc(Getattr(Name('w')
Sure, ok, I think I am with you now.
You get a (e.g.) variable name as a string, and you KNOW how to evaluate
it with "eval", but you also want to be able to assign back to (through)
the string representation?
One way (if I understand you correctly) is with the globals or locals
dicts. Try
Hi
You are probably typing this within IDLE. Try it after starting python in
a shell like DOS or Bash. Should work then (works for me, and I also get
the AttributeError in IDLE.
Thanks
Caleb
On Tue, 07 Dec 2004 21:15:51 GMT, It's me <[EMAIL PROTECTED]> wrote:
Why do I get an "AttributeError:
that I am only
taking 5 characters, but where does the newline (\n) come from? Is that a
remnant from when I terminated the previous 'g' input?
Thanks
Caleb
On Tue, 07 Dec 2004 23:36:56 -0500, Caleb Hattingh <[EMAIL PROTECTED]>
wrote:
Hi
You are probably typing this within
he IDLE and with
popen it comes with an error.
I haven't been able to read the stdin either so the problem so far is
unsolved for my point.
But the newline command would explain my problems with the program.
Can it be a problem under windows since I'm using XP and the winpython
Hopefully Lar
Peter, I second that.
Nick
In what way is it unreliable? I can't seem to create a situation where
the update through globals and locals doesn't work. Are you referring
perhaps to the possibility of variables being garbage collected and then
not being around later when one tries to access t
Steve,
I don't think I understand. Here is what I just tried:
'>>> def f():
x = 3
d = locals()
print x
print d['x']
d['x'] = 5
print x
'>>> f()
3
3
3
'>>>
In your example, x had not yet been initialised, maybe. What I am seeing
is that "x
lso be nice if globals and locals behaved the same, differing
only in scope (which is what I expected originally anyway). But we can't
have everything, I guess :)
Caleb
On Wed, 08 Dec 2004 20:49:53 +0100, Peter Otten <[EMAIL PROTECTED]> wrote:
Caleb Hattingh wrote:
In what way is it
u
ave a clear idea of
how to play nice with locals().
thx
Caleb
Peter Otten wrote:
> Caleb Hattingh wrote:
>
> > I am convinced now that locals() doesn't work as (I) expected.
Steven
> > says there was some or other reason why locals() as used in this
context
> > is not
Hi Dan
I must confess that upon rereading my words, there is some irony there
(but not really sarcasm, is there?). However, I *really* tried to keep
my tone, well, professional. I realise I didn't do a good job and
apologise. I hope that's ok.
Keep well
Caleb
--
http://mail.python.org/mailma
Diez
Ya got me there!
"""
I have a sript that downloads a webpage. According to the picture on
this webpage I need to pass a parameter to this , running script a few
lines later.
"""
Err, ya, I guess I would be suspicious too.Sorry about that!
Keep well
Caleb
--
http://mail.python.org/mai
Here is something I would try but don't have the guts for:
If you could write an extension to idle (yes, idle, not Boa, not Eric,
etc) that pops up a small list of possible completions in a listbox when
you type a '.' (period) after any object name or module name (including
builtins), that wo
Jeff
I do the same thing in Delphi -> prepend "Self" before all the members in
class methods even though its not required. I do it partially for the
same reason as you - so I can grok which variables are local and which are
global (well, global within the class, anyway).
The other reason is
Hi Brad
Not that I'm an expert but note:
1. If you already know C, fair enough. You should know what you are
getting into then. I sure as heck don't know it very well at all and I'm
not gonna make that time investment now. MAYBE if I really really needed
the extra speed (but this seems to
In fact, as one of the Peter's (either Otten or Hansen) explained to me,
for line in open(file):
is actually both faster (being buffered) and generally better for very
large files because it doesn't read the whole file into memory, like
readlines does (if you have a memory limitation).
On Fri,
Hi Eric
Check that ".py" and ".pyw" are in your PATHEXT environment variable
(are you using Windows?). Then, if the folder that cabel is in is in
your PATH environment variable, and the correct association for .py
files is set up (i.e. they get run by python.exe),
either
os.system('cabel')
or
o
I spent way too much time reading the recent massive ">500-messages"
thread, and then spent even more time (perhaps better spent) reading
wider on some aspects of the debate.
This recently-found link sets out (from one possibly-biased POV, I
guess) how the rift between GNU Emacs and XEmacs occurre
Hi Brian
You could make great use of XML-RPC here. XML-RPC is /really/ easy to
use.
Here is a simple example:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/81549
You put procedures on the server that will check the args against a the
required result, and report back to the student w
Hi Kevin
The other posters helped you with configParser, which is what you
wanted, i.e. text file access.
However, you can also get persistance really cheaply with pickling, if
you don't need the saved data to be text-editable:
(from memory)
verboseSettings = {}
verboseSettings['Detailed'] = '-
Hi Erich
If you're going to be doing a lot of string substitution, you should
look at the Templating support in the library:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/304005
and (a little bit fancier):
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/335308
Regards
Caleb
The Night Blogger wrote:
> Is there a way to push data to Microsoft Excel & Word from a Python
> Application
On Windows, it's easy after you install the win32 extensions. For
example, for
python:
import win32com.client
xl = win32com.client.Dispatch('Excel.Application')
after which you can oper
jansenh wrote:
> hi comp.lang.python.
>
> I need some newbe advice on idiomatic use of Python dictionaries.
>
> I have service with a dictionary which holds a bunch of objects as
> values, and an ID as key to each object. Then I want to change an
> objects state based on its key. The way I am doin
Hi Paul
> Thanks for the kind words!
No, thank _you_ for taking the time to write such a useful document.
regards
Caleb
--
http://mail.python.org/mailman/listinfo/python-list
> I want to build rsync server that can run in linux and windows, and
> configure by python. So I'm looking for something like rsync for python.
> I find rsync.py and pysync. But rsync.py looks like a client mode,
> it can't be a rsync server, is it? Can pysync be a rsync server?
Hi nienfe
On Apr 21, 11:02 pm, [EMAIL PROTECTED] wrote:
> Hi,
> I am using Python Thread library for my parallel processing course
> project. I am doing matrix convolution on a multi-processor machine
> running Solaris. I just found out that no speed-up is obtained with
> threading. It is probably because of
Pat wrote:
> I have to do a big programm. Could someone give me some suggests about
> IDE (on Linux) and books to learn.
http://groups.google.com/groups/search?q=python+ide&qt_s=Search
Lots and lots to read :)
Caleb
--
http://mail.python.org/mailman/listinfo/python-list
Hi everyone
I suspect this has come up before, but google and group searches for
"python package index query" or "pypi query" and the like haven't
turned anything up.
I want to monitor the versions of the list of packages I like having
around, and I expect that the python package index might be a
Hi Martin
Pretty much exactly what I wanted :)
How up-to-date does Debian keep its package list for python addons, or
are you running Unstable? My big problem, being in South Africa, is
that I have to get any distros on cover CDs or order from
distro-resellers, and they never have Testing or Un
I have had this same problem before, and what I ended up doing was
writing my own far more limited config parser that would create lists
for repeated named assignments.
Who is the maintainer of ConfigParser? Perhaps a keyword option can
be added so that this kind of behaviour can be added at cre
On Wed, 15 Apr 2009 15:47:05 +0200, wrote:
But, lambda functions can't be pickled. I would like to pickle my
objects, and i would really like to use parallel python (which
requires pickling).
If you are fixated on using lambda, you could probably use Recipe 7.6:
Pickling Code Objects in the
Hi
I don't think this is what you want (a string representation of the
argument passed to a function as that argument is at runtime is way
beyond my abilities), but this can retrieve the literal text in the
function call as it appears in the .py file, assuming you have the .py
file available a
Hi
Being a Delphi user at work, I know what you mean :)
The best python IDE I have found is Stani's Python Editor (SPE), and I
think Stani himself replied to your message as well.
It integrates wxGlade, which is nice for form-building, although I don't
really do much of that with the python co
Hi all
I want to write python extensions with FPC (Free Pascal Compiler,
http://www.freepascal.org). In Delphi, this is trivially easy due to
the great work of the P4D (Python-for-Delphi, http://mmm-experts.com/)
guys; however, when aiming for cross-platform binary extensions, that
strategy nat
Hi Derek
I went for an embarrassingly long time without knowing about
"enumerate()". It doesn't directly answer your question about counting
*within* nests, but I am going to tell you this on the off chance you
don't know yet (and apologies if you do):
This:
count = 0
for animal in zoo:
a =
Well, there it is:
* Added support for Free Pascal Compiler (http://www.freepascal.org/)
and Lazarus Project (http://www.lazarus.freepascal.org/)
Thanks to Michiel du Toit ([EMAIL PROTECTED])
That was easy. I just saw the new support for D2k6 recently.
thx Ravi
Caleb
--
http://mail.python.or
I tried this:
from timeit import *
#Try readlines
print Timer('import
gzip;lines=gzip.GzipFile("gztest.txt.gz").readlines();[i+"1" for i in
lines]').timeit(200) # This is one line
# Try file object - uses buffering?
print Timer('import gzip;[i+"1" for i in
gzip.GzipFile("gztest.txt.gz")]').time
Hi
The documentation for the python profiler in the python library
reference is extremely readable (well done James Roskin!?).
Profile your code, and when you find where the speed problem occurs,
try pitching just that section of code in comp.lang.python. You will
likely get much feedback. Ever
Hi Peter
Clearly I misunderstood what Martin was saying :)I was comparing
operations on lines via the file generator against first loading the
file's lines into memory, and then performing the concatenation.
What does ".readlines()" do differently that makes it so much slower
than ".read().sp
Hi everyone
[Short version: I put a some code below: what changes can make it run
faster?]
Unless you have a nice tool handy, calculating many folder sizes for
clearing disk space can be a click-fest nightmare. Looking around, I
found Baobab (gui tool); the "du" linux/unix command-line tool; th
Hi Dan
Pythonwin just adds support for specifically MS Windows features, most
prominently COM; writing Excel scripts in python is so cool. The
standard python distribution for windows runs perfectly on windows.
I'm not sure whether this was clear to you or not. Also, Thomas
ctypes and comtypes
Hi Christoph
On my linux py-2.4.1:
>>> 4.0//2 # Integer division, but still returns a float.
2.0
>>> 4.0//2 == 2
True
>>>
4.0//2 doesn't return an integer, but the equality against an integer
still holds. I agree that integer division should return an integer,
because using the operator at all
Thanks John
I will use your code :) 30% improvement is not insignificant, and
that's what I was looking for.
I find the log function a little harder to read, but I guess that is a
limitation of me, not your code.
Caleb
--
http://mail.python.org/mailman/listinfo/python-list
Hi Fredrik
Fair enough; I wasn't precise. Upon further reflection, I actually
meant floor division, via the // operator. In the following snippet:
>>> 4/2
2
>>> 4//2
2
>>> 4.0/2.0
2.0
>>> 4.0//2
2.0
>>> 4.0//2.0
2.0
We know the last two operations can only return what are effectively
integer n
Christoph
I understand the explanation regarding the underlying math.floor()
call. Were I using this functionality in my code,
int(a//b)* some_list
would not be something I consider a big deal. However, I see what
you're saying: The multiplcation by list can only work with an int, and
you hav
Hi Dennis
Sure, I get it. I do most of my work in Delphi, which is, shall we
say, not lax about floating-point types. Thinking about this more, I
realise my initial interest was in looking at the // operator as
something new, whereas I now see it probably just wraps math.floor();
obviously then
Hi
Use the "timeit" module, like so:
>>> from timeit import Timer
>>> t = Timer('[i for i in range(1)]') # The string is code to execute
>>> (for timing)
>>> print t.timeit(100) # execute it 100 times and print the result
0.222389936447
I would appreciate it if you could present your resul
Hi Ernesto
SPE, or Stani's python editor is actually a decent IDE that can lauch
the winpdb debugger to step through code, with side windows for locals,
and watches and so on. It's not exactly integrated debugging a la
Delphi, but in general my need for debugging is much less with python;
the fe
1 - 100 of 110 matches
Mail list logo