On Wed, Apr 17, 2013 at 7:40 AM, Walter Hurry wrote:
> On Wed, 17 Apr 2013 01:30:03 +1000, Chris Angelico wrote:
>
>> By the way, regarding your email address: there are no cheat codes in
>> Python
>
> ROFLMAO. Incidentally, my son used to use IDDQD rather than IDKFA.
>
> I of course spurned all s
On Wed, 17 Apr 2013 01:30:03 +1000, Chris Angelico wrote:
> By the way, regarding your email address: there are no cheat codes in
> Python
ROFLMAO. Incidentally, my son used to use IDDQD rather than IDKFA.
I of course spurned all such, since I preferred to do it the hard way.
Thus I was Doomed.
On 2013-04-16, Lele Gaifax wrote:
> Neil Cerutti writes:
>
>> Imagine something like the following for loop taking place
>> somewhere:
>>
>> for (int i = 2; i <= 0; --i) {
>> fprintf(a[i]);
>> }
>
> Neil most probably meant
>
> for (int i = 2; i >= 0; --i) {
> fprintf(a[i]);
> }
>
> where
Neil Cerutti writes:
> Imagine something like the following for loop taking place
> somewhere:
>
> for (int i = 2; i <= 0; --i) {
> fprintf(a[i]);
> }
Neil most probably meant
for (int i = 2; i >= 0; --i) {
fprintf(a[i]);
}
where "fprintf" is actually a fictitious "do_something" functi
On 2013-04-16, idkfaidkfaid...@gmail.com wrote:
> Hi all,
> i'm programming in python for the first time (usually i use C as programming
> language). I don't understand these results:
>
a=[1,2,3,4,5]
a[:-1]
> [1, 2, 3, 4]
a[::-1]
> [5, 4, 3, 2, 1]
a[2::-1]
> [3, 2, 1]
The thi
When slicing: l[start:end:step]
In your example of "a[2::-1]" you are reversing the list by using a step of
-1, then you are slicing at index 2 (third element).
*Matt Jones*
On Tue, Apr 16, 2013 at 10:30 AM, Chris Angelico wrote:
> On Wed, Apr 17, 2013 at 1:20 AM, wrote:
> > Hi all,
> > i'm
On Wed, Apr 17, 2013 at 1:20 AM, wrote:
> Hi all,
> i'm programming in python for the first time (usually i use C as programming
> language). I don't understand these results:
>
a=[1,2,3,4,5]
a[:-1]
> [1, 2, 3, 4]
a[::-1]
> [5, 4, 3, 2, 1]
a[2::-1]
> [3, 2, 1]
>
> what does a
On May 16, 9:54 pm, alex23 wrote:
> On May 17, 11:45 am, gwhite wrote:
>
> > 1. If running from the system command line, or the Sypder "run"
> > button, "__name__" is "__main__" rather than "newbie00", as seen
> > above.
>
> > So, how would I get the file name newbie00.py in these two noted
> >
On May 16, 9:33 pm, Steven D'Aprano wrote:
> On Wed, 16 May 2012 18:45:39 -0700, gwhite wrote:
> > #!
> > # Filename: newbie00.py
>
> "Supposed to"? Nothing -- it is completely optional.
>
> #! ("hash-bang") lines currently do nothing on Windows machines, they are
> just comments. However, on Uni
Steven D'Aprano wrote:
>#! ("hash-bang") lines currently do nothing on Windows machines, they are
>just comments. However, on Unix and Linux machines (and Macintosh?) they
>are interpreted by the shell (equivalent to cmd.exe or command.com), in
>order to tell the shell what interpreter to use
On 17/05/2012 05:29, Chris Rebert wrote:
On Wed, May 16, 2012 at 6:45 PM, gwhite wrote:
#!
That's a shebang line. See http://en.wikipedia.org/wiki/Shebang_(Unix)
It's doesn't matter at all since you're on Windows. On Unix-like
systems, one typically writes:
#!/usr/bin/env python
# File
On 05/17/2012 12:54 AM, alex23 wrote:
> On May 17, 11:45 am, gwhite wrote:
>
> I don't think that only-one-import is true for scripts that are run
> from the command line, though. They can exist as both '__main__' and
> their actual name in the module table. (Someone please correct me if
> this
On May 17, 11:45 am, gwhite wrote:
> 1. If running from the system command line, or the Sypder "run"
> button, "__name__" is "__main__" rather than "newbie00", as seen
> above.
>
> So, how would I get the file name newbie00.py in these two noted
> cases?
You can get it from the file name:
i
On Wed, 16 May 2012 18:45:39 -0700, gwhite wrote:
> #!
> # Filename: newbie00.py
"Supposed to"? Nothing -- it is completely optional.
#! ("hash-bang") lines currently do nothing on Windows machines, they are
just comments. However, on Unix and Linux machines (and Macintosh?) they
are interpre
On Wed, May 16, 2012 at 6:45 PM, gwhite wrote:
> Hi,
>
> I am a newbie running the latest pythonxy (2.7.2.1) & spyder and
> python 2.7.2. I suspect my questions are mostly basic to python, and
> not specific to Spyder or iPython.
>
> Note: Up until now, I mainly used MATLAB, and thus need to de-
On 5/16/2012 9:45 PM, gwhite wrote:
Hi,
I am a newbie running the latest pythonxy (2.7.2.1)& spyder and
python 2.7.2. I suspect my questions are mostly basic to python, and
not specific to Spyder or iPython.
Note: Up until now, I mainly used MATLAB, and thus need to de-program
myself appropr
Mahmoud Abdel-Fattah wrote:
Hello,
I'm coming from PHP background ant totally new to Python, I just
started using scrapy, but has some generic question in python.
1. How can I write the following code in easier way in Python ?
if len(item['description']) > 0:
item['description'] =
On Sun, Apr 15, 2012 at 9:00 AM, MRAB wrote:
> re.match(...) returns either a match object or None. In a condition, a
> match object always evaluates as True and None always evaluates as
> False.
Yes, should have clarified that. It's a deliberate feature of the re
module that you can do this. Ver
On 14/04/2012 23:45, Chris Angelico wrote:
On Sun, Apr 15, 2012 at 8:41 AM, Mahmoud Abdel-Fattah
wrote:
item['author_brand'] = author_brand.group(2) if type(author_brand) != None
else ''
Almost there! :)
None is a singleton, not a type; you don't need to check
type(author_brand) but rathe
On Sun, Apr 15, 2012 at 8:41 AM, Mahmoud Abdel-Fattah
wrote:
> item['author_brand'] = author_brand.group(2) if type(author_brand) != None
> else ''
Almost there! :)
None is a singleton, not a type; you don't need to check
type(author_brand) but rather its identity. Use "author_brand is not
None"
Thanks ChrisA a lot.
I just tried what you said, but I got an error, here's what I tried :
item['name'] = hxs.select('//div[@id="center-main"]/h1/text()').extract()[0]
author_brand = re.match(r'^[.*] - (.*)$', item['name'], re.I|re.S|re.M)
item['author_brand'] = author_brand.group(2) if type(autho
:
> 1. How can I write the following code in easier way in Python ?
> if len(item['description']) > 0:
> item['description'] = item['description'][0]
> else:
> item['description'] = ''
Assuming item['description'] is a string, all you need is
>>> item['description
On Sun, Apr 15, 2012 at 8:16 AM, Mahmoud Abdel-Fattah
wrote:
> Hello,
>
> I'm coming from PHP background ant totally new to Python, I just started
> using scrapy, but has some generic question in python.
>
> 1. How can I write the following code in easier way in Python ?
> if len(item['description
Title: Re: Newbie questions for Python usage
Thanks
Fred.
> just assign to the attribute and be done
with> it. if you want to use a placeholder value, use
None:
I thought I had tried that already but got an error.
I'll try it again, and as for the 2nd one, I was hoping t
Caolan wrote:
>1. I understand HOW to use the lambda operator, but WHY would you
> want to use it? Can anyone please give an example of WHY you would
> need it as opposed to just declaring a function either in the
> local scope, or outside?
you don't *need* it, because
meeper34 wrote:
> Hi,
>
> I'm just starting out with Python, and so far I am thoroughly impressed
> with what you can do very easily with the language.
>
> I'm coming from a
> C++ background here. A couple of questions came up as I was thinking
> about dynamically typed languages:
>
> 1. If so
meeper34 wrote:
> 4. Really basic question, and I'm sure I will learn this very quickly
> with more reading, but I'm confused by the lack of an entry point in a
> Python app, i.e. int main().
Keir's answer about testing for __main__ is good, but it might also help
you to think a bit about what
Hi!
1. Documentation... sorry...
2. There are no standars, it depends on the apidoc tool you want to use
3. I don't know, but when you extract the api documentation (using
tools as epydoc or happydoc) you have all the information you need (I
think)
4. As your python code is a script code, you
meeper34 wrote:
> Hi,
>
> I'm just starting out with Python, and so far I am thoroughly impressed
> with what you can do very easily with the language. I'm coming from a
> C++ background here. A couple of questions came up as I was thinking
> about dynamically typed languages:
>
> 1. If someone
On Saturday 05 November 2005 22:02, john boy wrote:
> have a few questions...i'm a newbieso i'd appreciate any help
>
> 1- what is the difference between Python GUI and Python command line?
GUI means "graphical user interface", a command line is something you type
commands into.
>
> 2-in Pyt
On Mon, 2004-12-13 at 11:30, houbahop -->
> thanks, very usefull answer.
>
>
> > Immutable types (e.g. strings, numbers, tuples) are generally returned
> > directly from functions, rather than returned as 'output parameters'. The
> > ability to return multiple values easily (via "return a, b, c
thanks, very usefull answer.
> Immutable types (e.g. strings, numbers, tuples) are generally returned
> directly from functions, rather than returned as 'output parameters'. The
> ability to return multiple values easily (via "return a, b, c" & "x, y, z
> = myfunc()" generally eliminates the n
Nick Coghlan wrote:
> Python could be said to pass everything by reference. You are getting caught
> more by the
> difference between mutable and immutable types, than by the distinction
> between 'pass by
> reference' and 'pass by value' that other languages have (Python actually
> uses a bl
houbahop wrote:
thanks, very usefull answer.
Immutable types (e.g. strings, numbers, tuples) are generally returned
directly from functions, rather than returned as 'output parameters'. The
ability to return multiple values easily (via "return a, b, c" & "x, y, z
= myfunc()" generally eliminate
"houbahop Thank you everyone, but I still not understand why such a comon feature like
passing parameters byref that is present in most serious programming
languages is not possible in a clean way,here in python.
I have the habit to never use globals as far as possible and this involve
that my m
houbahop wrote:
Thank you everyone, but I still not understand why such a comon feature like
passing parameters byref that is present in most serious programming
languages is not possible in a clean way,here in python.
I have the habit to never use globals as far as possible and this involve
tha
John Machin wrote:
>> > Even less overhead: del var1[:]
>>
>> even less overhead:
>>
>> var1 = []
>
> Firstly, your replacement is not functionally equivalent.
do you really have to tell me that? (as I said, if you rely on the difference,
your design is probably flawed)
> Secondly, it appea
Fredrik Lundh wrote:
> John Machin wrote:
>
> >> Of course, in this simple case, I wouldn't be likely to write the
clear
> >> function since the inline code is simpler and has less overhead:
> >>
> >> def main()
> >> var1 = []
> >> var1.append('a')
> >> var1[:] = []
> >
> > Even less
Fredrik Lundh wrote:
John Machin wrote:
Of course, in this simple case, I wouldn't be likely to write the clear
function since the inline code is simpler and has less overhead:
def main()
var1 = []
var1.append('a')
var1[:] = []
Even less overhead: del var1[:]
even less overhead:
v
John Machin wrote:
>> Of course, in this simple case, I wouldn't be likely to write the clear
>> function since the inline code is simpler and has less overhead:
>>
>> def main()
>> var1 = []
>> var1.append('a')
>> var1[:] = []
>
> Even less overhead: del var1[:]
even less overhead
"Dennis Lee Bieber" <[EMAIL PROTECTED]> a écrit dans le message de news:
[EMAIL PROTECTED]
> On Sat, 11 Dec 2004 12:43:01 GMT, "houbahop" me)@chello.fr> declaimed the following in comp.lang.python:
>
>> Thank you everyone, but I still not understand why such a comon feature
>> like
>> passing p
Steven Bethard wrote:
>
> Of course, in this simple case, I wouldn't be likely to write the
clear
> function since the inline code is simpler and has less overhead:
>
> def main()
> var1 = []
> var1.append('a')
> var1[:] = []
Even less overhead: del var1[:]
--
http://mail.python.
Thank you Steven,
The funny thing is that I have taken a look at wikipedia just before to be
sure that I wasn't wrong :D
I agree with you about not making a clear function to just put what I've put
in my sample, but
this sample was more simple that what I really need for explaining purpose.
In r
houbahop wrote:
Hello again everyone ,
var2[:]=[] has solved my problem, and I don't understand why it is
programming by side effect.
I don't think it's bad, look at this, it's what I've done :
def Clear(lvar)
lvar[:]=[]
def main (starting class)
var1=[]
var1.append('a')
Clear(var1)
houbahop wrote:
Passing a pointer by value appears to me as passing a var by reference.
Well, at least in the PL literature, there's a subtle difference. If
Python supported pass-by-reference, you could do something like:
>>> def clear(byref lst):
... lst = []
...
>>> x = [pow(x, 11, 17) for
Hello again everyone ,
var2[:]=[] has solved my problem, and I don't understand why it is
programming by side effect.
I don't think it's bad, look at this, it's what I've done :
def Clear(lvar)
lvar[:]=[]
def main (starting class)
var1=[]
var1.append('a')
Clear(var1)
var1 can only
> Thanks I will try all of that, but what does really means mutating in
> python? It's the first time I hear this word in programming :))
An object is called mutable if you can alter it - immutable otherwise. In
java and python e.g. strings are immutable. In python, tuples are
immutable:
>>> a =
Hi,
"Steven Bethard" <[EMAIL PROTECTED]> a écrit dans le message de news:
[EMAIL PROTECTED]
> houbahop wrote:
>> Thank you everyone, but I still not understand why such a comon feature
>> like passing parameters byref that is present in most serious programming
>> languages is not possible in a
In article <[EMAIL PROTECTED]>,
"houbahop" wrote:
>Thank you everyone, but I still not understand why such a comon feature like
>passing parameters byref that is present in most serious programming
>languages is not possible in a clean way,here in python.
>
>I have the habit to never use globals a
houbahop wrote:
Thank you everyone, but I still not understand why such a comon feature like
passing parameters byref that is present in most serious programming
languages is not possible in a clean way,here in python.
I understand from this statement that Java is not a serious programming
langua
Thank you everyone, but I still not understand why such a comon feature like
passing parameters byref that is present in most serious programming
languages is not possible in a clean way,here in python.
I have the habit to never use globals as far as possible and this involve
that my main functi
houbahop wrote:
def RAZVarAnimesDuJour(self,oSortiesAnimeTitreLabel):
for i in xrange(len(oSortiesAnimeTitreLabel)):
del oSortiesAnimeTitreLabel[i]
it doesn't emty my var (i don't want to destroy the var, just make it like
if it just have been created
Other posts are miss
Adam DePrince <[EMAIL PROTECTED]> writes:
> Alright. Now, as Erik pointed out if you assign to the variable the
> computer will add that to the local name space. This happens at
> "compile" time (which is right after you hit enter twice at the CPython
> command line.)
>
> For an example of this
On Fri, 2004-12-10 at 22:17, Erik Johnson wrote:
> > do yo have any idea of what is causing this problem?
> > is it possible to do self.SortiesAnimeTitreLabel = [] to reset the var?
> (it
> > seems to work outside of the sub, but I believe that the var I'm erasing
> is
> > not the one I want but a
> do yo have any idea of what is causing this problem?
> is it possible to do self.SortiesAnimeTitreLabel = [] to reset the var?
(it
> seems to work outside of the sub, but I believe that the var I'm erasing
is
> not the one I want but a local copy.
Yeah. I'm no Python guru, but I have a pre
55 matches
Mail list logo