22-08-2009 o 20:11:32 bolega gnuist...@gmail.com wrote:
sed/awk/perl:
How to replace all spaces each with an underscore that occur before a
specific string ?
$ rm -rf /home/bolega ; python -c 'for i in xrange(1000): print I will
never crosspost senselessly.'
;~]
--
Jan Kaliszewski (zuo
to as 'variables',
regarding other languages' terminology).
Cheers,
*j
--
Jan Kaliszewski (zuo) z...@chopin.edu.pl
--
http://mail.python.org/mailman/listinfo/python-list
?).
Otherwise, as Stephen noted, you should subclass set rather than list.
Cheers,
*j
--
Jan Kaliszewski (zuo) z...@chopin.edu.pl
--
http://mail.python.org/mailman/listinfo/python-list
in playerdata:
self.append(Player(data))
--
Jan Kaliszewski (zuo) z...@chopin.edu.pl
--
http://mail.python.org/mailman/listinfo/python-list
a = set(a)
n = sum(item in a for item in b)
Why set? Does it matter if I say that items in A are already unique?
Sets are hash-based, so it's (most probably) far more efficient for
sets than for sequences (especially if we say about big/long ones).
Regards,
*j
--
Jan Kaliszewski
19-08-2009 o 10:56:20 Michel Claveau -
MVPenleverLesX_XXmcX@xmclavxeaux.com wrote:
(envoyé via news:\\news.wanadoo.fr\comp.lang.python)
Hi!
See the module sets
No, see the builtin set type. Module sets is deprecated (removed in Py 3.x)
--
Jan Kaliszewski (zuo) z...@chopin.edu.pl
--
http
]))
Or (for long lists, when memory becomes expensive):
dict(li[i:i+2] for i in xrange(0, len(li), 2))
Or probably better:
from itertools import islice, izip
dict(izip(islice(li, 0, None, 2), islice(li, 1, None, 2)))
Cheers,
*j
--
Jan Kaliszewski (zuo) z...@chopin.edu.pl
--
http
element of A (separately) in B...
Hm, maybe something like this:
# result as a dict {element of A: how many occurences in B, ...}
dict((element, B.count(element)) for element in A)
If you mean: to count non overlaping occurences of string A in B
-- simply:
B.count(A)
Regards,
*j
--
Jan
20-08-2009 o 02:05:57 Jan Kaliszewski z...@chopin.edu.pl wrote:
Or probably better:
from itertools import islice, izip
dict(izip(islice(li, 0, None, 2), islice(li, 1, None, 2)))
Or similarly, perhaps more readable:
iterator = iter(li)
dict((iterator.next(), iterator.next
None)
I'd use conditional expression only (rather) in situation when the first
expression-part was 'common' and the other (after else) was 'rare'.
Cheers,
*j
--
Jan Kaliszewski (zuo) z...@chopin.edu.pl
--
http://mail.python.org/mailman/listinfo/python-list
curiosity) :-)
Regards,
*j
--
Jan Kaliszewski (zuo) z...@chopin.edu.pl
--
http://mail.python.org/mailman/listinfo/python-list
that some other
solution would be better (e.g. inheritance).
Cheers,
*j
--
Jan Kaliszewski (zuo) z...@chopin.edu.pl
--
http://mail.python.org/mailman/listinfo/python-list
want to avoid using a def if possible.
But what for? Usualy def is more readable than lambda and it's not worth
to lose readibility just to save a few keystrokes.
Cheers,
*j
--
Jan Kaliszewski (zuo) z...@chopin.edu.pl
--
http://mail.python.org/mailman/listinfo/python-list
examples like above.
*j
--
Jan Kaliszewski (zuo) z...@chopin.edu.pl
--
http://mail.python.org/mailman/listinfo/python-list
it (see: http://docs.python.org/3.1/whatsnew/3.0.html ).
Regards,
*j
--
Jan Kaliszewski (zuo) z...@chopin.edu.pl
--
http://mail.python.org/mailman/listinfo/python-list
(and even recommended over s=s+t or s+=t, when
applicable
-- see:
http://docs.python.org/library/stdtypes.html#sequence-types-str-unicode-list-tuple-buffer-xrange).
Cheers,
*j
--
Jan Kaliszewski (zuo) z...@chopin.edu.pl
--
http://mail.python.org/mailman/listinfo/python-list
' scope.
The only ways to reach Abc's attribute 'message' from that method are:
* 'Abc.message'
* 'self.__class__.message'
* 'self.message' (unless there is an instance attribute 'message' which
overrides the class attribute).
Cheers,
*j
--
Jan Kaliszewski (zuo) z...@chopin.edu.pl
--
http
19-08-2009 o 02:10:58 Jan Kaliszewski z...@chopin.edu.pl wrote:
The only ways to reach Abc's attribute 'message' from that method are:
* 'Abc.message'
* 'self.__class__.message'
* 'self.message' (unless there is an instance attribute 'message' which
overrides the class attribute
:\moo, C:\supermoo
print ', '.join('%s' % item for item in arrPlaces)
Output:
'C:\moo', 'C:\supermoo'
Cheers,
*j
--
Jan Kaliszewski (zuo) z...@chopin.edu.pl
--
http://mail.python.org/mailman/listinfo/python-list
strings (for sure most common case) it's ok: simple and clear.
But for huge ones, it's better not to materialize additional list for the
string -- then pure-iterator-sollutions would be better (like Gabriel's or
mine).
Cheers,
*j
--
Jan Kaliszewski (zuo) z...@chopin.edu.pl
--
http://mail.python.org
# than len(Polynome)
# of arguments
--
Jan Kaliszewski (zuo) z...@chopin.edu.pl
--
http://mail.python.org/mailman/listinfo/python-list
),
*repeated_iterator)
return sep.join(itertools.chain((text[:beg],), strings))
print separate('12345678')
print back_separate('12345678')
http://docs.python.org/library/itertools.html#recipes
was the inspiration for me (especially grouper).
Cheers,
*j
--
Jan Kaliszewski (zuo) z...@chopin.edu.pl
15-08-2009 Jan Kaliszewski z...@chopin.edu.pl wrote:
15-08-2009 candide cand...@free.invalid wrote:
Suppose you need to split a string into substrings of a given size
(except
possibly the last substring). I make the hypothesis the first slice is
at the end of the string.
A typical example
placeholder but it wont format the string
j must be a tuple -- so either define it as
(u'Tata', u'Oriovac', u'PrimorskoGoranska', u'hrvatska', u'Kuna')
or when using it, wrap it with tuple() constructor:
h = ... % tuple(j)
--
Jan Kaliszewski (zuo) z...@chopin.edu.pl
--
http
, v.id_valuta FROM ulica as u, opcina as o, zupanija as \
... z, drzava as d, valuta as v WHERE u.naziv = '{0}' AND o.naziv = \
... '{1}' AND z.naziv = '{2}' AND d.naziv = '{3}' AND v.naziv = '{4}'\
... .format(*j)
Cheers,
*j
--
Jan Kaliszewski (zuo) z...@chopin.edu.pl
--
http://mail.python.org/mailman
. isinstance(foo, YourType).
Cheers,
*j
--
Jan Kaliszewski (zuo) z...@chopin.edu.pl
--
http://mail.python.org/mailman/listinfo/python-list
'
special character) and not '\\r' (which would mean '\' char + 'r' char).
Regards,
*j
--
Jan Kaliszewski (zuo) z...@chopin.edu.pl
--
http://mail.python.org/mailman/listinfo/python-list
09-08-2009 r rt8...@gmail.com wrote:
On Aug 8, 12:43 pm, Jan Kaliszewski z...@chopin.edu.pl wrote:
08-08-2009 Steven D'Aprano st...@remove-this-cybersource.com.au wrote:
...(snip)
I use it very often, e.g.:
afunction('quite long string %s quite long string
, variable2, variable3))
(Note that multiline-'''-strings are usless in such cases).
*j
--
Jan Kaliszewski (zuo) z...@chopin.edu.pl
--
http://mail.python.org/mailman/listinfo/python-list
:
print nucleotides, ' foo bar length=76'
print nucleotides, seq[-76]
Cheers,
*j
--
Jan Kaliszewski (zuo) z...@chopin.edu.pl
--
http://mail.python.org/mailman/listinfo/python-list
:
print nucleotides, ' foo bar length=76'
print nucleotides, seq[-76]
Cheers,
*j
--
Jan Kaliszewski (zuo) z...@chopin.edu.pl
--
http://mail.python.org/mailman/listinfo/python-list
.
The last is ok: None != 0.
*j
--
Jan Kaliszewski (zuo) z...@chopin.edu.pl
--
http://mail.python.org/mailman/listinfo/python-list
are integers; the release level is 'alpha', 'beta',
'candidate', or 'final'. The version_info value corresponding to
the Python version 2.0 is (2, 0, 0, 'final', 0).
http://docs.python.org/library/sys.html#sys.version_info
Cheers,
*j
--
Jan Kaliszewski (zuo) z...@chopin.edu.pl
--
http
is the problem?
*j
--
Jan Kaliszewski (zuo) z...@chopin.edu.pl
--
http://mail.python.org/mailman/listinfo/python-list
(b'What makes you think she is a witch?') # but not this way
b'What makes you think she is a witch?'
[^ note this]
Cheers,
*j
--
Jan Kaliszewski (zuo) z...@chopin.edu.pl
--
http://mail.python.org/mailman/listinfo/python-list
but isn't sexy (and tends to lower readability
imo).
I don't see any real limitation. What's wrong in:
for localVar in container:
block
And ruby's container.each is very similar to Python's iter()
*j
--
Jan Kaliszewski (zuo) z...@chopin.edu.pl
--
http://mail.python.org/mailman/listinfo
[used_term]
print('Some text, {colors.blue}Something in blue, '
'{colors.red}And now in red.').format(colors=colors)
Regards,
*j
--
Jan Kaliszewski (zuo) z...@chopin.edu.pl
--
http://mail.python.org/mailman/listinfo/python-list
/reference/lexical_analysis.html#reserved-classes-of-identifiers
* http://docs.python.org/reference/datamodel.html#object.__del__
(in the the red Warning frame)
--
Jan Kaliszewski (zuo) z...@chopin.edu.pl
--
http://mail.python.org/mailman/listinfo/python-list
= []
for name in filenames:
results.append(some_function(name))
If filenames were generated according to a particular pattern, you can
mimic that pattern and generate filenames list using
list-comprehension, e.g.:
filenames = ['file{nr}.txt'.format(nr=nr) for nr in range(13)]
Chreers,
*j
--
Jan
Me wrote:
filenames = p'foo', 'bar', baz']
Sorry, should be of course:
filenames = ['foo', 'bar', baz']
*j
--
Jan Kaliszewski (zuo) z...@chopin.edu.pl
--
http://mail.python.org/mailman/listinfo/python-list
by
something else, can you please give me some guidance?
What operating system do you use?
*j
--
Jan Kaliszewski (zuo) z...@chopin.edu.pl
--
http://mail.python.org/mailman/listinfo/python-list
Hello Friends,
It's my first post to python-list, so first let me introduce myself...
* my name is Jan Kaliszewski,
* country -- Poland,
* occupation -- composer (studied in F. Chopin Academy of Music @Warsaw)
and programmer (currently in Record System company
27-07-2009 o 22:35:01 David 71da...@libero.it wrote:
I am writing a command line application, and I need to perform some
cleaning
on exit even if the process is killed.
How can I do that with python?
See: http://docs.python.org/library/signal.html
Cheers,
*j
--
Jan Kaliszewski (zuo) z
a good idea
to combine these two techniques (i.e. signal handlers call sys.exit(),
then sys.exitfunc/or function registered with atexit does the actual
cleaning actions).
*j
--
Jan Kaliszewski (zuo) z...@chopin.edu.pl
--
http://mail.python.org/mailman/listinfo/python-list
New submission from Jan Kaliszewski z...@chopin.edu.pl:
http://docs.python.org/3.1/download.html (available both with 'Download
these documents' link @docs and 'Download Current Python 3.1
Documentation' link @http://www.python.org/doc/) doesn't contain links
to packed docs, but text for dev
New submission from Jan Kaliszewski z...@chopin.edu.pl:
Some of links in re docs should lead to RegexObject.match()|
RegexObject.search() method but lead to re.match()|re.search() module
function.
These are the places in 2.6 docs (in 2.7-3.2 versions' you'll find the
bug in analogous places
New submission from Jan Kaliszewski z...@chopin.edu.pl:
The problem can be found in many places in docs -- tipically, where
there is a function/method with name identical to builtin name (or
sometimes to another function/method within the same module -- see:
#6575): links leads to te latter
New submission from Jan Kaliszewski z...@chopin.edu.pl:
* In 2.6 the content of that section isn't up to date (3.1 is
descripted as 'in development')
* In 3.0 there is no that section.
--
messages: 90945
nosy: zuo
severity: normal
status: open
title: 2 problems with 'Docs for other
Changes by Jan Kaliszewski z...@chopin.edu.pl:
--
assignee: - georg.brandl
components: +Documentation
nosy: +georg.brandl
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue6578
New submission from Jan Kaliszewski z...@chopin.edu.pl:
As we can read in http://docs.python.org/3.1/whatsnew/3.1.html#other-
language-changes:
The fields in format() strings can now be automatically numbered:
'Sir {} of {}'.format('Gallahad', 'Camelot')
'Sir Gallahad of Camelot
Jan Kaliszewski z...@chopin.edu.pl added the comment:
The matter had been discussed (and not once...), IMO without
satisfactory conclusion -- see:
* http://bugs.python.org/issue612627 (the feature added)
* http://bugs.python.org/issue1214889 (another feature rejected)
* http://bugs.python.org
Jan Kaliszewski z...@chopin.edu.pl added the comment:
PS. The main problem is not a lack of feature but that inconsistency,
and that's not documented if File type docs:
print my_file, my_unicode # - is encoded with my_file.encoding
my_file.write(my_unicode) # - is encoded
Jan Kaliszewski z...@chopin.edu.pl added the comment:
s / if File / in File
s / -- works # - is encoded with my_file.encoding / # - is encoded
with sys.stdout.encoding
(sorry, too little sleep)
--
___
Python tracker rep...@bugs.python.org
http
Changes by Jan Kaliszewski z...@chopin.edu.pl:
--
assignee: - georg.brandl
components: +Documentation
nosy: +georg.brandl
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue4947
New submission from Jan Kaliszewski z...@chopin.edu.pl:
Py2.4 and 2.5 (and probably other 2.x releases too):
try: f=open('existing_dir')
... except IOError, exc: print exc.filename
...
None
(expected result: existing_dir)
Py3.0 (and possibly 3.1 too):
try: f=open('existing_dir')
... except
101 - 155 of 155 matches
Mail list logo