Re: basic question on loop & type casting / list/str/array

2022-03-16 Thread Python
Kiran Kumar wrote: Hi. Pls check on below poython 3.9.x code & suggest how can i keep the string intactst in 2nd loop... ? these are aws ec2 ids Don't loop through it then. -- https://mail.python.org/mailman/listinfo/python-list

Re: basic question on how "import" works

2019-01-20 Thread Cameron Simpson
On 19Jan2019 11:42, joseph pareti wrote: [*u23885@c009 3_NeuralNetworks]$ cat foo.py* from __future__ import print_function # Import MNIST data from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets("/tmp/data/", one_hot=True) [u23885@c009 3_NeuralNetworks

Re: Basic Question. Deploy new Master/Slave (M/S) datastore

2012-08-30 Thread Mark Lawrence
On 30/08/2012 23:32, Ylodis wrote: That is the question, where have I to write, and what have I to write. My old acount was tarot-gratis, the new account is tarot-gratis-hrd. What have I to write, where Google help says "myapp" ? Where should I write appcfg.py update 'myapp'/ Probably where

Re: Basic Question. Deploy new Master/Slave (M/S) datastore

2012-08-30 Thread Ylodis
That is the question, where have I to write, and what have I to write. My old acount was tarot-gratis, the new account is tarot-gratis-hrd. What have I to write, where Google help says "myapp" ? Where should I write appcfg.py update 'myapp'/ -- http://mail.python.org/mailman/listinfo/python-lis

Re: Basic Question. Deploy new Master/Slave (M/S) datastore

2012-08-30 Thread Terry Reedy
On 8/30/2012 11:51 AM, Ylodis wrote: Hi, I had an old and deprecated Master/Slave (M/S) datastore and I trying to pass its content to a new Master/Slave (M/S) datastore as is expained here : https://developers.google.com/appengine/docs/adminconsole/migration#Deploying_Your_New_HRD_Application

Re: Basic Question. Deploy new Master/Slave (M/S) datastore

2012-08-30 Thread Ylodis
I am trying to use a Google public storage that is managed in python. I do web developement, I have very litle idea about python, english is not my natural language and as you can see, I am very lost. I do not even now which group cold help me. The details of what I want to do are in the link.

Re: Basic Question. Deploy new Master/Slave (M/S) datastore

2012-08-30 Thread Mark Lawrence
On 30/08/2012 16:51, Ylodis wrote: Hi, I had an old and deprecated Master/Slave (M/S) datastore and I trying to pass its content to a new Master/Slave (M/S) datastore as is expained here : https://developers.google.com/appengine/docs/adminconsole/migration#Deploying_Your_New_HRD_Application Wh

Re: Basic question about speed/coding style/memory

2012-07-23 Thread 88888 Dihedral
Chris Angelico於 2012年7月21日星期六UTC+8下午5時04分12秒寫道: > On Sat, Jul 21, 2012 at 5:33 PM, Jan Riechers > wrote: > > Block > > #-- > > if statemente_true: > > doSomething() > > else: > > doSomethingElseInstead() > > > > #--

Re: Basic question about speed/coding style/memory

2012-07-23 Thread 88888 Dihedral
Jan Riechers於 2012年7月21日星期六UTC+8下午3時33分27秒寫道: > Hello Pythonlist, > > I have one very basic question about speed,memory friendly coding, and > coding style of the following easy "if"-statement in Python 2.7, > but Im > sure its also the same in Python 3.x > > Block > #-

Re: Basic question about speed/coding style/memory

2012-07-21 Thread Devin Jeanpierre
On Sat, Jul 21, 2012 at 5:06 AM, Steven D'Aprano wrote: > So there is approximately 0.03 second difference per TWO MILLION > if...else blocks, or about 15 nanoseconds each. This is highly unlikely > to be the bottleneck in your code. Assuming the difference is real, and > not just measurement erro

Re: Basic question about speed/coding style/memory

2012-07-21 Thread Thomas 'PointedEars' Lahn
Jan Riechers wrote: > I have one very basic question about speed,memory friendly coding, and > coding style of the following easy "if"-statement in Python 2.7, but Im > sure its also the same in Python 3.x > > Block > #-- > if statemente_true: > doSomething() > els

Re: Basic question about speed/coding style/memory

2012-07-21 Thread Jan Riechers
On 21.07.2012 12:06, Steven D'Aprano wrote: But in general, you're worrying too much about trivia. One way or the other, any speed difference will be trivial. Write whatever style reads and writes most naturally, and only worry about what's faster where it actually counts. Notice that I try

Re: Basic question about speed/coding style/memory

2012-07-21 Thread Steven D'Aprano
On Sat, 21 Jul 2012 10:33:27 +0300, Jan Riechers wrote: > Hello Pythonlist, > > I have one very basic question about speed,memory friendly coding, and > coding style of the following easy "if"-statement in Python 2.7, but Im > sure its also the same in Python 3.x I assume that the following is m

Re: Basic question about speed/coding style/memory

2012-07-21 Thread Andrew Berg
On 7/21/2012 3:13 AM, Jan Riechers wrote: > Cause, as I understand the interpreter chooses either the "else" (1st > block) or just proceeds with following code outside the if. If none of the if/elif statements evaluate to something true, the else block is executed. > So if there is some overhead

Re: Basic question about speed/coding style/memory

2012-07-21 Thread Chris Angelico
On Sat, Jul 21, 2012 at 5:33 PM, Jan Riechers wrote: > Block > #-- > if statemente_true: > doSomething() > else: > doSomethingElseInstead() > > #-- This means, to me, that the two options are peers - you do this or yo

Re: Basic question about speed/coding style/memory

2012-07-21 Thread Jan Riechers
On 21.07.2012 11:02, Andrew Berg wrote: On 7/21/2012 2:33 AM, Jan Riechers wrote: Block ... versus this block: ... Now, very briefly, what is the better way to proceed in terms of execution speed, readability, coding style? Using if/else is the most readable in the general sense. Using return (

Re: Basic question about speed/coding style/memory

2012-07-21 Thread Andrew Berg
On 7/21/2012 2:33 AM, Jan Riechers wrote: > Block > ... > versus this block: > ... > Now, very briefly, what is the better way to proceed in terms of > execution speed, readability, coding style? Using if/else is the most readable in the general sense. Using return (or break or continue as applica

Re: Basic question from pure beginner

2009-07-01 Thread alex23
Dennis Lee Bieber wrote: >         There is also the getpass module to play with! I don't think I've ever seen getpass, so thanks for pointing that out. Unfortunately, it wouldn't have helped the OP understand why his original code wasn't working ;) -- http://mail.python.org/mailman/listinfo/pyt

Re: Basic question from pure beginner

2009-07-01 Thread alex23
On Jul 2, 3:47 am, Scott David Daniels wrote: > And even simpler: >      PASSWORD = "qwerty" >      MAXRETRY = 3 >      for attempt in range(MAXRETRY): >          if raw_input('Enter your password: ') == PASSWORD: >              print 'Password confirmed' >              break # this exits the for

Re: Basic question from pure beginner

2009-07-01 Thread Scott David Daniels
Charles Yeomans wrote: Let me offer a bit of editing Finally, I'd remove correct_password_given from the loop test, and replace it with a break statement when the correct password is entered. password = "qwerty" correct_password_given = False attemptcount = 0 MaxAttempts = 3 while attemptc

Re: Basic question from pure beginner

2009-07-01 Thread Charles Yeomans
Let me offer a bit of editing. First, using the condition count != 3 is perhaps risky. A mistake or a change in logic in the loop body might result in an infinite loop. So instead I suggest while count < 3... Second, I'd suggest storing the value 3 in a variable with a name that descri

Re: Basic question from pure beginner

2009-07-01 Thread MRAB
sato.ph...@gmail.com wrote: I have been going through some Python Programming exercises while following the MIT OpenCourseWare Intro to CS syllabus and am having some trouble with the first "If" exercise listed on this page: http://en.wikibooks.org/wiki/Python_Programming/Conditional_Statements#

Re: Basic question from pure beginner

2009-07-01 Thread Bruno Desthuilliers
Scott David Daniels a écrit : (snip) And even simpler: PASSWORD = "qwerty" MAXRETRY = 3 for attempt in range(MAXRETRY): if raw_input('Enter your password: ') == PASSWORD: print 'Password confirmed' break # this exits the for loop print 'Access

Re: Basic question from pure beginner

2009-07-01 Thread Bruno Desthuilliers
Charles Yeomans a écrit : Please don't top-post (not corrected) Let me offer a bit of editing. First, using the condition count != 3 is perhaps risky. A mistake or a change in logic in the loop body might result in an infinite loop. So instead I suggest while count < 3... Second, I'd su

Re: Basic question from pure beginner

2009-07-01 Thread Bruno Desthuilliers
sato.ph...@gmail.com a écrit : Thank you for all of the help. With your assistance and help from the Python Tutor mailing list I was able to come up with the following code: password = "qwerty" correct_password_given = False guess = "0" You could just use None here: guess=None count = 0

Re: Basic question from pure beginner

2009-07-01 Thread sato.ph...@gmail.com
Thank you for all of the help. With your assistance and help from the Python Tutor mailing list I was able to come up with the following code: password = "qwerty" correct_password_given = False guess = "0" count = 0 while count != 3 and not correct_password_given : guess = raw_input("Enter you

Re: Basic question from pure beginner

2009-07-01 Thread alex23
On Jul 1, 3:38 pm, "sato.ph...@gmail.com" wrote: > I have been able to make the module quit after entering a password > three times, but can't get it to quit right away after the correct one > is entered.   Not with the code you pasted, you haven't. There's a missing colon on line 7 & line 9 isn'

Re: Basic question from pure beginner

2009-07-01 Thread Peter Otten
sato.ph...@gmail.com wrote: > I have been going through some Python Programming exercises while > following the MIT OpenCourseWare Intro to CS syllabus and am having > some trouble with the first "If" exercise listed on this page: > > http://en.wikibooks.org/wiki/Python_Programming/Conditional_S

Re: Basic Question about Python WebServer File handling

2008-07-11 Thread Gabriel Genellina
En Thu, 10 Jul 2008 22:20:21 -0300, Alok Kumar <[EMAIL PROTECTED]> escribi�: I need to have a python webserver which can handle Get request from the clients and upload the *files* from 4 different directories. Can someone please point me what to exactly look for. Look at SimpleHTTPServer.py

Answer: Re: Basic question

2008-02-13 Thread WILLIAM SCHMIDT
Thank you Guilherme Solution below: >>> "Guilherme Polo" <[EMAIL PROTECTED]> 2008-02-13 06:48 >>> 2008/2/13, WILLIAM SCHMIDT <[EMAIL PROTECTED]>: > In several places in the Python documentation I have run across an extra "r" > that I can not explain: > * > In sys.p

Re: Basic question

2008-02-13 Thread Chris
On Feb 13, 2:22 pm, "WILLIAM SCHMIDT" <[EMAIL PROTECTED]> wrote: > In several places in the Python documentation I have run across an extra "r" > that I can not explain: > > * > In sys.path after the open bracket: >sys.path = [r'd:\temp'] > > In the on line help

Re: Basic question

2008-02-13 Thread Guilherme Polo
2008/2/13, WILLIAM SCHMIDT <[EMAIL PROTECTED]>: > In several places in the Python documentation I have run across an extra "r" > that I can not explain: > > > * > In sys.path after the open bracket: >sys.path = [r'd:\temp'] > > In the on line help in the DATA

Re: Basic question

2007-05-14 Thread Max M
Dmitry Dzhus skrev: >> Actually I'm trying to convert a string to a list of float numbers: >> str = '53,20,4,2' to L = [53.0, 20.0, 4.0, 2.0] > > str="53,20,4,2" > map(lambda s: float(s), str.split(',')) > > Last expression returns: [53.0, 20.0, 4.0, 2.0] The lambda is not needed there, as float

Re: Basic question

2007-05-14 Thread Gabriel Genellina
En Mon, 14 May 2007 02:05:47 -0300, Alex Martelli <[EMAIL PROTECTED]> escribió: > Gabriel Genellina <[EMAIL PROTECTED]> wrote: >> But that's not the same as requested - you get a plain list, and the >> original was a list of lists: > Are we talking about the same code?! What I saw at the root of

Re: Basic question

2007-05-13 Thread Alex Martelli
Gabriel Genellina <[EMAIL PROTECTED]> wrote: > En Sat, 12 May 2007 20:13:48 -0300, Alex Martelli <[EMAIL PROTECTED]> > escribió: > > > Cesar G. Miguel <[EMAIL PROTECTED]> wrote: > >> --- > >> L = [] > >> file = ['5,1378,1,9', '2,1,4,5'] > >> str='' > >> for item in file: > >>

Re: Basic question

2007-05-13 Thread Gabriel Genellina
En Sat, 12 May 2007 20:13:48 -0300, Alex Martelli <[EMAIL PROTECTED]> escribió: > Cesar G. Miguel <[EMAIL PROTECTED]> wrote: >> --- >> L = [] >> file = ['5,1378,1,9', '2,1,4,5'] >> str='' >> for item in file: >> L.append([float(n) for n in item.split(',')]) > > The assignment

Re: Basic question

2007-05-13 Thread Cesar G. Miguel
On May 12, 8:13 pm, [EMAIL PROTECTED] (Alex Martelli) wrote: > Cesar G. Miguel <[EMAIL PROTECTED]> wrote: > > > On May 12, 3:40 pm, Dmitry Dzhus <[EMAIL PROTECTED]> wrote: > > > > Actually I'm trying to convert a string to a list of float numbers: > > > > str = '53,20,4,2' to L = [53.0, 20.0, 4.0,

Re: Basic question

2007-05-12 Thread sturlamolden
On May 12, 6:18 pm, "Cesar G. Miguel" <[EMAIL PROTECTED]> wrote: > Am I missing something? Python for loops iterates over the elements in a container. It is similar to Java's "for each" loop. for j in range(10): print j if(True): j=j+2 print 'interno',j Is equivalent to: int[

Re: Basic question

2007-05-12 Thread Alex Martelli
Cesar G. Miguel <[EMAIL PROTECTED]> wrote: > On May 12, 3:40 pm, Dmitry Dzhus <[EMAIL PROTECTED]> wrote: > > > Actually I'm trying to convert a string to a list of float numbers: > > > str = '53,20,4,2' to L = [53.0, 20.0, 4.0, 2.0] > > > > str="53,20,4,2" > > map(lambda s: float(s), str.split(','

Re: Basic question

2007-05-12 Thread Kirk Job Sluder
"Cesar G. Miguel" <[EMAIL PROTECTED]> writes: > I've been studying python for 2 weeks now and got stucked in the > following problem: > > for j in range(10): > print j > if(True): >j=j+2 >print 'interno',j > > What happens is that "j=j+2" inside IF does not change the loop > co

Re: Basic question

2007-05-12 Thread Cesar G. Miguel
On May 12, 3:40 pm, Dmitry Dzhus <[EMAIL PROTECTED]> wrote: > > Actually I'm trying to convert a string to a list of float numbers: > > str = '53,20,4,2' to L = [53.0, 20.0, 4.0, 2.0] > > str="53,20,4,2" > map(lambda s: float(s), str.split(',')) > > Last expression returns: [53.0, 20.0, 4.0, 2.0] >

Re: Basic question

2007-05-12 Thread Grant Edwards
On 2007-05-12, Dmitry Dzhus <[EMAIL PROTECTED]> wrote: > str="53,20,4,2" > map(lambda s: float(s), str.split(',')) There's no need for the lambda. map(float,str.split(',')) Does exactly the same thing. -- Grant Edwards grante Yow! I feel like I am

Re: Basic question

2007-05-12 Thread Grant Edwards
On 2007-05-12, Cesar G. Miguel <[EMAIL PROTECTED]> wrote: > Actually I'm trying to convert a string to a list of float numbers: > str = '53,20,4,2' to L = [53.0, 20.0, 4.0, 2.0] >>> str = '53,20,4,2' >>> [float(w) for w in str.split(',')] [53.0, 20.0, 4.0, 2.0] >>> map(float,str.split(',')) [

Re: Basic question

2007-05-12 Thread Dmitry Dzhus
> Actually I'm trying to convert a string to a list of float numbers: > str = '53,20,4,2' to L = [53.0, 20.0, 4.0, 2.0] str="53,20,4,2" map(lambda s: float(s), str.split(',')) Last expression returns: [53.0, 20.0, 4.0, 2.0] -- Happy Hacking. Dmitry "Sphinx" Dzhus http://sphinx.net.ru -- http:

Re: Basic question

2007-05-12 Thread Cesar G. Miguel
On May 12, 3:09 pm, Karlo Lozovina <[EMAIL PROTECTED]> wrote: > Cesar G. Miguel wrote: > > - > > L = [] > > file = ['5,1378,1,9', '2,1,4,5'] > > str='' > > for item in file: > >j=0 > >while(j > while(item[j] != ','): > > str+=item[j] > >

Re: Basic question

2007-05-12 Thread Karlo Lozovina
Cesar G. Miguel wrote: > - > L = [] > file = ['5,1378,1,9', '2,1,4,5'] > str='' > for item in file: >j=0 >while(j while(item[j] != ','): > str+=item[j] > j=j+1 >if(j>= len(item)): break > > if(str != ''): >L

Re: Basic question

2007-05-12 Thread Cesar G. Miguel
On May 12, 2:45 pm, Basilisk96 <[EMAIL PROTECTED]> wrote: > On May 12, 12:18 pm, "Cesar G. Miguel" <[EMAIL PROTECTED]> wrote: > > > > > I've been studying python for 2 weeks now and got stucked in the > > following problem: > > > for j in range(10): > > print j > > if(True): > >j=j+2 >

Re: Basic question

2007-05-12 Thread Basilisk96
On May 12, 12:18 pm, "Cesar G. Miguel" <[EMAIL PROTECTED]> wrote: > I've been studying python for 2 weeks now and got stucked in the > following problem: > > for j in range(10): > print j > if(True): >j=j+2 >print 'interno',j > > What happens is that "j=j+2" inside IF does not c

Re: Basic question

2007-05-12 Thread Dmitry Dzhus
> "j=j+2" inside IF does not change the loop > counter ("j") You might be not truly catching the idea of Python `for` statements sequence nature. It seems that will make things quite clear. > The suite may assign to the variable(s) in the target list; this >

Re: Basic question

2007-05-12 Thread Arnaud Delobelle
On May 12, 5:18 pm, "Cesar G. Miguel" <[EMAIL PROTECTED]> wrote: > I've been studying python for 2 weeks now and got stucked in the > following problem: > > for j in range(10): > print j > if(True): >j=j+2 >print 'interno',j > > What happens is that "j=j+2" inside IF does not ch

Re: Basic question

2007-05-12 Thread Karlo Lozovina
Cesar G. Miguel wrote: > for j in range(10): > print j > if(True): >j=j+2 >print 'interno',j > > What happens is that "j=j+2" inside IF does not change the loop > counter ("j") as it would in C or Java, for example. > Am I missing something? If you want that kind of behaviour

Re: Basic question

2007-05-12 Thread Gary Herron
Cesar G. Miguel wrote: > I've been studying python for 2 weeks now and got stucked in the > following problem: > > for j in range(10): > print j > if(True): >j=j+2 >print 'interno',j > > What happens is that "j=j+2" inside IF does not change the loop > counter ("j") as it would

Re: Basic question about sockets and security

2007-05-07 Thread Steve Holden
Dave Dean wrote: [socket security inquiry] One further point: everything I wrote for server sockets applies to client sockets too if there's a possibility they are interacting with a server that's been maliciously coded, or compromised in some way by an attacker. regards Steve -- Steve Hold

Re: Basic question about sockets and security

2007-05-07 Thread Steve Holden
Dave Dean wrote: > Hi all, > I'm just starting out in sockets/network programming, and I have a very > basic question...what are the 'security' implications of opening up a > socket? For example, suppose I've written a simple chat server and chat > client. The server opens a socket, listens