am concerned about efficiency - so I would appreciate suggestions.
Again, the number of sublists may vary, and sizes of sublists are not
always the same (there will always be at least one sublist).
thanks!
Esmail
Here is my working code so far.
#!/usr/bin/env python
from
= f.readlines()
number = len(data)
pick = randrange(0, number)
print data[pick]
should do the trick.
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
Ok, well I'm glad no one threw up their hands in horror
to the code I posted.
I'll have to study the alternate solutions offered (thanks!)
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
.
Definition: im.show(self, title=None, command=None)
Any suggestions/help/workarounds? If you can get this to work
with Vista or Windows 7 I'd love to hear from you.
Thanks!
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
im = Image.open('c://mypic.jpg')
sorry, slip of the finger, there's only one forward slash
or you can use two backward slashes.
The problem isn't with opening it (I know it opens fine
since I can get its size attribute via im.size) - the show()
is the problem.
Esmail
--
http
when I
call show.
Definition: im.show(self, title=None, command=None)
I installed irfanview and specified it/its path in the parameter,
but that didn't work either. It's really quite puzzling in the
case of Vista since that's been around for quite a few years now.
Esmail
--
http
On Nov 30, 4:37 pm, David Bolen db3l@gmail.com wrote:
Esmail ebo...@gmail.com writes:
I dug around in the docs and found a named parameter that I can set
when I
call show.
Definition: im.show(self, title=None, command=None)
I installed irfanview and specified it/its path
Ok, this is somewhat unexpected:
Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
[GCC 4.3.3] on linux2
Type help, copyright, credits or license for more information.
-3**2
-9
x = -3
x**2
9
I would have expected the same result in both cases.
Initially I would have expected -3**2
Brian J Mingus wrote:
I think you answered your own question. 3**2 comes first in the order of
operations, followed by the negation.
No, that's not the problem, I'm ok with the operator precedence of - vs **
My problem is why I don't get the same result if I use the literal -3 or
a
or the
distinction you make. Your distinction explains the behavior, but I
find it somewhat counter-intuitive. (I use the Python interpreter frequently
for small calculations - otherwise I'd never have realized this)
Thanks,
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
Thanks all!! I get it now :-)
It helped to have a number of different explanations, thanks
for taking the time to post. Much appreciated.
Cheers,
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
Could someone help confirm/clarify the semantics of the [:] operator
in Python?
a = range(51,55)
# 1 ##
b = a[:] # b receives a copy of a, but they are independent
# The following two are equivalent
# 2 ##
c = []
c = a[:] # c receives a
Diez B. Roggisch wrote:
Esmail schrieb:
Could someone help confirm/clarify the semantics of the [:] operator
in Python?
a = range(51,55)
# 1 ##
b = a[:] # b receives a copy of a, but they are independent
# The following two are equivalent
# 2
Thank you all for your posts - this was very enlightening
and I printed this thread off for future reference.
--
http://mail.python.org/mailman/listinfo/python-list
Diez B. Roggisch wrote:
Esmail schrieb:
None of your operations changes a. But I talked about the lists you
bound b and c to before. Those aren't changed as well - they simply are
not pointed to anymore. In your example, that means the will be
garbage-collected, in other scenarios
switch()
statement can be expressed with dictionaries or attributes instead.
Here is a dorks approach to calling a specific function with arguments
based on a command:
...
Here is more of a look up table approach:
...
Neat -- thanks for sharing this TerryP
Esmail
--
http://mail.python.org
:
value = 42
elif ...
You can even provide a default value by using table.get().
cool .. I hadn't seen that. Not working quite at the 'pythonic' level yet
I am not sure I think it's more readable that the if statement. Also, curious
if the dictionary approach is more efficient.
thanks,
Esmail
and let me know what could have been done better. Once again
this is really my first time using python.
You may want to check out pylint ( pychecker)
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
about my minute use unless it gets within
95% of my allowable plan, so a little program that could check
this and send me an e-mail or text alert would be great.
Any ideas how to go about writing a program like this (assuming
there isn't one already available)?
Thanks,
Esmail
--
http
.
Cheers,
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
Paul Rubin wrote:
Esmail ebo...@hotmail.com writes:
What is your favorite tool to help you debug your
code? I've been getting along with 'print' statements
but that is getting old and somewhat cumbersome.
Beyond print statements, I use pdb a lot. Winpdb (www.winpdb.org) is
even better
Michele Simionato wrote:
On Aug 22, 4:25 pm, Esmail ebo...@hotmail.com wrote:
Hi all,
What is your favorite tool to help you debug your
code?
The times when I would just use 'print' are long past. Nowadays I
spend lots of my time
with code written by others than myself. I use pdb all
Robert Marshall wrote:
On 24 Aug 2009, Paul Rubin wrote:
Esmail ebo...@hotmail.com writes:
What is your favorite tool to help you debug your
code? I've been getting along with 'print' statements
but that is getting old and somewhat cumbersome.
Beyond print statements, I use pdb a lot
walterbyrd wrote:
If I took the time to really learn to use python for sysadmin work,
would I be able to find jobs, or even contract jobs?
FWIW, I think one of the qualities of a good system admin would be the ability
to work with a variety of tools and languages and not focus on one
useful, but
to me still doesn't quite do what a full-fledged debugger can - but perhaps
that is a reflection of my skill with the shell at this point.
Always more to learn.
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
Ben Finney wrote:
Esmail ebo...@hotmail.com writes:
Hi Ben,
Ben Finney wrote:
Whenever a simple output statement is too cumbersome for debugging, I
take it as a sign that the program is too cumbersome to follow.
I'll have to think about this .. though my gut says this is true :-)
Note
this shell).
For now I ended up giving winpdb a whirl and it did help me find
the bug that had been elusive to my print statement approach :-)
Thanks again .. and if there are additional postings, I'll be
reading them too with great interest.
Esmail
--
http://mail.python.org/mailman/listinfo/python
primary development environment, FWIW.
Someone mentioned winpdb .. anyone have experience/comments
on this? Others?
Thanks,
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
Hello Senad,
You might find this style guide useful too in your toolbox of
Python skills tricks.
http://www.python.org/dev/peps/pep-0008/
This is a great and helpful group of people here, we are lucky to
have access to groups like this.
Best,
Esmail
--
http://mail.python.org/mailman
Hello Senad,
You might find this style guide useful too in your toolbox of
Python skills tricks.
http://www.python.org/dev/peps/pep-0008/
This is a great and helpful group of people here, we are lucky to
have access to groups like this.
Best,
Esmail
--
http://mail.python.org/mailman
/methods more easily once I
come back to the project after some lengthy interruptions.
Best,
Esmail
Jean-Michel Pichavant wrote:
I've never used Happydoc. I am using Epydoc, which is very efficient.
Sphinx is very good as well, but its scope is much larger than
documenting python code
somename')
data = dir_size.readlines()
dir_size = int(data[0].split()[0])
print 'dir size: ', dir_size
tar_size = os.popen('ls -s somename.tar.gz')
data = tar_size.readlines()
tar_size = int(data[0].split()[0])
print 'tar size: ', tar_size
Thanks
Esmail
--
http
re...@yahoo.co.uk wrote:
On Aug 13, 8:28 pm, Esmail ebo...@hotmail.com wrote:
Hi all,
Essentially all I want to know the size of a directory, and the size
of a zipped tarball so that I can compute/report the compression ratio.
dir_size = os.popen('du -sk somename')
data
you're doing with du, but is cross-platform and
not dependent on shelling a process and scraping its stdout.
Thanks Albert, I'll take a look,
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
the way to go, or should I use something else?
Thanks,
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
the full list of projects using Sphinx at
http://sphinx.pocoo.org/examples.html
- Shailesh
Hi,
Thanks for the links. Have you heard of something called HappyDoc? I just
came across it by looking for info on epydoc.
Thanks,
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
with something called HappyDoc? Just came across it.
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
there)?
Thanks,
Esmail
-
My current code:
-
def tar_it_up(target_dir_name, tar_file_name=None):
'''
tar up target_dir_name directory and create a
tar/zip file with base name tar_file_name
appends a date/timestamp to tar_file_name
'''
time_string
can't find tarfile.gzopen in the tarfile docs, I'm looking here:
http://docs.python.org/library/tarfile.html
Am I looking at the wrong page?
Thanks,
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
at the help in the
interactive interpreter. It doesn't seem to be in the official docs,
but you can use pydoc to view the docstrings.
Thanks for the additional information,
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
was mostly just
curious if there was a way to specify the compression level, so far
I'm ok with the generated file sizes, but it's good to know that there
are other options to specify my own compression level.
Thanks again,
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
has to be taken to make sure the string representation corresponds to
the actual function computed. It would be nice if there was an
automatic way to convert the function to its string representation.
Comments or problems with the approach I have taken?
Thanks,
Esmail
--
#!/usr/bin/env python
best to store this
data along with the function I am going to optimize in order to verify
the results for a given range (for instance).
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
figure out __call__ ..?
Thank you for taking the time to help, always good to learn new things.
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
Thanks everyone, I learned more than I expected about
floats :-) and got some good explanations and ideas about
all of this.
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
on the web and found that
--reports=n
on the command line will truncate the various tables output at the end.
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
between the two max values might be minimal.
Thanks,
Esmail
ps: I'm confused by the docs for uniform():
random.uniform(a, b)
Return a random floating point number N such that a = N = b for a = b
this seems to imply an inclusive range, ie. [a,b]
but this seems to contradict it:
In [3
Gabriel Genellina wrote:
En Tue, 09 Jun 2009 18:33:39 -0300, Esmail ebo...@hotmail.com escribió:
random.random() will generate a random value in the range [0, 1).
Is there an easy way to generate random values in the range [0, 1]?
I.e., including 1?
I think you shouldn't worry about
Robert Kern wrote:
On 2009-06-09 18:05, Mensanator wrote:
On Jun 9, 4:33 pm, Esmailebo...@hotmail.com wrote:
That's wrong. Where did you get it?
http://docs.python.org/library/random
What he said :-)
(thanks Robert)
--
http://mail.python.org/mailman/listinfo/python-list
close.
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
Here is part of the specification of an algorithm I'm implementing that
shows the reason for my original query:
vid = w * vid + c1 * rand( ) * ( pid – xid ) + c2 * Rand( ) * (pgd –xid ) (1a)
xid = xid + vid (1b)
where c1 and c2 are two positive constants,
rand() and Rand() are two random
people agreeing or telling me I'm
way off :) .. in which case perhaps my recollection/reading of PEP 8
is not accurate.
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
else here seems to have had
the same observation.
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
Ben Finney wrote:
Esmail ebo...@hotmail.com writes:
I am confused by pylint's naming conventions, I don't think the are in
tune with Python's style recommendations (PEP 8?)
Anyone else think this?
It's hard to know, without examples. Can you give some output of pylint
that you think doesn't
this? Is there an easy way to get this in
compliance? Or lacking this just turn this off (I'd rather not
turn it off if it's easy to get in tune with the standards).
Or am I wrong about my assertion with regard to the naming
conventions?
Thanks,
Esmail
ps: if anyone else wants to toss in some other
Nick Craig-Wood wrote:
Here is a demo with pygame...
Thanks Nick, I'll be studying this too :-)
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
the graph as values changed ..
I've only heard about Mayavi, so I'll check it out.
Thanks Gökhan,
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
particle simulation or realistic
cloud simulation.
I've just started to read more about Particle Swarm Optimization and
since I plan to implement this in Python, I thought it would be nice
to visualize the process too, without spending too much on the nitty
gritty details of graphics.
Esmail, you
Mensanator wrote:
On Jun 3, 10:53 am, Esmail ebo...@hotmail.com wrote:
Hi all,
I am trying to visualize a number of small objects moving over
a 2D surface during run-time. I was wondering what would the easiest
way to accomplish this using Python?
Try Turtle Graphics using goto's. With pen
it would be fine since I've already
used it a bit before - so there would be less of a learning curve.
Regards,
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
and feature rich.
Esmail
---
here is a sample. again, direct questions to the matplotlib list for
possible better ideas.
from pylab import *
# initial positions
x0=rand(5)
y0=rand(5)
ion() # interactive on
for t in linspace(0,10,100):
x=x0+0.1*cos(t)
y=y0+0.1*sin(t
Scott David Daniels wrote:
Esmail wrote:
... Tk seems a bit more complex .. but I really don't know much about
it and its interface with Python to make any sort of judgments as
to which option would be better.
This should look pretty easy:
Thanks Scott for taking the time to share this code
may find it useful.
thanks! I played around just a bit with RPy yesterday, but I had no
idea there was Rpy2 .. I'll be sure to take a look.
Best,
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
am sure) composition... The R people have a publication
somewhat like the python papers where you might find something
intresting.
Thanks .. I tried out a few simple things with RPy yesterday (calling
a few functions and some simple plots) and it seemed to work ok.
Esmail
--
http
anyway), but other than that I'm
pretty happy with it :-)
HTH,
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
to know the outcome.
For sure, if I end up trying it I will post a message about my
results.
The parasol options to launch Microsoft Office apps Excel, Power Point, and
Word; or the ray tracing app POV-Ray, will very likely fail.
:-)
thanks again for the information about Parasol,
Esmail
this would also
work under Linux?
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
algorithm I'm working with, both for functions using f(x) and f(x,y) over a
variety of intervals so I would like to have a way to verify results for
more challenging functions.
Thanks a lot,
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
.
PYTHONCASEOK : ignore case in 'import' statements (Windows).
PYTHONIOENCODING: Encoding[:errors] used for stdin/stdout/stderr.
HTH,
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
John Machin wrote:
1. Will is also allow me to maximize a function (I only saw minimum)?
To maximise f(x,y), minimise -f(x,y)
Ooops .. yes of course!
Thanks,
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
of simple Python module that would allow me to
evaluate this type of function?
In this particular instance I am interested in the minimum of
x * sin(4*x) + 1.1 * sin(2*y), where x,y in range 0-10
though in other problems the range may not be identical for x and y.
Thanks,
Esmail
ps: Does anyone
Hello!
Anyone using Python scripts and accessing some of R's functionality?
If so, what are you using? I have read about RPy, is that a good
solution? Are there others that can be recommended or are preferred?
I would prefer to code in Python instead of R :-)
Thanks,
Esmail
--
http
Minh Doan wrote:
Hi,
I'm a newbie to python. I am having stuck with the following problem. I
want to download the info(price) from fromcity to tocity at a certain
time from kayak.com http://kayak.com/ website. If we do it manually,
we can go to the website, choose the appropriate info we
keeps getting mentioned, I'll have to check it out.
Perhaps some of you can share what about it you like in
particular.
Thanks,
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
have to sign
up for a trial membership for this? I'd prefer to do this w/o .. so I
guess I'll poke around a bit more. Thanks for the lead,
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
like a place with a lot of useful information!
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
the necessary
information from this place without the need to edit the program
and its flags.
Some sample code for using ConfigParser would be helpful - haven't
been able to find any on-line so far beyond the standard documentation.
Thanks,
Esmail
--
http://mail.python.org/mailman/listinfo/python
simple here...
Thanks,
Esmail
---
#!/usr/bin/env python
#
# quick test to deal with 'private' attributes and
# python properties ...
#
import sys
class Rectangle(object):
def __init__(self):
self.__width = 0
self.__height = 0
def setSize(self, width, height):
print
hi Scott,
Scott David Daniels wrote:
Esmail wrote:
I am just reading about properties in Python. I am thinking
of this as an indirection mechanism, is that wrong? If so, how
come the getter/setters aren't called when I use properties
instead of the functions directly?
Because you weren't
'-'
r.size = 3, 7
print r.size
Yup, I know Python is a dynamically typed language, but I wish it would
point this sort of silliness out .. but there are tradeoffs. I should
probably run pyflakes/pychecker/pylint on my my tiny test/try out codes
too.
Best,
Esmail
--
http://mail.python.org/mailman
Scott David Daniels wrote:
... good stuff ...
the Python 3.X world is wisely losing the unpacking in parameter
passing trick.
Thanks Scott, useful information,
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
Gabriel Genellina wrote:
Isn't so easy. You have representation errors and rounding errors here,
and they accumulate. The last number printed should be 10.4 but I get 10.5:
...
10.3
10.4
10.5
(or more precisely, 10.459)
Also, after exiting a for loop, the *last* value used is
).
Thanks,
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
Thanks all, I appreciate the various suggestions and
caveats. Just wanted to make sure I'm not re-inventing
the wheel as Python seems to have already so much.
Cheers,
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
bearophileh...@lycos.com wrote:
Esmail:
Is there a Python construct to allow me to do something like
this:
for i in range(-10.5, 10.5, 0.1):
Sometimes I use an improved version of this:
http://code.activestate.com/recipes/66472/
neat .. lots of code to study there. Thanks,
Esmail
:
... print amount
...
Another nice solution stored away for use!
Thanks,
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
with print is
going away eventually and we should start using something
else? Is that true and if so, what?
Thanks,
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
Matt Nordhoff wrote:
Esmail wrote:
Hello all,
I use the print method with % for formatting my output to
the console since I am quite familiar with printf from my
C days, and I like it quite well.
I am wondering if there is a way to use print to write
formatted output to files?
Also, it seems
I have been meaning to find out more about this too, so
this is a good chance to learn something new).
Thanks again!
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
Duncan Booth wrote:
Esmail ebo...@hotmail.com wrote:
(for some reason I can't get the from __future__ import
to work,
You can only use the print function on 2.6 and later. If you have an older
version of Python then you'll get that error.
Ooops, yes, you wrote that and I tried with 2.6
hope that the information will help you decide what to use.
absolutely, very useful information, thanks!
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
: 123 bar: 123.5 4.567890e+02'
I'll have to check it out - thanks again,
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
Zooko O'Whielacronx wrote:
I like pyflakes. I haven't tried the others. I made a setuptools
plugin named setuptools_pyflakes. If you install that package, then
python ./setup.py flakes runs pyflakes on your package.
Regards,
Thanks Zooko
I decided to give all of them a try :-)
Esmail
) use?
Thanks,
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
Thanks Tim,
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
,
chapters, computer programs, manuals, etc... These need the searchers
(equivalent to the Unix diff) for checking equivalence.)
HTH
Steve
Thanks Steve for bringing up various items to consider for these sort
of tasks, very helpful indeed.
Best,
Esmail
--
http://mail.python.org/mailman
I seem to recall something about starting up the python
(and ipython) interpreter with the -i flag, but I am not
certain.
There is a ipython mailing list/user group too, you may
want to post your query there too.
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
John Yeung wrote:
so does your initial solution,
which I like best:
sorted(a)==sorted(b)
This is concise, clear, and in my opinion, the most Pythonic. It may
well even be the fastest.
Great .. I can live with that :-)
--
http://mail.python.org/mailman/listinfo/python-list
MRAB wrote:
You could use Raymond Hettinger's Counter class:
http://code.activestate.com/recipes/576611/
on both lists and compare them for equality.
thanks for the pointer, I'll study the code provided.
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
Thanks all, after reading all the posting and suggestions for
alternatives, I think I'll be going with
sorted(a)==sorted(b)
it seems fast, intuitive and clean and can deal with
duplicates too.
Best,
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
1 - 100 of 185 matches
Mail list logo