Re: Unable to get PIL to load jpeg images

2006-02-15 Thread gr
Peter,

Can you share the name of the library on the Fedora distro?

thx,

gerry rodman
http://www.gerryrodman.com/


[EMAIL PROTECTED] wrote:
> Thanks for that tip
>
> Following a dialogue in that discussion group it is now working.  The
> problem was that I didn't have the right jpeg library installed
> (although what I had was enough to show jpegs in gThumb, GIMP and the
> Gnome and KDE desktops so I don't understand why it wasn't). I had to
> also install a jpeg development library, which fortunately was
> available on my Fedora Core 3 installation disc.
>
> A final glitch was that the previous broken build interfered with the
> linking of PIL to the libraries.  I went for overkill, and deleted all
> the PIL installation and site-packages directories, then reinstalled
> from the original tarball.  This gave a curious glitch, in that the
> first time I ran it it failed to load Tkinter with some obscure error
> message, but on a retry everything was fine.  This worries me slightly,
> as I don't know what happened and there is always a chance it could
> happen again, but until it does I can't investigate it.
>
> Slightly off topic, but I think my experience here is typical of any
> installation on a Linux system, and illustrates why, despite huge
> improvements over the last few years, Linux is not yet really suitable
> for non expert use.
>
> Thanks to everyone who's helped me over the last few months.
> 
> Peter

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Unable to get PIL to load jpeg images

2006-02-15 Thread gr
Found it...and will share.

You need to install the "X Software Developement" library (standard
only is enough) from you Fedora distro...not sure what will be required
on other Linux distro's.

Worked like a charm...thanks Peter.

gerry rodman
http://www.gerryrodman.com/

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: String to Float, without introducing errors

2022-12-19 Thread Ángel GR

On 2022-12-19 16:14, MRAB wrote:
To be fair, I don't think I've never seen that notation either! I've 
only ever seen the form 6.67430E-11 ± 0.00015E-11, which is much clearer.


We use it regularly in our experimental data: 6.3(4), 15.002(10). Things 
would become complex using exponential forms for errors, specially when 
starting to play with exponents: 6.67430E-11 ± 1.5E-15.

--
Ángel GR

--
https://mail.python.org/mailman/listinfo/python-list


Re: Trying to set a cookie within a python script

2010-08-03 Thread Nik Gr

 Στις 3/8/2010 10:39 πμ, ο/η Chris Rebert έγραψε:

Please tell me the difference between 3 things.

a) Asking Notepad++(my editor) to save all my python scripts as UTF-8
without BOM.

That affects what encoding the text file comprising the source code
itself is in.


What does this practically mean? Perhaps you mean that it affects the 
way this file will be stored in the hard disk?


For example is it different to say to Notapad++ to save it as 'Asci'i 
and different to save it as 'UTF-8 without BOM'?


What should i use? My script only containes python code(english) and 
greek chars inside print statemetns.



b) Using this line '# -*- coding: utf-8 -*-' Isn't this line supposed
to tell browser that the contents of this python script as in UTF-8
and to handle it as such?

This tells Python what encoding the text file comprising the source
code itself is in.


What practically does this mean?

What difference does it have with (a) ?


c) print ''' Content-Type: text/html; charset=UTF-8 /n'''

This tells the web browser what encoding the HTML you're sending it is
in. Said HTML is output by your Python script and must match the
encoding you specify in (c).
When a python script runs it produces html output or only after the 
python's output to the Web Server the html output is produced?

--
http://mail.python.org/mailman/listinfo/python-list


Re: String substitution VS proper mysql escaping

2010-08-18 Thread Nik Gr

 Στις 18/8/2010 7:31 πμ, ο/η Cameron Simpson έγραψε:

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 substitution ("%") on SQL statements
| and to let MySQLdb do it
| for me, with proper escaping like the following
|
| ===
| cursor.execute('''SELECT host, hits, date FROM visitors WHERE page=%s
| ORDER BY date DESC''', (page,))
| ===
|
| The difference is that if some external source can control "page",
| and
| they put in a value like
| 100 ; DELETE FROM visitors; SELECT * FROM visitors
| i will be losing my database table data.

That other difference is that the mysql dialect support knows how to
correctly escape a string for insertion into an SQL statement. You may
not, or may forget to pre-escape the string, etc. Using the MySQLdb
stuff do it for you is reliable and robust.


Can you please tell me what escaping means by giving me an example of 
what is escaped and whats isn't?


Also hwo can i delete my data for testing purposes as?

http://webville.gr/index.html?page="100 ; DELETE FROM visitors; SELECT * 
FROM visitors"


I get an error...

| a) I wanted to ask what is proper escaping mean and why after variable
| page syntax has a comma

Because this:

   (page)

means the same thing as:

   page

i.e. the argument to the "%" operator is just the string in page.

This:

   (page,)

is a _tuple_ containing a single element, the page variable.
A bit like:

   [page]

which is a list containing a single element. The trailing comma is
needed to tell python you want to use a tuple, not the bare string.

The "%" operator has special knowledge that is it is passed as string instead
of a list or tuple or other sequence then it should act _as_ _if_ it had been
passed a single element tuple containing the string.

%s and %d is behaving the same due to % expecting a string instead of an 
integer?



Otherwise, because a string _is_ a sequence the "%" might want to treat
the string "foo" as the sequence:

   ("f", "o", "o")
cursor.execute('''SELECT host, hits, date FROM visitors WHERE page=%s 
ORDER BY date DESC''',  page)


But it alss might treat it an entity, i mean since 'page' is a variable 
containing a string why not just 'page' as it is expecting 'page' variable to 
give its value when asked?



Run these three loops to see the difference:

   for s in "foo":
 print s
   for s in ("foo"):
 print s
   for s in ("foo",):
 print s

Cheers,

>>> for s in "nikos":
print s


n
i
k
o
s

# this handles the string "nikos" as a series of chars right?

>>> for s in ("nikos"):
print s


n
i
k
o
s

# this handles the string "nikos" as a series of chars too but what si 
the difference with the above in htis with the parentheses? is "nikos" 
is handles still as string here?


>>> for s in ("nikos",):
print s


nikos

# Here yes it handles "nikos" as the 1st item of a tuple

nikos
>>> for s in ["nikos"]:
print s


nikos

# Here? why is it behaving fifferent than the above ("nikos") and is 
proccessign it all chars in one?


>>> for s in ["nikos",]:
print s


nikos

# Here it handles "nikos" as the 1st item of a list right?

--
http://mail.python.org/mailman/listinfo/python-list


Re: String substitution VS proper mysql escaping

2010-08-19 Thread Nik Gr

 Στις 19/8/2010 2:32 μμ, ο/η Tim Chase έγραψε:
So Python needs a way to express that you *explicitly* mean "this is 
one of those rare one-element tuples, not an order of operations 
prioritization":


  (1,) + (2,)
to return "(1,2)"
Yes i can see the difference now!! I just had to look at the big picture 
here! There is no other way of seperating this for that.



You can also prefix any of them with "r" such as

  file_path = r"c:\path\to\file.txt"
  file_path = r'c:\path\to\file.txt
  file_path = r"""c:\path\to\file.txt"""
  file_path = r'''c:\path\to\file.txt''' 


'r' is to avoid escaping backslashes only or other special charcaters as 
well?


As for the string i noticed that if i'am to mix single quotes and double 
quotes(any number of them not just always pairs)
and backslashes and other special stuff in them then i'm best off using 
3-sinlge-quotes like


name='''My name is "Nikos" and i'am from Thessaloniki\Greece'''

The above example can only be written by using 3-single quoting right? 
Not 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 fails when i try to

http://webville.gr/index.html?page="100 ; DELETE FROM visitors; SELECT * 
FROM visitors" 



please try it yourself, i dont mind lossign the data i just want to see 
if this mysql in jection can actually work.


Thank you.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: String substitution VS proper mysql escaping

2010-08-19 Thread Nik Gr

 Στις 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


Re: String substitution VS proper mysql escaping

2010-08-19 Thread Nik Gr

 Στις 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 Thessaloniki\\Greece"



So if i enclose the string in double quotes the inner double quotes have 
to be escaped while
if i enclose the string in single quotes the inner single quotes have to 
be escaped.


But in 3-single-quoting thing became easier since i don't have to escape 
all kind of quotes right? just the backslashes.



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. :)


So the best way to write the above assignment statement would be:

name = r'''My name is "Nikos" and I'm from Thessaloniki\Greece'''

It cannot get any easier that that can it? :)

''' ''' helps avoid escaping all kind of quotes!
'r' avoid escaping backslashes!

=
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. Would i might facing a problem? Of what? MySQLdb 
instead of give the whole value to the placeholder to give just a single 
char?
Also do i need 3-single-quoting here as well or it can be written qith 
signle/double quotes?

What appleis to  strings apply to mysql queries as well?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: String substitution VS proper mysql escaping

2010-08-19 Thread Nik Gr

 Στις 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 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.


I didn't undersatnd.


So the thing on the right is_supposed_  to
| I have a strong desire to use it like this:
| cursor.execute( '''SELECT hits FROM counters WHERE page = %s''' , page )
| opposed to tuple.

Hmm. This isn't the python "%" format operator at all.
This is the database API's .execute() method.
If it expects its second argument to be a sequence of parameters
(which is does) then you need to supply a sequence of parameters.
It is that simple!

In you usage above you're supplying "page" instead of "(page,)".
The latter matches the .execute() method's requirements.

I don't follow either.
--
http://mail.python.org/mailman/listinfo/python-list