OdarR wrote:
Hi guys,
how would you do a clever find and replace, where the value replacing
the tag
is changing on each occurence ?
"...TAGTAGTAG..TAG."
is replaced by this :
"...REPL01REPL02REPL03..REPL04..."
John Machin wrote:
> def fancyrepl(tag, replfunc, input_string):
> count = 0
> pieces = []
> pos = 0
> taglen = len(tag)
> while 1:
> try:
> newpos = input_string.index(tag, pos)
> except ValueError:
> pieces.append(input_string[pos:])
>
Is there anyway, having been passed a file handle, to get the
filename?
I am assuming not, but thought I would ask
--
http://mail.python.org/mailman/listinfo/python-list
On 2/17/09, loial wrote:
>
> Is there anyway, having been passed a file handle, to get the
> filename?
>
> I am assuming not, but thought I would ask
>>> a = open('/etc/passwd')
>>> a.name
'/etc/passwd'
>>>
Best regards,
Nop
--
http://mail.python.org/mailman/listinfo/python-list
On Feb 16, 11:21 pm, Yuanxin Xi wrote:
> I'm having some problems with the memory recycling/garbage collecting
> of the following testing code:
>
> >>> a=[str(i) for i in xrange(1000)]
>
> This takes 635m/552m/2044 memory (VIRT/RES/SHR)
>
> >>> b={}
> >>> for i in xrange(1000):
>
> ...
En Fri, 13 Feb 2009 20:17:35 -0200, Bryan escribió:
On Feb 13, 1:52 pm, Jason Scheirer wrote:
On Feb 13, 12:42 pm, Bryan wrote:
> I have a Python v2.5.2 server running and I found some undesirable
> behavior in the xmlrpclib module that is included with that version of
> Python. The xmlrpcl
On Tue, Feb 17, 2009 at 12:33 AM, Aaron Brady wrote:
> On Feb 16, 11:21 pm, Yuanxin Xi wrote:
>> I'm having some problems with the memory recycling/garbage collecting
>> of the following testing code:
>>
>> >>> a=[str(i) for i in xrange(1000)]
>>
>> This takes 635m/552m/2044 memory (VIRT/RES/
Gerard Flanagan wrote:
def replace(s, patt, repls):
def onmatch(m):
onmatch.idx += 1
return repls[onmatch.idx]
onmatch.idx = -1
return patt.sub(onmatch, s)
test = """
abcTAG TAG asdTAGxyz
"""
REPLS = [
'REPL1',
'REPL2',
'REPL3',
]
print replace(t
loial wrote:
> Is there anyway, having been passed a file handle, to get the
> filename?
>
> I am assuming not, but thought I would ask
>
>
If you mean a Python file object then file.name (but it may not exist on
all file objects).
If you mean a system file handle, then which filename would
Hi all
I'm trying to find a way to output strings in the raw-string format, e.g.
print_as_raw_string(r"\.") should output r"\." instead of "\\."
Is there a better way than writing your own print function? Some magic
encoding?
Mirko
--
http://mail.python.org/mailman/listinfo/python-list
On Feb 17, 9:21 am, loial wrote:
> Is there anyway, having been passed a file handle, to get the
> filename?
>
> I am assuming not, but thought I would ask
If by file handle you mean the object returned by 'file' and 'open'
functions, it has a name attribute.
If by file handle you mean the file d
Nick Matzke:
> I have to do this hundreds of times, so speed would be useful.
Try to create a 2D array with NumPy, and then slice it. Note that
slicing syntax has a "stride" too.
Bye,
bearophile
--
http://mail.python.org/mailman/listinfo/python-list
"Aahz" wrote:
> In article ,
> Hendrik van Rooyen wrote:
> >
> >Occam was the language that should have won the marketing prize, but
> >didn't.
>
> It wasn't simple enough.
I thought (at the time) that it was quite good at hiding some
horrible complexities of communication between different
p
"Ben Finney" wrote:
a...@pythoncraft.com (Aahz) writes:
> In article ,
> Hendrik van Rooyen wrote:
> >Occam was the language that should have won the marketing prize,
> >but didn't.
>
> It wasn't simple enough.
*bdom-tsssh* http://en.wikipedia.org/wiki/Occam's_razor>
If Aahz was trolling, th
I have released an updated version of Assembly Line,
my entry in PyWeek 6 and later the Pyggy Awards.
http://media.pyweek.org/dl/1007/greg_pgF09/AssemblyLine-0.8.2.zip
About Assembly Line
---
Become a FADE!
That's Factory Automation Design Engineer for Pixall Manufacturing, the
En Tue, 17 Feb 2009 03:44:51 -0200, Sambit Samal
escribió:
I am new to Python world
I need a python script , which binds at a user defind port & sends to
other enity , which waits at particular port.
The other enity will respond & Python script should receive that at the
defined port
The c
Mirko Dziadzka wrote:
Hi all
I'm trying to find a way to output strings in the raw-string format, e.g.
print_as_raw_string(r"\.") should output r"\." instead of "\\."
Is there a better way than writing your own print function? Some magic
encoding?
Thats nonsense. print r"\." or in python3.0
Mirko Dziadzka schrieb:
Hi all
I'm trying to find a way to output strings in the raw-string format, e.g.
print_as_raw_string(r"\.") should output r"\." instead of "\\."
Is there a better way than writing your own print function? Some magic
encoding?
There is no need to do this. Rawstrings ar
On Mon, 2009-02-16 at 16:47 -0800, bearophileh...@lycos.com wrote:
> Jayson Santos:
> > Do I need use some patters or others progamming conventions ?
>
> That's a strong question...
> Knowing OOP well is important, and it's often a good way to program,
> etc. But... You may try to rewrite your cod
En Tue, 17 Feb 2009 03:04:23 -0200, Peter Billam
escribió:
Greetings. (Newbie warning as usual) In Python3, sys.stdout is a
io.TextIOWrapper object; but I want to output bytes
(e.g. muscript -midi t > t.mid )
and they're coming out stringified :-( How can I either change the
encoding on sy
why do you think that current work is ignorant of occam? occam itself was
based on hoare's "communicating sequential processes" which is a classic
of the field. the ideas behind occam are not unknown and it hasn't been
forgotten (there are many libraries based on synchronous message passing;
one
rushen...@gmail.com a écrit :
(snip)
And the story begins here. As i search on the net, I have found that
because of the natural characteristics of python such as GIL, we are
not able to write multi threaded programs.
I'm surprised no one here corrected that point yet, so here we go: yes,
Py
Diez B. Roggisch wrote:
>> I'm trying to find a way to output strings in the raw-string format, e.g.
>>
>> print_as_raw_string(r"\.") should output r"\." instead of "\\."
>>
>> Is there a better way than writing your own print function? Some magic
>> encoding?
>
> There is no need to do this. R
Bruno Desthuilliers wrote:
> rushen...@gmail.com a écrit :
> (snip)
>> And the story begins here. As i search on the net, I have found that
>> because of the natural characteristics of python such as GIL, we are
>> not able to write multi threaded programs.
>
> I'm surprised no one here corrected
Mirko Dziadzka wrote:
> Hi all
>
> I'm trying to find a way to output strings in the raw-string format, e.g.
>
> print_as_raw_string(r"\.") should output r"\." instead of "\\."
Ok, lets make a better example:
>>> re_list = {}
>>> re_list['foo'] = r'\..*'
>>> re_list['bar'] = r'.*bar.*'
>>> prin
Nicolas Dandrimont wrote:
> I would go for something like:
>
> for char in word:
> if char in 'aeiouAEIUO':
> char_found = True
> break
> else:
> char_found = False
>
> (No, I did not forget to indent the else statement, see
> http://docs.python.org/reference/compound_stm
Diez B. Roggisch wrote:
> Mirko Dziadzka schrieb:
>> Hi all
>>
>> I'm trying to find a way to output strings in the raw-string format, e.g.
>>
>> print_as_raw_string(r"\.") should output r"\." instead of "\\."
>>
>> Is there a better way than writing your own print function? Some magic
>> encod
Roy Smith wrote:
>> > Do you really want to except SystemExit, KeyboardInterrupt, MemoryError
>> > and SyntaxError?
>
> Absolutely. Let's take my example -- you're writing software for a Mars
> Rover. I have no idea how you might get a MemoryError, but let's say you
> do. Which would you rathe
Peter Billam schrieb:
> Greetings. (Newbie warning as usual) In Python3, sys.stdout is a
> io.TextIOWrapper object; but I want to output bytes
> (e.g. muscript -midi t > t.mid )
> and they're coming out stringified :-( How can I either change the
> encoding on sys.stdout, or close sys.stdout and
Hi all,
Recently I am studying some python ORM libraries, such as sqlalchemy.
These are very powerful technologies to handle database. But I think
my project are not complicated to enough to benefit from a complete
ORM system.
What I really want, is some easy ways to load data from database, an
Hi,
I am using python 2.5 on sun solaris.
I want to limit the number of files returned by os.listdir() to some number
(say 1000), how can I do it ?
Also I wan to list the files only if they are older than some x days, how
can I do it?
I can do this through shell script using command.
find ${
On Tue, Feb 17, 2009 at 4:31 AM, Deepak Rokade wrote:
> Hi,
>
> I am using python 2.5 on sun solaris.
>
> I want to limit the number of files returned by os.listdir() to some number
> (say 1000), how can I do it ?
>
> Also I wan to list the files only if they are older than some x days, how
> can
一首诗 wrote:
> Hi all,
>
> Recently I am studying some python ORM libraries, such as sqlalchemy.
>
> These are very powerful technologies to handle database. But I think
> my project are not complicated to enough to benefit from a complete
> ORM system.
>
> What I really want, is some easy ways to
On Feb 17, 7:18 pm, Duncan Booth wrote:
> John Machin wrote:
> > def fancyrepl(tag, replfunc, input_string):
> > count = 0
> > pieces = []
> > pos = 0
> > taglen = len(tag)
> > while 1:
> > try:
> > newpos = input_string.index(tag, pos)
> > except V
一首诗 schrieb:
Hi all,
Recently I am studying some python ORM libraries, such as sqlalchemy.
These are very powerful technologies to handle database. But I think
my project are not complicated to enough to benefit from a complete
ORM system.
What I really want, is some easy ways to load data fr
On Feb 17, 1:27 pm, 一首诗 wrote:
> Hi all,
>
> Recently I am studying some python ORM libraries, such as sqlalchemy.
>
> These are very powerful technologies to handle database. But I think
> my project are not complicated to enough to benefit from a complete
> ORM system.
>
> What I really want, i
On 16 fev, 21:47, bearophileh...@lycos.com wrote:
> Jayson Santos:
>
> > Do I need use some patters or others progamming conventions ?
>
> That's a strong question...
> Knowing OOP well is important, and it's often a good way to program,
> etc. But... You may try to rewrite your code with functions
hello,
I'm making a virtual machine,
in which (small) pieces of software (called bricks) are connected,
by connecting an output of a brick to the input of another brick.
A connection between 2 bricks may be of any type,
so it might be simple integer,
or a multi-nested dictionary / list or whatso
On Tue, 2009-02-17 at 00:40 -0800, Chris Rebert wrote:
> >
> > 'gc.collect()' -- I believe, but I'm not the specialist in it.
>
> If I understand correctly, that only effects objects that are part of
> a reference cycle and doesn't necessarily force the freed memory to be
> released to the OS.
I
Yes I can do that but for that I will have to go through entire list of
files and also I will have to first get the whole list of files present in
directory.
In case of my application this list can be huge and so want to list the
files which suits my criteria.
Similar to the unix find command I se
Thanks for your reply.
With sqlalchemy, an mapped must living in a session, you have no way
to disconnect it with its session.
For example :
#-
user = session.query(User).first()
session.expunge(user)
print user.name #Error here
#
Stef Mientki schrieb:
hello,
I'm making a virtual machine,
in which (small) pieces of software (called bricks) are connected,
by connecting an output of a brick to the input of another brick.
A connection between 2 bricks may be of any type,
so it might be simple integer,
or a multi-nested dict
On Feb 17, 5:31 am, Chris Rebert wrote:
> My understanding is that for efficiency purposes Python hangs on to
> the extra memory even after the object has been GC-ed and doesn't give
> it back to the OS right away.
Even if Python would free() the space no more used by it's own memory
allocator (P
On Tue, 2009-02-17 at 19:46 +0530, Deepak Rokade wrote:
>
> Yes I can do that but for that I will have to go through entire list
> of files and also I will have to first get the whole list of files
> present in directory.
>
> In case of my application this list can be huge and so want to list
> t
thanks Diez,
Diez B. Roggisch wrote:
Stef Mientki schrieb:
hello,
I'm making a virtual machine,
in which (small) pieces of software (called bricks) are connected,
by connecting an output of a brick to the input of another brick.
A connection between 2 bricks may be of any type,
so it might be
How do I do this in Python ?
#
declare A,B
function getA
return A
function getB
return B
function setA(value)
A = value
function setB(value)
B = value
main()
getA
getB
dosomething
setA(aValue)
setB(aValue)
#
In article <01aaa1da$0$20629$c3e8...@news.astraweb.com>,
Steven D'Aprano wrote:
> Okay, but that surely falls under chapter 18 of the "Advanced Python
> Programming for the Mars Rover" book rather than chapter 5 of "Newbies
> Guide to Python".
Well, sure, but this thread started out with my tak
On Feb 17, 8:15 am, 一首诗 wrote:
> Thanks for your reply.
>
> With sqlalchemy, an mapped must living in a session, you have no way
> to disconnect it with its session.
>
> For example :
>
> #-
> user = session.query(User).first()
> session.expunge(user)
> print us
Linuxguy123 wrote:
How do I do this in Python ?
#
declare A,B
function getA
return A
function getB
return B
function setA(value)
A = value
function setB(value)
B = value
main()
getA
getB
dosomething
setA(aValue)
setB(aValue)
In article ,
Steven D'Aprano wrote:
.
.
.
>> And now for my version (which admitedly isn't really mine, and returns
>> slightly incorrect fib(n) for large values of n, due to the limited
>> floating point precision).
>
>The f
Use the global statement.
http://docs.python.org/reference/simple_stmts.html#the-global-statement
A working example based on your pseudocode would be:
def getA():
global A
return A
def getB():
global B
return B
def setA(value):
global A
2009/2/17 MRAB :
> It isn't possible to have an uninitialised variable. If it doesn't have
> a value then it doesn't exist.
True, but you can use the global statement to refer to the variable
within a function and read from the variable there, without it being
already initialised in the module.
O
On Feb 16, 12:05 am, Mel wrote:
> Christian Heimes wrote:
> > Roy Smith wrote:
> >> They make sense when you need to recover from any error that may occur,
> >> possibly as the last resort after catching and dealing with more specific
> >> exceptions. In an unattended embedded system (think Mars R
Hi,
May I have your recommendations in choosing threads or processes for the
following ?
I have a wxPython application that builds an internal database from a list of
files and then displays various aspects of that data,
in response to user's requests.
I want to add a module that finds events
On Tue, 2009-02-17 at 06:15 -0800, 一首诗 wrote:
> Thanks for your reply.
>
> With sqlalchemy, an mapped must living in a session, you have no way
> to disconnect it with its session.
>
> For example :
>
> #-
> user = session.query(User).first()
> session.expung
On Feb 16, 7:09 am, Python Nutter wrote:
> silly me, forgot to mention
>
> build a set from digits + '.' and use that for testing.
`.' is locale dependent. Some locales might use `,' instead and maybe
there's even more out there that I don't know of. So developing this
yourself from scratch see
2009/2/16 Python Nutter :
> silly me, forgot to mention
>
> build a set from digits + '.' and use that for testing.
>
> Cheers,
> PN
>
>
> 2009/2/16 Python Nutter :
>> Type casting seems to be the wrong way to go about this.
>>
>> teststring = '15719'
>> teststring.isdigit()
>> returns True
>>
>> T
On Feb 17, 12:34 am, "Gabriel Genellina"
wrote:
> En Fri, 13 Feb 2009 20:17:35 -0200, Bryan escribió:
>
>
>
> > On Feb 13, 1:52 pm, Jason Scheirer wrote:
> >> On Feb 13, 12:42 pm, Bryan wrote:
>
> >> > I have a Python v2.5.2 server running and I found some undesirable
> >> > behavior in the xml
>> > Try this change:
>> >
>> > from: btn.configure(image = None)
>> > to: img1.blank()
>> >
>>
>> This does in fact clear the image out, however it isn't causing the
>> text to display... Do i have have to create a new button and swap it
>> out?
I knew you were gonna ask that! :-)
Original poster here: Just for the record, my *original* post did
include an explicit trapping of the ValueError exception. :)
My point is that the coaching offered by this forum does not always fall
on deaf ears.
Thanks for everyone's help on this and all the other posts in this
forum.
Regards
On 16 Feb, 10:34, rushen...@gmail.com wrote:
> And the story begins here. As i search on the net, I have found that
> because of the natural characteristics of python such as GIL, we are
> not able to write multi threaded programs. Oooops, in a kind of time
> with lots of cpu cores and we are not
Yuanxin Xi wrote:
> Could anyone please explain why this happens? It seems some memory
> are not freed. I'm running into problems with this as my program is
> very memory cosuming and need to frequently free some object to reuse
> the memory. What is the best way to free the memory of b complete
On 16 Feb, 15:18, rushen...@gmail.com wrote:
> As you mentioned, using multi cores makes programs more fast and more
> popular. But what about stackless python? Does it interpret same set
> of python libraries with Cpython or Does it have a special sub set?
Stackless and CPython have a GIL, Jytho
Very well written response! Thanks Sturla
On Tue, Feb 17, 2009 at 10:50 AM, sturlamolden wrote:
> On 16 Feb, 10:34, rushen...@gmail.com wrote:
>
> > And the story begins here. As i search on the net, I have found that
> > because of the natural characteristics of python such as GIL, we are
> >
Tim Wintle wrote:
> Basically malloc() and free() are computationally expensive, so Python
> tries to call them as little as possible - but it's quite clever at
> knowing what to do - e.g. if a list has already grown large then python
> assumes it might grow large again and keeps hold of a percenta
Hi,
I have the following simple code:
r = {}
r[1] = [0.00]
r_new = {}
print r[1][0]
r_new[1] = r[1]
r_new[1][0] = r[1][0] + 0.02
print r[1][0]
It outputs:
0.0
0.02
it is something strange to me since in the first and second case I
output the same variable (r[1][0]) and it the two cases it ha
On Tue, Feb 17, 2009 at 8:19 AM, Kurda Yon wrote:
> r_new[1] = r[1]
This is the problem. "r" is a dictionary, a set of key/object pairs in
essence. You're making the object that "r[1]" is pointing to a list, a
mutable sequence of items.
The expression "r[1]" will then return that list object and
"Paddy O'Loughlin" wrote:
> True, but you can use the global statement to refer to the variable
> within a function and read from the variable there, without it being
> already initialised in the module.
You don't need the global statement unless you plan to *write* the variable
from the functi
I have the following simple code:
r = {}
r[1] = [0.00]
r_new = {}
print r[1][0]
r_new[1] = r[1]
r_new[1][0] = r[1][0] + 0.02
print r[1][0]
It outputs:
0.0
0.02
it is something strange to me since in the first and second case I
output the same variable (r[1][0]) and it the two cases it has
On Feb 17, 7:28 am, Christian Heimes wrote:
> Peter Billam schrieb:
>
> > Greetings. (Newbie warning as usual) In Python3, sys.stdout is a
> > io.TextIOWrapper object; but I want to output bytes
> > (e.g. muscript -midi t > t.mid )
> > and they're coming out stringified :-( How can I either cha
On Feb 17, 2009, at 7:27 AM, 一首诗 wrote:
Hi all,
Recently I am studying some python ORM libraries, such as sqlalchemy.
These are very powerful technologies to handle database. But I think
my project are not complicated to enough to benefit from a complete
ORM system.
What I really want, is s
Philip Semanchuk wrote:
[... snip comments on SqlAlchemy which could likewise apply
to other similar offerings ...]
I don't intend this as a criticism of SqlAlchemy. On the contrary I am
impressed by what it does. But I often see people promoting ORM as the
solution to all database access prob
Philip Semanchuk wrote:
> In short, I gather that others on this list are a lot more fond of
> SqlAlchemy and ORMs in general than I am. Granted, my experience is
> very limited. I tried to integrate SqlAlchemy in one project,
> struggled for a long time to express how I wanted my tables joined,
>
rushen...@gmail.com wrote:
> As you mentioned, using multi cores makes programs more fast and more
> popular. But what about stackless python? Does it interpret same set
> of python libraries with Cpython or Does it have a special sub set?
Your assumption is wrong. Multiple cores are able to speed
After reading the docs and seeing a few examples i think this should
work ?
Am I forgetting something here or am I doing something stupid ?
Anyway I see my yellow screen, that has to count for something :)
from tkinter import *
from threading import Thread
class Weegbrug(Thread):
def __init__
Hi All,
new to python. i have a directory with about 50 text file and i need to
iterate through them and get
line 7 to 11 from each file and write those lines into another file(one file
that will contain all lines).
Cheers, Omer.
--
View this message in context:
http://www.nabble.com/Reading-fr
Jayson Santos:
> After changing my code to use only functions instead classes
> my code is too much faster.
> Here cProfile statistcs:
> Using old code : 633608 function calls in 1.361 CPU seconds
> Using new code: 475487 function calls in 0.800 CPU seconds
If you show a pastebin of the new versio
On 17 velj, 00:09, "alejandro" wrote:
> Provjeri da si nisi stavio ansii kada si instalirao wx.python.
> Mozes probat ubacit iznad svega u fajlu komentar u kojem pise da je fajl u
> UTF-8 i onda bi ti trebalo sljakat. Nadem sutra pa ti posaljem
Pozdrav / Hello,
It works now, all post were very u
On Feb 17, 2009, at 10:18 AM, Barak, Ron wrote:
I have a wxPython application that builds an internal database from
a list of files and then displays various aspects of that data,
in response to user's requests.
I want to add a module that finds events in a set of log files
(LogManager).
T
QOTW: "The hardest part of design ...is keeping features out." - Donald
Norman, design guru and former Apple exec
https://www.technologyreview.com/business/18621/
Two short recipes:
Determine whether a string is a number or not:
http://groups.google.com/group/comp.lang
On 2009-02-17 10:52, andrew cooke wrote:
Philip Semanchuk wrote:
In short, I gather that others on this list are a lot more fond of
SqlAlchemy and ORMs in general than I am. Granted, my experience is
very limited. I tried to integrate SqlAlchemy in one project,
struggled for a long time to expre
There exist a number of versioning schemes to keep track of software
version. Each developer certainly have it's own style and preferred
scheme. However, I am wonder if there is a specific versioning scheme
for python modules.
Regards,
Krzysztof
--
http://mail.python.org/mailman/listinfo/python-li
oamram a écrit :
Hi All,
new to python. i have a directory with about 50 text file and i need to
iterate through them and get
line 7 to 11 from each file and write those lines into another file(one file
that will contain all lines).
First create a function that read and parse one file
Then cre
On 2009-02-17, Christian Heimes wrote:
> Peter Billam schrieb:
>> Greetings. (Newbie warning as usual) In Python3, sys.stdout is a
>> io.TextIOWrapper object; but I want to output bytes
>> (e.g. muscript -midi t > t.mid )
>> and they're coming out stringified :-( How can I either change the
>>
On 2009-02-17 11:16, kretel wrote:
There exist a number of versioning schemes to keep track of software
version. Each developer certainly have it's own style and preferred
scheme. However, I am wonder if there is a specific versioning scheme
for python modules.
A number of Python tools that man
Casey wrote:
> Is this really the 'official' way to do this? This isn't meant to be
> confrontational or trolling; I honestly don't know the answer and I
> had similar questions when I first started with the 3.0 release
> candidates and I have yet to find a good answer in the Python v3.0
> documen
I would like to start write a Python script that upload multiple files
to a web server. I research the methods, and I am somewhat confused
between using the http & urllib2 modules. I assume (and could be
wrong) that the most basic method would be to use a cgi-Python script
on the web server then
oamram:
> i have a directory with about 50 text file and i need to
> iterate through them and get
> line 7 to 11 from each file and write those lines into another
> file(one file that will contain all lines).
Files can be iterated line-by-line, so this idiom:
for line in file: ...
will give you
On 17 fev, 14:00, bearophileh...@lycos.com wrote:
> Jayson Santos:
>
> > After changing my code to use only functions instead classes
> > my code is too much faster.
> > Here cProfile statistcs:
> > Using old code : 633608 function calls in 1.361 CPU seconds
> > Using new code: 475487 function call
Philip Semanchuk wrote:
> The general rule is that it is a lot easier to share data between
> threads than between processes. The multiprocessing library makes the
> latter easier but is only part of the standard library in Python >= 2.6.
> The design of your application matters a lot. For instance
bearophileh...@lycos.com wrote:
oamram:
i have a directory with about 50 text file and i need to
iterate through them and get
line 7 to 11 from each file and write those lines into another
file(one file that will contain all lines).
Files can be iterated line-by-line, so this idiom:
for line
On 2009-02-17, oamram wrote:
> i have a directory with about 50 text file and i need to
> iterate through them and get line 7 to 11 from each file and
> write those lines into another file(one file that will contain
> all lines).
Assuming this is a real task and not a homework problem, then
I'd
On Feb 17, 12:33 pm, Christian Heimes wrote:
> Yes, it's really the official way. You can google up the discussion
> between me and Guido on the python-dev list if you don't trust me. ;)
> The docs concur with me, too.
>
> http://docs.python.org/3.0/library/sys.html#sys.stdin
>
> Note: The standar
Casey schrieb:
> On Feb 17, 12:33 pm, Christian Heimes wrote:
>> Yes, it's really the official way. You can google up the discussion
>> between me and Guido on the python-dev list if you don't trust me. ;)
>> The docs concur with me, too.
>>
>> http://docs.python.org/3.0/library/sys.html#sys.stdin
Casey wrote:
... Is this the 'official' way to do this?... Why wouldn't you just use:
print(bytes.decode(b'abc\n'), end='')
Because that code is incapable of sending bytes that cannot be
interpreted as encoded in the "default" encoding. If you are
sending a picture, for example, all possible
Jayson Santos:
> And here is the final code:http://pastebin.com/f3e20d669
Note that if you use Psyco this lookup trick isn't useful, but if the
Psyco isn't available it can improve performance a little:
append = BitmapList['lines'].append
I suggest to replace this code:
red, green, blue
Assuming this is a real task and not a homework problem, then
I'd do it this way:
$ cd [directory containing 50 test files]
$ (for file in *; do head -n11 $file | tail -n5; done)
>/path/to/results-file.txt
I'd use sed:
sed -ns 7,11p /source/path/*.txt >/path/to/results.txt
hard to get
Hi,
Sorry for resurrecting an old thread, but it just bothers me that this
is the best way that python has to deal with killing running
functions... it's quite an ugly hack, no?
Is it a feature that's needed bit missing from python, or is it left out
on purpose (same way like java has deprecated t
> So is there some libraries like that?
I always use a DB-API implementation for the database I use,
i.e. psycopg/psycopg2.
Named tuples are really easy to provide:
class NamedTuple:
def __init__(self, names, values):
for name, value in izip(names, values):
setattr(self, name, valu
Steven D'Aprano wrote:
Diez B. Roggisch wrote:
Mirko Dziadzka schrieb:
I'm trying to find a way to output strings in the raw-string format, e.g.
print_as_raw_string(r"\.") should output r"\." instead of "\\." ...
In any case, this is just a variation of what repr() does.
repr(r'\.')
"'
1 - 100 of 164 matches
Mail list logo