Erik Bernoth wrote:
Hi List,
look at the following code:
def evens():
# iterator returning even numbers
i = 0
while True:
yield i
i += 2
# now get all the even numbers up to 15
L = [n for n in evens() if n < 15]
Isn't it strange, that this code runs (in a lazy lang
I've coded my own 'relpath' implementation for 2.5 (shown below) and I
want to make sure it follows as closely as it should to 2.6 and later.
I've got a question regarding that. When attempting to convert to a
relative path and it is not possible for some reason (different drive or
UNC share)
Gabriel Genellina wrote:
En Tue, 02 Jun 2009 19:02:47 -0300, Brian Allen Vanderburg II
escribió:
What is the best way to copy an object that has multiple inheritance
with the copy module. Particularly, some of the instances in the
hierarchy
("...some of the classes in...",
What is the best way to copy an object that has multiple inheritance
with the copy module. Particularly, some of the instances in the
hierarchy use the __copy__ method to create a copy (because even for
shallow copies they need some information updated a little
differently), so how can I mak
todp...@hotmail.com wrote:
>
> I've been trying to figure this out for over 2 hours and I'm really
frustrated right now.
>
> I first made Python to ask user to input height in meters. If user
puts certain value in meter, then it converts it to feet and inches as
follows:
>
>
> Enter the hei
mrk...@gmail.com wrote:
Baolong zhen wrote:
less list creation.
At the cost of doing this at each 'flatten' call:
if res is None:
res = []
The number of situations of executing above code is the same as the
number of list creations (once for each 'flatten' call, obviously).
Is list cre
mrk...@gmail.com wrote:
Hello everybody,
Any better solution than this?
def flatten(x):
res = []
for el in x:
if isinstance(el,list):
res.extend(flatten(el))
else:
res.append(el)
return res
a = [1, 2, 3, [4, 5, 6], [[7, 8], [9, 10]]]
print fl
bruno.42.desthuilli...@websiteburo.invalid wrote:
So the lookup chain is:
1/ lookup the class and bases for a binding descriptor
2/ then lookup the instance's __dict__
3/ then lookup the class and bases for a non-binding descriptor or
plain attribute
4/ then class __getattr__
Also and FWIW,
an0...@gmail.com wrote:
Below are two semantically same snippets for querying the same partial
HTTP response, for Python2.5 and Python 3.0 respectively.
However, the 3.0 version returns a not-so-right result(msg) which is a
bytes of length 239775, while the 2.5 version returns a good msg which
is
linuxguy...@gmail.com wrote:
Does anyone know where I would find libsudo ?
http://sourceforge.net/projects/libsudo
If you had the choice of using pexpect or libsudo, which would you use ?
libsudo does all the work for you of executing sudo, checking for the
expected responses and all. I
schi...@gmail.com wrote:
On Jan 29, 7:38 pm, Mel wrote:
schickb wrote:
I'd like to add bound functions to instances, and found the
instancemethod function in the new module. A few questions:
1. Why is instancemethod even needed? Its counter-intuitive (to me at
least) that assig
I'm trying to better understand descriptors and I've got a few questions
still after reading some sites. Here is what I 'think', but please let
me know if any of this is wrong as I'm sure it probably is.
First when accessing an attribute on a class or instance it must be
found. For an insta
astan.c...@al.com.au wrote:
Tim Roberts wrote:
Sorry, but you have NOT created a USB device, and I sincerely hope
you do
not try to plug it in to a real USB port.
Sorry, by USB device, I meant a device that is powered/activated by a
bunch of wires that I want to control using a computer and
vinc...@vincentdavis.net wrote:
I have a short peace of code that is not doing what I expect. when I
assign a value to a list in a list alist[2][4]=z this seems replace
all the 4 elements in all the sub lists. I assume it is supposed to
but this is not what I expect. How would I assign a value
gra...@visi.com wrote:
On 2009-01-24, Linuxguy123 wrote:
I want to make a python program that I can run as a normal
user that changes the permission on some device files. It
will need to ask me for the root password and then run chown
as root in order to do this.
How do I accomplish thi
unine...@gmail.com wrote:
class Person:
def __init__(self):
for prop in props:
setattr(self, "__" + prop[0], prop[1])
setattr(Person, "Get" + prop[0], lambda self: getattr
(self, "__" + prop[0]))
I've had a similar problem here and here is best how I can ex
astan.c...@al.com.au wrote:
Hi,
Thanks for all the responses but I forgot to mention that I have very
little hardware understanding (at least in english) and the device
itself it very simple and only needs about 5V power to be active. The
problem here is that I want to control when the device
There was a small error in setprivate/getprivate:
import sys
import inspect
def get_private_codes(class_):
codes = []
for i in class_.__dict__:
value = class_.__dict__[i]
if inspect.isfunction(value):
codes.append(value.func_code)
return codes
def get_protect
Okay so I don't really care about public/private but I was watching the
lists (Does python follow its idea of readability or something like
that) and I thought of a 'possible' way to add this support to the language.
I have implemented a class which allows creating both a private as well
as a
bock...@virgilio.it wrote:
Constants would be a nice addition in python, sure enough.
But I'm not sure that this can be done without a run-time check every time
the constant is used, and python is already slow enough. Maybe a check
that is disabled when running with optimizing flags ?
But I'm su
astan.c...@al.com.au wrote:
Hi,
Im trying to write a program for my USB device and I'm thinking of
using python to do this. The USB device is of my own making and it is
activated when one of the two data pins of the USB is given about 5V
(or similar to whatever the power pin is getting). Now I
rt8...@gmail.com wrote:
Here is a piece of C code this same guy showed me saying Pythonic
indention would make this hard to read -- Well lets see then!
I swear, before god, this is the exact code he showed me. If you don't
believe me i will post a link to the thread.
// Warning ugly C code ahe
I'm doing some multi-threaded programming and before diving into the
C/C++ code I though I'd do some in Python first. I decided to read
through the threading module and I understand some of it, but I don't
understand this, though I'm sure it is easy:
The condition object has a method _is_owne
martin.lal...@gmail.com wrote:
very interesting
http://www.aegisub.net/2008/12/if-programming-languages-were-religions.html
"Python would be Humanism: It's simple, unrestrictive, and all you
need to follow it is common sense. Many of the followers claim to feel
relieved from all the burden impos
nicholas.c...@gmail.com wrote:
Imagine a module that looks like
ModuleDir
__init__.py
a.py
b.py
In python 2.x I used to have tests at the end of each of my modules,
so that module b.py might look something like
import a
..
..
if __name__ == '__main__':
run
yinon...@gmail.com wrote:
On Dec 14, 8:07 pm, Brian Allen Vanderburg II
wrote:
Hi,
The interface of extract_tb is:
traceback.extract_tb(tb, limit=None)
try to play with the 'limit' argument
Good luck,
Yinon
--
http://mail.python.org/mailman/listinfo/python-list
I hav
I've looked at traceback module but I can't find how to limit traceback
from the most recent call if it is possible. I see that extract_tb has
a limit parameter, but it limits from the start and not the end.
Currently I've made my own traceback code to do this but wonder if
python already has
man...@gmail.com wrote:
On Dec 13, 11:13 pm, Bryan Olson wrote:
Software firewalls will often simply refuse incoming connections. The
basic protection of the garden-variety home router comes from "network
address translation" (NAT), in which case TCP connections initiated from
the inside wil
[EMAIL PROTECTED] wrote:
Unless you are calling reload() on the module, it will only ever get
_loaded_ once. Each additional import will just yield the existing
module. Perhaps if you post an example of the behavior that leads you
to believe that the class variables are getting reinitialized I c
[EMAIL PROTECTED] wrote:
Why not use pkgutil.get_data()?
Provided you remember to put your zip file on PYTHONPATH you can already
run modules directly out of a zipfile (Python 2.5 and later).If your
zipfile contains __main__.py then with Python 2.6 or later you can run it
directly: just spec
Python Community
The following is just an idea that I considered that may be helpful in
creating an application in a single archive easier and with less code.
Such an application would be similar to jar files for Java.
First, the application and all data files should be able to run either
e
31 matches
Mail list logo