On Oct 28, 2018 10:17 PM, "listo factor via Python-list" <
python-list@python.org> wrote:
>
> Hi all,
> I'm new to Python, but not to programming.
>
> As a teaching exercise, I am converting a bunch of bash shell
> scripts to Python, so that they can be run on all three OS-es
> (Linux, Windows, Mac
Hi all,
I'm new to Python, but not to programming.
As a teaching exercise, I am converting a bunch of bash shell
scripts to Python, so that they can be run on all three OS-es
(Linux, Windows, MacOS).
The scripts in questions make extensive use of Linux "zenity"
dialogs.
Is there an equivalent f
On 2017-03-02 09:55, Christian Gollwitzer wrote:
> you could do it "the (theoretical) right way", which is using
> another table. Insert your keys into a table, maybe temporary one,
> and then do
>
> select * from mumble where key in (select key from keytable)
>
> In theory that should also be fa
Am 28.02.17 um 18:28 schrieb Skip Montanaro:
Most of the time (well, all the time if you're smart), you let the
database adapter do parameter substitution for you to avoid SQL
injection attacks (or stupid users). So:
curs.execute("select * from mumble where key = ?", (key,))
On 28.02.17 19:28, Skip Montanaro wrote:
Most of the time (well, all the time if you're smart), you let the
database adapter do parameter substitution for you to avoid SQL
injection attacks (or stupid users). So:
curs.execute("select * from mumble where key = ?", (key,))
On 2017-03-01 04:40, Chris Angelico wrote:
> curs.execute("select * from mumble where key in (" +
> ",".join(["?"]*len(keys)) + ")", keys)
>
> If this is combined with another parameter, it'd be messier, but you
> could do something like:
>
> curs.execute("select * from mumble where key in (" +
>
On 2017-02-28, Skip Montanaro wrote:
> Some database adapters provide a function to do explicit
> substitution (e.g., mySQLdb.escape, psycopg2._param_escape),
> but the sqlite3 adapter doesn't.
It's clunky but you can use sqlite's core "quote" function.
On Tue, Feb 28, 2017 at 12:42 PM, Chris Angelico wrote:
> That isn't what you were doing in your post, so it seemed worth
> mentioning.
Sorry, my original post was a bit abbreviated. I can't copy text from
inside to outside, so have to retype everything. I guess I missed
that.
S
--
https://mail
On Wed, Mar 1, 2017 at 5:40 AM, Skip Montanaro wrote:
> On Tue, Feb 28, 2017 at 11:40 AM, Chris Angelico wrote:
>> Testing with PostgreSQL (which *does* transform lists) suggests that
>> "in" doesn't work; I used "key = any(%s)". I'd try that with sqlite3
>> first, just in case it makes a differe
On Tue, Feb 28, 2017 at 11:40 AM, Chris Angelico wrote:
> Testing with PostgreSQL (which *does* transform lists) suggests that
> "in" doesn't work; I used "key = any(%s)". I'd try that with sqlite3
> first, just in case it makes a difference. Probably it won't, but
> worth a try.
Yeah, doesn't wo
Skip Montanaro wrote:
> Most of the time (well, all the time if you're smart), you let the
> database adapter do parameter substitution for you to avoid SQL
> injection attacks (or stupid users). So:
>
> curs.execute("select * from mumble where key = ?", (key
On Wed, Mar 1, 2017 at 4:28 AM, Skip Montanaro wrote:
> Some database adapters provide a function to do explicit substitution
> (e.g., mySQLdb.escape, psycopg2._param_escape), but the sqlite3
> adapter doesn't. Is there a function floating around out there which
> does the righ
Most of the time (well, all the time if you're smart), you let the
database adapter do parameter substitution for you to avoid SQL
injection attacks (or stupid users). So:
curs.execute("select * from mumble where key = ?", (key,))
If you want to select from several possible ke
MRAB wrote:
> On 2015-08-18 22:42, Laurent Pointal wrote:
>> Hello,
>> ellipfind_re = re.compile(r"((?=\.\.\.)|…)", re.IGNORECASE|re.VERBOSE)
>> ellipfind_re.sub(' ... ',
>> "C'est un essai... avec différents caractères… pour voir.")
> (?=...) is a lookahead; a non-capture group is (?:..
On 2015-08-18 22:42, Laurent Pointal wrote:
Hello,
I want to make a replacement in a string, to ensure that ellipsis are
surrounded by spaces (this is not a typographycal problem, but a preparation
for late text chunking).
I tried with regular expressions and the SRE_Pattern.sub() method, but I
Hello,
I want to make a replacement in a string, to ensure that ellipsis are
surrounded by spaces (this is not a typographycal problem, but a preparation
for late text chunking).
I tried with regular expressions and the SRE_Pattern.sub() method, but I
have an unexpected duplication of the repl
massi_...@msn.com wrote:
> Hi everyone,
>
> I'm not really sure if this is the right place to ask about regular
> expressions, but since I'm usin python I thought I could give a try
:-)
> Here is the problem, I'm trying to write a regex in order to
substitute
> all the occurences in the form $"
On 28Oct2014 04:02, massi_...@msn.com wrote:
I'm not really sure if this is the right place to ask about regular
expressions, but since I'm usin python I thought I could give a try :-)
Here is the problem, I'm trying to write a regex in order to substitute all the
occurences in the form $"some
On 2014-10-28 12:28, massi_...@msn.com wrote:
Hi Chris, thanks for the reply. I tried to use look ahead assertions, in
particular I modified the regex this way:
newstring = re.sub(ur"""(?u)(\$\"[\s\w(?<=\\)\"]+\")""", subst, oldstring)
but it does not work. I'm absolutely not a regex guru so I
On Tuesday, October 28, 2014 7:03:00 AM UTC-4, mass...@msn.com wrote:
> Hi everyone,
> I'm not really sure if this is the right place to ask about regular
> expressions, but since I'm usin python I thought I could give a try :-)
> Here is the problem, I'm trying to write a regex in order to substi
On Tue, Oct 28, 2014 at 4:02 AM, wrote:
> Hi everyone,
>
> I'm not really sure if this is the right place to ask about regular
> expressions, but since I'm usin python I thought I could give a try :-)
> Here is the problem, I'm trying to write a regex in order to substitute
> all the occurences i
(Please quote enough of the previous text to provide context, and
write your replies underneath the quoted text - don't assume that
everyone's read the previous posts. Thanks!)
On Tue, Oct 28, 2014 at 11:28 PM, wrote:
> Hi Chris, thanks for the reply. I tried to use look ahead assertions, in
>
Hi Chris, thanks for the reply. I tried to use look ahead assertions, in
particular I modified the regex this way:
newstring = re.sub(ur"""(?u)(\$\"[\s\w(?<=\\)\"]+\")""", subst, oldstring)
but it does not work. I'm absolutely not a regex guru so I'm surely missing
something. The strings I'm d
On Tue, Oct 28, 2014 at 10:02 PM, wrote:
> I'm not really sure if this is the right place to ask about regular
> expressions, but since I'm usin python I thought I could give a try :-)
Yeah, that sort of thing is perfectly welcome here. Same with
questions about networking in Python, or file I/
Hi everyone,
I'm not really sure if this is the right place to ask about regular
expressions, but since I'm usin python I thought I could give a try :-)
Here is the problem, I'm trying to write a regex in order to substitute all the
occurences in the form $"somechars" with another string. This i
On 17/01/2014 06:07, gmflanagan wrote:
On Sunday, January 12, 2014 3:08:31 PM UTC, Eric S. Johansson wrote:
As part of speech recognition accessibility tools that I'm building, I'm
using string.Template. In order to construct on-the-fly grammar, I need
to know all of the identifiers before the
On Sunday, January 12, 2014 3:08:31 PM UTC, Eric S. Johansson wrote:
> As part of speech recognition accessibility tools that I'm building, I'm
>
> using string.Template. In order to construct on-the-fly grammar, I need
>
> to know all of the identifiers before the template is filled in. what i
On 1/13/2014 2:24 AM, Steven D'Aprano wrote:
On Sun, 12 Jan 2014 10:08:31 -0500, Eric S. Johansson wrote:
Now just walk the template for $ signs. Watch out for $$ which escapes
the dollar sign. Here's a baby parser:
found a different way
import string
cmplxstr="""a simple $string a longer $s
On Sun, 12 Jan 2014 10:08:31 -0500, Eric S. Johansson wrote:
> As part of speech recognition accessibility tools that I'm building, I'm
> using string.Template. In order to construct on-the-fly grammar, I need
> to know all of the identifiers before the template is filled in. what is
> the best wa
As part of speech recognition accessibility tools that I'm building, I'm
using string.Template. In order to construct on-the-fly grammar, I need
to know all of the identifiers before the template is filled in. what is
the best way to do this?
can string.Template handle recursive expansion i.e.
Hi,
On Mon, Mar 04, 2013 at 09:22:38AM -0800, Ferrous Cranus wrote:
> can i just put the liens you provided me inside "files.html" and thwy
> will work?
>
> Thats pure pythjon code!
There are several template-engines where you more or less include
python-code into the template, e.g.: empy, mako,
Τη Δευτέρα, 4 Μαρτίου 2013 5:14:00 μ.μ. UTC+2, ο χρήστης Νίκος Γκρ33κ έγραψε:
> Hello pythonistas!
>
>
>
> I'am tryign to populate a table with dictionary keys and values:
>
>
>
> Foe that iam using an html template and the questions is what i should write
> inside 'files.html' so then then
On 03/04/2013 01:06 PM, Ferrous Cranus wrote:
> What do you advise me to do?
> Generate html via python code like print '''stuf..''' or use an
> html templating system?
> Up until now i was using the first method and i though it would be a
> nice idea to seperate design from code.
>
> But p
Τη Δευτέρα, 4 Μαρτίου 2013 5:59:34 μ.μ. UTC+2, ο χρήστης Michael Torrie έγραψε:
> On 03/04/2013 08:14 AM, Ferrous Cranus wrote:
>
> > Instead of writing the above html data inside my html template how
>
> > would i write it with a for that then will be substituted by the
>
> > python script?
>
On 03/04/2013 08:14 AM, Ferrous Cranus wrote:
> Instead of writing the above html data inside my html template how
> would i write it with a for that then will be substituted by the
> python script?
What templating system are you using? Django's?
> can you please write an example for me that use
Hello pythonistas!
I'am tryign to populate a table with dictionary keys and values:
Foe that iam using an html template and the questions is what i should write
inside 'files.html' so then then the python script populate the table.
SuperHost - Economy
Χώρος στο δίσκο: 1 GB
Hi Hans
[...]
>
>
> However, once he does that, it's simpler to cut out xargs and invoke
>
> "sh" directly. Or even cut out "sh" and "test" and instead use
>
> os.path.isfile and then call md5sum directly. And once he does that,
>
> he no longer needs to worry about single quotes.
>
Yes i
On 13/11/12 22:36:47, Thomas Rachel wrote:
> Am 12.11.2012 19:30 schrieb Hans Mulder:
>
>> This will break if there are spaces in the file name, or other
>> characters meaningful to the shell. If you change if to
>>
>> xargsproc.append("test -f '%s/{}'&& md5sum '%s/{}'"
>>
Am 12.11.2012 19:30 schrieb Hans Mulder:
This will break if there are spaces in the file name, or other
characters meaningful to the shell. If you change if to
xargsproc.append("test -f '%s/{}'&& md5sum '%s/{}'"
% (mydir, mydir))
, then it will only bre
Am 09.11.2012 02:12 schrieb Hans Mulder:
That's what 'xargs' will do for you. All you need to do, is invoke
xargs with arguments containing '{}'. I.e., something like:
cmd1 = ['tar', '-czvf', 'myfile.tgz', '-c', mydir, 'mysubdir']
first_process = subprocess.Popen(cmd1, stdout=subprocess.PIPE)
Hi Hans
[...]
>
> > xargsproc.append("test -f %s/{} && md5sum %s/{}" % (mydir,
> > mydir))
>
> This will break if there are spaces in the file name, or other
> characters meaningful to the shell. If you change if to
>
> xargsproc.append("test -f '%s/{}' && md5sum '%s/{}'"
>
On 12/11/12 18:22:44, jkn wrote:
> Hi Hans
>
> On Nov 12, 4:36 pm, Hans Mulder wrote:
>> On 12/11/12 16:36:58, jkn wrote:
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>> slight followup ...
>>
>>> I have made some progress; for now I'm using subprocess.communicate to
>>> read the output from the first subprocess,
Hi Hans
On Nov 12, 4:36 pm, Hans Mulder wrote:
> On 12/11/12 16:36:58, jkn wrote:
>
>
>
>
>
>
>
>
>
> > slight followup ...
>
> > I have made some progress; for now I'm using subprocess.communicate to
> > read the output from the first subprocess, then writing it into the
> > secodn subprocess. T
On Nov 12, 4:58 pm, Rebelo wrote:
> Dana četvrtak, 8. studenoga 2012. 19:05:12 UTC+1, korisnik jkn napisao je:
>
> > Hi All
>
> > i am trying to build up a set of subprocess.Ponen calls to
>
> > replicate the effect of a horribly long shell command. I'm not clear
>
> > how I can do one part of
Dana četvrtak, 8. studenoga 2012. 19:05:12 UTC+1, korisnik jkn napisao je:
> Hi All
>
> i am trying to build up a set of subprocess.Ponen calls to
>
> replicate the effect of a horribly long shell command. I'm not clear
>
> how I can do one part of this and wonder if anyone can advise. I'm o
On 12/11/12 16:36:58, jkn wrote:
> slight followup ...
>
> I have made some progress; for now I'm using subprocess.communicate to
> read the output from the first subprocess, then writing it into the
> secodn subprocess. This way I at least get to see what is
> happening ...
>
> The reason 'we' w
slight followup ...
I have made some progress; for now I'm using subprocess.communicate to
read the output from the first subprocess, then writing it into the
secodn subprocess. This way I at least get to see what is
happening ...
The reason 'we' weren't seeing any output from the second call (th
Hi Hans
thanks a lot for your reply:
> That's what 'xargs' will do for you. All you need to do, is invoke
> xargs with arguments containing '{}'. I.e., something like:
>
> cmd1 = ['tar', '-czvf', 'myfile.tgz', '-c', mydir, 'mysubdir']
> first_process = subprocess.Popen(cmd1, stdout=subproces
t from a shell
> guru).
>
> IIUC, when called like this, the two occurences of '{}' in the xargs
> command will get replaced with the file being added to the tarfile.
>
> Also IIUC, I will need two calls to subprocess.Popen() and use
> subprocess.stdin on the second
args
command will get replaced with the file being added to the tarfile.
Also IIUC, I will need two calls to subprocess.Popen() and use
subprocess.stdin on the second to receive the output from the first.
But how can I achive the substitution of the '{}' construction across
these two ca
would break the Liskov substitution principle, yes. Anything that
asks for a Student instance should receive an object that can do at
least everything Student can do.
If you want to implement something that can't do some of the things
Student can do, the Liskov substitution principle says you a
On Sat, Jul 16, 2011 at 10:04 AM, Ben Finney wrote:
> def study(self, subject):
> raise NotImplementedError
>
> See? We can have overstretched analogies *and* remain within the Liskov
> substitution principle.
>
Hehe! Of course I was speaking utterly in jes
Chris Angelico writes:
> The analogy with reality breaks down a bit here. I've seen plenty of
> students with no idea of what it means to study. But Python can handle
> that too - just 'del' the method in the subclass.
No, please don't. That would break the Liskov
In article ,
=?UTF-8?B?zp3Or866zr/Pgg==?= wrote:
>
>After all () used to define tuples and [] usedd to define lists. Why
>commas?
No, "()" does *not* define tuples, except for the empty tuple. The comma
defines tuples, with parentheses simply used for visual effect:
>>> 1, 2, 3
(1, 2, 3)
--
A
you substitute
into the placeholders must end up looking like SQL literals.
That means string values need to be in quotes, and probably
dates as well, although numbers don't.
When you use the execute method's own parameter substitution
mechanism, things are different. It'
On 30/08/2010 17:34, Alexander Kapps wrote:
Nik the Greek wrote:
cursor.execute(''' SELECT hits FROM counters WHERE page = %s and
date = %s and host = %s ''' , a_tuple )
and
cursor.execute(''' SELECT hits FROM counters WHERE page = %s and
date = %s and host = %s ''' , (a_tuple) )
are both sy
syntactically valid SQL. The values that you substitute
into the placeholders must end up looking like SQL literals.
That means string values need to be in quotes, and probably
dates as well, although numbers don't.
When you use the execute method's own parameter substitution
mechanism,
Nik the Greek wrote:
cursor.execute(''' SELECT hits FROM counters WHERE page = %s and
date = %s and host = %s ''' , a_tuple )
and
cursor.execute(''' SELECT hits FROM counters WHERE page = %s and
date = %s and host = %s ''' , (a_tuple) )
are both syntactically correct right?
buw what about
c
actically valid SQL. The values that you substitute
> into the placeholders must end up looking like SQL literals.
> That means string values need to be in quotes, and probably
> dates as well, although numbers don't.
>
> When you use the execute method's own parameter substitut
On Aug 30, 8:52 am, naugiedoggie wrote:
> On Aug 29, 1:14 pm, MRAB wrote:
>
>
>
>
>
> > On 29/08/2010 15:22, naugiedoggie wrote:
> > > I'm having a problem with using a function as the replacement in
> > > re.sub().
> > > Here is the function:
> > > def normalize(s) :
> > > return
> > > urll
On Aug 29, 1:14 pm, MRAB wrote:
> On 29/08/2010 15:22, naugiedoggie wrote:
> > I'm having a problem with using a function as the replacement in
> > re.sub().
> > Here is the function:
> > def normalize(s) :
> > return
> > urllib.quote(string.capwords(urllib.unquote(s.group('provider'
>
end up looking like SQL literals.
That means string values need to be in quotes, and probably
dates as well, although numbers don't.
When you use the execute method's own parameter substitution
mechanism, things are different. It's not a textual replacement,
and you don't p
t; cursor.execute(''' SELECT hits FROM counters WHERE page = '%s' and
> >>> date = '%s' and host = '%s' ''' % (page, date, host) )
>
> >>> does work, while same thign qithout the quotes
>
> >>> cursor.
cursor.execute(''' SELECT hits FROM counters WHERE page = %s and date
= %s and host = %s ''' % (page, date, host) )
doesn't. Dont know why but quotes somehopw confuse me both in strings
and sql_queries as well when it comes to substitutions.
Don't qu
= %s and date
> > = %s and host = %s ''' % (page, date, host) )
>
> > doesn't. Dont know why but quotes somehopw confuse me both in strings
> > and sql_queries as well when it comes to substitutions.
>
> Don't quote the placeholders yourself. Let the
On 30/08/2010 02:38, Νίκος wrote:
On 29 Αύγ, 21:34, MRAB wrote:
It likes the values to be in a tuple. If there's one value, that's a
1-tuple: (page, ).
I noticed that if we are dealing with just a single value 'page' will
do, no need to tuple for 1-value.
it handles fine as a string.
I tri
On 29 Αύγ, 21:34, MRAB wrote:
> It likes the values to be in a tuple. If there's one value, that's a
> 1-tuple: (page, ).
I noticed that if we are dealing with just a single value 'page' will
do, no need to tuple for 1-value.
it handles fine as a string.
> >> cursor.execute('''SELECT hits FROM
On 29/08/2010 06:13, Νίκος wrote:
On 28 Αύγ, 23:12, MRAB wrote:
On 28/08/2010 20:51, Νίκος wrote:
On 28 Αύγ, 22:35, MRABwrote:
"""When there's more than one value you provide a tuple. It's makes sense
from the point of view of consistency that you also provide a tuple when
ther
On 29/08/2010 15:22, naugiedoggie wrote:
Hello,
I'm having a problem with using a function as the replacement in
re.sub().
Here is the function:
def normalize(s) :
return
urllib.quote(string.capwords(urllib.unquote(s.group('provider'
This normalises the provider and returns only tha
On 8/29/2010 10:22 AM, naugiedoggie wrote:
Hello,
I'm having a problem with using a function as the replacement in
re.sub().
Here is the function:
def normalize(s) :
return
urllib.quote(string.capwords(urllib.unquote(s.group('provider'
To debug your problem, I would start with print
In article
<9170aad0-478a-4222-b6e2-88d00899d...@t2g2000yqe.googlegroups.com>,
naugiedoggie wrote:
> Hello,
>
> I'm having a problem with using a function as the replacement in
> re.sub().
>
> Here is the function:
>
> def normalize(s) :
> return
> urllib.quote(string.capwords(urllib.unq
Hello,
I'm having a problem with using a function as the replacement in
re.sub().
Here is the function:
def normalize(s) :
return
urllib.quote(string.capwords(urllib.unquote(s.group('provider'
The purpose of this function is to proper-case the words contained in
a URL query string param
On 28 Αύγ, 23:12, MRAB wrote:
> On 28/08/2010 20:51, Νίκος wrote:
>
>
>
>
>
>
>
>
>
> > On 28 Αύγ, 22:35, MRAB wrote:
>
> >> """When there's more than one value you provide a tuple. It's makes sense
> >> from the point of view of consistency that you also provide a tuple when
> >> there's only on
On 28/08/2010 20:51, Νίκος wrote:
On 28 Αύγ, 22:35, MRAB wrote:
"""When there's more than one value you provide a tuple. It's makes sense
from the point of view of consistency that you also provide a tuple when
there's only one value."""
Can you write something that make use of more than one
when
there's only one value."""
cursor.execute(sql_query, (page, ))
is different than?
cursor.execute(sql_query, page, )
?
Yes.
The first has 2 arguments: a string and a tuple containing the value of
'page'.
The second has 2 arguments: a string and the value of
2010/8/29 Νίκος :
> On 28 Αύγ, 22:35, MRAB wrote:
>
>> """When there's more than one value you provide a tuple. It's makes sense
>> from the point of view of consistency that you also provide a tuple when
>> there's only one value."""
>
> Can you write something that make use of more than one valu
On 28 Αύγ, 22:35, MRAB wrote:
> """When there's more than one value you provide a tuple. It's makes sense
> from the point of view of consistency that you also provide a tuple when
> there's only one value."""
Can you write something that make use of more than one value?
Perhaps you mena somet
t;"When there's more than one value you provide a tuple. It's makes sense
> from the point of view of consistency that you also provide a tuple when
> there's only one value."""
cursor.execute(sql_query, (page, ))
is different than?
curso
On 28/08/2010 20:10, Νίκος wrote:
On 20 Αύγ, 09:04, Nik Gr wrote:
With regard to the "%" operator, it considers the string on the left to
be a format string with multiple %blah things in it to replace. The
thing on the right is a sequence of items to place into the format
string.
Can you plea
On 20 Αύγ, 09:04, Nik Gr wrote:
> With regard to the "%" operator, it considers the string on the left to
> be a format string with multiple %blah things in it to replace. The
> thing on the right is a sequence of items to place into the format
> string.
Can you please clarify what you mean by th
In message
, Νίκος
wrote:
> I would expect that:
>
> ("nikos") is a single element tuple.
Then how would you do a simple parenthesized expression?
--
http://mail.python.org/mailman/listinfo/python-list
Στις 20/8/2010 8:22 πμ, ο/η Cameron Simpson έγραψε:
[...snip...]
| Why does the page variable which is actually a string needs to be a
| tuple or a list and not just as a string which is what it actually
| is?
With regard to the "%" operator, it considers the string on the left to
be a format s
On 19Aug2010 21:50, Nik Gr wrote:
| Στις 19/8/2010 6:58 μμ, ο/η Tim Chase έγραψε:
| >It can be written as a non-3-quote string, you just have to escape
| >the inner quotes (single & double) and the backslash to be seen:
| >
| > name = 'My name is "Nikos" and I\'m from Thessaloniki\\Greece'
| >
ors WHERE page =
|>| '%s' ORDER BY date DESC ''' % (page) )
|>| ===
|>|
|>| Someone told me NOT to do string substitution ("%") on SQL statements
|>| and to let MySQLdb do it
|>| for me, with proper escaping like the follow
Nik Gr wrote:
[snip]
Why does the page variable which is actually a string needs to be a
tuple or a list and not just as a string which is what it actually is?
I have a strong desire to use it like this:
cursor.execute( '''SELECT hits FROM counters WHERE page = %s''' , page )
opposed to tuple.
Στις 19/8/2010 6:58 μμ, ο/η Tim Chase έγραψε:
It can be written as a non-3-quote string, you just have to escape the
inner quotes (single & double) and the backslash to be seen:
name = 'My name is "Nikos" and I\'m from Thessaloniki\\Greece'
name = "My name is \"Nikos\" and I'm from Thessal
niki\\Greece"
And i dont have to use the 'r' in fornt of it too.
Using the 'r' in front would make it much more challenging,
because it would prevent the backslashes from being seen as
escaping. :)
(1,) + (2,)
to return "(1,2)"
This is actually joinin
Στις 19/8/2010 2:32 μμ, ο/η Tim Chase έγραψε:
(1,) + (2,)
to return "(1,2)"
This is actually joining two single element tuples (1,) and (2, ) to a
new bigger tuple of two elements, correct?
--
http://mail.python.org/mailman/listinfo/python-list
by pairs of single or double quotes, correct?
And i dont have to use the 'r' in fornt of it too.
===
Also if you please comment on my mysql string substitution example i've
posted in my previous post just to make it work.
I want it to be able to delete my data but it
Hi Νίκος,
On 2010-08-19 09:10, Νίκος wrote:
> On 18 Αύγ, 12:50, Cameron Simpson wrote:
>>
>> ("nikos",) is a single element tuple.
>> ["nikos"] is a single element list.
>> ["nikos",] is also a single element list, just written like the tuple.
>
> It makes more sense if i:
>
> "nikos" is just a
On 08/19/10 02:10, Νίκος wrote:
("nikos",) is a single element tuple.
["nikos"] is a single element list.
["nikos",] is also a single element list, just written like the tuple.
It makes more sense if i:
"nikos" is just a string
("nikos") is a single element tuple
["nikos"] is also a single ele
ing
("nikos") is a single element tuple
["nikos"] is also a single element list
After all () used to define tuples and [] usedd to define lists. Why
commas?
Also is there a difference between 'nikos' or "nikos" or '''nikos'''
Y date DESC''', page)
instead which i tend to like more, would there i have a problem?
Also how how this part here page=%s doesn't need to be written as
page='%s' which is the way i used to have it written with myssql
string substitution?
==
On 08/18/10 04:50, Cameron Simpson wrote:
("nikos",) is a single element tuple.
["nikos"] is a single element list.
["nikos",] is also a single element list, just written like the tuple.
You don't see the ["nikos",] form very often because ["nikos"] is not
ambiguous.
I most frequently see/use
' ORDER BY date DESC ''' % (page) )
| >| ===
| >|
| >| Someone told me NOT to do string substitution ("%") on SQL statements
| >| and to let MySQLdb do it
| >| for me, with proper escaping like the following
| >|
| >|
=====
|
| Someone told me NOT to do string substitution ("%") on SQL statements
| and to let MySQLdb do it
| for me, with proper escaping like the following
|
| ===
| cursor.execute('''SELECT host, hits, date F
On 17Aug2010 20:15, Νίκος wrote:
| ===
| cursor.execute( ''' SELECT host, hits, date FROM visitors WHERE page =
| '%s' ORDER BY date DESC ''' % (page) )
| ===
|
| Someone told me NOT to do string su
2010/8/18 Νίκος
> a) I wanted to ask what is proper escaping mean and
>
>
Proper escaping means that value is wrapped in quotes properly, and quotes
and backslashes (or any other special to RDBMS symbol) are escaped with
backslashes.
why after variable page syntax has a comma
>
Comma just means
===
cursor.execute( ''' SELECT host, hits, date FROM visitors WHERE page =
'%s' ORDER BY date DESC ''' % (page) )
===
Someone told me NOT to do string substitution ("%") on SQL statements
and
Wilbert Berendsen wrote:
> # sort the keys, longest first, so 'aa' gets matched before 'a', because
> # in Python regexps the first match (going from left to right) in a
> # |-separated group is taken
> keys = sorted(mapping.keys(), key=len, reverse=True)
>
This would do just as well (although
1 - 100 of 268 matches
Mail list logo