[Tutor] Python 3.6.5 for MAC

2018-04-23 Thread Giorgio De Angelis
Hello guys,

I have a problem with my MacBook Pro ’13, version 10.13.4, because when I try 
to open the shell it says that it couldn’t make any connection because it 
wasn’t able to make a subprocess. Can you help me?

Giorgio
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] WSGI / Apache

2010-03-10 Thread Giorgio
2010/3/8 Benno Lang 

>
>
> WSGI is based on CGI, so I imagine that it's not too difficult to have
> a wrapper that converts between the protocols. I haven't tried
> wsgiref, though.
>

Yes Benno it isn't. It seems that mod_wsgi is the most used alternative.


>
> > Do you have any idea i should use mod_wsgi instead of wsgiref + mod_cgi?
>
> From your application's perspective, if it talks WSGI it shouldn't
> make any difference. But if you're using GAE, what good will it do to
> have a local Apache server anyway?
>

Ok, that was a general question, not GAE related. Someone says that mod_wsgi
is faster than wsgiref + cgi.


>
> Cheers,
> benno
>



-- 
--
AnotherNetFellow
Email: anothernetfel...@gmail.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Encoding

2010-03-10 Thread Giorgio
2010/3/8 Dave Angel 

>
>>  You still didn't provide the full context.  Are you trying to do store
> binary data, or not?
>

Yes i think ti's binary data. I'm just reading with file.read a JPG image.

Stefan: yes, read that tutorial :)

Giorgio

>
>
>


-- 
--
AnotherNetFellow
Email: anothernetfel...@gmail.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Encoding

2010-03-07 Thread Giorgio
2010/3/7 Dave Angel 

>
> Those two lines don't make any sense by themselves.  Show us some context,
> and we can more sensibly comment on them.  And try not to use names that
> hide built-in keywords, or Python stdlib names.
>

Hi Dave,

I'm considering Amazon SimpleDB as an alternative to PGSQL, but i need to
store blobs.

Amazon's FAQs says that:

"Q: What kind of data can I store?
You can store any UTF-8 string data in Amazon SimpleDB. Please refer
to the Amazon
Web Services Customer Agreement <http://aws.amazon.com/agreement> for
details."

This is the problem. Any idea?


> DaveA
>

Giorgio



-- 
--
AnotherNetFellow
Email: anothernetfel...@gmail.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Encoding

2010-03-07 Thread Giorgio
2010/3/7 spir 

>
> > Oh, right. And, if i'm not wrong B is an UTF8 string decoded to unicode
> (due
> > to the coding: statement at the top of the file) and re-encoded to latin1
>
> Si! :-)
>

Ahah. Ok, Grazie!

One more question: Amazon SimpleDB only accepts UTF8.

So, let's say i have to put into an image file:

filestream = file.read()
filetoput = filestream.encode('utf-8')

Do you think this is ok?

Oh, of course everything url-encoded then

Giorgio


>
> Denis
> --
> 
>
> la vita e estrany
>
> spir.wikidot.com
>
>


-- 
--
AnotherNetFellow
Email: anothernetfel...@gmail.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Encoding

2010-03-06 Thread Giorgio
2010/3/5 Dave Angel 

I'm not angry, and I'm sorry if I seemed angry.  Tone of voice is hard to
> convey in a text message.


Ok, sorry. I've misunderstood your mail :D


> I'm still not sure whether your confusion is to what the rules are, or why
> the rules were made that way.


WHY the rules are made that way. But now it's clear.

2010/3/6 Mark Tolonen 
>

>
>  Maybe this will help:
>
>   # coding: utf-8
>
>   a = "ciao è ciao"
>   b = u"ciao è ciao".encode('latin-1')
>
> a is a UTF-8 string, due to #coding line in source.
> b is a latin-1 string, due to explicit encoding.
>

Oh, right. And, if i'm not wrong B is an UTF8 string decoded to unicode (due
to the coding: statement at the top of the file) and re-encoded to latin1


> -Mark


Thankyou again

Giorgio




-- 
--
AnotherNetFellow
Email: anothernetfel...@gmail.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Encoding

2010-03-05 Thread Giorgio
2010/3/5 Dave Angel 
>
> In other words, you don't understand my paragraph above.


Maybe. But please don't be angry. I'm here to learn, and as i've run into a
very difficult concept I want to fully undestand it.


> Once the string is stored in t as an 8 bit string, it's irrelevant what the
> source file encoding was.


Ok, you've said this 2 times, but, please, can you tell me why? I think
that's the key passage to understand how encoding of strings works. The
source file encoding affects all file lines, also strings. If my encoding is
UTF8 python will read the string "ciao è ciao" as 'ciao \xc3\xa8 ciao' but
if it's latin1 it will read 'ciao \xe8 ciao'. So, how can it be irrelevant?

I think the problem is that i can't find any difference between 2 lines
quoted above:

a = u"ciao è ciao"

and

a = "ciao è ciao"
a = unicode(a)


> If you then (whether it's in the next line, or ten thousand calls later)
> try to convert to unicode without specifying a decoder, it uses the default
> encoder, which is a application wide thing, and not a source file thing.  To
> see what it is on your system, use sys.getdefaultencoding().
>

And this is ok. Spir said that it uses ASCII, you now say that it uses the
default encoder. I think that ASCII on spir's system is the default encoder
so.


> The point is that there isn't just one global value, and it's a good thing.
>  You should figure everywhere characters come into  your program (eg. source
> files, raw_input, file i/o...) and everywhere characters go out of your
> program, and deal with each of them individually.


Ok. But it always happen this way. I hardly ever have to work with strings
defined in the file.


> Don't store anything internally as strings, and you won't create the
> ambiguity you have with your 't' variable above.
>
> DaveA
>

Thankyou Dave

Giorgio



-- 
--
AnotherNetFellow
Email: anothernetfel...@gmail.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Encoding

2010-03-05 Thread Giorgio
>
>
>> Ok,so you confirm that:
>>
>> s = u"ciao è ciao" will use the file specified encoding, and that
>>
>> t = "ciao è ciao"
>> t = unicode(t)
>>
>> Will use, if not specified in the function, ASCII. It will ignore the
>> encoding I specified on the top of the file. right?
>>
>>
>>
> A literal  "u" string, and only such a (unicode) literal string, is
> affected by the encoding specification.  Once some bytes have been stored in
> a 8 bit string, the system does *not* keep track of where they came from,
> and any conversions then (even if they're on an adjacent line) will use the
> default decoder.  This is a logical example of what somebody said earlier on
> the thread -- decode any data to unicode as early as possible, and deal only
> with unicode strings in the program.  Then, if necessary, encode them into
> whatever output form immediately before (or while) outputting them.
>
>
>
 Ok Dave, What i don't understand is why:

s = u"ciao è ciao" is converting a string to unicode, decoding it from the
specified encoding but

t = "ciao è ciao"
t = unicode(t)

That should do exactly the same instead of using the specified encoding
always assume that if i'm not telling the function what the encoding is, i'm
using ASCII.

Is this a bug?

Giorgio
-- 
--
AnotherNetFellow
Email: anothernetfel...@gmail.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] WSGI / Apache

2010-03-04 Thread Giorgio
Hi,

as you all probably know i'm using the Google App Engine platform for my
python code.

As I learn python i try to understand more and more how GAE works. Today
i've noticed that all applications on GAE are running on WSGI. A quick
Google search told me that WSGI is a new standard for web applications,
developed by python.

So, I decided to try it. With Apache.

I found that Apache has a dedicated mod, mod_wsgi to handle this type of
requests. But, as I always try to be "platform/daemon indipended" i've
looked for other solutions. I found WSGIREF that as wsgi.org states
"includes a threaded HTTP server, a CGI server (for running any WSGI
application as a CGI script)".

So it seems that wsgiref, that is actually included in python, can "convert"
my apps to work with a standard CGI interface (in other words, working with
EVERY server that supports CGI not only with apache and his dedicated mod).
Can you confirm this?

Do you have any idea i should use mod_wsgi instead of wsgiref + mod_cgi?

Thankyou

Giorgio

-- 
--
AnotherNetFellow
Email: anothernetfel...@gmail.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Encoding

2010-03-04 Thread Giorgio
2010/3/4 spir 

>
>
> How do you know your win XP terminal is configured to deal with text using
> utf8? Why do you think it should?
>

I think there is an option in IDLE configuration to set this. So, if my
entire system is not utf8 i can't use the IDLE for this test?


>
> This trial uses the default format of your system. It does the same as
>   a = "giorgio è giorgio".encode(default_format)
> It's a shorcut for ustring *literals* (constants), directly expressed by
> the programmer. In source code, it would use the format specified on top of
> the file.
>



> This trial uses ascii because you give no format (yes, it can be seen as a
> flaw). It does the same as
>   a = "giorgio è giorgio".encode("ascii")
>

Ok,so you confirm that:

s = u"ciao è ciao" will use the file specified encoding, and that

t = "ciao è ciao"
t = unicode(t)

Will use, if not specified in the function, ASCII. It will ignore the
encoding I specified on the top of the file. right?

Again, thankyou. I'm loving python and his community.

Giorgio




-- 
--
AnotherNetFellow
Email: anothernetfel...@gmail.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Encoding

2010-03-04 Thread Giorgio
Thankyou.

You have clarificated many things in those emails. Due to high numbers of
messages i won't quote everything.

So, as i can clearly understand reading last spir's post, python gets
strings encoded by my editor and to convert them to unicode i need to
specify HOW they're encoded. This makes clear this example:

c = "giorgio è giorgio"
d = c.decode("utf8")

I create an utf8 string, and to convert it into unicode i need to tell
python that the string IS utf8.

Just don't understand why in my Windows XP computer in Python IDLE doesn't
work:

>>>  RESTART
============
>>>
>>> c = "giorgio è giorgio"
>>> c
'giorgio \xe8 giorgio'
>>> d = c.decode("utf8")

Traceback (most recent call last):
  File "", line 1, in 
d = c.decode("utf8")
  File "C:\Python26\lib\encodings\utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode bytes in position 8-10:
invalid data
>>>

In IDLE options i've set encoding to UTF8 of course. I also have some linux
servers where i can try the IDLE but Putty doesn't seem to support UTF8.

But, let's continue:

In that example i've specified UTF8 in the decode method. If i hadn't set it
python would have taken the one i specified in the second line of the file,
right?

As last point, i can't understand why this works:

>>> a = u"giorgio è giorgio"
>>> a
u'giorgio \xe8 giorgio'

And this one doesn't:

>>> a = "giorgio è giorgio"
>>> b = unicode(a)

Traceback (most recent call last):
  File "", line 1, in 
b = unicode(a)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe8 in position 8:
ordinal not in range(128)
>>>

The second doesn't work because i have not told python how the string was
encoded. But in the first too i haven't specified the encoding O_O.

Thankyou again for your help.

Giorgio
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Encoding

2010-03-03 Thread Giorgio
I'm sorry, it's utf8_unicode_ci that's confusing me.

So, "UTF-8 is one of the most commonly used encodings. UTF stands for
"Unicode Transformation Format"" UTF8 is, we can say, a type of "unicode",
right? And what about utf8_unicode_ci in mysql?

Giorgio

2010/3/3 Stefan Behnel 

> Giorgio, 03.03.2010 18:28:
>
>  string = u"blabla"
>>
>> This is unicode, ok. Unicode UTF-8?
>>
>
> No, not UTF-8. Unicode.
>
> You may want to read this:
>
> http://www.amk.ca/python/howto/unicode
>
>
> Stefan
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>



-- 
--
AnotherNetFellow
Email: anothernetfel...@gmail.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Encoding

2010-03-03 Thread Giorgio
Please let me post the third update O_o. You can forgot other 2, i'll put
them into this email.

---
>>> s = "ciao è ciao"
>>> print s
ciao è ciao
>>> s.encode('utf-8')

Traceback (most recent call last):
  File "", line 1, in 
s.encode('utf-8')
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe8 in position 5:
ordinal not in range(128)
---

I am getting more and more confused.

I was coding in PHP and was saving some strings in the DB. Was using
utf8_encode to encode them before sending to the utf8_unicode_ci table. Ok,
the result was that strings were "double encoded". To fix that I simply
removed the utf8_encode() function and put the "raw" data in the database
(that converts them in utf8). In other words, in PHP, I can encode a string
multiple times:

$c = "giorgio è giorgio";
$c = utf8_encode($c); // this will work in an utf8 html page
$d = utf8_encode($c); // this won't work, will print a strange letter
$d = utf8_decode($d); // this will work. will print an utf8 string

Ok, now, the point is: you (and the manual) said that this line:

s = u"giorgio è giorgio"

will convert the string as unicode. But also said that the part between ""
will be encoded with my editor BEFORE getting encoded in unicode by python.
So please pay attention to this example:

My editor is working in UTF8. I create this:

c = "giorgio è giorgio" // This will be an UTF8 string because of the file's
encoding
d = unicode(c) // This will be an unicode string
e = c.encode() // How will be encoded this string? If PY is working like PHP
this will be an utf8 string.

Can you help me?

Thankyou VERY much

Giorgio
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Encoding

2010-03-03 Thread Giorgio
Ops, i have another update:

string = u"blabla"

This is unicode, ok. Unicode UTF-8?

Thankyou

2010/3/3 Giorgio 

> Ok.
>
> So, how do you encode .py files? UTF-8?
>
> 2010/3/3 Dave Angel 
>
> Giorgio wrote:
>>
>>>
>>>>
>>>>>  Depends on your python version. If you use python 2.x, you have to use
>>>>> a
>>>>>
>>>>>
>>>> u before the string:
>>>>
>>>> s = u'Hallo World'
>>>>
>>>>
>>>
>>>
>>> Ok. So, let's go back to my first question:
>>>
>>> s = u'Hallo World' is unicode in python 2.x -> ok
>>> s = 'Hallo World' how is encoded?
>>>
>>>
>>>
>> Since it's a quote literal in your source code, it's encoded by your text
>> editor when it saves the file, and you tell Python which encoding it was by
>> the second line of your source file, right after the shebang line.
>>
>> A sequence of bytes in an html file should be should have its encoding
>> identified by the tag at the top of the html file.  And I'd  *guess* that on
>> a form result, the encoding can be assumed to match that of the html of the
>> form itself.
>>
>> DaveA
>>
>>
>
>
> --
> --
> AnotherNetFellow
> Email: anothernetfel...@gmail.com
>



-- 
--
AnotherNetFellow
Email: anothernetfel...@gmail.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Encoding

2010-03-03 Thread Giorgio
Ok.

So, how do you encode .py files? UTF-8?

2010/3/3 Dave Angel 

> Giorgio wrote:
>
>>
>>>
>>>>  Depends on your python version. If you use python 2.x, you have to use
>>>> a
>>>>
>>>>
>>> u before the string:
>>>
>>> s = u'Hallo World'
>>>
>>>
>>
>>
>> Ok. So, let's go back to my first question:
>>
>> s = u'Hallo World' is unicode in python 2.x -> ok
>> s = 'Hallo World' how is encoded?
>>
>>
>>
> Since it's a quote literal in your source code, it's encoded by your text
> editor when it saves the file, and you tell Python which encoding it was by
> the second line of your source file, right after the shebang line.
>
> A sequence of bytes in an html file should be should have its encoding
> identified by the tag at the top of the html file.  And I'd  *guess* that on
> a form result, the encoding can be assumed to match that of the html of the
> form itself.
>
> DaveA
>
>


-- 
--
AnotherNetFellow
Email: anothernetfel...@gmail.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Encoding

2010-03-03 Thread Giorgio
Uff, encoding is a very painful thing in programming.

Ok so now comes last "layer" of the encoding: the webserver.

I now know how to handle encoding in a python app and in interactions with
the db, but the last step is sending the content to the webserver.

How should i encode pages? The encoding i choose has to be the same than the
one i choose in the .htaccess file? Or maybe i can send content encoded how
i like more to apache and it re-encodes in the right way all pages?

Thankyou

2010/3/3 Patrick Sabin 

> Giorgio wrote:
>
>>
>>Depends on your python version. If you use python 2.x, you have to
>>use a u before the string:
>>
>>s = u'Hallo World'
>>
>>
>> Ok. So, let's go back to my first question:
>> s = u'Hallo World' is unicode in python 2.x -> ok
>> s = 'Hallo World' how is encoded?
>>
>
> I am not 100% sure, but I think it depends on the encoding of your source
> file or the coding you specify. See PEP 263
> http://www.python.org/dev/peps/pep-0263/
>
>
>  Well, the problem comes,  i.e when i'm getting a string from an HTML form
>> with POST. I don't and can't know the encoding, right? It depends on
>> browser.
>>
>
> Right, but you can do something about it. Tell the browser, which encoding
> you are going to accept:
>
> 
> ...
> 
>
> - Patrick
>



-- 
--
AnotherNetFellow
Email: anothernetfel...@gmail.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Encoding

2010-03-03 Thread Giorgio
>
>
>>  Depends on your python version. If you use python 2.x, you have to use a
> u before the string:
>
> s = u'Hallo World'


Ok. So, let's go back to my first question:

s = u'Hallo World' is unicode in python 2.x -> ok
s = 'Hallo World' how is encoded?


>> I think the encoding of the db doesn't matter much in this case, but I
> would prefer utf-8 over latin-1. If you get an utf-8 encoded raw byte string
> you call .decode('utf-8'). In case of an latin-1 encoded string you call
> .decode('latin1')
>

Ok, setting it to UTF-8.


> If you don't know the encoding on the way in, reject the input.
>
>
Well, the problem comes,  i.e when i'm getting a string from an HTML form
with POST. I don't and can't know the encoding, right? It depends on
browser.

Giorgio



-- 
--
AnotherNetFellow
Email: anothernetfel...@gmail.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Encoding

2010-03-03 Thread Giorgio
Oh, sorry, let me update my last post:

if i have a string, let's say:

s = "hi giorgio";

and want to store it in a latin1 db, i need to convert it to latin1 before
storing, right?

2010/3/3 Giorgio 

>
>>>  byte_string = unicode_string.encode('utf-8')
>>
>> If you use unicode strings throughout your application, you will be happy
>> with the above. Note that this is an advice, not a condition.
>
>
>
> Mmm ok. So all strings in the app are unicode by default?
>
> Do you know if there is a function/method i can use to check encoding of a
> string?
>
>
>>
>> "default encodings" are bad, don't rely on them.
>>
>
> No, ok, it was just to understand what i'm working with.
>
> Patrick, ok. I should check if it's possible to save unicode strings in the
> DB.
>
> Do you think i'd better set my db to utf8? I don't need latin1, it's just
> the default value.
>
> Thankyou
>
> Giorgio
>
>
> --
> --
> AnotherNetFellow
> Email: anothernetfel...@gmail.com
>



-- 
--
AnotherNetFellow
Email: anothernetfel...@gmail.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Encoding

2010-03-03 Thread Giorgio
>
>
>>  byte_string = unicode_string.encode('utf-8')
>
> If you use unicode strings throughout your application, you will be happy
> with the above. Note that this is an advice, not a condition.



Mmm ok. So all strings in the app are unicode by default?

Do you know if there is a function/method i can use to check encoding of a
string?


>
> "default encodings" are bad, don't rely on them.
>

No, ok, it was just to understand what i'm working with.

Patrick, ok. I should check if it's possible to save unicode strings in the
DB.

Do you think i'd better set my db to utf8? I don't need latin1, it's just
the default value.

Thankyou

Giorgio


-- 
--
AnotherNetFellow
Email: anothernetfel...@gmail.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Encoding

2010-03-03 Thread Giorgio
Hi,

i am looking for more informations about encoding in python:

i've read that Amazon SimpleDB accepts every string encoded in UTF-8. How
can I encode a string? And, what's the default string encoding in python?

the other question is about mysql DB: if i have a mysql field latin1 and
extract his content in a python script, how can I handle it?

thankyou

Giorgio

-- 
--
AnotherNetFellow
Email: anothernetfel...@gmail.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] CGI File Uploads

2010-02-28 Thread Giorgio
Alan, i don't know how to use it in this case.

import cgi
form = cgi.FieldStorage()
fileitem = form['file']
fileitem.file.read()

Function dir() lists all functions in a module, i could only use it for
"cgi" O_O.

Thankyou

2010/2/28 Alan Gauld 

>
> "Giorgio"  wrote
>
>  It's talking from fileitem attributes like filename and file.
>>
>>
>> Where is the complete list of those attributes or methods?
>>
>
> Probably on a web page somewhere but you are probably better using the
> help() function and dir() to examine an instance from the >>> prompt.
>
> HTH,
>
>
> --
> Alan Gauld
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>



-- 
--
AnotherNetFellow
Email: anothernetfel...@gmail.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] CGI File Uploads

2010-02-28 Thread Giorgio
Hi,

today i need some help with the python manual.

I've found this fileupload example
http://webpython.codepoint.net/cgi_file_upload on that site.

It's taking from fileitem attributes like filename and file.

Where is the complete list of those attributes or methods?

Thankyou

-- 
--
AnotherNetFellow
Email: anothernetfel...@gmail.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] What Editori?

2010-02-24 Thread Giorgio
And, what about more powerful editors? I mean editors with features like
SVN/GIT management and  so on.

I use Netbeans, but also know Eclipse/Aptana.

>


-- 
--
AnotherNetFellow
Email: anothernetfel...@gmail.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] What Editori?

2010-02-24 Thread Giorgio
> The editors could be configured differently with respect to the "tab
> button".
> Some may insert tabs some may insert spaces.
>

Ok, found the problem. I'm inserting tabs, but the original file only has
spaces.

Do you think i can look for a function that automatically inserts a certain
number of spaces when i press tab?


>
> By the way, I'm using Eclipse/Pydev.
>
>
NetBeans is a good alternative, and supports py in the new beta plugin.

I've also tried eclipse/aptana/pydev but think they're too difficult!


-- 
--
AnotherNetFellow
Email: anothernetfel...@gmail.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] What Editori?

2010-02-24 Thread Giorgio
>
>
>>
>> Are you sure you're not mixing spaces and tabs?
>

Yes i'm sure. I'm using the "tab button" and the same button works perfectly
in the IDLE editor.



-- 
--
AnotherNetFellow
Email: anothernetfel...@gmail.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] What Editori?

2010-02-23 Thread Giorgio
O_O.

I've downloaded some python examples from my debian server. Then, have
edited one of them with pyscript. The IDLE (the real idle alan :D) was
giving out a "unexpected indent" error, so i've checked again and again the
code -it was ok-.

Then, i've opened it in the IDLE. And there, ONLY there i see a double
indentation for the line that was giving the error.

I think it's because the script has been written on linux and i'm modifying
it from windows, any idea or solution?

2010/2/23 Alan Gauld 

>
> "Wayne Werner"  wrote
>
>
>  I use vim - for me it's the hands-down best editor. I usually have two
>> terminals (I run linux) open - one for ipython, and one for vim. I usually
>> have vim split into several buffers for each of the files I'm editing, and
>> I
>> have some nice scripts and plugins that help me edit/modify python code.
>>
>> But then again I've never worked on any huge (read: 1000+ lines,
>> unquantifiable "many" files).
>>
>
> I have, same setup except I use a third terminal for actually running
> the program for testing.
>
> And of course I use ctags for navigating around from file to file from vim.
> If you haven't played with ctags and vim start reading man ctags now! :-)
>
>
> Alan G
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>



-- 
--
AnotherNetFellow
Email: anothernetfel...@gmail.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] What Editori?

2010-02-23 Thread Giorgio
Yes sorry Alan i've only used the wrong word :D

I know the difference :)

Giorgio

2010/2/23 Alan Gauld 

>
> "Giorgio"  wrote
>
>  Definitely i just use pyscripter because it has the py idle integrated in
>> the window.
>>
>
> PyScripter is an alternative to IDLE but it doesn't have IDLE embedded
> within it. I think you are getting confused between IDLE and the Python
> interactive prompt which is available in several tools.
>
> The only snag I found with Pyscripter is that its shell  is hard coded to
> a Python release as far as I could tell. But thats not unusual, IDLE is
> too,
> as is Pythonwin.
>
> HTH,
>
>
> --
> Alan Gauld
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>



-- 
--
AnotherNetFellow
Email: anothernetfel...@gmail.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Functions returning multiple values

2010-02-23 Thread Giorgio
Ok Hugo,

so, going back to your example:

def nochange(some_list):
   # create shallow copy of list. NOTE: Shallow copies may still bite
you if you change the list members.
   some_list = some_list[:]
   some_list[1] = 2

Here we've created a new list. It's an object in the global "object-space
:)" but i can't access it outside the function because i don't have a name
referring to it in the global namespace.

Right?

And, please let me ask a question: Kent told that nested_namespace(s) are
default in python 2.6. And i found a line confirming this in py2.6 library.
But, what about python 2.5 that as you know is the default on linux?

Thankyou

Giorgio

2010/2/23 Hugo Arts 

> On Tue, Feb 23, 2010 at 2:28 PM, Giorgio 
> wrote:
> > Thankyou Hugo!
> > Ok, so i think the key is of my problem is that when doing X = 0 i'm
> > creating a new object, that only exist in the local namespace. BUT, when
> > using a list as a parameter for a function i'm only giving it a new name,
> > but the object it's referring to it's always the same, and is in the
> global
> > namespace.
> > Right?
>
> Well, mostly, yes. It's important to see that it's not so much the
> objects that live in namespaces, it's the names (otherwise they would
> be called object-spaces, yes?). The objects do not live inside a
> namespace, but are in a conceptually separate place altogether. A name
> lives in a namespace, and can only be referenced inside that space. An
> object can be referenced from anywhere, as long as you have a name
> that points to it.
>
> So, when you're doing x = 0, you're creating a new object, and the
> name x (in the local namespace) points to that object. That doesn't
> mean the object itself is confined to the local namespace. You could
> write 'return x', which allows you to have a name in the global
> namespace point to that same object.
>
> Hugo
>



-- 
--
AnotherNetFellow
Email: anothernetfel...@gmail.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] What Editori?

2010-02-23 Thread Giorgio
Definitely i just use pyscripter because it has the py idle integrated in
the window.

It's very useful!



2010/2/23 Steve Willoughby 

> On Tue, Feb 23, 2010 at 05:24:13PM +0100, Giorgio wrote:
> > what text-editor do you use for python?
>
> While the can of worms that particular question tends to
> open is always an issue (for some reason people get very
> emotionally passionate about why their editor is the best)
> I'm not sure you're going to get much of a useful answer
> beyond a few suggestions to try, since this is such a
> personal choice and depends so much on how you want to
> work.
>
> Personally, I find vim (on all platforms) to work well
> for me.  I'm giving Eclipse+pydev a try to see how I like
> that.
>
> > Do you think it's a good editor? Do you know other names?
>
> Whether any particular editor is "good" as long as it does
> the minimum amount necessary for programming, is entirely
> subjective.  Try a few and see how they work for you.
>
> Actually, I suppose even ed and TECO qualify for some work
> models ;)
>
>
> --
> Steve Willoughby|  Using billion-dollar satellites
> st...@alchemy.com   |  to hunt for Tupperware.
>



-- 
--
AnotherNetFellow
Email: anothernetfel...@gmail.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] What Editori?

2010-02-23 Thread Giorgio
Hi All,

what text-editor do you use for python?

I've always used kate/nano on Linux and Notepad++/PSPad on Win. Today i've
installed portablepython to my pendrive, and found pyscripter in that. It's
nice!

Do you think it's a good editor? Do you know other names?

Giorgio

-- 
--
AnotherNetFellow
Email: anothernetfel...@gmail.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Functions returning multiple values

2010-02-23 Thread Giorgio
Thankyou Hugo!

Ok, so i think the key is of my problem is that when doing X = 0 i'm
creating a new object, that only exist in the local namespace. BUT, when
using a list as a parameter for a function i'm only giving it a new name,
but the object it's referring to it's always the same, and is in the global
namespace.

Right?

2010/2/23 Hugo Arts 

> On Tue, Feb 23, 2010 at 1:13 PM, Giorgio 
> wrote:
> > I have an update:
> > I can easily undertand why this example doesn't work:
> > def nochange(x):
> > x = 0
> > y = 1
> > nochange(y)
> > print y # Prints out 1
> > X is a local variable, and only gets modified in the function, that
> doesn't
> > return any value.
> > But it's very difficult for me to understand WHY this works:
> > def change(some_list):
> > some_list[1] = 4
> > x = [1,2,3]
> > change(x)
> > print x # Prints out [1,4,3]
> > some_list is a "local" list, isn't it? Maybe i can't have lists that are
> > only existing in a function?
>
> Here is what happens, as I understand it:
> When you enter the function, a new name (x, in your case) is created
> in the local scope. That name points to the object you supplied when
> you called the function (an integer object, with a value of 1). the x
> = 0 statement creates a new object, and has the name x now pointing to
> this new object. The old integer object still exists, and y still
> points to it. This is why the global y name is not affected by the
> change in x
>
> Now, in the second example, the same thing basically happens. A new
> name is created and pointed at the object you supplied. However, the
> statement some_list[1] = 4 is different from the assignment, in that
> it doesn't create a new object; It modifies the existing one. Since
> the global and local names both point to the same object, the change
> you make is reflected in both.
>
> You can of course create a new list object, so that the original is
> not affected:
>
> def nochange(some_list):
># create shallow copy of list. NOTE: Shallow copies may still bite
> you if you change the list members.
>some_list = some_list[:]
>some_list[1] = 2
>
> >>> x = [1, 2, 3]
> >>> nochange(x)
> >>> x
> [1, 2, 3]
>
> HTH,
> Hugo
>



-- 
--
AnotherNetFellow
Email: anothernetfel...@gmail.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Functions returning multiple values

2010-02-23 Thread Giorgio
Thankyou.

It's clear, this definitely helps me with the first question. But still
doesn't explain almost anything about the example i've posted in the last
post, right?

Giorgio

2010/2/23 Christian Witts 

> Giorgio wrote:
>
>> I have an update:
>>
>> I can easily undertand why this example doesn't work:
>>
>> def nochange(x):
>>x = 0
>>
>> y = 1
>> nochange(y)
>> print y # Prints out 1
>>
>> X is a local variable, and only gets modified in the function, that
>> doesn't return any value.
>>
>> But it's very difficult for me to understand WHY this works:
>>
>> def change(some_list):
>>some_list[1] = 4
>>
>> x = [1,2,3]
>> change(x)
>> print x # Prints out [1,4,3]
>>
>> some_list is a "local" list, isn't it? Maybe i can't have lists that are
>> only existing in a function?
>>
>> Thankyou all
>>
>> 2010/2/22 Kent Johnson mailto:ken...@tds.net>>
>>
>>
>>On Mon, Feb 22, 2010 at 9:13 AM, Giorgio
>>mailto:anothernetfel...@gmail.com>>
>>
>>wrote:
>>
>>> And, i have some difficulties understanding the other "strange"
>>example in
>>> that howto. Just scroll down to: "However, the point is that the
>>value
>>> of x is picked up from the environment at the time when the
>>function is
>>> defined. How is this useful? Let’s take an example — a function
>>which
>>> composes two other functions."
>>> He is working on a function that compose other 2 functions. This
>>is the
>>> final solution
>>> def compose(fun1, fun2):
>>> def inner(x, fun1=fun1, fun2=fun2):
>>> return fun1(fun2(x))
>>> return inner
>>> But also tries to explain why this example:
>>> # Wrong version
>>> def compose(fun1, fun2):
>>> def inner(x):
>>> return fun1(fun2(x))
>>> return inner
>>> def fun1(x):
>>> return x + " world!"
>>> def fun2(x):
>>> return "Hello,"
>>> sincos = compose(sin,cos)  # Using the wrong version
>>> x = sincos(3)
>>> Won't work. Now, the problem is that the "inner" function gets
>>fun1 and fun2
>>> from other 2 functions.
>>> My question is: why? inner is a sub-function of compose, where
>>fun1 and fun2
>>> are defined.
>>
>>It does work:
>>In [6]: def compose(fun1, fun2):
>>  ...: def inner(x):
>>  ...: return fun1(fun2(x))
>>  ...: return inner
>>  ...:
>>
>>In [7]: def fun1(x):
>>  ...: return x + " world!"
>>  ...:
>>
>>In [8]: def fun2(x):
>>  ...: return "Hello,"
>>  ...:
>>
>>In [9]: from math import sin, cos
>>
>>In [10]: sincos = compose(sin,cos)  # Using the wrong version
>>
>>In [11]:
>>
>>In [12]: x = sincos(3)
>>
>>In [13]:
>>
>>In [14]: x
>>Out[14]: -0.8360218615377305
>>
>>That is a very old example, from python 2.1 or before where nested
>>scopes were not supported. See the note "A Note About Python 2.1 and
>>Nested Scopes" - that is now the default behaviour.
>>
>>Kent
>>
>>
>>
>>
>> --
>> --
>> AnotherNetFellow
>> Email: anothernetfel...@gmail.com <mailto:anothernetfel...@gmail.com>
>> 
>>
>>
>> ___
>> Tutor maillist  -  Tutor@python.org
>> To unsubscribe or change subscription options:
>> http://mail.python.org/mailman/listinfo/tutor
>>
>>
> Take a look at the Python gothcha's:
> http://www.ferg.org/projects/python_gotchas.html#contents_item_6
>
> --
> Kind Regards,
> Christian Witts
>
>
>


-- 
--
AnotherNetFellow
Email: anothernetfel...@gmail.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Functions returning multiple values

2010-02-23 Thread Giorgio
I have an update:

I can easily undertand why this example doesn't work:

def nochange(x):
x = 0

y = 1
nochange(y)
print y # Prints out 1

X is a local variable, and only gets modified in the function, that doesn't
return any value.

But it's very difficult for me to understand WHY this works:

def change(some_list):
some_list[1] = 4

x = [1,2,3]
change(x)
print x # Prints out [1,4,3]

some_list is a "local" list, isn't it? Maybe i can't have lists that are
only existing in a function?

Thankyou all

2010/2/22 Kent Johnson 

> On Mon, Feb 22, 2010 at 9:13 AM, Giorgio 
> wrote:
>
> > And, i have some difficulties understanding the other "strange" example
> in
> > that howto. Just scroll down to: "However, the point is that the value
> > of x is picked up from the environment at the time when the function is
> > defined. How is this useful? Let’s take an example — a function which
> > composes two other functions."
> > He is working on a function that compose other 2 functions. This is the
> > final solution
> > def compose(fun1, fun2):
> > def inner(x, fun1=fun1, fun2=fun2):
> > return fun1(fun2(x))
> > return inner
> > But also tries to explain why this example:
> > # Wrong version
> > def compose(fun1, fun2):
> > def inner(x):
> > return fun1(fun2(x))
> > return inner
> > def fun1(x):
> > return x + " world!"
> > def fun2(x):
> > return "Hello,"
> > sincos = compose(sin,cos)  # Using the wrong version
> > x = sincos(3)
> > Won't work. Now, the problem is that the "inner" function gets fun1 and
> fun2
> > from other 2 functions.
> > My question is: why? inner is a sub-function of compose, where fun1 and
> fun2
> > are defined.
>
> It does work:
> In [6]: def compose(fun1, fun2):
>...: def inner(x):
>   ...: return fun1(fun2(x))
>   ...: return inner
>...:
>
> In [7]: def fun1(x):
>   ...: return x + " world!"
>   ...:
>
> In [8]: def fun2(x):
>   ...: return "Hello,"
>   ...:
>
> In [9]: from math import sin, cos
>
> In [10]: sincos = compose(sin,cos)  # Using the wrong version
>
> In [11]:
>
> In [12]: x = sincos(3)
>
> In [13]:
>
> In [14]: x
> Out[14]: -0.8360218615377305
>
> That is a very old example, from python 2.1 or before where nested
> scopes were not supported. See the note "A Note About Python 2.1 and
> Nested Scopes" - that is now the default behaviour.
>
> Kent
>



-- 
--
AnotherNetFellow
Email: anothernetfel...@gmail.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Functions returning multiple values

2010-02-22 Thread Giorgio
Ahah Kent this is amazing.

I was reading the ITALIAN
http://www.python.it/doc/articoli/instpy-0.html version
of that guide that is not updated. But, when i decided to post there i've
posted the link of the guide in english, but actually that's not what i've
readen.

Ok, so in the new python version it works. Tha manual also states that: "The
features recognized by Python 2.6 are unicode_literals, print_function,
absolute_import, division, generators, nested_scopes andwith_statement.
generators, with_statement, nested_scopes are redundant in Python version
2.6 and above because they are always enabled."

Kent, as i'm learning py, can you please spend some words on nested scopes?
What are them? And why are supported anymore?

And, if i'm not asking you too much: can you plase post an example on how
that function can return HEllo World in py 2.6?

Thankyou!

Giorgio

2010/2/22 Kent Johnson 

> On Mon, Feb 22, 2010 at 9:13 AM, Giorgio 
> wrote:
>
> > And, i have some difficulties understanding the other "strange" example
> in
> > that howto. Just scroll down to: "However, the point is that the value
> > of x is picked up from the environment at the time when the function is
> > defined. How is this useful? Let’s take an example — a function which
> > composes two other functions."
> > He is working on a function that compose other 2 functions. This is the
> > final solution
> > def compose(fun1, fun2):
> > def inner(x, fun1=fun1, fun2=fun2):
> > return fun1(fun2(x))
> > return inner
> > But also tries to explain why this example:
> > # Wrong version
> > def compose(fun1, fun2):
> > def inner(x):
> > return fun1(fun2(x))
> > return inner
> > def fun1(x):
> > return x + " world!"
> > def fun2(x):
> > return "Hello,"
> > sincos = compose(sin,cos)  # Using the wrong version
> > x = sincos(3)
> > Won't work. Now, the problem is that the "inner" function gets fun1 and
> fun2
> > from other 2 functions.
> > My question is: why? inner is a sub-function of compose, where fun1 and
> fun2
> > are defined.
>
> It does work:
> In [6]: def compose(fun1, fun2):
>...: def inner(x):
>   ...: return fun1(fun2(x))
>   ...: return inner
>...:
>
> In [7]: def fun1(x):
>   ...: return x + " world!"
>   ...:
>
> In [8]: def fun2(x):
>   ...: return "Hello,"
>   ...:
>
> In [9]: from math import sin, cos
>
> In [10]: sincos = compose(sin,cos)  # Using the wrong version
>
> In [11]:
>
> In [12]: x = sincos(3)
>
> In [13]:
>
> In [14]: x
> Out[14]: -0.8360218615377305
>
> That is a very old example, from python 2.1 or before where nested
> scopes were not supported. See the note "A Note About Python 2.1 and
> Nested Scopes" - that is now the default behaviour.
>
> Kent
>



-- 
--
AnotherNetFellow
Email: anothernetfel...@gmail.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Functions returning multiple values

2010-02-22 Thread Giorgio
Ok, thankyou.

So, in other words, i must pay attention to what i set as default value in a
function. I should NEVER set empty lists as default values.

The guide i've linked says "To learn more about this, you should read the
documentation and look for the difference between *identity* and *equality*.
".

Can you please help me also with that? Where can i read what is the
difference?

And, i have some difficulties understanding the other "strange" example in
that howto. Just scroll down to: "However, the *point* is that the value of
x is picked up from the *environment* at the time when the function is
defined. How is this useful? Let’s take an example — a function which
composes two other functions."

He is working on a function that compose other 2 functions. This is the
final solution

def compose(fun1, fun2):
def inner(x, fun1=fun1, fun2=fun2):
return fun1(fun2(x))
return inner

But also tries to explain why this example:

# Wrong version
def compose(fun1, fun2):
def inner(x):
return fun1(fun2(x))
return inner

def fun1(x):
return x + " world!"

def fun2(x):
return "Hello,"

sincos = compose(sin,cos)  # Using the wrong version

x = sincos(3)

Won't work. Now, the problem is that the "inner" function gets fun1 and fun2
from other 2 functions.

My question is: why? inner is a sub-function of compose, where fun1 and fun2
are defined.

Giorgio

2010/2/21 Steven D'Aprano 

> On Mon, 22 Feb 2010 03:00:32 am Giorgio wrote:
> > Hi,
> >
> > do you know if there is a way so that i can get multiple values from
> > a function?
> >
> > For example:
> >
> > def count(a,b):
> >  c = a + b
> >  d = a - b
> >
> > How can I return the value of C and D?
>
> Return a tuple of c and d:
>
> >>> def count(a, b):
> ... c = a + b
> ... d = a - b
> ... return c, d
> ...
> >>> t = count(15, 11)
> >>> t
> (26, 4)
>
> You can also unpack the tuple immediately:
>
> >>> x, y = count(15, 11)
> >>> x
> 26
> >>> y
> 4
>
>
>
> > Then, i have another question: i've read, some time ago, this guide
> > http://hetland.org/writing/instant-python.html, skipping the
> > object-related part. Now i've started reading it, and have found
> > something strange: just go where it says "Of course, now you know
> > there is a better way. And why don’t we give it the default value of
> > [] in the first place? Because of the way Python works, this would
> > give all the Baskets the same empty list as default contents.". Can
> > you please help me understanding this part?
>
> When you declare a default value in a function like this:
>
> def f(a, b, c=SOMETHING):
>
> the expression SOMETHING is calculated once, when the function is
> defined, and *not* each time you call the function.
>
> So if I do this:
>
> x = 1
> y = 2
>
> def f(a, b, c=x+y):
>return a+b+c
>
> the default value for c is calculated once, and stored inside the
> function:
>
> >>> f(0, 0)
> 3
>
> Even if I change x or y:
>
> >>> x = 
> >>> f(0, 0)
> 3
>
> So if I use a list as a default value (or a dict), the default is
> calculated once and stored in the function. You can see it by looking
> at the function's defaults:
>
> >>> def f(alist=[]):
> ... alist.append(1)
> ... return alist
> >>>
> >>> f.func_defaults[0]
> []
>
> Now, call the function without an argument:
>
> >>> f()
> [1]
> >>> f()
> [1, 1]
> >>> f()
> [1, 1, 1]
> >>> f.func_defaults[0]
> [1, 1, 1]
>
> How is this happening? Because every time you call the function, it
> appends 1 to the argument. If you don't supply an argument, it appends
> 1 to the default, changing it in place.
>
> Why doesn't the same thing happen here?
>
> >>> def g(x=0):
> ... x += 1
> ... return x
> ...
> >>> g.func_defaults[0]
> 0
> >>> g()
> 1
> >>> g()
> 1
> >>> g.func_defaults[0]
> 0
>
> The answer is that ints are immutable: you can't change their value.
> When you do x+=1, it doesn't modify the int 0 in place, turning it into
> 1. It leaves 0 as zero, and gives you a new int equal to one. So the
> default value stored in the function never changes.
>
> The difference boils down to immutable objects, which can't be changed
> in place, and mutable objects, which can.
>
> Immutable:
> ints, floats, strings, tuples, frozensets
>
> Mutable:
> lists, dicts, sets, most custom classes
>
>
>
> --
> Steven D'Aprano
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>



-- 
--
AnotherNetFellow
Email: anothernetfel...@gmail.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Functions returning multiple values

2010-02-21 Thread Giorgio
Hi,

do you know if there is a way so that i can get multiple values from a
function?

For example:

def count(a,b):
 c = a + b
 d = a - b

How can I return the value of C and D?

Then, i have another question: i've read, some time ago, this guide
http://hetland.org/writing/instant-python.html, skipping the object-related
part. Now i've started reading it, and have found something strange: just go
where it says "Of course, now you know there is a better way. And why don’t
we give it the default value of [] in the first place? Because of the way
Python works, this would give all the Baskets the same empty list as default
contents.". Can you please help me understanding this part?

Thankyou

Giorgio



-- 
--
AnotherNetFellow
Email: anothernetfel...@gmail.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Import Modules

2009-04-15 Thread Giorgio Bonfiglio
Hi,
hope this mailing list is still active.

I'm learning phyton. I can write simple programs, and i've studied all
examples provided by the Google App Engine Documentation.

As i understood, i can import a module using something like:

import modulename

Or, import a specific function, using:

from modulename import functionname

Ok, now let's look at the first example provided by google:

http://code.google.com/intl/it-IT/appengine/docs/python/gettingstarted/usingwebapp.html

I can see those lines:

from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app

The first line imports the webapp subpackage (that is not actually a module,
it's a subdirectory with some .py files into). So why do i need to import
the specific function in the second line? Does'nt it get imported in the
first?

Thankyou for your help.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor