z*g
print foo(2,5,4,69)
The problem is that i get the following error message on line 7:
TypeError: arg 5 (closure) must be tuple
f.func_closure is indeed empty while
f.func_code.co_consts[1].co_freevars is logically equal to ('x','y').
Thanks for responding
Alain
--
http://mail.python.org/mailman/listinfo/python-list
value a_value would become a 2-tuple
(a_value,rank_of_a_value)
I seek an elegant solution.
Alain
--
http://mail.python.org/mailman/listinfo/python-list
Hi,
Could someone tell me how to uninstall SPE under windows?
Alain
--
http://mail.python.org/mailman/listinfo/python-list
Thanks to all in advance
Alain
--
http://mail.python.org/mailman/listinfo/python-list
On Apr 4, 1:30 pm, alf <[EMAIL PROTECTED]> wrote:
> twistedmatrix.org?
I already took a look at it but the agent functionality is somewhat
primitive. I need something production-ready.
Alain
--
http://mail.python.org/mailman/listinfo/python-list
On Apr 5, 6:50 pm, [EMAIL PROTECTED] (Cameron Laird) wrote:
> In article <[EMAIL PROTECTED]>,
>
> alain <[EMAIL PROTECTED]> wrote:
> >On Apr 4, 1:30 pm, alf <[EMAIL PROTECTED]> wrote:
>
> >> twistedmatrix.org?
>
> >I already took a look at it b
Shawn Minisall a écrit :
> I'm trying to unpack a list of 5 floats from a list read from a file and
> python is telling me 5 variables are too many for the string.split
> statement. Anyone have any other idea's? NOTE: the only reason I
> convert it to a float instead of just leaving it as a st
ey with your blog.more information there
>
> > support!
> > !
>
> good
Wow ! I have a question though.
If you really make $38600 a month, how come you even bother to spam
us?
Alain
--
http://mail.python.org/mailman/listinfo/python-list
I tried the following:
myobj=object()
myobj.newattr=5
results in:
Traceback (most recent call last):
File "", line 1, in ?
AttributeError: 'object' object has no attribute 'newattr'
Any idea?
Alain
--
http://mail.python.org/mailman/listinfo/python-list
On Feb 2, 1:57 pm, Bart Van Loon <[EMAIL PROTECTED]> wrote:
> It was 2 Feb 2007 04:41:48 -0800, when alain wrote:
>
> > I tried the following:
>
> > myobj=object()
> > myobj.newattr=5
>
> > results in:
>
> > Traceback (most recent call last):
>
st likely containing prepackaged binaries.
> What have I missed?
>
> Kay
I think i understand his complaint.
Have you ever tried to install a package making use of easy_install?
If you have, then you understand this is a real pain in the ass,
especially if your internet access requires prox
the issue?
>
> Thanks
No,
and the more i look at your post, the more i can't see why.
Sorry for not being able to help.
Alain
--
http://mail.python.org/mailman/listinfo/python-list
done enough to choose.
Paraphrasing Steve Jobs but in this context:
PYTHON = a bycycle for the mind
Best regards
Alain
--
http://mail.python.org/mailman/listinfo/python-list
uot;.
This is what i feel when programming in Python: a productivity boost
compared to pedestrians and an immense pleasure.
Alain
--
http://mail.python.org/mailman/listinfo/python-list
oopLable is not referenced, and LoopLabel is not defined.
>
> TIA,
> Bill
>
> PSwww.SynectixLtd.comis not relevant
def __LINE__():
try:
raise Exception
except:
return sys.exc_info()[2].tb_frame.f_back.f_lineno
def __FILE__():
return inspe
On Feb 12, 7:44 pm, Jeff Schwab <[EMAIL PROTECTED]> wrote:
> It still would be nice to have syntax as clean as __FILE__ and __LINE__.
There exists an undocumented builtin called __file__, but
unfortunately no corresponding __line__
Alain
--
http://mail.python.org/mailman/listinfo/python-list
On Feb 14, 1:50 am, "Gabriel Genellina" <[EMAIL PROTECTED]>
wrote:
> En Wed, 13 Feb 2008 13:07:31 -0200, alain <[EMAIL PROTECTED]> escribió:
>
> > There exists an undocumented builtin called __file__, but
> > unfortunately no corresponding __line__
>
>
ls.py", line 10, in
from _functools import partial
File "C:\Python25\lib\imputil.py", line 106, in _import_hook
raise ImportError, 'No module named ' + fqname
ImportError: No module named _functools
The mere fact of installing a custom importer seems to break the
import functionality.
Alain
--
http://mail.python.org/mailman/listinfo/python-list
werful, its syntax is not intuitive or easy to remember.
I therefore welcome any attempt to simplify the api for a specific
group of non-power users.
Alain
--
http://mail.python.org/mailman/listinfo/python-list
c.html
Read this and check your setup to see if it matches.
-- Alain.
--
http://mail.python.org/mailman/listinfo/python-list
keep the GUI aspect separated from the rest. Here is
stackoverflow entry discussing the use guis for (unix) shell scripts:
http://stackoverflow.com/questions/928019/how-to-make-a-gui-for-bash-scripts
(via google "linux shell script gui").
-- Alain.
--
http://mail.python.org/mailman/listinfo/python-list
pawn family" in... the doc.
> def go_back():
> version = '0.3'
> print(subprocess.Popen('cd !!:1'))
Hopeless. Have you tried this?
> def reboot():
> version = '0.3'
> print(subprocess.Popen('shutdown -r now'))
What do you expect this to print? I mean, after shutdown/reboot.
> version = '0.6b'
So, what's the version? 0.3 or 0.6b
(btw, are you sure this "version" is the same as the one you use in all
functions?).
-- Alain.
--
http://mail.python.org/mailman/listinfo/python-list
he last restriction (single evaluation of involved expressions) makes
this a bit more than raw syntactic sugar.
-- Alain.
--
http://mail.python.org/mailman/listinfo/python-list
are comparisons.
> As soon as you read it as a ternary operator, the two comparisons are
> logically simultaneous.
There is no ternary operator, you can chain as many as you want, using
whatever operators:
if a <= b < c > d >= e:
...
Once you view this as a conjonction of conditions, you find back the
semantics of "and": short-circuit, left to right evaluation. I find this
consistent.
-- Alain.
--
http://mail.python.org/mailman/listinfo/python-list
e information.
>>>>> fööbär = 3
>>>>> fööbär
>> 3
>>
>> I didn't know this. How awful.
>
> Apparently, not all characters are fine with Python. Why can I not have
> domino tiles are identifier characters?
The answer is in the
>> print('>>> entering foo ...',file=sys.stderr)
>>>
>>> Now, when executing this, I always get
>>>
>>> +++ before calling foo
>>> --- after calling foo
>>>>>> entering foo ...
This can't happen with "normal" code. Are you playing with lambdas or
generators here? Or anything else that could introduce lazyness?
-- Alain.
--
http://mail.python.org/mailman/listinfo/python-list
#x27;, 'sefwr', 'dfsews'])
>
> #Thanks for your help!
Try with ['xasd', 'sefwr', 'xjkl', 'dfsews'] and you'll understand what
happens. Also, have a look at:
http://docs.python.org/reference/compound_stmts.html#the-for-statemen
comprehension is, imo, the most useful
program construct ever. Extremely useful.
But not when it makes the program traverse twice the same list, where
one traversal is enough.
-- Alain.
--
http://mail.python.org/mailman/listinfo/python-list
over
(before or after the various tutorials, depending on your background).
-- Alain.
--
http://mail.python.org/mailman/listinfo/python-list
7;.
No, it means that connect received a single string "user = 'root'..."
instead of a set of individual keyword parameters, and took the whole
string to be the name of the host (its first parameter). Of course,
there is no host with such a name.
The solution is to parse the string into individual values, and pass
these in the correct order.
-- Alain.
--
http://mail.python.org/mailman/listinfo/python-list
e =
> sqlalchemy.create_engine("mssql+pyodbc://DumpResult:123456@localhost/DumpResult")
> c = engine.execute(cmdTest1)
>
>
> !
> case1 :wrong,(sqlalchemy.exc.ProgrammingError: (ProgrammingError) ('42000',
> "[42000] [Microsoft][ODBC SQL Server Driv
testing for equality, I can't see how this could matter, even
with variable-length encodings.
If you're comparing different encodings, then you need different access
methods to random characters (but this doesn't affect the algorithm). If
you're using variable-length encoding, e.g., UTF-8, accessing at a
specific position is not possible.
-- Alain.
--
http://mail.python.org/mailman/listinfo/python-list
).
If you want to change the binding of a in g(), you can declare it
global:
def g():
global a
a = 20
f()
Very tricky, actually.
-- Alain.
--
http://mail.python.org/mailman/listinfo/python-list
Jason Friedman writes:
[...]
> I want my python 3.2.2 script, called via cron, to know what those
> additional variables are. How?
This is not a python question. Have a look at the crontab(5) man page,
it's all explained there.
-- Alain.
--
http://mail.python.org/mailman/listinfo/python-list
27;, 'bA', 'bA']]
I can't make sense of your explanation, which doesn't seem to match your
example (the result is not of the same size as h).
Here is a way to compute { xh | x in m }, where xh is a list where x is
prepended to each element of h.
result = [ [ x+l for l in h ] for x in m ]
If there is no duplicate in the original lists, then there will be no
duplicate in the result. Is that what you are looking for?
-- Alain.
--
http://mail.python.org/mailman/listinfo/python-list
de characters (at least the
ones you use). See http://en.wikipedia.org/wiki/Unicode_font for a
start. I don't know enough about Windows to give you a name. Anyone?
-- Alain.
P/S: and this has not much to do with python, which will happily send
out any unicode char, and cannot know which ones
Steven D'Aprano writes:
> On Sun, 14 Oct 2012 19:19:33 +0200, Alain Ketterlin wrote:
>
>> Usenet has no attachments.
>
> *snarfle*
>
> You almost owed me a new monitor. I nearly sprayed my breakfast all over
> it. [...]
I owe you nothing, and you can do whate
ntrol]"):
x = child.find("ParentalControl/Rating").text
if x == "NC":
...
Note that a complete XPath implementation would make that simpler: your
query basically is //*[ParentalControl/Rating=="NC"]
-- Alain.
--
http://mail.python.org/mailman/listinfo/python-list
ly unreasonable to load several Gs of data in a
32-bit address space, especially if this is text. So my real advice
would be:
* read the file line per line and pack the contents of every line into
a list of objects; once you have all your stuff, process it
-- Alain.
--
http://mail.python.org/mailman/listinfo/python-list
get multiple files like
> A1980JE3937.txt and A1980KK18700010.txt, where each file will
> contain column2, 3 and 4.
Sorry for being completely off-topic here, but awk has a very convenient
feature to deal with this. Simply use:
awk '{ print $2,$3,$4 > $1".txt&
e object referenced by
any name, unless you impose strong conventions on the code.
> Pseudo-python-code example:
>
> i = MyClass()
>
> xxx(i, 1, 2);
>
> ...
> def xxx(self, MyClass myclass, number, foobar):
>myclass.classsmethod() #myclass - is an instance of kn
the January
| 2013 PLT Games competition.
|
| Many programming languages claim to take testing, contracts and safety
| seriously, but only Vigil is truly vigilant about not allowing code
| that fails to pass programmatic specifications.
Enjoy.
-- Alain.
--
http://mail.python.org/mailman/listi
ou really want commas whatever locale you're running in, you will
need to use setlocale to change number formatting to a locale that uses
commas. For instance:
locale.setlocale(LC_NUMERIC,"en_US.utf8")
locale.format('%d', 2348721, True)
-- Alain.
--
http://mail.python.org/mailman/listinfo/python-list
, or move to specialized packages, like decimal.
-- Alain.
--
http://mail.python.org/mailman/listinfo/python-list
e opens a tracker
> enhancement issue and presents an argument in favor.
It's not. The man page says "This call is Linux-specific."
-- Alain.
--
http://mail.python.org/mailman/listinfo/python-list
> ... if(g23tag.get(key)):
> ... g23tag[key].append(value)
> ... else:
> ... g23tag[key] = [value]
for item in tag23gr:
g23tag.setdefault(item[0],[]).append(item[1])
-- Alain.
--
http://mail.python.org/mailman/listinfo/python-list
al I dislike the idea of silently
inserting a default value when the access is a read, e.g., in
x=g23tag[wrung]. Explicit is better than implicit, as they say. YMMV.
-- Alain.
--
http://mail.python.org/mailman/listinfo/python-list
.copy only "copies" contents and permissions
(no access times, etc.) You probably mean shutil.copy2.
And sparse files are really hard to reproduce, at least on Unix: on
Linux even the system's cp doesn't guarantee sparseness of the copy (the
manual mentions a "crude heuristic").
But of course shutil.copy is the best solution to mimic a raw cp.
-- Alain.
--
http://mail.python.org/mailman/listinfo/python-list
return x # forgot self
a = A()
x = 1
print a.r() # prints 1
I know there is "no remedy". It's just really tricky.
-- Alain.
--
http://mail.python.org/mailman/listinfo/python-list
., number of open files,
or stack-size, or... But of course it's only a guess.
-- Alain.
--
http://mail.python.org/mailman/listinfo/python-list
ck whether the process has
finished, and finally Popen.kill() if it has not.
-- Alain.
--
http://mail.python.org/mailman/listinfo/python-list
. I.e., you need several distinct empty lists,
to make sure they can change value independently.
(In case you wonder: lists in Python are not linked lists of cons-cells,
they are more monolithic structures, and two lists cannot share a common
tail.)
-- Alain.
--
http://mail.python.org/mailman/listinfo/python-list
randint(0, sys.maxint)
> f.close()
sys.version is '2.6.6 (r266:84292, Sep 15 2010, 16:22:56) \n[GCC 4.4.5]'
here, and your script works like a charm. BTW, I would use f.write()
instead of print >> f (which I think is deprecated).
-- Alain.
--
http://mail.python.org/mailman/listinfo/python-list
mlangenho...@gmail.com writes:
> I would like to pass something like this into a function
> test(val1,val2,'>=')
>
> and it should come back with True or False.
def test(x,y,c):
return c(x,y)
Call with: test(v1,v2, lambda x,y:x<=y ). A bit noisy imho.
If you have a finite number of comparis
o compile python? Isn't there a binary
package available for your platform?
-- Alain.
--
http://mail.python.org/mailman/listinfo/python-list
As noted in another message, you're probably better off using an
existing syntax (json, python literals, yaml, xml, ...)
-- Alain.
#!/usr/bin/env python
import sys
import re
RE = re.compile("( *)(.*)")
stack = [("-",[])] # tree nodes are: (head,[children])
for line in sys
ch = re.search("List of \d (.+) elements", couple[0])
return ("%s_elements" % match.group(1),couple[1])
else:
pass # put a test here
> fo = open(filename, "r")
> RE = re.compile("( *)(.*)")
> stack = [("-
gt;> > d=1
>> > e=2
>> > f=3
>> > List of 1 B elements
>> > Instance of B element
>> > a=1
>> > b=2
>> > c=3
>> > List of 2 C elements
>> > Instance of C element
>> > a=1
>&g
Alain Ketterlin writes:
> loial writes:
>
>> I have a requirement to test the creation time of a file with the
>> current time and raise a message if the file is more than 15 minutes
>> old.
>> Platform is Unix.
>> I have looked at using os.path.get
TTP request,
you pay the same price again and again for something which is not even
related to your scripts' execution.
-- Alain.
--
http://mail.python.org/mailman/listinfo/python-list
for i in range(10)]
> funcs[0](1)
[...]
> Do you agree that `a` should be late bound in this situation?
No, absolutely, definitely not. But hey, I didn't learn programming with
python.
-- Alain.
--
http://mail.python.org/mailman/listinfo/python-list
Gregory Ewing writes:
> Alain Ketterlin wrote:
>> But going against generally accepted semantics should at least
>> be clearly indicated. Lambda is one of the oldest computing abstraction,
>> and they are at the core of any functional programming language.
>
> Yes,
You get the idea.
-- Alain.
--
http://mail.python.org/mailman/listinfo/python-list
Alain Ketterlin writes:
> aux = lambda s1,s2,n: (s2 - s1*s1/n)/(n-1)
> sv = lambda d: aux(sum(d),sum(x*x for x in d),len(d))
Err, sorry, the final square root is missing.
-- Alain.
--
http://mail.python.org/mailman/listinfo/python-list
to left in the chain of calls pictured
as above). Somewhat surprisingly, this is usually less efficient than
the one you show. The reason is that here there is some work to do
before the recursive call (extracting a chunk) *and* after the call
(pasting together the chunk with the result coming back from t
n considered a
scam. See, e.g.,
http://gcc.gnu.org/ml/gcc/2011-05/msg00046.html
and messages referenced therein.
-- Alain.
--
http://mail.python.org/mailman/listinfo/python-list
olling or just dumb:
Steven is right, and you look dumb.
>>> fibo(4)
3.0004
Even though the math is correct, your program is wrong. It doesn't even
produce integers. And it will fail with overflow for big values.
-- Alain.
--
http://mail.python.org/mailman/listinfo/python-list
t orthogonal to that question), at least it
couldn't do much better than CPython. It just has to go through all the
lookups. IIRC, unladden-swallow has tried the JIT route, using LLVM as
the backend. It seems they gave up.
-- Alain.
--
http://mail.python.org/mailman/listinfo/python-list
od one, but probably not because of
arithmetic optims, rather because of all the lookups Pike doesn't
perform dynamically.
-- Alain.
--
http://mail.python.org/mailman/listinfo/python-list
rs
- re. named parameters with default, use a map, or change the call sites
to remove them
-- Alain.
--
http://mail.python.org/mailman/listinfo/python-list
gt; return re.search(s1, s2)
This is complete nonsense (try it on [12] and [1,2]).
The original problem is "string searching" (where strings here are
sequences of numbers instead of characters). See
http://en.wikipedia.org/wiki/String_searching_algorithm
for any algorithm (Rabin-Karp see
somewhere else in this thread is
probably the way to go, unless the lists are really long, in which case
one of the "string searching" algorithm should be used (I would be
surprised noone has implemented Boyer-Moore or Karp-Rabin).
-- Alain.
--
http://mail.python.org/mailman/listinfo/python-list
efficient function to do this, especially when
> li1 and li2 are long lists.
It's not difficult to write your own:
def product(l1,l2):
for x1 in l1:
for x2 in l2:
yield x1+x2
use it like: for p in product(l1,l2) ... The call to product() produces
a generator, the cros
n academic server).
No spam at all.
-- Alain.
--
http://mail.python.org/mailman/listinfo/python-list
o spam, no need to store messages on your machine,
auto-purge after a configurable delay, etc.
Problem solved.
-- Alain.
--
http://mail.python.org/mailman/listinfo/python-list
for months (I'm
talking about 15-20 groups, not comp.lang.python only).
The real problem here seems to be google groups, which in some way
forwards spam to the mailing-list. How this happens is beyond my
understanding. But let's try to fix the real problem.
-- Alain.
--
http://mail.python.org/mailman/listinfo/python-list
's regexp, you can
build the regexp step by step:
number = r"\d\.\d+e\+\d+"
numbersequence = r"%s( %s){31}" % (number,number)
There are better ways to build your regexp, but I think this one is
convenient to answer your question. You still have to append what will
match
confuse threads
with processes?
Re. the original question: since you can define your own Thread
subclass, with wathever attribute you want, I guess there was no need to
use join() to communicate the result. The Thread's run() can store its
result in an attribute, and the "client" can
Adam Skutt writes:
> On Sep 2, 2:23 pm, Alain Ketterlin
> wrote:
>> Sorry, you're wrong, at least for POSIX threads:
>>
>> void pthread_exit(void *value_ptr);
>> int pthread_join(pthread_t thread, void **value_ptr);
>>
>> pthread_exit can pass
Alain Ketterlin writes:
>> Passing a void* is not equivalent to passing anything, not even in C.
>> Moreover, specific values are still reserved, like PTHREAD_CANCELLED.
>
> Thread cancellation is program logic (pthread_cancel), it doesn't mean
> you thread crashed, it
as well. (Try first with a statically linked executable, e.g.,
/bin/busybox, and everything should be ok).
I agree the message is strange. For some reason, subprocess is calling
pickle.loads, which calls rep.decode("string-escape"), which probably
needs to access some file and fails because
#x27;-')
if len(bounds) == 1:
yield int(bounds[0])
elif len(bounds) == 2:
for v in range(int(bounds[0]),1+int(bounds[1])):
yield v
else:
pass # ignore, or throw, or...
# Use as in:
for x in values(["1",&q
he script that the
interpreter started with.
-- Alain.
--
http://mail.python.org/mailman/listinfo/python-list
use HTML's SGML DTD in a XML document. Direct your
doctype to XHTML's DTD, and everything will be fine (hopefully).
BTW, your installation will probably let you use a locally cached copy
of the DTD, instead of fetching a file at every parse. How this works
depends somehow on the parse
>
> The Pi release of Python :-)
And the same day we get the e release of Python...
-- Alain.
--
http://mail.python.org/mailman/listinfo/python-list
loaded to a Chinese IP address. NBU officials contacted PyPI
| administrators last week who removed the packages before officials
| published a security advisory on Saturday."
-- Alain.
--
https://mail.python.org/mailman/listinfo/python-list
hod,
| nor stack trace, stack frame, nor file, socket, window, nor array, nor
| any similar types.
But who knows what "similar types" are...
-- Alain.
--
https://mail.python.org/mailman/listinfo/python-list
w Lua operates too?
No. Lua uses a register-based (virtual) machine. See
https://www.lua.org/doc/jucs05.pdf
I think Lua was the first language in widespread use to move to a
register-based machine.
-- Alain.
--
https://mail.python.org/mailman/listinfo/python-list
ck that 39 is
correct). Your data look like fixed-width fields.
-- Alain.
--
https://mail.python.org/mailman/listinfo/python-list
/conventional resolution.
By the way, the use of gettimeofday() is strange since this function is
now deprecated... clock_gettime() should be used instead. It has an
associated clock_getres() as well.
-- Alain.
[*] WTF is wrong with these microsoft developpers? Clocks and
performance counters are
any side-effect and/or throw an exception). And be fired right
after your first code review.
-- Alain.
--
https://mail.python.org/mailman/listinfo/python-list
too complex to
capture, testing will be incomplete, and all you can do is run your
program and see whether is goes through.
As a general rule, if that's all you expect from typing, then, fine,
call this "strong". I won't go as far, and just say that it is good
enough for th
Chris Angelico writes:
> On Mon, Feb 19, 2018 at 7:40 PM, Alain Ketterlin
> wrote:
>> No. C has much stronger rules, not on casting, but on accessing the
>> pointees, which basically invalidates your argument. Refer to the C
>> standard for details.
>
> Really
Chris Angelico writes:
> On Mon, Feb 19, 2018 at 9:04 PM, Alain Ketterlin
> wrote:
>> Look at the C11 standard, section 6.3.2.3 ("Pointers"), 6.5.§6-7
>> ("effective types"), and 6.5.3.2 ("Address and indirection operators").
>> It i
Steven D'Aprano writes:
> On Mon, 19 Feb 2018 09:40:09 +0100, Alain Ketterlin wrote:
>
>> Tim Delaney writes:
>>
>> [...]
>>> As others have said, typing is about how the underlying memory is
>>> treated.
>>
>> No. It is much more t
ns no matching
blocks).
It is all due to the "Autojunk" heuristics (see difflib's doc for
details), which considers the first characters as junk. Call
SM(...,autojunk=False).
I have no idea why the maintainers made this stupid autojunk idea the
default. Complain with them.
-- Al
t I haven't checked).
Are you sure this is your (real) problem?
-- Alain.
--
https://mail.python.org/mailman/listinfo/python-list
tle will
> have the date a year off.
>
> What I would like to do it output to another file that show those two
> as a match.
Try the difflib module (read the doc, its default behavior may be
surprising).
-- Alain.
--
https://mail.python.org/mailman/listinfo/python-list
taneously), you just
overwrite the first element twice.
Congratulations, a very good corner case (you can't call it a bug, since
it conforms to the definition of the language).
-- Alain.
--
https://mail.python.org/mailman/listinfo/python-list
d horizontal line elements?
Box-drawing characters. At least that's how Unicode calls them. Even if
you don't draw boxes...
https://en.wikipedia.org/wiki/Box-drawing_character
-- Alain.
--
https://mail.python.org/mailman/listinfo/python-list
1 - 100 of 289 matches
Mail list logo