On 06/07/2012 12:29 AM, Alexander Quest wrote:
> Hey all; my question is regarding editing Python code in Notepad++. When I
> run this piece of code in Notepad++:
>
> def fix_start(s):
> var1 = s[0]
> var2 = "*"
> var3 = s.replace(var1, var2)
>
> return var3
>
>
> I get an indentation err
Hey all; my question is regarding editing Python code in Notepad++. When I
run this piece of code in Notepad++:
def fix_start(s):
var1 = s[0]
var2 = "*"
var3 = s.replace(var1, var2)
return var3
I get an indentation error, which reads:
File "C:\google-python-exercises\google-python
On 06/06/12 20:33, dohoang4...@comcast.net wrote:
i am writing a python script that will be invoked as follows:
cmd_line = Popen(["egrep", "(x,y)", aLogFile], stdout=PIPE, stdin=PIPE,
stderr=STDOUT)
Assuming you really want to use egrep, why?
You could process the file directly in Python sea
On 06/06/12 21:32, Dave wrote:
I'm not sure where this comment belongs, but I want to share my
perspective on the documentation of these special method names. In the
following section there is an inconsistency which could be confusing to
someone just learning Python (e.g., me).
In general someo
Dave wrote:
I was reading some tutorial material on creating iterators. It shows the
following example implementation of an iterator:
class Reverse:
"""Iterator for looping over a sequence backwards."""
def __init__(self, data):
self.data = data
self.index = len(data)
Prasad, Ramit wrote:
That is, for loops first try to build an iterator by calling __iter__, and if
that fails they try the sequence protocol obj[0], obj[1], obj[2], ...
So...I could instead write __getitem__ for the same effect?
Er, no... __getitem__ and __iter__ do very different things. __
Prasad, Ramit wrote:
But more importantly, some years ago (Python 2.4, about 8 years ago?) the
Python developers found a really neat trick that they can do to optimize
string concatenation so it doesn't need to repeatedly copy characters over
and
over and over again. I won't go into details, but
> That is, for loops first try to build an iterator by calling __iter__, and if
> that fails they try the sequence protocol obj[0], obj[1], obj[2], ...
So...I could instead write __getitem__ for the same effect?
Ramit
Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Mai
Prasad, Ramit wrote:
For instance, the __iter__() method is called by the iter() built-in.
It can also called by any other piece of code that needs to acquire an
iterator from a generic container object. There is no list of all
such pieces of code that could ever call the __iter__() method of yo
> For instance, the __iter__() method is called by the iter() built-in.
> It can also called by any other piece of code that needs to acquire an
> iterator from a generic container object. There is no list of all
> such pieces of code that could ever call the __iter__() method of your
A lot of ti
Please respond back to the list (so others know what worked
and that the problem is solved).
:)
>
> hi all,
>
> thanks a lot for your quick response.
>
> Dave, actually it's a 2 arguments. Sorry, i did not make it clear in my
> question. I used Ramit's hint and it worked. The code should
On Wed, Jun 6, 2012 at 4:32 PM, Dave wrote:
> I'm not sure where this comment belongs, but I want to share my perspective
> on the documentation of these special method names. In the following section
> there is an inconsistency which could be confusing to someone just learning
> Python (e.g., me)
I'm not sure where this comment belongs, but I want to share my perspective
on the documentation of these special method names. In the following
section there is an inconsistency which could be confusing to someone just
learning Python (e.g., me).
In the sentence on implementing custom mapping obj
> > x = "Device " + sys.argv[1] + " restored the database"
> > y = "Created connection to " + sys.argv[1]
> >
> > cmd_line = Popen(["egrep", "(x,y)", aLogFile], stdout=PIPE, stdin=PIPE,
> > stderr=STDOUT)
> >
> > the above code does not work because it will look for x and y in aLogFile
> x = "Device " + sys.argv[1] + " restored the database"
> y = "Created connection to " + sys.argv[1]
>
> cmd_line = Popen(["egrep", "(x,y)", aLogFile], stdout=PIPE, stdin=PIPE,
> stderr=STDOUT)
>
> the above code does not work because it will look for x and y in aLogFile
> instead of
On Wed, Jun 6, 2012 at 3:40 PM, Mark Lawrence wrote:
> On 06/06/2012 20:19, Dave wrote:
>
>> I was reading some tutorial material on creating iterators. It shows the
>> following example implementation of an iterator:
>>
>> class Reverse:
>> """Iterator for looping over a sequence backwards.""
On Wed, Jun 6, 2012 at 3:30 PM, Prasad, Ramit wrote:
> > My question is how was I supposed to kinow that the function I call
> using the
> > name iter() is implemented using the name __iter__()?
> >
> > Is there a rule that describes when I would implement an attribute name
> with
> > leading and
On 06/06/2012 03:33 PM, dohoang4...@comcast.net wrote:
> i am writing a python script that will be invoked as follows:
>
> myScript.py
>
> and the script is as follwos:
>
> x = "Device " + sys.argv[1] + " restored the database"
> y = "Created connection to " + sys.argv[1]
>
> cmd_line = Popen
On 06/06/2012 20:19, Dave wrote:
I was reading some tutorial material on creating iterators. It shows the
following example implementation of an iterator:
class Reverse:
"""Iterator for looping over a sequence backwards."""
def __init__(self, data):
self.data = data
s
>
> 1. import sqlite3
> 2. conn=sqlite3.connect("mydb2.db")
> 3. c=conn.cursor()
> 4. c.execute('create table family (Id integer primary key, name text, age
> integer)')
> 5. c.execute("insert into family values (1,'elham',32)")
> 6. c.execute('select * from family')
> 7. conn.commit()
> 8. for i
i am writing a python script that will be invoked as follows:
myScript.py
and the script is as follwos:
x = "Device " + sys.argv[1] + " restored the database"
y = "Created connection to " + sys.argv[1]
cmd_line = Popen(["egrep", "(x,y)", aLogFile], stdout=PIPE, stdin=PIPE,
stderr=STDOUT)
> My question is how was I supposed to kinow that the function I call using the
> name iter() is implemented using the name __iter__()?
>
> Is there a rule that describes when I would implement an attribute name with
> leading and trailing double underscores, and then call it without those
> under
Hi All,
hi Joel,
Regarding sqlite3 practice code below:
1. import sqlite3
2. conn=sqlite3.connect("mydb2.db")
3. c=conn.cursor()
4. c.execute('create table family (Id integer primary key, name text,
age integer)')
5. c.execute("insert into family values (1,'elham',32)")
6.
I was reading some tutorial material on creating iterators. It shows the
following example implementation of an iterator:
class Reverse:
"""Iterator for looping over a sequence backwards."""
def __init__(self, data):
self.data = data
self.index = len(data)
def __iter__(
On Tue, May 29, 2012 at 9:26 PM, Opher Lubzens wrote:
>
> That actually might be workable- I'll have to look into it. I'll have
> to understand them better then I do after a brief look in their
> webpages and check whether they're compatible with our specific flavor
> of OS, since both of these ar
Le 06/06/2012 11:02, BILAL Mustapha a écrit :
Hello,
I am working to connect to a serial link (USB). In order to do that I
have to write this command:
sudo ../../tools/stm32w/serialdump-linux -b115200 -d1 (keeping in
mind dat*serialdump-linux*, which is in the path, is not a folder,
it
Marc Tompkins, 06.06.2012 10:21:
> On Tue, Jun 5, 2012 at 11:22 PM, Stefan Behnel wrote:
>
>> You can do this:
>>
>>connection = urllib2.urlopen(url)
>>tree = etree.parse(connection, my_html_parser)
>>
>> Alternatively, use fromstring() to parse from strings:
>>
>>page = urllib2.urlope
Hello,
I am working to connect to a serial link (USB). In order to do that I
have to write this command:
sudo ../../tools/stm32w/serialdump-linux -b115200 -d1 (keeping in
mind dat*serialdump-linux*, which is in the path, is not a folder, it's
an executable)
To get to the root, I have
On Tue, Jun 5, 2012 at 11:22 PM, Stefan Behnel wrote:
> You can do this:
>
>connection = urllib2.urlopen(url)
>tree = etree.parse(connection, my_html_parser)
>
> Alternatively, use fromstring() to parse from strings:
>
>page = urllib2.urlopen(url)
>pagecontents = page.read()
>
Hello,
Thank you for your reply.
Please read underlines.
Le 05/06/2012 23:12, Alan Gauld a écrit :
On 05/06/12 12:53, BILAL Mustapha wrote:
Hello,
Hi, Its best not to hijack somebody else's thread coz it messes up all
the threaded mail/news readers out there. (At least you changed the
s
30 matches
Mail list logo